XPressME Integration Kit

Trac

source: branches/Ver3.0/xpressme_integration_kit/admin/index.php @ 749

Last change on this file since 749 was 749, checked in by toemon, 13 years ago

Database::getInstance()を使わずに、global $xoopsDB を使用する。(xoops3対策)

File size: 29.9 KB
Line 
1<?php
2// $Id: xoops_version.php,v 1.8 2005/06/03 01:35:02 phppp Exp $
3//  ------------------------------------------------------------------------ //
4//                XOOPS - PHP Content Management System                      //
5//                    Copyright (c) 2000 XOOPS.org                           //
6//                       <http://www.xoops.org/>                             //
7//  ------------------------------------------------------------------------ //
8//  This program is free software; you can redistribute it and/or modify     //
9//  it under the terms of the GNU General Public License as published by     //
10//  the Free Software Foundation; either version 2 of the License, or        //
11//  (at your option) any later version.                                      //
12//                                                                           //
13//  You may not change or alter any portion of this comment or credits       //
14//  of supporting developers from this source code or any supporting         //
15//  source code which is considered copyrighted (c) material of the          //
16//  original comment or credit authors.                                      //
17//                                                                           //
18//  This program is distributed in the hope that it will be useful,          //
19//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21//  GNU General Public License for more details.                             //
22//                                                                           //
23//  You should have received a copy of the GNU General Public License        //
24//  along with this program; if not, write to the Free Software              //
25//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26//  ------------------------------------------------------------------------ //
27// Author: phppp (D.J.)                                                      //
28// URL: http://xoopsforge.com, http://xoops.org.cn                           //
29// ------------------------------------------------------------------------- //
30//include_once 'cp_functions.php';
31
32function admin_check_user_meta_prefix($is_report = false){
33        global $xoopsModule,$xoopsDB;
34       
35        $mydirname = basename(dirname(dirname(__FILE__)));
36        $my_dirpath = dirname(dirname(__FILE__));
37        $wp_prefix_only = preg_replace('/wordpress/','wp',$mydirname);
38        $db_prefix = $xoopsDB->prefix($wp_prefix_only);
39
40        $usermeta_tbl = $db_prefix . '_usermeta';       
41        $meta_key_pattern = '_' . $wp_prefix_only . '_';
42
43        $sql = "SELECT count(umeta_id) as data_count ,meta_key FROM $usermeta_tbl GROUP BY meta_key HAVING meta_key LIKE '%" . $meta_key_pattern ."%'" ;
44        $res =  $xoopsDB->query($sql, 0, 0);
45       
46        if ($res === false){
47                $check_str = _AM_XP2_USER_META_NONE . "<br />\n";
48        } else {
49                $error =false;
50                $check_str = '';
51                while($row = $xoopsDB->fetchArray($res)){
52                        $data_count  = $row['data_count'];
53                        $meta_key = $row['meta_key'];
54                        if ( !preg_match('/^'.$db_prefix. '_.*/',$meta_key , $maches)){
55                                $check_str .= sprintf(_AM_XP2_USER_META_ERR , $meta_key,$data_count) ."<br /> \n";
56                                $error = true;
57                        }
58                }
59                if (!$error)
60                        $check_str = _AM_XP2_USER_META_OK ;
61        }
62        if ($is_report) {
63                echo "******** "  . _AM_XP2_USER_META_KEY . "********" . "<br />\n";
64                echo $check_str . "<br />\n<br />\n";
65        } else {
66                echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_XP2_USER_META_KEY . "</legend>";
67                echo "<div style='padding: 8px;'>";
68                echo $check_str;
69                echo "</div>";
70                echo '</legend>';
71                echo "</fieldset><br />";
72        }
73
74}
75
76function get_xpress_plugin_data( $plugin_file, $markup = true, $translate = true ) {
77        // We don't need to write to the file, so just open for reading.
78        $fp = fopen($plugin_file, 'r');
79
80        // Pull only the first 8kiB of the file in.
81        $plugin_data = fread( $fp, 8192 );
82
83        // PHP will close file handle, but we are good citizens.
84        fclose($fp);
85
86        preg_match( '|Plugin Name:(.*)$|mi', $plugin_data, $name );
87        preg_match( '|Plugin URI:(.*)$|mi', $plugin_data, $uri );
88        preg_match( '|Version:(.*)|i', $plugin_data, $version );
89        preg_match( '|Description:(.*)$|mi', $plugin_data, $description );
90        preg_match( '|Author:(.*)$|mi', $plugin_data, $author_name );
91        preg_match( '|Author URI:(.*)$|mi', $plugin_data, $author_uri );
92        preg_match( '|Text Domain:(.*)$|mi', $plugin_data, $text_domain );
93        preg_match( '|Domain Path:(.*)$|mi', $plugin_data, $domain_path );
94
95        foreach ( array( 'name', 'uri', 'version', 'description', 'author_name', 'author_uri', 'text_domain', 'domain_path' ) as $field ) {
96                if ( !empty( ${$field} ) )
97                        ${$field} = trim(${$field}[1]);
98                else
99                        ${$field} = '';
100        }
101
102        $plugin_data = array(
103                                'Name' => $name, 'Title' => $name, 'PluginURI' => $uri, 'Description' => $description,
104                                'Author' => $author_name, 'AuthorURI' => $author_uri, 'Version' => $version,
105                                'TextDomain' => $text_domain, 'DomainPath' => $domain_path
106                                );
107//      if ( $markup || $translate )
108//              $plugin_data = _get_plugin_data_markup_translate($plugin_data, $markup, $translate);
109        return $plugin_data;
110}
111
112
113function get_xpress_active_plugin_list($before_str = '')
114{
115        global $xoopsModule,$xoopsDB;
116       
117        $mydirname = basename(dirname(dirname(__FILE__)));
118        $my_dirpath = dirname(dirname(__FILE__));
119        $prefix = preg_replace('/wordpress/','wp',$mydirname);
120        $wp_prefix = $xoopsDB->prefix($prefix);
121
122        $option_table = $wp_prefix . '_options';
123       
124        $sql = "SELECT option_value FROM $option_table WHERE option_name = 'active_plugins'";
125        $res =  $xoopsDB->query($sql, 0, 0);
126        if ($res === false){
127            return ;
128        } else {
129                $row = $xoopsDB->fetchArray($res);
130                $active_plugins = @unserialize($row['option_value']);
131                $output = '';
132                foreach($active_plugins as $active_plugin_path){
133                        $file_name =  $my_dirpath . '/wp-content/plugins/' . $active_plugin_path;
134                        $active_plugin = get_xpress_plugin_data($file_name);
135                        $output .= $before_str . $active_plugin['Name'] . ':   Version ' . $active_plugin['Version'] . ':  (' .$active_plugin['PluginURI'] . ')<br />';
136                }
137               
138               
139                return $output;
140        }
141
142       
143}
144
145function xpress_active_plugin_list($is_report = false)
146{
147        if ($is_report) {
148                echo "******** "  . _AM_XP2_PLUGIN . "********" . "<br />\n";
149                echo get_xpress_active_plugin_list('') . "<br />\n";
150        } else {
151                echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_XP2_PLUGIN . "</legend>";
152                echo "<div style='padding: 8px;'>";
153                echo get_xpress_active_plugin_list();
154                echo "</div>";
155                echo '</legend>';
156                echo "</fieldset><br />";
157        }
158}
159
160function xpress_sys_info($is_report = false)
161{
162        global $xoopsModule;
163        include(dirname(__FILE__) . '/../wp-includes/version.php');
164        require_once dirname(dirname( __FILE__ )).'/include/memory_limit.php' ;
165
166        if ($is_report) {
167                echo "******** "  . _AM_XP2_SYSTEM_INFO . "********" . "<br />\n";
168                echo "SERVER:  ". $_SERVER['SERVER_SOFTWARE']. "<br />\n";
169                echo "PHP Version:   " . phpversion() . "<br />\n";
170                echo 'libxml Version:  ';
171                if (defined('LIBXML_DOTTED_VERSION')) echo LIBXML_DOTTED_VERSION ; else echo "Can't detect.";
172                echo "<br />\n";;
173                echo "MySQL Version:   " . mysql_get_server_info() . "</text><br />";
174                echo "XOOPS Version:   " . XOOPS_VERSION . "</text><br />";
175                echo "XPressME Version:   " . $xoopsModule->getInfo('version') . ' ' . $xoopsModule->getInfo('codename') . "<br />\n";
176                echo "WordPress Version:   " . $wp_version . "<br />\n";
177                echo "WP DB Version:   " . $wp_db_version . "<br />\n";
178                echo "<br />\n";
179                echo "safemode:   " ;
180                echo ( ini_get( 'safe_mode' ) ) ? "ON" : "OFF";
181                echo "<br />\n";
182                echo "register_globals:   " ;
183                echo ( ini_get( 'register_globals' )) ? "ON" : "OFF" ;
184                echo "<br />\n";
185                echo "allow_url_fopen:   " ;
186                echo ( ini_get( 'allow_url_fopen' )) ? "ON" : "OFF" ;
187                echo "<br />\n";
188                echo "magic_quotes_gpc:   " ;
189                echo ( ini_get( 'magic_quotes_gpc' )) ? "ON" : "OFF";
190                echo "<br />\n";
191                echo "XML extension:   " ;
192                echo ( extension_loaded( 'xml' )) ? "ON" : "OFF";
193                echo "<br />\n";
194                echo "default memory_limit:   " ;
195                echo  ini_get( 'memory_limit' );
196                echo "<br />\n";
197                xpress_set_memory_limmit();
198                echo "change memory_limit:   " ;
199                echo  ini_get( 'memory_limit' );
200                echo "<br />\n";
201               
202                echo "post_max_size:   " ;
203                echo  ini_get( 'post_max_size' );
204                echo "<br />\n";
205                echo "upload_max_filesize:   " ;
206                echo  ini_get( 'upload_max_filesize' );
207                echo "<br />\n";
208                echo "display_errors:   " ;
209                echo ( ini_get( 'display_errors' )) ? "ON" : "OFF";
210                echo "<br />\n";
211                echo "MB extension:   " ;
212                echo ( extension_loaded( 'mbstring' )) ? "ON" : "OFF";
213                echo "<br />\n";
214                echo "mbstring.language:   " ;
215                echo  ini_get( 'mbstring.language' );
216                echo "<br />\n";
217                echo "mbstring.encoding_translation:   " ;
218                echo  ( ini_get( 'mbstring.encoding_translation' )) ? "ON" : "OFF";
219                echo "<br />\n";
220                echo "mbstring.internal_encoding:   " ;
221                echo  ini_get( 'mbstring.internal_encoding' );
222                echo "<br />\n";
223                echo "mbstring.http_input:   " ;
224                echo  ini_get( 'mbstring.http_input' );
225                echo "<br />\n";
226                echo "mbstring.http_output:   " ;
227                echo  ini_get( 'mbstring.http_output' );
228                echo "<br />\n";
229                echo "mbstring.detect_order:   " ;
230                echo  ini_get( 'mbstring.detect_order' );
231                echo "<br />\n";
232                echo "mbstring.substitute_character:   " ;
233                echo  ini_get( 'mbstring.substitute_character' );
234                echo "<br />\n";
235                echo "mbstring.func_overload:   " ;
236                echo  ( ini_get( 'mbstring.func_overload' )) ? "ON" : "OFF";
237                echo "<br />\n";
238                echo "<br />\n";
239        } else {
240                echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_XP2_SYSTEM_INFO . "</legend>";
241                echo "<div style='padding: 8px;'>";
242                echo "<label>" . "<strong>SERVER:</strong>" . ":</label><text>" . $_SERVER['SERVER_SOFTWARE'] . "</text><br />";
243                echo "<label>" . "<strong>PHP Version:</strong>" . ":</label><text>" . phpversion() . "</text><br />";
244                echo "<label>" . "<strong>libxml Version:</strong>" . ":</label><text>";
245                if (defined('LIBXML_DOTTED_VERSION')) echo LIBXML_DOTTED_VERSION ; else echo "Can't detect.";
246                echo "</text><br />";
247                echo "<label>" . "<strong>MySQL Version:</strong>" . ":</label><text>" . mysql_get_server_info() . "</text><br />";
248                echo "<label>" . "<strong>XOOPS Version:</strong>" . ":</label><text>" . XOOPS_VERSION . "</text><br />";
249                echo "<label>" . "<strong>XPressME Version:</strong>" . ":</label><text>" . $xoopsModule->getInfo('version') . ' ' . $xoopsModule->getInfo('codename') . "</text><br />";
250                echo "<label>" . "<strong>WordPress Version:</strong>" . ":</label><text>" . $wp_version . "</text><br />";
251                echo "<label>" . "<strong>WP DB Version:</strong>" . ":</label><text>" . $wp_db_version . "</text><br />";
252
253                echo "</div>";
254                echo "<div style='padding: 8px;'>";
255                echo "<label>safemode:</label><text>";
256                echo ( ini_get( 'safe_mode' ) ) ? "ON" : "OFF";
257                echo "</text><br />";
258                echo "<label>register_globals:</label><text>";
259                echo ( ini_get( 'register_globals' )) ? "ON" : "OFF";
260                echo "</text><br />";
261                echo "<label>allow_url_fopen:</label><text>";
262                echo ( ini_get( 'allow_url_fopen' )) ? "ON" : "OFF";
263                echo "</text><br />";
264                echo "<label>magic_quotes_gpc:</label><text>";
265                echo ( ini_get( 'magic_quotes_gpc' )) ? "ON" : "OFF";
266                echo "</text><br />";
267                echo "<label>XML extension:</label><text>";
268                echo ( extension_loaded( 'xml' )) ? "ON" : "OFF";
269                echo "</text><br />";
270                echo "<label>default memory_limit:</label><text>";
271                echo  ini_get( 'memory_limit' );
272                echo "</text><br />";
273                xpress_set_memory_limmit();
274                echo "<label>change memory_limit:</label><text>";
275                echo  ini_get( 'memory_limit' );
276                echo "</text><br />";
277
278                echo "<label>post_max_size:</label><text>";
279                echo  ini_get( 'post_max_size' );
280                echo "</text><br />";
281                echo "<label>upload_max_filesize:</label><text>";
282                echo  ini_get( 'upload_max_filesize' );
283                echo "</text><br />";
284                echo "<label>display_errors:</label><text>";
285                echo ( ini_get( 'display_errors' )) ? "ON" : "OFF";
286                echo "</text><br />";
287                echo "<label>MB extension:</label><text>";
288                echo ( extension_loaded( 'mbstring' )) ? "ON" : "OFF";
289                echo "</text><br />";
290                echo "<label>mbstring.language:</label><text>";
291                echo  ini_get( 'mbstring.language' );
292                echo "</text><br />";
293                echo "<label>mbstring.encoding_translation:</label><text>";
294                echo  ( ini_get( 'mbstring.encoding_translation' )) ? "ON" : "OFF";
295                echo "</text><br />";
296                echo "<label>mbstring.internal_encoding:</label><text>";
297                echo  ini_get( 'mbstring.internal_encoding' );
298                echo "</text><br />";
299                echo "<label>mbstring.http_input:</label><text>";
300                echo  ini_get( 'mbstring.http_input' );
301                echo "</text><br />";
302                echo "<label>mbstring.http_output:</label><text>";
303                echo  ini_get( 'mbstring.http_output' );
304                echo "</text><br />";
305                echo "<label>mbstring.detect_order:</label><text>";
306                echo  ini_get( 'mbstring.detect_order' );
307                echo "</text><br />";
308                echo "<label>mbstring.substitute_character:</label><text>";
309                echo  ini_get( 'mbstring.substitute_character' );
310                echo "</text><br />";
311                echo "<label>mbstring.func_overload:</label><text>";
312                echo  ( ini_get( 'mbstring.func_overload' )) ? "ON" : "OFF";
313                echo "</text><br />";
314                echo "</div>";
315                echo '</legend>';
316                echo "</fieldset><br />";
317        }
318}
319
320
321function xpress_config_report_view()
322{
323        require_once dirname(dirname( __FILE__ )).'/class/config_from_xoops.class.php' ;
324        $xoops_config = new ConfigFromXoops;
325        echo 'XOOPS_ROOT_PATH:  ' ;
326        if(XOOPS_ROOT_PATH !== $xoops_config->xoops_root_path)
327                echo 'ERROR ';
328        else
329                echo 'OK ';     
330        echo "<br />\n";
331
332        echo 'XOOPS_TRUST_PATH:  ' ;
333        if(XOOPS_TRUST_PATH !== $xoops_config->xoops_trust_path)
334                echo 'ERROR ';
335        else
336                echo 'OK ';     
337        echo "<br />\n";
338
339        echo 'XOOPS_URL:  ' ;
340        if(XOOPS_URL !== $xoops_config->xoops_url)
341                echo 'ERROR ';
342        else
343                echo 'OK ';     
344        echo "<br />\n";
345
346        if (defined('XOOPS_SALT')){
347                echo 'XOOPS_SALT:  ' ;
348                if(XOOPS_SALT !== $xoops_config->xoops_salt)
349                        echo 'ERROR ';
350                else
351                        echo 'OK ';     
352                echo "<br />\n";
353        }
354
355        if (defined('XOOPS_DB_SALT')){
356                echo 'XOOPS_DB_SALT:  ' ;
357                if(XOOPS_DB_SALT !== $xoops_config->xoops_db_salt)
358                        echo 'ERROR ';
359                else
360                        echo 'OK ';     
361                echo "<br />\n";
362        }
363
364        echo 'XOOPS_DB_HOST:  ' ;
365        if(XOOPS_DB_HOST !== $xoops_config->xoops_db_host)
366                echo 'ERROR ';
367        else
368                echo 'OK ';     
369        echo "<br />\n";
370
371        echo 'XOOPS_DB_USER:  ' ;
372        if(XOOPS_DB_USER !== $xoops_config->xoops_db_user)
373                echo 'ERROR ';
374        else
375                echo 'OK ';     
376        echo "<br />\n";
377
378        echo 'XOOPS_DB_PASS:  ' ;
379        if(XOOPS_DB_PASS !== $xoops_config->xoops_db_pass)
380                echo 'ERROR ';
381        else
382                echo 'OK ';     
383        echo "<br />\n";
384
385        echo 'XOOPS_DB_NAME:  ' ;
386        if(XOOPS_DB_NAME !== $xoops_config->xoops_db_name)
387                echo 'ERROR ';
388        else
389                echo 'OK ';     
390        echo "<br />\n";
391
392        echo 'XOOPS_DB_PREFIX:  ' ;
393        if(XOOPS_DB_PREFIX !== $xoops_config->xoops_db_prefix)
394                echo 'ERROR ';
395        else
396                echo 'OK ';     
397        echo "<br />\n";
398}
399
400function xpress_config_nomal_view()
401{
402        require_once dirname(dirname( __FILE__ )).'/class/config_from_xoops.class.php' ;
403        $xoops_config = new ConfigFromXoops;
404       
405        echo '<table width="400" cellspacing="1" cellpadding="1" border="1">';
406        echo '<tbody>';
407        echo '<tr>';
408        echo '<td>Define item</td>';
409        echo '<td>XOOPS setting value</td>';
410        echo '<td>xoops_config get value</td>';
411        echo '</tr>';
412        echo '<tr>';
413        if(XOOPS_ROOT_PATH !== $xoops_config->xoops_root_path)
414                echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_ROOT_PATH</span></strong></td>';
415        else
416                echo '<td>XOOPS_ROOT_PATH</td>';       
417        echo '<td>' . XOOPS_ROOT_PATH . '</td>';
418        echo '<td>' . $xoops_config->xoops_root_path . '</td>';
419        echo '</tr>';
420
421        echo '<tr>';
422        if(XOOPS_TRUST_PATH !== $xoops_config->xoops_trust_path)
423                echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_TRUST_PATH</span></strong></td>';
424        else
425                echo '<td>XOOPS_TRUST_PATH</td>';       
426        echo '<td>' . XOOPS_TRUST_PATH . '</td>';
427        echo '<td>' . $xoops_config->xoops_trust_path . '</td>';
428        echo '</tr>';
429
430        echo '<tr>';
431        if(XOOPS_URL !== $xoops_config->xoops_url)
432                echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_URL</span></strong></td>';
433        else
434                echo '<td>XOOPS_URL</td>';     
435        echo '<td>' . XOOPS_URL . '</td>';
436        echo '<td>' . $xoops_config->xoops_url . '</td>';
437        echo '</tr>';
438
439        if (defined('XOOPS_SALT')){
440                echo '<tr>';
441                if(XOOPS_SALT !== $xoops_config->xoops_salt)
442                        echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_SALT</span></strong></td>';
443                else
444                        echo '<td>XOOPS_SALT</td>';
445                echo '<td>' . XOOPS_SALT . '</td>';
446                echo '<td>' . $xoops_config->xoops_salt . '</td>';
447                echo '</tr>';
448        }
449
450        if (defined('XOOPS_DB_SALT')){
451                echo '<tr>';
452                if(XOOPS_DB_SALT !== $xoops_config->xoops_db_salt)
453                        echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_DB_SALT</span></strong></td>';
454                else
455                        echo '<td>XOOPS_DB_SALT</td>';
456                echo '<td>' . XOOPS_DB_SALT . '</td>';
457                echo '<td>' . $xoops_config->xoops_db_salt . '</td>';
458                echo '</tr>';
459        }
460
461        echo '<tr>';
462        if(XOOPS_DB_HOST !== $xoops_config->xoops_db_host)
463                echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_DB_HOST</span></strong></td>';
464        else
465                echo '<td>XOOPS_DB_HOST</td>';
466        echo '<td>' . XOOPS_DB_HOST . '</td>';
467        echo '<td>' . $xoops_config->xoops_db_host . '</td>';
468        echo '</tr>';
469
470        echo '<tr>';
471        if(XOOPS_DB_USER !== $xoops_config->xoops_db_user)
472                echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_DB_USER</span></strong></td>';
473        else
474                echo '<td>XOOPS_DB_USER</td>';
475        echo '<td>' . XOOPS_DB_USER . '</td>';
476        echo '<td>' . $xoops_config->xoops_db_user . '</td>';
477        echo '</tr>';
478
479        echo '<tr>';
480        if(XOOPS_DB_PASS !== $xoops_config->xoops_db_pass)
481                echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_DB_PASS</span></strong></td>';
482        else
483                echo '<td>XOOPS_DB_PASS</td>';
484        echo '<td>' . XOOPS_DB_PASS . '</td>';
485        echo '<td>' . $xoops_config->xoops_db_pass . '</td>';
486        echo '</tr>';
487
488        echo '<tr>';
489        if(XOOPS_DB_NAME !== $xoops_config->xoops_db_name)
490                echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_DB_NAME</span></strong></td>';
491        else
492                echo '<td>XOOPS_DB_NAME</td>';
493        echo '<td>' . XOOPS_DB_NAME . '</td>';
494        echo '<td>' . $xoops_config->xoops_db_name . '</td>';
495        echo '</tr>';
496
497        echo '<tr>';
498        if(XOOPS_DB_PREFIX !== $xoops_config->xoops_db_prefix)
499                echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_DB_PREFIX</span></strong></td>';
500        else
501                echo '<td>XOOPS_DB_PREFIX</td>';
502        echo '<td>' . XOOPS_DB_PREFIX . '</td>';
503        echo '<td>' . $xoops_config->xoops_db_prefix . '</td>';
504        echo '</tr>';
505        echo '</tbody>';
506        echo '</table>';
507}
508function xpress_config_from_xoops_view($is_report = false)
509{
510        global $xoopsUserIsAdmin,$xoopsUser;
511
512        $user_groups = $xoopsUser->getGroups();
513        $is_admin_group = in_array('1',$user_groups);
514       
515        require_once dirname(dirname( __FILE__ )).'/class/config_from_xoops.class.php' ;
516        $xoops_config = new ConfigFromXoops;
517        if ($is_report) {
518                echo "******** "  . _AM_XP2_XOOPS_CONFIG_INFO . "********" . "<br />\n";
519                xpress_config_report_view();
520                echo "<br />\n";
521        } else {
522                echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_XP2_XOOPS_CONFIG_INFO . "</legend>";
523                echo "<div style='padding: 8px;'>";
524                if ($xoopsUserIsAdmin && $is_admin_group){
525                        xpress_config_nomal_view();
526                } else {
527                        xpress_config_report_view();
528                }
529                echo "</div>";
530                echo '</legend>';
531                echo "</fieldset><br />";
532        }
533}
534
535function xpress_state($is_report = false)
536{
537        global $xoopsModule,$xoopsDB;
538        include(dirname(__FILE__) . '/../wp-includes/version.php');
539        include_once(dirname(__FILE__) . '/../include/general_functions.php');
540
541       
542        $xp_prefix = $GLOBALS['xoopsModule']->getInfo('dirname');
543        $xp_prefix = preg_replace('/wordpress/','wp',$xp_prefix);
544
545        $prefix = $xoopsDB->prefix($xp_prefix . '_');
546       
547        $posts_tables = get_table_list($prefix,'posts');
548        $blogname = array();
549        $count_article = array();
550        $count_author = array();
551        $count_category = array();
552        $array_index = 0;
553        foreach( $posts_tables as $posts_table){
554                $sql = "SELECT COUNT(DISTINCT post_author) AS count_author, COUNT(*) AS count_article FROM ". $posts_table . " WHERE post_type = 'post' AND (post_status = 'publish' OR post_status = 'private')";
555                $result = $xoopsDB->query($sql);
556                if($myrow = $xoopsDB->fetchArray($result)){
557                        $count_article[$array_index] = $myrow["count_article"];
558                        $count_author[$array_index] = $myrow["count_author"];
559                } else {
560                        $count_article[$array_index] = 0;
561                        $count_author[$array_index] = 0;
562                }
563                $mid_prefix = get_multi_mid_prefix($prefix,'posts' , $posts_table);
564               
565                $sql = "SELECT option_value AS blogname FROM ".$prefix. $mid_prefix . "options" . " WHERE option_name = 'blogname'";
566                $result = $xoopsDB->query($sql);
567                if($myrow = $xoopsDB->fetchArray($result)){
568                        $blogname[$array_index] = $myrow["blogname"];
569                } else {
570                        $blogname[$array_index] = 'none name';
571                }
572               
573                if ($wp_db_version < 6124){
574                       
575                        $sql = "SELECT COUNT(*) AS count_category FROM ".$prefix. $mid_prefix . "categories";
576                } else {
577                        $sql = "SELECT COUNT(*) AS count_category FROM ".$prefix. $mid_prefix . "term_taxonomy" . " WHERE taxonomy = 'category'";
578                }
579                $result = $xoopsDB->query($sql);
580                if($myrow = $xoopsDB->fetchArray($result)){
581                        $count_category[$array_index] = $myrow["count_category"];
582                } else {
583                        $count_category[$array_index] = 0;
584                }
585                $array_index++;
586        }
587        for ($i = 0 ; $i < $array_index ; $i++){
588                if ($is_report){
589                        echo "******** " . $blogname[$i] . _AM_XP2_STATS . "********" . "<br />\n";
590                        echo _AM_XP2_CATEGORIES .":  ".@$count_category[$i]. "<br />\n";
591                        echo _AM_XP2_ARTICLES .":  ". $count_article[$i]. "<br />\n";
592                        echo _AM_XP2_AUTHORS .":  ". $count_author[$i]. "<br />\n";
593                       
594                } else {
595                        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . $blogname[$i] . _AM_XP2_STATS . "</legend>";
596                        echo "<div style='padding: 8px;'>";
597                        echo "<label>" . _AM_XP2_CATEGORIES .":</label><text>".@$count_category[$i];
598                        echo "</text><br />";
599                        echo "<label>" . _AM_XP2_ARTICLES .":</label><text>". $count_article[$i];
600                        echo "</text><br />";
601                        echo "<label>" . _AM_XP2_AUTHORS .":</label><text>". $count_author[$i];
602                        echo "</text>";
603                        echo "</div>";
604                        echo '</legend>';
605                        echo "</fieldset>";
606                }
607        }
608}
609
610function xpress_group_role_state($is_report = false)
611{
612        global $xoopsModule,$xoopsDB;
613        $xp_prefix = $GLOBALS['xoopsModule']->getInfo('dirname');
614        $xp_prefix = preg_replace('/wordpress/','wp',$xp_prefix);
615        $prefix = $xoopsDB->prefix($xp_prefix . '_');
616        $group_role_tables = $prefix.'group_role';
617        $sql = "SELECT groupid , name AS xoops_groupe ,group_type, role , login_all FROM ". $group_role_tables;
618        $result = $xoopsDB->query($sql);
619        if ($is_report){
620                echo "******** " . _AM_XP2_GROUP_ROLE . "********" . "<br />\n";
621        } else {
622                echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_XP2_GROUP_ROLE . "</legend>";
623                echo "<div style='padding: 8px;'>";
624                echo '<table width="400" cellspacing="1" cellpadding="1" border="1">';
625                echo '<tbody>';
626                echo '<tr>';
627                echo '<td>GROUP</td>';
628                echo '<td>GROUPE TYPE</td>';
629                echo '<td>ROLE</td>';
630                echo '<td>Allways Check</td>';
631                echo '</tr>';
632        }
633        $groupe_list = '';
634        while ($myrow = $xoopsDB->fetchArray($result)){
635                $xoops_groupe = $myrow["xoops_groupe"] ;
636                $group_type = empty($myrow["group_type"]) ? "None" : $myrow["group_type"] ;
637                $role = empty($myrow["role"]) ? "inhibit register" : $myrow["role"] ;
638                $login_all = empty($myrow["login_all"]) ? 'No' : 'Yes' ;
639                if (!empty($groupe_list)) $groupe_list .= ',';
640                $groupe_list .= $myrow["groupid"];
641                if ($is_report){
642                        echo $xoops_groupe . ' : ';
643                        echo '(' . $group_type. ') : ';
644                        echo $role;
645                        echo '(' . $login_all. ') : ';
646                        echo '<br />';
647                } else {
648                        echo '<tr>';
649                        echo '<td>' . $xoops_groupe . '</td>';
650                        echo '<td>' . $group_type . '</td>';
651                        echo '<td>' . $role . '</td>';
652                        echo '<td>' . $login_all . '</td>';
653                        echo '</tr>';
654                }
655        }
656        if ($is_report){
657                echo "<br />";
658        } else {
659                echo '</tbody>';
660                echo '</table>';
661                echo "</div>";
662                echo '</legend>';
663                echo "</fieldset><br />";
664        }
665}
666function xpress_block_state($is_report = false)
667{
668        $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
669
670        include_once(dirname(dirname(__FILE__) ). '/class/check_blocks_class.php');
671        $xoops_block_check =& xoops_block_check::getInstance();
672        $xoops_block_check->check_blocks($mydirname);
673        if ($is_report){
674                echo "******** " . _AM_XP2_BLOCK_STATS . "********" . "<br />\n";
675                echo $xoops_block_check->get_message();
676                echo "<br />\n";
677                echo "<br />\n";
678        } else {
679                echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_XP2_BLOCK_STATS . "</legend>";
680                echo "<div style='padding: 8px;'>";
681                echo $xoops_block_check->get_message();
682                echo "</div>";
683                echo '</legend>';
684                echo "</fieldset><br />";
685        }               
686}
687
688function xpress_block_options($is_report = false)
689{
690        global $xoopsModule;
691        $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
692
693        $module_objs = & get_module_objects($mydirname);
694        $module_obj = $module_objs[0];
695        $mod_id = $xoopsModule->getVar('mid', 'n');
696        $blocks = & get_block_object_orber_num_bymodule_id( $mod_id );
697        $infos    = $xoopsModule->getInfo('blocks');
698        if ($is_report){
699                echo "******** " . _AM_XP2_BLOCK_OPTIONS . "********" . "<br />\n";
700                foreach ( $blocks as $block )
701                {
702                        echo $block->getVar('title') . ' : ' . $block->getVar('options') . '<br />';
703                }
704                echo "<br />\n";
705        } else {
706                echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_XP2_BLOCK_OPTIONS . "</legend>";
707                echo "<div style='padding: 8px;'>";
708                echo '<table width="400" cellspacing="1" cellpadding="1" border="1">';
709                echo '<tbody>';
710                echo '<tr>';
711                echo '<td>Title</td>';
712                echo '<td>Options</td>';
713                echo '</tr>';
714                foreach ( $blocks as $block )
715                {
716                        echo '<tr>';
717                        echo '<td>' . $block->getVar('title') . '</td>';
718                        echo '<td>' . $block->getVar('options') . '</td>';
719                        echo '</tr>';
720                }
721                echo '</tbody>';
722                echo '</table>';
723                echo '</div>';
724                echo '</legend>';
725                echo "</fieldset><br />";
726        }
727
728}
729//--------------------------------------------------------
730// module handler
731//--------------------------------------------------------
732function &get_module_objects($module_dir)
733{
734        $criteria = new CriteriaCompo();
735        $criteria->add( new Criteria('isactive', '1', '=') );
736        $criteria->add( new Criteria('dirname', $module_dir, '=') );
737
738        $module_handler =& xoops_gethandler('module');
739        $objs           =& $module_handler->getObjects( $criteria );
740        return $objs;
741}
742
743//--------------------------------------------------------
744// block handler
745//--------------------------------------------------------
746function &get_block_object_orber_num_bymodule_id( $mid )
747{
748        $arr  = array();
749        $objs =& get_block_object_bymodule_id( $mid );
750        foreach ( $objs as $obj )
751        {
752                $arr[ $obj->getVar('func_num', 'n') ] = $obj;
753        }
754        return $arr;
755}
756
757function &get_block_object_bymodule_id( $mid, $asobject=true )
758{
759        if ( defined('ICMS_VERSION_BUILD') && ICMS_VERSION_BUILD > 27  ) { /* ImpressCMS 1.2+ */
760                $block_handler =& xoops_gethandler ('block');
761                $objs =& $block_handler->getByModule( $mid, $asobject );
762        } else { /* legacy support */
763                $objs =& XoopsBlock::getByModule( $mid, $asobject ) ; /* from class/xoopsblock.php */
764        }
765        return $objs;
766}
767
768
769
770$mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
771$mydirpath = dirname( dirname( __FILE__ ) ) ;
772//require_once($mydirpath.'/wp-config.php');
773
774require_once '../../../include/cp_header.php' ;
775//require_once '../include/gtickets.php' ;
776//define( '_MYMENU_CONSTANT_IN_MODINFO' , '_MI_XP2_NAME' ) ;
777
778// branch for altsys
779if( defined( 'XOOPS_TRUST_PATH' ) && ! empty( $_GET['lib'] ) ) {
780
781        // common libs (eg. altsys)
782        $lib = preg_replace( '/[^a-zA-Z0-9_-]/' , '' , $_GET['lib'] ) ;
783        $page = preg_replace( '/[^a-zA-Z0-9_-]/' , '' , @$_GET['page'] ) ;
784       
785        if( file_exists( XOOPS_TRUST_PATH.'/libs/'.$lib.'/'.$page.'.php' ) ) {
786                include XOOPS_TRUST_PATH.'/libs/'.$lib.'/'.$page.'.php' ;
787        } else if( file_exists( XOOPS_TRUST_PATH.'/libs/'.$lib.'/index.php' ) ) {
788                include XOOPS_TRUST_PATH.'/libs/'.$lib.'/index.php' ;
789        } else {
790                die( 'wrong request' ) ;
791        }
792        exit ;
793}
794include_once $mydirpath .'/include/wp_check.php' ;
795
796// beggining of Output
797xoops_cp_header();
798if(is_wpdb_installed()){
799        include( './mymenu.php' ) ;
800
801        echo "
802                <style type=\"text/css\">
803                label,text {
804                        display: block;
805                        float: left;
806                        margin-bottom: 2px;
807                }
808                label {
809                        text-align: right;
810                        width: 200px;
811                        padding-right: 20px;
812                }
813                br {
814                        clear: left;
815                }
816                </style>
817        ";
818        if (!empty($_POST['submit_report'])) $report = true; else $report = false;
819        xpress_sys_info($report);
820        xpress_config_from_xoops_view($report);
821        xpress_active_plugin_list($report);
822        xpress_block_state($report);
823        xpress_block_options($report);
824        xpress_group_role_state($report);
825        admin_check_user_meta_prefix($report);
826        xpress_state($report);
827        echo '<form method="POST">'."\n";
828        echo '<input type="submit" name="submit_report" value="' . _AM_XP2_SYS_REPORT .' " />'.'&emsp;';
829        echo '<input type="submit" name="submit_normal" value="' . _AM_XP2_SYS_NORMAL .' " />'."<br />\n";
830        echo "</form>\n";
831} else {
832
833        include_once $mydirpath .'/include/wp_installer.php' ;
834        if (!empty($_POST['submit_install'])) {
835                $i_mess = wp_installer($mydirname);
836                foreach( $i_mess as $message ) {
837                        echo $message ;
838                }
839
840        } else {
841                echo '<font size="5" color="#ff0000">'. _AM_XP2_NO_WP. '</font><br /><br />';
842
843                if (xp_permission_check($mydirname , $mydirpath)){
844                        echo '<form method="POST">'."\n";
845                        echo '<input type="submit" name="submit_install" value="' . _AM_XP2_WP_INSTALL .' " />'.'&emsp;';
846                        echo "</form>\n";
847                } else {
848                        include_once $mydirpath .'/admin/help/wp_install_help.php' ;
849                        wp_install_guide();
850                        echo '<form method="POST">'."\n";
851                        echo '<input type="submit" name="submit_recheck" value="' . _AM_XP2_WP_RE_CHK .' " />'.'&emsp;';
852                        echo "</form>\n";
853                }
854        }
855}
856xoops_cp_footer();
857
858       
859?>
Note: See TracBrowser for help on using the repository browser.