XPressME Integration Kit

Trac

source: trunk/xpressme_integration_kit/admin/index.php @ 860

Last change on this file since 860 was 860, checked in by toemon, 8 years ago

PHP7 対応 Fix #431
thx nao-pon

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