XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
functions.php
1<?php
13
14
15function getLanguage() {
16 $language_array = [
17 'en' => 'english',
18// 'cn' => 'schinese',
19 'cs' => 'czech',
20// 'de' => 'german',
21 'el' => 'greek',
22// 'es' => 'spanish',
23 'fr' => 'french',
24 'ja' => 'japanese',
25 'ko' => 'korean',
26// 'nl' => 'dutch',
27 'pt' => 'pt_utf8',
28 'ru' => 'russian',
29 'zh' => 'schinese',
30
31 ];
32
33 $charset_array = [
34 'Shift_JIS' => 'ja_utf8',
35 ];
36
37 $language = 'english';
38 if ( ! empty( $_POST['lang'] ) ) {
39 $language = $_POST['lang'];
40 } else if ( isset( $_COOKIE['install_lang'] ) ) {
41 $language = $_COOKIE['install_lang'];
42 } else if ( isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) {
43 foreach ( explode( ',', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) as $al ) {
44 $al = strtolower( $al );
45 $al_len = strlen( $al );
46 if ( $al_len > 2 ) {
47 if ( preg_match( '/([a-z]{2});q=[0-9.]+$/', $al, $al_match ) ) {
48 $al = $al_match[1];
49 } else {
50 continue;
51 }
52 }
53 if ( isset( $language_array[ $al ] ) ) {
54 $language = $language_array[ $al ];
55 break;
56 }
57 }
58 if ( file_exists( dirname( __DIR__ ) . '/language/' . $al . '_utf8' ) ) {
59 $language = $al . '_utf8';
60 }
61 } elseif ( isset( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
62 foreach ( $charset_array as $ac => $lg ) {
63 if ( strpos( $_SERVER['HTTP_ACCEPT_CHARSET'], $ac ) !== false ) {
64 $language = $lg;
65 break;
66 }
67 }
68 }
69 if ( ! file_exists( './language/' . $language . '/install.php' ) ) {
70 $language = 'english';
71 }
72 setcookie( 'install_lang', $language, ['expires' => ini_get( 'session.cookie_lifetime' ), 'path' => ini_get( 'session.cookie_path' ), 'domain' => ini_get( 'session.cookie_domain' ), 'secure' => ini_get( 'session.cookie_secure' ), 'httponly' => ini_get( 'session.cookie_httponly' )]
73 );
74
75 return $language;
76}
77
78/*
79 * gets list of name of directories inside a directory
80 */
81function getDirList( $dirname ) {
82 $dirlist = [];
83 if ( is_dir( $dirname ) && $handle = opendir( $dirname ) ) {
84 while ( false !== ( $file = readdir( $handle ) ) ) {
85 if ( ! preg_match( '/^[.]{1,2}$/', $file ) && 'cvs' !== strtolower( $file ) && is_dir( $dirname . $file ) ) {
86 $dirlist[ $file ] = $file;
87 }
88 }
89 closedir( $handle );
90 asort( $dirlist );
91 reset( $dirlist );
92 }
93
94 return $dirlist;
95}
96
97/*
98 * gets list of name of files within a directory
99 */
100function getImageFileList( $dirname ) {
101 $filelist = [];
102 if ( is_dir( $dirname ) && $handle = opendir( $dirname ) ) {
103 while ( false !== ( $file = readdir( $handle ) ) ) {
104 if ( ! preg_match( '/^[.]{1,2}$/', $file ) && preg_match( '/[.gif|.jpg|.png]$/i', $file ) ) {
105 $filelist[ $file ] = $file;
106 }
107 }
108 closedir( $handle );
109 asort( $filelist );
110 reset( $filelist );
111 }
112
113 return $filelist;
114}
115
116function &xoops_module_gettemplate( $dirname, $template, $block = false ) {
117 if ( $block ) {
118 $path = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/templates/blocks/' . $template;
119 } else {
120 $path = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/templates/' . $template;
121 }
122 if ( ! file_exists( $path ) ) {
123 $ret = false;
124
125 return $ret;
126 }
127
128 $lines = file( $path );
129 if ( ! $lines ) {
130 $ret = false;
131
132 return $ret;
133 }
134 $ret = '';
135 foreach ( $lines as $i => $iValue ) {
136 $ret .= str_replace( "\n", "\r\n", str_replace( "\r\n", "\n", $lines[ $i ] ) );
137 }
138
139 return $ret;
140}
141
142function check_language( $language ) {
143 if ( file_exists( './language/' . $language . '/install.php' ) ) {
144 return $language;
145 }
146
147 return 'english';
148}
149
150function b_back( $option = null ) {
151 if ( ! isset( $option ) || ! is_array( $option ) ) {
152 return '';
153 }
154 $content = '';
155 if ( isset( $option[0] ) && '' !== $option[0] ) {
156 $content .= '<a href="javascript:void(0);" onclick=\'location.href="index.php?op='
157 . htmlspecialchars( $option[0], ENT_QUOTES | ENT_HTML5 )
158 . '"\' class="wizard-back" style="display:inline-block;vertical-align:top;">
159 <svg xmlns="http://www.w3.org/2000/svg" title="' . _INSTALL_L42
160 . '" aria-hidden="true" focusable="false" width="1em" height="1em" style="vertical-align: -0.125em;" viewBox="0 0 24 24">
161 <path d="M17 13H8.75L12 16.25l-.664.75l-4.5-4.5l4.5-4.5l.664.75L8.75 12H17v1zm-15-.5a9.5 9.5 0 1 1 19 0a9.5 9.5 0 0 1-19 0zm1 0a8.5 8.5 0 1 0 17 0a8.5 8.5 0 0 0-17 0z" fill="currentColor"></path>
162 </svg></a>';
163 } else {
164 $content .= '<a href="javascript:history.back();" class="wizard-back" style="display:inline-block;vertical-align:top;">
165 <svg xmlns="http://www.w3.org/2000/svg" title="' . _INSTALL_L42
166 . '" aria-hidden="true" focusable="false" width="1em" height="1em" style="vertical-align: -0.125em;" viewBox="0 0 24 24">
167 <path d="M17 13H8.75L12 16.25l-.664.75l-4.5-4.5l4.5-4.5l.664.75L8.75 12H17v1zm-15-.5a9.5 9.5 0 1 1 19 0a9.5 9.5 0 0 1-19 0zm1 0a8.5 8.5 0 1 0 17 0a8.5 8.5 0 0 0-17 0z" fill="currentColor"></path>
168 </svg></a>';
169 }
170 if ( isset( $option[1] ) && '' != $option[1] ) {
171 $content .= '<label class="wizard-back-label">' . htmlspecialchars( $option[1], ENT_QUOTES | ENT_HTML5 ) . '</label>';
172 }
173
174 return $content;
175}
176
177function b_reload( $option = '' ) {
178 if ( empty( $option ) ) {
179 return '';
180 }
181 if ( ! defined( '_INSTALL_L200' ) ) {
182 define( '_INSTALL_L200', 'Reload' );
183 }
184 if ( ! empty( $_POST['op'] ) ) {
185 $op = $_POST['op'];
186 } elseif ( ! empty( $_GET['op'] ) ) {
187 $op = $_GET['op'];
188 } else {
189 $op = 'langselect';
190 }
191
192 return '<a href="javascript:void(0);" onclick=\'location.href="index.php?op='
193 . htmlspecialchars( $op, ENT_QUOTES | ENT_HTML5 )
194 . '"\' class="wizard-reload" style="display:inline-block;vertical-align:top;">
195 <svg xmlns="http://www.w3.org/2000/svg" title="' . _INSTALL_L200 . '" aria-hidden="true" focusable="false" width="1em" height="1em" style="vertical-align: -0.125em;" viewBox="0 0 24 24">
196 <path d="M4.996 5h5v5h-1V6.493a6.502 6.502 0 0 0 2.504 12.5a6.5 6.5 0 0 0 1.496-12.827V5.142A7.5 7.5 0 1 1 7.744 6H4.996V5z" fill="#face74"/>
197 </svg></a>';
198}
199
200function b_next( $option = null ) {
201 if ( ! isset( $option ) || ! is_array( $option ) ) {
202 return '';
203 }
204 $content = '';
205 if ( isset( $option[1] ) && '' !== $option[1] ) {
206 $content .= '<label class="wizard-next-label">' . htmlspecialchars( $option[1], ENT_QUOTES | ENT_HTML5 ) . '</label>';
207 }
208 $content .= '<input type="hidden" name="op" value="' . htmlspecialchars( $option[0], ENT_QUOTES | ENT_HTML5 ) . '">';
209 $content .= '<button type="submit" class="wizard-next" title="' . _INSTALL_L47
210 . '" name="submit" value="' . _INSTALL_L47 . '">
211 <svg xmlns="http://www.w3.org/2000/svg" title="' . _INSTALL_L47
212 . '" aria-hidden="true" focusable="false" width="1em" height="1em" style="vertical-align: -0.125em;" viewBox="0 0 24 24">
213 <path d="M6.003 12h8.25l-3.25-3.25l.664-.75l4.5 4.5l-4.5 4.5l-.664-.75l3.25-3.25h-8.25v-1zm15 .5a9.5 9.5 0 1 1-19 0a9.5 9.5 0 0 1 19 0zm-1 0a8.5 8.5 0 1 0-17 0a8.5 8.5 0 0 0 17 0z" fill="currentColor"></path>
214 </svg></button>';
215
216 return $content;
217}