| [123] | 1 | <?php |
|---|
| 2 | |
|---|
| 3 | function get_language_file_ex($name, $l, $s) |
|---|
| 4 | { |
|---|
| [182] | 5 | static $lmap = array( |
|---|
| [123] | 6 | 'zh' => 'zh-simplified', |
|---|
| 7 | 'zh-hk' => 'zh-traditional', |
|---|
| 8 | 'zh-tw' => 'zh-traditional', |
|---|
| 9 | ); |
|---|
| [182] | 10 | static $smap = array( |
|---|
| 11 | 'gbk' => 'gb2312', |
|---|
| 12 | 'gb18030' => 'gb2312', |
|---|
| 13 | ); |
|---|
| [123] | 14 | |
|---|
| [182] | 15 | if (isset($lmap[$l])) { |
|---|
| 16 | $l = $lmap[$l]; |
|---|
| [123] | 17 | } |
|---|
| 18 | if (file_exists($file = "$name-$l-$s.lang.php")) { |
|---|
| 19 | return $file; |
|---|
| 20 | } |
|---|
| [182] | 21 | if (isset($smap[$s])) { |
|---|
| 22 | $s = $smap[$s]; |
|---|
| 23 | if (file_exists($file = "$name-$l-$s.lang.php")) { |
|---|
| 24 | return $file; |
|---|
| 25 | } |
|---|
| 26 | } |
|---|
| [123] | 27 | if (file_exists($file = "$name-$l.lang.php")) { |
|---|
| 28 | return $file; |
|---|
| 29 | } |
|---|
| 30 | return null; |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | function get_language_file($name) |
|---|
| 34 | { |
|---|
| 35 | global $charset, $lang; |
|---|
| 36 | $s = strtolower($charset); |
|---|
| 37 | if (isset($lang)) { |
|---|
| [134] | 38 | $l = strtolower($lang); |
|---|
| 39 | $file = get_language_file_ex($name, $l, $s); |
|---|
| 40 | if (!isset($file)) { |
|---|
| 41 | $l = strtok($l, '-'); |
|---|
| 42 | $file = get_language_file_ex($name, $l, $s); |
|---|
| 43 | } |
|---|
| [123] | 44 | } |
|---|
| 45 | else if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|---|
| 46 | foreach (explode(',', str_replace(' ', '', $_SERVER['HTTP_ACCEPT_LANGUAGE'])) as $l) { |
|---|
| 47 | $l = strtok($l, ';'); |
|---|
| 48 | $file = get_language_file_ex($name, $l, $s); |
|---|
| 49 | if (isset($file)) { |
|---|
| [125] | 50 | $lang = $l; |
|---|
| [123] | 51 | break; |
|---|
| 52 | } |
|---|
| 53 | if (strpos($l, '-') !== false) { |
|---|
| [125] | 54 | $ll = strtok($l, '-'); |
|---|
| 55 | $file = get_language_file_ex($name, $ll, $s); |
|---|
| [123] | 56 | if (isset($file)) { |
|---|
| [125] | 57 | $lang = $l; |
|---|
| [123] | 58 | break; |
|---|
| 59 | } |
|---|
| 60 | } |
|---|
| 61 | } |
|---|
| 62 | } |
|---|
| 63 | return isset($file) ? $file : "$name-en.lang.php"; |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | function _T($str) |
|---|
| 67 | { |
|---|
| 68 | if (isset($GLOBALS['strings'][$str])) { |
|---|
| 69 | return $GLOBALS['strings'][$str]; |
|---|
| 70 | } |
|---|
| 71 | if (!empty($GLOBALS['show_todo_strings'])) { |
|---|
| 72 | return '<span style="color:red">' . htmlspecialchars($str) . '</span>'; |
|---|
| 73 | } |
|---|
| 74 | return $str; |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| [418] | 77 | function stripaddslashes_array($value, $mqs = false) |
|---|
| 78 | { |
|---|
| 79 | if (is_array($value)) { |
|---|
| 80 | foreach($value as $k => $v) { |
|---|
| 81 | $value[$k] = stripaddslashes_array($v, $mqs); |
|---|
| 82 | } |
|---|
| 83 | } |
|---|
| 84 | else if(is_string($value)) { |
|---|
| 85 | $value = $mqs ? str_replace('\'\'', '\'', $value) : stripslashes($value); |
|---|
| 86 | } |
|---|
| 87 | return $value; |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| [123] | 90 | error_reporting(E_ALL); |
|---|
| [181] | 91 | ini_set('display_errors', 'On'); |
|---|
| [123] | 92 | define('REQUEST_TIME', time()); |
|---|
| 93 | |
|---|
| [418] | 94 | if (get_magic_quotes_gpc()) { |
|---|
| 95 | $mqs = (bool) ini_get('magic_quotes_sybase'); |
|---|
| 96 | $_GET = stripaddslashes_array($_GET, $mqs); |
|---|
| 97 | $_POST = stripaddslashes_array($_POST, $mqs); |
|---|
| 98 | $_REQUEST = stripaddslashes_array($_REQUEST, $mqs); |
|---|
| 99 | } |
|---|
| 100 | ini_set('magic_quotes_runtime', '0'); |
|---|
| 101 | |
|---|
| [123] | 102 | $charset = "UTF-8"; |
|---|
| 103 | if (file_exists("./config.php")) { |
|---|
| 104 | include("./config.php"); |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | include(get_language_file("common")); |
|---|
| [125] | 108 | if (!isset($lang)) { |
|---|
| 109 | $lang = 'en-us'; |
|---|
| 110 | } |
|---|
| [526] | 111 | if (!isset($usage_graph_width) && !isset($free_graph_width)) { |
|---|
| 112 | $usage_graph_width = 120; |
|---|
| [517] | 113 | } |
|---|
| [526] | 114 | $graph_width = isset($free_graph_width) ? $free_graph_width : $usage_graph_width; |
|---|
| [123] | 115 | |
|---|
| 116 | ?> |
|---|