protection against XSS when register_globals is on and .htaccess has no effect
[phpmyadmin/crack.git] / libraries / select_lang.lib.php
blob540cab282ce171107fb69e31e0d38123a358c064
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * phpMyAdmin Language Loading File
6 * @version $Id$
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 /**
13 * tries to find the language to use
15 * @uses $GLOBALS['cfg']['lang']
16 * @uses $GLOBALS['cfg']['DefaultLang']
17 * @uses $GLOBALS['lang_failed_cfg']
18 * @uses $GLOBALS['lang_failed_cookie']
19 * @uses $GLOBALS['lang_failed_request']
20 * @uses $_REQUEST['lang']
21 * @uses $_COOKIE['pma_lang']
22 * @uses $_SERVER['HTTP_ACCEPT_LANGUAGE']
23 * @uses $_SERVER['HTTP_USER_AGENT']
24 * @uses PMA_langSet()
25 * @uses PMA_langDetect()
26 * @uses explode()
27 * @return bool success if valid lang is found, otherwise false
29 function PMA_langCheck()
31 // check forced language
32 if (! empty($GLOBALS['cfg']['Lang'])) {
33 if (PMA_langSet($GLOBALS['cfg']['Lang'])) {
34 return true;
35 } else {
36 $GLOBALS['lang_failed_cfg'] = $GLOBALS['cfg']['Lang'];
40 // Don't use REQUEST in following code as it might be confused by cookies with same name
41 // check user requested language (POST)
42 if (! empty($_POST['lang'])) {
43 if (PMA_langSet($_POST['lang'])) {
44 return true;
45 } elseif (!is_string($_POST['lang'])) {
46 /* Faked request, don't care on localisation */
47 $GLOBALS['lang_failed_request'] = 'Yes';
48 } else {
49 $GLOBALS['lang_failed_request'] = $_POST['lang'];
53 // check user requested language (GET)
54 if (! empty($_GET['lang'])) {
55 if (PMA_langSet($_GET['lang'])) {
56 return true;
57 } elseif (!is_string($_GET['lang'])) {
58 /* Faked request, don't care on localisation */
59 $GLOBALS['lang_failed_request'] = 'Yes';
60 } else {
61 $GLOBALS['lang_failed_request'] = $_GET['lang'];
65 // check previous set language
66 if (! empty($_COOKIE['pma_lang'])) {
67 if (PMA_langSet($_COOKIE['pma_lang'])) {
68 return true;
69 } elseif (!is_string($_COOKIE['lang'])) {
70 /* Faked request, don't care on localisation */
71 $GLOBALS['lang_failed_request'] = 'Yes';
72 } else {
73 $GLOBALS['lang_failed_cookie'] = $_COOKIE['pma_lang'];
77 // try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE variable
78 if (PMA_getenv('HTTP_ACCEPT_LANGUAGE')) {
79 foreach (explode(',', PMA_getenv('HTTP_ACCEPT_LANGUAGE')) as $lang) {
80 if (PMA_langDetect($lang, 1)) {
81 return true;
86 // try to findout user's language by checking its HTTP_USER_AGENT variable
87 if (PMA_langDetect(PMA_getenv('HTTP_USER_AGENT'), 2)) {
88 return true;
91 // Didn't catch any valid lang : we use the default settings
92 if (PMA_langSet($GLOBALS['cfg']['DefaultLang'])) {
93 return true;
96 return false;
99 /**
100 * checks given lang and sets it if valid
101 * returns true on success, otherwise flase
103 * @uses $GLOBALS['available_languages'] to check $lang
104 * @uses $GLOBALS['lang'] to set it
105 * @param string $lang language to set
106 * @return bool success
108 function PMA_langSet(&$lang)
110 if (!is_string($lang) || empty($lang) || empty($GLOBALS['available_languages'][$lang])) {
111 return false;
113 $GLOBALS['lang'] = $lang;
114 return true;
118 * Analyzes some PHP environment variables to find the most probable language
119 * that should be used
121 * @param string string to analyze
122 * @param integer type of the PHP environment variable which value is $str
124 * @return bool true on success, otherwise false
126 * @global $available_languages
128 * @access private
130 function PMA_langDetect(&$str, $envType)
132 if (empty($str)) {
133 return false;
135 if (empty($GLOBALS['available_languages'])) {
136 return false;
139 foreach ($GLOBALS['available_languages'] as $lang => $value) {
140 // $envType = 1 for the 'HTTP_ACCEPT_LANGUAGE' environment variable,
141 // 2 for the 'HTTP_USER_AGENT' one
142 $expr = $value[0];
143 if (strpos($expr, '[-_]') === FALSE) {
144 $expr = str_replace('|', '([-_][[:alpha:]]{2,3})?|', $expr);
146 if (($envType == 1 && eregi('^(' . $expr . ')(;q=[0-9]\\.[0-9])?$', $str))
147 || ($envType == 2 && eregi('(\(|\[|;[[:space:]])(' . $expr . ')(;|\]|\))', $str))) {
148 if (PMA_langSet($lang)) {
149 return true;
154 return false;
155 } // end of the 'PMA_langDetect()' function
158 * @global string path to the translations directory
160 $GLOBALS['lang_path'] = './lang/';
163 * @global string interface language
165 $GLOBALS['lang'] = 'en-iso-8859-1';
167 * @global boolean wether loading lang from cfg failed
169 $GLOBALS['lang_failed_cfg'] = false;
171 * @global boolean wether loading lang from cookie failed
173 $GLOBALS['lang_failed_cookie'] = false;
175 * @global boolean wether loading lang from user request failed
177 $GLOBALS['lang_failed_request'] = false;
179 * @global string text direction ltr or rtl
181 $GLOBALS['text_dir'] = 'ltr';
184 * All the supported languages have to be listed in the array below.
185 * 1. The key must be the "official" ISO 639 language code and, if required,
186 * the dialect code. It can also contain some informations about the
187 * charset (see the Russian case).
188 * 2. The first of the values associated to the key is used in a regular
189 * expression to find some keywords corresponding to the language inside two
190 * environment variables.
191 * These values contains:
192 * - the "official" ISO language code and, if required, the dialect code
193 * also ('bu' for Bulgarian, 'fr([-_][[:alpha:]]{2})?' for all French
194 * dialects, 'zh[-_]tw' for Chinese traditional...), the dialect has to
195 * be specified as first;
196 * - the '|' character (it means 'OR');
197 * - the full language name.
198 * 3. The second values associated to the key is the name of the file to load
199 * without the 'inc.php' extension.
200 * 4. The third values associated to the key is the language code as defined by
201 * the RFC1766.
202 * 5. The fourth value is native name in html entities.
204 * Beware that the sorting order (first values associated to keys by
205 * alphabetical reverse order in the array) is important: 'zh-tw' (chinese
206 * traditional) must be detected before 'zh' (chinese simplified) for
207 * example.
209 * When there are more than one charset for a language, we put the -utf-8
210 * last because we need the default charset to be non-utf-8 to avoid
211 * problems on MySQL < 4.1.x if AllowAnywhereRecoding is FALSE.
213 * For Russian, we put 1251 first, because MSIE does not accept 866
214 * and users would not see anything.
217 * @global array supported languages
219 $GLOBALS['available_languages'] = array(
220 'af-iso-8859-1' => array('af|afrikaans', 'afrikaans-iso-8859-1', 'af', ''),
221 'af-utf-8' => array('af|afrikaans', 'afrikaans-utf-8', 'af', ''),
222 'ar-win1256' => array('ar|arabic', 'arabic-windows-1256', 'ar', '&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;'),
223 'ar-utf-8' => array('ar|arabic', 'arabic-utf-8', 'ar', '&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;'),
224 'az-iso-8859-9' => array('az|azerbaijani', 'azerbaijani-iso-8859-9', 'az', 'Az&#601;rbaycanca'),
225 'az-utf-8' => array('az|azerbaijani', 'azerbaijani-utf-8', 'az', 'Az&#601;rbaycanca'),
227 'becyr-win1251' => array('be|belarusian', 'belarusian_cyrillic-windows-1251', 'be', '&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1072;&#1103;'),
228 'becyr-utf-8' => array('be|belarusian', 'belarusian_cyrillic-utf-8', 'be', '&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1072;&#1103;'),
229 'belat-utf-8' => array('be[-_]lat|belarusian latin', 'belarusian_latin-utf-8', 'be-lat', 'Byelorussian'),
230 'bg-win1251' => array('bg|bulgarian', 'bulgarian-windows-1251', 'bg', '&#1041;&#1098;&#1083;&#1075;&#1072;&#1088;&#1089;&#1082;&#1080;'),
231 'bg-koi8-r' => array('bg|bulgarian', 'bulgarian-koi8-r', 'bg', '&#1041;&#1098;&#1083;&#1075;&#1072;&#1088;&#1089;&#1082;&#1080;'),
232 'bg-utf-8' => array('bg|bulgarian', 'bulgarian-utf-8', 'bg', '&#1041;&#1098;&#1083;&#1075;&#1072;&#1088;&#1089;&#1082;&#1080;'),
233 'bs-win1250' => array('bs|bosnian', 'bosnian-windows-1250', 'bs', 'Bosanski'),
234 'bs-utf-8' => array('bs|bosnian', 'bosnian-utf-8', 'bs', 'Bosanski'),
235 'ca-iso-8859-1' => array('ca|catalan', 'catalan-iso-8859-1', 'ca', 'Catal&agrave;'),
236 'ca-utf-8' => array('ca|catalan', 'catalan-utf-8', 'ca', 'Catal&agrave;'),
237 'cs-iso-8859-2' => array('cs|czech', 'czech-iso-8859-2', 'cs', '&#268;esky'),
238 'cs-win1250' => array('cs|czech', 'czech-windows-1250', 'cs', '&#268;esky'),
239 'cs-utf-8' => array('cs|czech', 'czech-utf-8', 'cs', '&#268;esky'),
240 'da-iso-8859-1' => array('da|danish', 'danish-iso-8859-1', 'da', 'Dansk'),
241 'da-utf-8' => array('da|danish', 'danish-utf-8', 'da', 'Dansk'),
242 'de-iso-8859-1' => array('de|german', 'german-iso-8859-1', 'de', 'Deutsch'),
243 'de-iso-8859-15' => array('de|german', 'german-iso-8859-15', 'de', 'Deutsch'),
244 'de-utf-8' => array('de|german', 'german-utf-8', 'de', 'Deutsch'),
245 'el-iso-8859-7' => array('el|greek', 'greek-iso-8859-7', 'el', '&Epsilon;&lambda;&lambda;&eta;&nu;&iota;&kappa;&#940;'),
246 'el-utf-8' => array('el|greek', 'greek-utf-8', 'el', '&Epsilon;&lambda;&lambda;&eta;&nu;&iota;&kappa;&#940;'),
247 'en-iso-8859-1' => array('en|english', 'english-iso-8859-1', 'en', ''),
248 'en-iso-8859-15' => array('en|english', 'english-iso-8859-15', 'en', ''),
249 'en-utf-8' => array('en|english', 'english-utf-8', 'en', ''),
250 'es-iso-8859-1' => array('es|spanish', 'spanish-iso-8859-1', 'es', 'Espa&ntilde;ol'),
251 'es-iso-8859-15' => array('es|spanish', 'spanish-iso-8859-15', 'es', 'Espa&ntilde;ol'),
252 'es-utf-8' => array('es|spanish', 'spanish-utf-8', 'es', 'Espa&ntilde;ol'),
253 'et-iso-8859-1' => array('et|estonian', 'estonian-iso-8859-1', 'et', 'Eesti'),
254 'et-utf-8' => array('et|estonian', 'estonian-utf-8', 'et', 'Eesti'),
255 'eu-iso-8859-1' => array('eu|basque', 'basque-iso-8859-1', 'eu', 'Euskara'),
256 'eu-utf-8' => array('eu|basque', 'basque-utf-8', 'eu', 'Euskara'),
257 'fa-win1256' => array('fa|persian', 'persian-windows-1256', 'fa', '&#1601;&#1575;&#1585;&#1587;&#1740;'),
258 'fa-utf-8' => array('fa|persian', 'persian-utf-8', 'fa', '&#1601;&#1575;&#1585;&#1587;&#1740;'),
259 'fi-iso-8859-1' => array('fi|finnish', 'finnish-iso-8859-1', 'fi', 'Suomi'),
260 'fi-iso-8859-15' => array('fi|finnish', 'finnish-iso-8859-15', 'fi', 'Suomi'),
261 'fi-utf-8' => array('fi|finnish', 'finnish-utf-8', 'fi', 'Suomi'),
262 'fr-iso-8859-1' => array('fr|french', 'french-iso-8859-1', 'fr', 'Fran&ccedil;ais'),
263 'fr-iso-8859-15' => array('fr|french', 'french-iso-8859-15', 'fr', 'Fran&ccedil;ais'),
264 'fr-utf-8' => array('fr|french', 'french-utf-8', 'fr', 'Fran&ccedil;ais'),
265 'gl-iso-8859-1' => array('gl|galician', 'galician-iso-8859-1', 'gl', 'Galego'),
266 'gl-utf-8' => array('gl|galician', 'galician-utf-8', 'gl', 'Galego'),
267 'he-iso-8859-8-i' => array('he|hebrew', 'hebrew-iso-8859-8-i', 'he', '&#1506;&#1489;&#1512;&#1497;&#1514;'),
268 'he-utf-8' => array('he|hebrew', 'hebrew-utf-8', 'he', '&#1506;&#1489;&#1512;&#1497;&#1514;'),
269 'hi-utf-8' => array('hi|hindi', 'hindi-utf-8', 'hi', '&#2361;&#2367;&#2344;&#2381;&#2342;&#2368;'),
270 'hr-win1250' => array('hr|croatian', 'croatian-windows-1250', 'hr', 'Hrvatski'),
271 'hr-iso-8859-2' => array('hr|croatian', 'croatian-iso-8859-2', 'hr', 'Hrvatski'),
272 'hr-utf-8' => array('hr|croatian', 'croatian-utf-8', 'hr', 'Hrvatski'),
273 'hu-iso-8859-2' => array('hu|hungarian', 'hungarian-iso-8859-2', 'hu', 'Magyar'),
274 'hu-utf-8' => array('hu|hungarian', 'hungarian-utf-8', 'hu', 'Magyar'),
275 'id-iso-8859-1' => array('id|indonesian', 'indonesian-iso-8859-1', 'id', 'Bahasa Indonesia'),
276 'id-utf-8' => array('id|indonesian', 'indonesian-utf-8', 'id', 'Bahasa Indonesia'),
277 'it-iso-8859-1' => array('it|italian', 'italian-iso-8859-1', 'it', 'Italiano'),
278 'it-iso-8859-15' => array('it|italian', 'italian-iso-8859-15', 'it', 'Italiano'),
279 'it-utf-8' => array('it|italian', 'italian-utf-8', 'it', 'Italiano'),
280 'ja-euc' => array('ja|japanese', 'japanese-euc', 'ja', '&#26085;&#26412;&#35486;'),
281 'ja-sjis' => array('ja|japanese', 'japanese-sjis', 'ja', '&#26085;&#26412;&#35486;'),
282 'ja-utf-8' => array('ja|japanese', 'japanese-utf-8', 'ja', '&#26085;&#26412;&#35486;'),
283 'ko-euc-kr' => array('ko|korean', 'korean-euc-kr', 'ko', '&#54620;&#44397;&#50612;'),
284 'ko-utf-8' => array('ko|korean', 'korean-utf-8', 'ko', '&#54620;&#44397;&#50612;'),
285 'ka-utf-8' => array('ka|georgian', 'georgian-utf-8', 'ka', '&#4325;&#4304;&#4320;&#4311;&#4323;&#4314;&#4312;'),
286 'lt-win1257' => array('lt|lithuanian', 'lithuanian-windows-1257', 'lt', 'Lietuvi&#371;'),
287 'lt-utf-8' => array('lt|lithuanian', 'lithuanian-utf-8', 'lt', 'Lietuvi&#371;'),
288 'lv-win1257' => array('lv|latvian', 'latvian-windows-1257', 'lv', 'Latvie&scaron;u'),
289 'lv-utf-8' => array('lv|latvian', 'latvian-utf-8', 'lv', 'Latvie&scaron;u'),
290 'mkcyr-win1251' => array('mk|macedonian', 'macedonian_cyrillic-windows-1251', 'mk', 'Macedonian'),
291 'mkcyr-utf-8' => array('mk|macedonian', 'macedonian_cyrillic-utf-8', 'mk', 'Macedonian'),
292 'mn-utf-8' => array('mn|mongolian', 'mongolian-utf-8', 'mn', '&#1052;&#1086;&#1085;&#1075;&#1086;&#1083;'),
293 'ms-iso-8859-1' => array('ms|malay', 'malay-iso-8859-1', 'ms', 'Bahasa Melayu'),
294 'ms-utf-8' => array('ms|malay', 'malay-utf-8', 'ms', 'Bahasa Melayu'),
295 'nl-iso-8859-1' => array('nl|dutch', 'dutch-iso-8859-1', 'nl', 'Nederlands'),
296 'nl-iso-8859-15' => array('nl|dutch', 'dutch-iso-8859-15', 'nl', 'Nederlands'),
297 'nl-utf-8' => array('nl|dutch', 'dutch-utf-8', 'nl', 'Nederlands'),
298 'no-iso-8859-1' => array('no|norwegian', 'norwegian-iso-8859-1', 'no', 'Norsk'),
299 'no-utf-8' => array('no|norwegian', 'norwegian-utf-8', 'no', 'Norsk'),
300 'pl-iso-8859-2' => array('pl|polish', 'polish-iso-8859-2', 'pl', 'Polski'),
301 'pl-win1250' => array('pl|polish', 'polish-windows-1250', 'pl', 'Polski'),
302 'pl-utf-8' => array('pl|polish', 'polish-utf-8', 'pl', 'Polski'),
303 'ptbr-iso-8859-1' => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-iso-8859-1', 'pt-BR', 'Portugu&ecirc;s'),
304 'ptbr-utf-8' => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-utf-8', 'pt-BR', 'Portugu&ecirc;s'),
305 'pt-iso-8859-1' => array('pt|portuguese', 'portuguese-iso-8859-1', 'pt', 'Portugu&ecirc;s'),
306 'pt-iso-8859-15' => array('pt|portuguese', 'portuguese-iso-8859-15', 'pt', 'Portugu&ecirc;s'),
307 'pt-utf-8' => array('pt|portuguese', 'portuguese-utf-8', 'pt', 'Portugu&ecirc;s'),
308 'ro-iso-8859-1' => array('ro|romanian', 'romanian-iso-8859-1', 'ro', 'Rom&acirc;n&#259;'),
309 'ro-utf-8' => array('ro|romanian', 'romanian-utf-8', 'ro', 'Rom&acirc;n&#259;'),
310 'ru-win1251' => array('ru|russian', 'russian-windows-1251', 'ru', '&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;'),
311 'ru-cp-866' => array('ru|russian', 'russian-cp-866', 'ru', '&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;'),
312 'ru-koi8-r' => array('ru|russian', 'russian-koi8-r', 'ru', '&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;'),
313 'ru-utf-8' => array('ru|russian', 'russian-utf-8', 'ru', '&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;'),
314 'si-utf-8' => array('si|sinhala', 'sinhala-utf-8', 'si', '&#3523;&#3538;&#3458;&#3524;&#3517;'),
315 'sk-iso-8859-2' => array('sk|slovak', 'slovak-iso-8859-2', 'sk', 'Sloven&#269;ina'),
316 'sk-win1250' => array('sk|slovak', 'slovak-windows-1250', 'sk', 'Sloven&#269;ina'),
317 'sk-utf-8' => array('sk|slovak', 'slovak-utf-8', 'sk', 'Sloven&#269;ina'),
318 'sl-iso-8859-2' => array('sl|slovenian', 'slovenian-iso-8859-2', 'sl', 'Sloven&scaron;&#269;ina'),
319 'sl-win1250' => array('sl|slovenian', 'slovenian-windows-1250', 'sl', 'Sloven&scaron;&#269;ina'),
320 'sl-utf-8' => array('sl|slovenian', 'slovenian-utf-8', 'sl', 'Sloven&scaron;&#269;ina'),
321 'sq-iso-8859-1' => array('sq|albanian', 'albanian-iso-8859-1', 'sq', 'Shqip'),
322 'sq-utf-8' => array('sq|albanian', 'albanian-utf-8', 'sq', 'Shqip'),
323 'srlat-win1250' => array('sr[-_]lat|serbian latin', 'serbian_latin-windows-1250', 'sr-lat', 'Srpski'),
324 'srlat-utf-8' => array('sr[-_]lat|serbian latin', 'serbian_latin-utf-8', 'sr-lat', 'Srpski'),
325 'srcyr-win1251' => array('sr|serbian', 'serbian_cyrillic-windows-1251', 'sr', '&#1057;&#1088;&#1087;&#1089;&#1082;&#1080;'),
326 'srcyr-utf-8' => array('sr|serbian', 'serbian_cyrillic-utf-8', 'sr', '&#1057;&#1088;&#1087;&#1089;&#1082;&#1080;'),
327 'sv-iso-8859-1' => array('sv|swedish', 'swedish-iso-8859-1', 'sv', 'Svenska'),
328 'sv-utf-8' => array('sv|swedish', 'swedish-utf-8', 'sv', 'Svenska'),
329 'th-tis-620' => array('th|thai', 'thai-tis-620', 'th', '&#3616;&#3634;&#3625;&#3634;&#3652;&#3607;&#3618;'),
330 'th-utf-8' => array('th|thai', 'thai-utf-8', 'th', '&#3616;&#3634;&#3625;&#3634;&#3652;&#3607;&#3618;'),
331 'tr-iso-8859-9' => array('tr|turkish', 'turkish-iso-8859-9', 'tr', 'T&uuml;rk&ccedil;e'),
332 'tr-utf-8' => array('tr|turkish', 'turkish-utf-8', 'tr', 'T&uuml;rk&ccedil;e'),
333 'tt-iso-8859-9' => array('tt|tatarish', 'tatarish-iso-8859-9', 'tt', 'Tatar&ccedil;a'),
334 'tt-utf-8' => array('tt|tatarish', 'tatarish-utf-8', 'tt', 'Tatar&ccedil;a'),
335 'uk-win1251' => array('uk|ukrainian', 'ukrainian-windows-1251', 'uk', '&#1059;&#1082;&#1088;&#1072;&#1111;&#1085;&#1089;&#1100;&#1082;&#1072;'),
336 'uk-utf-8' => array('uk|ukrainian', 'ukrainian-utf-8', 'uk', '&#1059;&#1082;&#1088;&#1072;&#1111;&#1085;&#1089;&#1100;&#1082;&#1072;'),
337 'zhtw-big5' => array('zh[-_](tw|hk)|chinese traditional', 'chinese_traditional-big5', 'zh-TW', '&#20013;&#25991;'),
338 'zhtw-utf-8' => array('zh[-_](tw|hk)|chinese traditional', 'chinese_traditional-utf-8', 'zh-TW', '&#20013;&#25991;'),
339 'zh-gb2312' => array('zh|chinese simplified', 'chinese_simplified-gb2312', 'zh', '&#20013;&#25991;'),
340 'zh-utf-8' => array('zh|chinese simplified', 'chinese_simplified-utf-8', 'zh', '&#20013;&#25991;'),
343 // Language filtering support
344 if (! empty($GLOBALS['cfg']['FilterLanguages'])) {
345 $new_lang = array();
346 foreach ($GLOBALS['available_languages'] as $key => $val) {
347 if (preg_match('@' . $GLOBALS['cfg']['FilterLanguages'] . '@', $key)) {
348 $new_lang[$key] = $val;
351 if (count($new_lang) > 0) {
352 $GLOBALS['available_languages'] = $new_lang;
354 unset($key, $val, $new_lang);
358 * first check for lang dir exists
360 if (! is_dir($GLOBALS['lang_path'])) {
361 // language directory not found
362 trigger_error('phpMyAdmin-ERROR: path not found: '
363 . $GLOBALS['lang_path'] . ', check your language directory.',
364 E_USER_WARNING);
365 // and tell the user
366 PMA_fatalError('path to languages is invalid: ' . $GLOBALS['lang_path']);
370 * check for language files
372 foreach ($GLOBALS['available_languages'] as $each_lang_key => $each_lang) {
373 if (! file_exists($GLOBALS['lang_path'] . $each_lang[1] . '.inc.php')) {
374 unset($GLOBALS['available_languages'][$each_lang_key]);
377 unset($each_lang_key, $each_lang);
380 * @global array MySQL charsets map
382 $GLOBALS['mysql_charset_map'] = array(
383 'big5' => 'big5',
384 'cp-866' => 'cp866',
385 'euc-jp' => 'ujis',
386 'euc-kr' => 'euckr',
387 'gb2312' => 'gb2312',
388 'gbk' => 'gbk',
389 'iso-8859-1' => 'latin1',
390 'iso-8859-2' => 'latin2',
391 'iso-8859-7' => 'greek',
392 'iso-8859-8' => 'hebrew',
393 'iso-8859-8-i' => 'hebrew',
394 'iso-8859-9' => 'latin5',
395 'iso-8859-13' => 'latin7',
396 'iso-8859-15' => 'latin1',
397 'koi8-r' => 'koi8r',
398 'shift_jis' => 'sjis',
399 'tis-620' => 'tis620',
400 'utf-8' => 'utf8',
401 'windows-1250' => 'cp1250',
402 'windows-1251' => 'cp1251',
403 'windows-1252' => 'latin1',
404 'windows-1256' => 'cp1256',
405 'windows-1257' => 'cp1257',
409 * Do the work!
413 * @global boolean whether charset recoding should be allowed or not
415 $GLOBALS['allow_recoding'] = false;
416 if (empty($GLOBALS['convcharset'])) {
417 if (isset($_COOKIE['pma_charset'])) {
418 $GLOBALS['convcharset'] = $_COOKIE['pma_charset'];
419 } else {
420 // session.save_path might point to a bad folder, in which case
421 // $GLOBALS['cfg'] would not exist
422 $convcharset = isset($GLOBALS['cfg']['DefaultCharset']) ? $GLOBALS['cfg']['DefaultCharset'] : 'utf-8';
426 if (! PMA_langCheck()) {
427 // fallback language
428 $fall_back_lang = 'en-utf-8';
429 $line = __LINE__;
430 if (! PMA_langSet($fall_back_lang)) {
431 trigger_error('phpMyAdmin-ERROR: invalid lang code: '
432 . __FILE__ . '#' . $line . ', check hard coded fall back language.',
433 E_USER_WARNING);
434 // stop execution
435 // and tell the user that his choosen language is invalid
436 PMA_fatalError('Could not load any language, please check your language settings and folder.');
440 // Defines the associated filename and load the translation
441 $lang_file = $GLOBALS['lang_path'] . $GLOBALS['available_languages'][$GLOBALS['lang']][1] . '.inc.php';
442 require_once $lang_file;
444 // now, that we have loaded the language strings we can send the errors
445 if ($GLOBALS['lang_failed_cfg']) {
446 $GLOBALS['PMA_errors'][] = sprintf($GLOBALS['strLanguageUnknown'], htmlspecialchars($GLOBALS['lang_failed_cfg']));
448 if ($GLOBALS['lang_failed_cookie']) {
449 $GLOBALS['PMA_errors'][] = sprintf($GLOBALS['strLanguageUnknown'], htmlspecialchars($GLOBALS['lang_failed_cookie']));
451 if ($GLOBALS['lang_failed_request']) {
452 $GLOBALS['PMA_errors'][] = sprintf($GLOBALS['strLanguageUnknown'], htmlspecialchars($GLOBALS['lang_failed_request']));
455 unset($line, $fall_back_lang,
456 $GLOBALS['lang_failed_cfg'], $GLOBALS['lang_failed_cookie'], $GLOBALS['ang_failed_request'], $GLOBALS['strLanguageUnknown']);