1: <?php
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27: function getLanguage() {
28: $language_array = array(
29: 'en' => 'english',
30:
31: 'cs' => 'czech',
32:
33: 'el' => 'greek',
34:
35: 'fr' => 'french',
36: 'ja' => 'japanese',
37: 'ko' => 'korean',
38:
39: 'pt' => 'pt_utf8',
40: 'ru' => 'russian',
41: 'zh' => 'schinese',
42:
43: );
44:
45: $charset_array = array(
46: 'Shift_JIS' => 'ja_utf8',
47: );
48:
49: $language = 'english';
50: if ( !empty($_POST['lang']) ) {
51: $language = $_POST['lang'];
52: } else {
53: if (isset($_COOKIE['install_lang'])) {
54: $language = $_COOKIE['install_lang'];
55: } else {
56: if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
57: $accept_langs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
58: foreach ($accept_langs as $al) {
59: $al = strtolower($al);
60: $al_len = strlen($al);
61: if ($al_len > 2) {
62: if (preg_match('/([a-z]{2});q=[0-9.]+$/', $al, $al_match)) {
63: $al = $al_match[1];
64: } else {
65: continue;
66: }
67: }
68: if (isset($language_array[$al])) {
69: $language = $language_array[$al];
70: break;
71: }
72: }
73: } else if (isset($_SERVER['HTTP_ACCEPT_CHARSET'])) {
74: foreach ($charset_array as $ac => $lg) {
75: if (strstr($_SERVER['HTTP_ACCEPT_CHARSET'],$ac)) {
76: $language = $lg ;
77: break ;
78: }
79: }
80: }
81: }
82: }
83: if ( !file_exists('./language/'.$language.'/install.php') ) {
84: $language = 'english';
85: }
86: setcookie('install_lang', $language);
87: return $language;
88: }
89:
90: 91: 92:
93: function getDirList($dirname)
94: {
95: $dirlist = array();
96: if (is_dir($dirname) && $handle = opendir($dirname)) {
97: while (false !== ($file = readdir($handle))) {
98: if ( !preg_match('/^[.]{1,2}$/',$file) ) {
99: if (strtolower($file) != 'cvs' && is_dir($dirname.$file) ) {
100: $dirlist[$file]=$file;
101: }
102: }
103: }
104: closedir($handle);
105: asort($dirlist);
106: reset($dirlist);
107: }
108: return $dirlist;
109: }
110:
111: 112: 113:
114: function getImageFileList($dirname)
115: {
116: $filelist = array();
117: if (is_dir($dirname) && $handle = opendir($dirname)) {
118: while (false !== ($file = readdir($handle))) {
119: if (!preg_match('/^[.]{1,2}$/', $file) && preg_match('/[.gif|.jpg|.png]$/i', $file) ) {
120: $filelist[$file]=$file;
121: }
122: }
123: closedir($handle);
124: asort($filelist);
125: reset($filelist);
126: }
127: return $filelist;
128: }
129:
130: function &xoops_module_gettemplate($dirname, $template, $block=false)
131: {
132: if ($block) {
133: $path = XOOPS_ROOT_PATH.'/modules/'.$dirname.'/templates/blocks/'.$template;
134: } else {
135: $path = XOOPS_ROOT_PATH.'/modules/'.$dirname.'/templates/'.$template;
136: }
137: if (!file_exists($path)) {
138: $ret = false;
139: return $ret;
140: } else {
141: $lines = file($path);
142: }
143: if (!$lines) {
144: $ret = false;
145: return $ret;
146: }
147: $ret = '';
148: $count = count($lines);
149: for ($i = 0; $i < $count; $i++) {
150: $ret .= str_replace("\n", "\r\n", str_replace("\r\n", "\n", $lines[$i]));
151: }
152: return $ret;
153: }
154:
155: function check_language($language){
156: if ( file_exists('./language/'.$language.'/install.php') ) {
157: return $language;
158: } else {
159: return 'english';
160: }
161: }
162:
163: function b_back($option = null)
164: {
165: if(!isset($option) || !is_array($option)) return '';
166: $content = '';
167: if(isset($option[0]) && $option[0] != ''){
168: $content .= '<a href="javascript:void(0);" onclick=\'location.href="index.php?op='.htmlspecialchars($option[0]).'"\' class="back" style="display:inline-block;vertical-align:top;"><img src="img/back.png" alt="'._INSTALL_L42.'"></a>';
169: }else{
170: $content .= '<a href="javascript:history.back();" class="back" style="display:inline-block;vertical-align:top;"><img src="img/back.png" alt="'._INSTALL_L42.'" /></a>';
171: }
172: if(isset($option[1]) && $option[1] != ''){
173: $content .= '<span style="font-size:90%;"> << '.htmlspecialchars($option[1]).'</span>';
174: }
175: return $content;
176: }
177:
178: function b_reload($option=''){
179: if(empty($option)) return '';
180: if (!defined('_INSTALL_L200')) {
181: define('_INSTALL_L200', 'Reload');
182: }
183: if(!empty($_POST['op'])) {
184: $op = $_POST['op'];
185: } elseif(!empty($_GET['op'])) {
186: $op = $_GET['op'];
187: } else {
188: $op = 'langselect';
189: }
190: return '<a href="javascript:void(0);" onclick=\'location.href="index.php?op='.htmlspecialchars($op).'"\' class="reload" style="display:inline-block;vertical-align:top;"><img src="img/reload.png" alt="'._INSTALL_L200.'"></a>';
191: }
192:
193: function b_next($option=null){
194: if(!isset($option) || !is_array($option)) return '';
195: $content = '';
196: if(isset($option[1]) && $option[1] != ''){
197: $content .= '<span style="font-size:90%;">'.htmlspecialchars($option[1]).' >> </span>';
198: }
199: $content .= '<input type="hidden" name="op" value="'.htmlspecialchars($option[0]).'" />';
200: $content .= '<input type="image" src="img/next.png" class="next" title="'._INSTALL_L47.'" name="submit" value="'._INSTALL_L47.'" />';
201: return $content;
202: }
203:
204: ?>
205: