1 | <?php
|
---|
2 | /*
|
---|
3 | * XPressME - WordPress for XOOPS
|
---|
4 | *
|
---|
5 | * @copyright XPressME Project http://www.toemon.com
|
---|
6 | * @license http://www.fsf.org/copyleft/gpl.html GNU public license
|
---|
7 | * @author toemon
|
---|
8 | * @package module::xpress
|
---|
9 | */
|
---|
10 | class wpInfo {
|
---|
11 | var $mod_dirpath;
|
---|
12 | var $mod_name;
|
---|
13 | var $mod_url;
|
---|
14 |
|
---|
15 | var $xoops_Lang;
|
---|
16 | var $wp_Lang;
|
---|
17 | var $php_version;
|
---|
18 | var $mysql_version;
|
---|
19 | // The language of XOOPS is set as Key of the array.
|
---|
20 | // The language of WP is set as Value of the array.
|
---|
21 | var $wp_lang_array = array(
|
---|
22 | 'english' => 'en_US',
|
---|
23 | 'japanese' => 'ja',
|
---|
24 | 'ja_utf8' => 'ja',
|
---|
25 | 'pt-br_utf8' => 'pt_BR',
|
---|
26 | // The key(language of XOOPS) of the following lists has not been set yet.
|
---|
27 | 'Afrikaans' => 'af',
|
---|
28 | 'Albanian' => 'al',
|
---|
29 | 'Arabic' => 'ar',
|
---|
30 | 'Bangla' => 'bn_BD',
|
---|
31 | 'Basque' => 'eu',
|
---|
32 | 'Belarusian' => 'be_BY',
|
---|
33 | 'Bosnian' => 'bs_BA',
|
---|
34 | 'Bulgarian' => 'bg_BG',
|
---|
35 | 'Catalan' => 'ca',
|
---|
36 | 'Chinese' => 'zh_CN',
|
---|
37 | 'Hong Kong' => 'zh_HK',
|
---|
38 | 'Taiwan' => 'zh_TW',
|
---|
39 | 'Croatian' => 'hr',
|
---|
40 | 'Czech' => 'cs_CZ',
|
---|
41 | 'Danish' => 'da_DK',
|
---|
42 | 'Dutch' => 'nl_NL',
|
---|
43 | 'Esperanto' => 'eo',
|
---|
44 | 'Estonian' => 'et',
|
---|
45 | 'Faroese' => 'fo',
|
---|
46 | 'Finnish' => 'fi',
|
---|
47 | 'Galician' => 'gl_ES',
|
---|
48 | 'Georgian' => 'ge_GE',
|
---|
49 | 'German' => 'de_DE',
|
---|
50 | 'Greek' => 'el',
|
---|
51 | 'Hebrew' => 'he_IL',
|
---|
52 | 'Hungarian' => 'hu_HU',
|
---|
53 | 'Icelandic' => 'is_IS',
|
---|
54 | 'Indonesian' => 'id_ID',
|
---|
55 | 'Italian' => 'it_IT',
|
---|
56 | 'Khmer' => 'km_KH',
|
---|
57 | 'ko_utf8' => 'ko_KR',
|
---|
58 | 'Latvian' => 'lv',
|
---|
59 | 'Lithuanian' => 'lt_LT',
|
---|
60 | 'Macedonian' => 'mk_MK',
|
---|
61 | 'Malagasy' => 'mg_MG',
|
---|
62 | 'Malay' => 'ms_MY',
|
---|
63 | 'Nias' => 'ni_ID',
|
---|
64 | 'Norwegian' => 'nb_NO',
|
---|
65 | 'Persian' => 'fa_IR',
|
---|
66 | 'Polish' => 'pl_PL',
|
---|
67 | 'European Portuguese' => 'pt_PT',
|
---|
68 | 'Romanian' => 'ro',
|
---|
69 | 'Russian' => 'ru_RU',
|
---|
70 | 'Serbian' => 'sr_RS',
|
---|
71 | 'Sinhala' => 'si_LK',
|
---|
72 | 'Slovak' => 'sk_SK',
|
---|
73 | 'Slovenian' => 'sl_SI',
|
---|
74 | 'Spanish' => 'es_ES',
|
---|
75 | 'Sundanese' => 'su_ID',
|
---|
76 | 'Swedish' => 'sv_SE',
|
---|
77 | 'Tajik' => 'tg',
|
---|
78 | 'Thai' => 'th',
|
---|
79 | 'Turkish' => 'tr',
|
---|
80 | 'Ukrainian' => 'uk',
|
---|
81 | 'Uzbek' => 'uz_UZ',
|
---|
82 | 'Vietnamse' => 'vi',
|
---|
83 | 'Welsh' => 'cy',
|
---|
84 | );
|
---|
85 |
|
---|
86 | function wpInfo(){
|
---|
87 | $this->__construct();
|
---|
88 | }
|
---|
89 | function __construct() {
|
---|
90 | global $xoopsDB;
|
---|
91 | $this->mod_dirpath = dirname(dirname(__FILE__));
|
---|
92 | $this->mod_name = basename(dirname(dirname(__FILE__)));
|
---|
93 | $this->mod_url = XOOPS_URL . '/modules/'.$this->mod_name;
|
---|
94 | $this->load_lang();
|
---|
95 | $this->xoops_Lang = @$GLOBALS["xoopsConfig"]['language'];
|
---|
96 | $this->php_version = phpversion();
|
---|
97 | list($SV) = $xoopsDB->fetchRow($xoopsDB->query('SELECT version()'));
|
---|
98 | $this->mysql_version = $SV;
|
---|
99 |
|
---|
100 | $this->get_wpLang();
|
---|
101 | }
|
---|
102 | function text_indent($text,$num = 1,$css_option='')
|
---|
103 | {
|
---|
104 | $ret = '';
|
---|
105 | $px = 24 * $num;
|
---|
106 | $ret = '<div style="padding-left:' .$px .'px;'.$css_option.'">';
|
---|
107 | $ret .= $text . '</div>';
|
---|
108 | return $ret;
|
---|
109 | }
|
---|
110 | public function load_lang()
|
---|
111 | {
|
---|
112 | $lang = @$GLOBALS["xoopsConfig"]['language'];
|
---|
113 |
|
---|
114 | // language file (modinfo.php)
|
---|
115 | if( file_exists( $this->mod_dirpath .'/language/'.$lang.'/admin.php' ) ) {
|
---|
116 | include_once $this->mod_dirpath .'/language/'.$lang.'/admin.php' ;
|
---|
117 | } else if( file_exists( $this->mod_dirpath .'/language/english/admin.php' ) ) {
|
---|
118 | include_once $this->mod_dirpath .'/language/english/admin.php' ;
|
---|
119 | }
|
---|
120 | }
|
---|
121 |
|
---|
122 | public function get_php_version()
|
---|
123 | {
|
---|
124 | return $this->php_version;
|
---|
125 | }
|
---|
126 | public function get_mysql_version()
|
---|
127 | {
|
---|
128 | return $this->mysql_version;
|
---|
129 | }
|
---|
130 | public function get_wpLang($xoops_Lang = '')
|
---|
131 | {
|
---|
132 | if(!empty($xoops_Lang)) $this->xoops_Lang = $xoops_Lang;
|
---|
133 | $this->wp_Lang = $this->wp_lang_array[$this->xoops_Lang];
|
---|
134 | if (empty($this->wp_Lang)) $this->wp_Lang = 'en_US';
|
---|
135 | return $this->wp_Lang;
|
---|
136 | }
|
---|
137 | public function get_mod_image_link($file_name='')
|
---|
138 | {
|
---|
139 | $link_url = '';
|
---|
140 | if(!empty($file_name)){
|
---|
141 | if(file_exists($this->mod_dirpath.'/images/'.$file_name)){
|
---|
142 | $link_url = '<img alt="'.$file_name.'" src="'. $this->mod_url .'/images/'.$file_name.'" title="'.$file_name.'" align=top>';
|
---|
143 | }
|
---|
144 | }
|
---|
145 | return $link_url;
|
---|
146 | }
|
---|
147 |
|
---|
148 | function is_wpdb_installed(){
|
---|
149 | global $xoopsDB;
|
---|
150 | $prefix_mod = XOOPS_DB_PREFIX .'_' . preg_replace('/wordpress/','wp',$this->mod_name) . '_';
|
---|
151 | $sql = "SHOW TABLES LIKE '$prefix_mod%'";
|
---|
152 | if ($result = $xoopsDB->queryf($sql)){
|
---|
153 | if($xoopsDB->getRowsNum($result)) return true;
|
---|
154 | }
|
---|
155 | return false;
|
---|
156 | }
|
---|
157 |
|
---|
158 | public function is_wp_file_found()
|
---|
159 | {
|
---|
160 | if (!file_exists($this->mod_dirpath . '/wp-settings.php')){
|
---|
161 | return false;
|
---|
162 | }
|
---|
163 | return true;
|
---|
164 | }
|
---|
165 | public function get_download_info($locale='')
|
---|
166 | {
|
---|
167 | $local_package = '';
|
---|
168 | $mysql_version = preg_replace('/[^0-9.].*/', '', $this->mysql_version);
|
---|
169 | $php_version = $this->php_version;
|
---|
170 |
|
---|
171 | if (empty($locale)) $locale = $this->wp_Lang;
|
---|
172 |
|
---|
173 | /* test
|
---|
174 | $mysql_version='4.0.27';
|
---|
175 | $php_version = '4.1.1';
|
---|
176 | */
|
---|
177 | // wprdpress original option
|
---|
178 | // ?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package";
|
---|
179 | $option = "?php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package";
|
---|
180 | $url = "http://api.wordpress.org/core/version-check/1.5/" .$option;
|
---|
181 | $handle = @fopen($url,'r');
|
---|
182 | if ($handle) {
|
---|
183 | $ans = array();
|
---|
184 | $num = 0;
|
---|
185 | $pos = 0;
|
---|
186 | while (($buffer = fgets($handle, 4096)) !== false) {
|
---|
187 | $buffer = trim($buffer);
|
---|
188 | if (strlen($buffer) == 0) {
|
---|
189 | $num++;
|
---|
190 | $pos=0;
|
---|
191 | } else {
|
---|
192 | $ans[$num][$pos] = $buffer;
|
---|
193 | $pos++;
|
---|
194 | }
|
---|
195 | }
|
---|
196 | if (!feof($handle)) {
|
---|
197 | echo "Error: unexpected fgets() fail\n";
|
---|
198 | }
|
---|
199 | fclose($handle);
|
---|
200 | }
|
---|
201 | $ressponce = $ans[0][0];
|
---|
202 | $site_url = $ans[0][1];
|
---|
203 | $download_url = $ans[0][2];
|
---|
204 | $wp_version = $ans[0][3];
|
---|
205 | $download_lang = $ans[0][4];
|
---|
206 | // print_r($ans);
|
---|
207 | if (isset($ans[1])){
|
---|
208 | $en_download_url = $ans[1][2];
|
---|
209 | }
|
---|
210 | $ret = $this->text_indent('(Check URL: '.$url.')',3);
|
---|
211 | if ($locale == $download_lang){
|
---|
212 | $ret .= $this->text_indent(sprintf(_AM_XP2_WP_INFO_1,$locale),2);
|
---|
213 | $ret .= $this->text_indent('<a href="'.$download_url.'">' . $download_url .'</a>' ,3);
|
---|
214 | if (!empty($en_download_url)){
|
---|
215 | $ret .= $this->text_indent(_AM_XP2_WP_INFO_4,2);
|
---|
216 | $ret .= $this->text_indent('<a href="'.$en_download_url .'">' . $en_download_url .'</a>' ,3);
|
---|
217 | }
|
---|
218 | } else {
|
---|
219 | $ret .= $this->text_indent(sprintf(_AM_XP2_WP_INFO_2,$locale));
|
---|
220 | $ret .= $this->text_indent(_AM_XP2_WP_INFO_3,2);
|
---|
221 | $ret .= $this->text_indent('<a href="http://codex.wordpress.org/WordPress_in_Your_Language" target=" _blank">WordPress_in_Your_Language</a>' ,3);
|
---|
222 | $ret .= $this->text_indent(_AM_XP2_WP_INFO_4,2);
|
---|
223 | $ret .= $this->text_indent('<a href="'.$download_url.'">' . $download_url .'</a>' ,3);
|
---|
224 | }
|
---|
225 | echo $ret;
|
---|
226 | }
|
---|
227 | }
|
---|
228 | ?> |
---|