XPressME Integration Kit

Trac

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

Last change on this file since 510 was 510, checked in by toemon, 14 years ago

ブロックの配置権限をもたせたユーザがDB接続情報を見ることができてしまうバグを修正 Fixes #283

File size: 24.5 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 =& Database::getInstance();
35       
36        $mydirname = basename(dirname(dirname(__FILE__)));
37        $my_dirpath = dirname(dirname(__FILE__));
38        $wp_prefix_only = $mydirname;
39        if ($wp_prefix_only == 'wordpress') $wp_prefix_only ='wp';
40        $db_prefix = $xoopsDB->prefix($wp_prefix_only);
41
42        $usermeta_tbl = $db_prefix . '_usermeta';       
43        $meta_key_pattern = '_' . $wp_prefix_only . '_';
44
45        $sql = "SELECT count(umeta_id) as data_count ,meta_key FROM $usermeta_tbl GROUP BY meta_key HAVING meta_key LIKE '%" . $meta_key_pattern ."%'" ;
46        $res =  $xoopsDB->query($sql, 0, 0);
47       
48        if ($res === false){
49                $check_str = _AM_XP2_USER_META_NONE . "<br />\n";
50        } else {
51                $error =false;
52                $check_str = '';
53                while($row = $xoopsDB->fetchArray($res)){
54                        $data_count  = $row['data_count'];
55                        $meta_key = $row['meta_key'];
56                        if ( !preg_match('/^'.$db_prefix. '_.*/',$meta_key , $maches)){
57                                $check_str .= sprintf(_AM_XP2_USER_META_ERR , $meta_key,$data_count) ."<br /> \n";
58                                $error = true;
59                        }
60                }
61                if (!$error)
62                        $check_str = _AM_XP2_USER_META_OK ;
63        }
64        if ($is_report) {
65                echo "******** "  . _AM_XP2_USER_META_KEY . "********" . "<br />\n";
66                echo $check_str . "<br />\n<br />\n";
67        } else {
68                echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_XP2_USER_META_KEY . "</legend>";
69                echo "<div style='padding: 8px;'>";
70                echo $check_str;
71                echo "</div>";
72                echo "</fieldset>";
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 =& Database::getInstance();
118       
119        $mydirname = basename(dirname(dirname(__FILE__)));
120        $my_dirpath = dirname(dirname(__FILE__));
121        $prefix = $mydirname;
122        if ($prefix == 'wordpress') $prefix ='wp';
123        $wp_prefix = $xoopsDB->prefix($prefix);
124
125        $option_table = $wp_prefix . '_options';
126       
127        $sql = "SELECT option_value FROM $option_table WHERE option_name = 'active_plugins'";
128        $res =  $xoopsDB->query($sql, 0, 0);
129        if ($res === false){
130            return ;
131        } else {
132                $row = $xoopsDB->fetchArray($res);
133                $active_plugins = @unserialize($row['option_value']);
134                $output = '';
135                foreach($active_plugins as $active_plugin_path){
136                        $file_name =  $my_dirpath . '/wp-content/plugins/' . $active_plugin_path;
137                        $active_plugin = get_xpress_plugin_data($file_name);
138                        $output .= $before_str . $active_plugin['Name'] . ':   Version ' . $active_plugin['Version'] . ':  (' .$active_plugin['PluginURI'] . ')<br />';
139                }
140               
141               
142                return $output;
143        }
144
145       
146}
147
148function xpress_active_plugin_list($is_report = false)
149{
150        if ($is_report) {
151                echo "******** "  . _AM_XP2_PLUGIN . "********" . "<br />\n";
152                echo get_xpress_active_plugin_list('') . "<br />\n";
153        } else {
154                echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_XP2_PLUGIN . "</legend>";
155                echo "<div style='padding: 8px;'>";
156                echo get_xpress_active_plugin_list();
157                echo "</div>";
158                echo "</fieldset>";
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__ )).'/class/config_from_xoops.class.php' ;
167
168        if ($is_report) {
169                echo "******** "  . _AM_XP2_SYSTEM_INFO . "********" . "<br />\n";
170                echo "SERVER:  ". $_SERVER['SERVER_SOFTWARE']. "<br />\n";
171                echo "PHP Version:   " . phpversion() . "<br />\n";
172                echo 'libxml Version:  ';
173                if (defined('LIBXML_DOTTED_VERSION')) echo LIBXML_DOTTED_VERSION ; else echo "Can't detect.";
174                echo "<br />\n";;
175                echo "MySQL Version:   " . mysql_get_server_info() . "</text><br />";
176                echo "XOOPS Version:   " . XOOPS_VERSION . "</text><br />";
177                echo "XPressME Version:   " . $xoopsModule->getInfo('version') . ' ' . $xoopsModule->getInfo('codename') . "<br />\n";
178                echo "WordPress Version:   " . $wp_version . "<br />\n";
179                echo "WP DB Version:   " . $wp_db_version . "<br />\n";
180                echo "<br />\n";
181                echo "safemode:   " ;
182                echo ( ini_get( 'safe_mode' ) ) ? "ON" : "OFF";
183                echo "<br />\n";
184                echo "register_globals:   " ;
185                echo ( ini_get( 'register_globals' )) ? "ON" : "OFF" ;
186                echo "<br />\n";
187                echo "magic_quotes_gpc:   " ;
188                echo ( ini_get( 'magic_quotes_gpc' )) ? "ON" : "OFF";
189                echo "<br />\n";
190                echo "XML extension:   " ;
191                echo ( extension_loaded( 'xml' )) ? "ON" : "OFF";
192                echo "<br />\n";
193                echo "default memory_limit:   " ;
194                echo  ini_get( 'memory_limit' );
195                echo "<br />\n";
196                $xoops_config = new ConfigFromXoops;
197                $xoops_config->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>magic_quotes_gpc:</label><text>";
262                echo ( ini_get( 'magic_quotes_gpc' )) ? "ON" : "OFF";
263                echo "</text><br />";
264                echo "<label>XML extension:</label><text>";
265                echo ( extension_loaded( 'xml' )) ? "ON" : "OFF";
266                echo "</text><br />";
267                echo "<label>default memory_limit:</label><text>";
268                echo  ini_get( 'memory_limit' );
269                echo "</text><br />";
270                $xoops_config = new ConfigFromXoops;
271                $xoops_config->xpress_set_memory_limmit();
272                echo "<label>change memory_limit:</label><text>";
273                echo  ini_get( 'memory_limit' );
274                echo "</text><br />";
275
276                echo "<label>post_max_size:</label><text>";
277                echo  ini_get( 'post_max_size' );
278                echo "</text><br />";
279                echo "<label>upload_max_filesize:</label><text>";
280                echo  ini_get( 'upload_max_filesize' );
281                echo "</text><br />";
282                echo "<label>display_errors:</label><text>";
283                echo ( ini_get( 'display_errors' )) ? "ON" : "OFF";
284                echo "</text><br />";
285                echo "<label>MB extension:</label><text>";
286                echo ( extension_loaded( 'mbstring' )) ? "ON" : "OFF";
287                echo "</text><br />";
288                echo "<label>mbstring.language:</label><text>";
289                echo  ini_get( 'mbstring.language' );
290                echo "</text><br />";
291                echo "<label>mbstring.encoding_translation:</label><text>";
292                echo  ( ini_get( 'mbstring.encoding_translation' )) ? "ON" : "OFF";
293                echo "</text><br />";
294                echo "<label>mbstring.internal_encoding:</label><text>";
295                echo  ini_get( 'mbstring.internal_encoding' );
296                echo "</text><br />";
297                echo "<label>mbstring.http_input:</label><text>";
298                echo  ini_get( 'mbstring.http_input' );
299                echo "</text><br />";
300                echo "<label>mbstring.http_output:</label><text>";
301                echo  ini_get( 'mbstring.http_output' );
302                echo "</text><br />";
303                echo "<label>mbstring.detect_order:</label><text>";
304                echo  ini_get( 'mbstring.detect_order' );
305                echo "</text><br />";
306                echo "<label>mbstring.substitute_character:</label><text>";
307                echo  ini_get( 'mbstring.substitute_character' );
308                echo "</text><br />";
309                echo "<label>mbstring.func_overload:</label><text>";
310                echo  ( ini_get( 'mbstring.func_overload' )) ? "ON" : "OFF";
311                echo "</text><br />";
312                echo "</div>";
313                echo "</fieldset><br />";
314        }
315}
316
317
318function xpress_config_report_view()
319{
320        require_once dirname(dirname( __FILE__ )).'/class/config_from_xoops.class.php' ;
321        $xoops_config = new ConfigFromXoops;
322        echo 'XOOPS_ROOT_PATH:  ' ;
323        if(XOOPS_ROOT_PATH !== $xoops_config->xoops_root_path)
324                echo 'ERROR ';
325        else
326                echo 'OK ';     
327        echo "<br />\n";
328
329        echo 'XOOPS_TRUST_PATH:  ' ;
330        if(XOOPS_TRUST_PATH !== $xoops_config->xoops_trust_path)
331                echo 'ERROR ';
332        else
333                echo 'OK ';     
334        echo "<br />\n";
335
336        echo 'XOOPS_URL:  ' ;
337        if(XOOPS_URL !== $xoops_config->xoops_url)
338                echo 'ERROR ';
339        else
340                echo 'OK ';     
341        echo "<br />\n";
342
343        if (defined('XOOPS_SALT')){
344                echo 'XOOPS_SALT:  ' ;
345                if(XOOPS_SALT !== $xoops_config->xoops_salt)
346                        echo 'ERROR ';
347                else
348                        echo 'OK ';     
349                echo "<br />\n";
350        }
351
352        if (defined('XOOPS_DB_SALT')){
353                echo 'XOOPS_DB_SALT:  ' ;
354                if(XOOPS_DB_SALT !== $xoops_config->xoops_db_salt)
355                        echo 'ERROR ';
356                else
357                        echo 'OK ';     
358                echo "<br />\n";
359        }
360
361        echo 'XOOPS_DB_HOST:  ' ;
362        if(XOOPS_DB_HOST !== $xoops_config->xoops_db_host)
363                echo 'ERROR ';
364        else
365                echo 'OK ';     
366        echo "<br />\n";
367
368        echo 'XOOPS_DB_USER:  ' ;
369        if(XOOPS_DB_USER !== $xoops_config->xoops_db_user)
370                echo 'ERROR ';
371        else
372                echo 'OK ';     
373        echo "<br />\n";
374
375        echo 'XOOPS_DB_PASS:  ' ;
376        if(XOOPS_DB_PASS !== $xoops_config->xoops_db_pass)
377                echo 'ERROR ';
378        else
379                echo 'OK ';     
380        echo "<br />\n";
381
382        echo 'XOOPS_DB_NAME:  ' ;
383        if(XOOPS_DB_NAME !== $xoops_config->xoops_db_name)
384                echo 'ERROR ';
385        else
386                echo 'OK ';     
387        echo "<br />\n";
388
389        echo 'XOOPS_DB_PREFIX:  ' ;
390        if(XOOPS_DB_PREFIX !== $xoops_config->xoops_db_prefix)
391                echo 'ERROR ';
392        else
393                echo 'OK ';     
394        echo "<br />\n";
395}
396
397function xpress_config_nomal_view()
398{
399        require_once dirname(dirname( __FILE__ )).'/class/config_from_xoops.class.php' ;
400        $xoops_config = new ConfigFromXoops;
401       
402        echo '<table width="400" cellspacing="1" cellpadding="1" border="1">';
403        echo '<tbody>';
404        echo '<tr>';
405        echo '<td>Define item</td>';
406        echo '<td>XOOPS setting value</td>';
407        echo '<td>xoops_config get value</td>';
408        echo '</tr>';
409        echo '<tr>';
410        if(XOOPS_ROOT_PATH !== $xoops_config->xoops_root_path)
411                echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_ROOT_PATH</span></strong></td>';
412        else
413                echo '<td>XOOPS_ROOT_PATH</td>';       
414        echo '<td>' . XOOPS_ROOT_PATH . '</td>';
415        echo '<td>' . $xoops_config->xoops_root_path . '</td>';
416        echo '</tr>';
417
418        echo '<tr>';
419        if(XOOPS_TRUST_PATH !== $xoops_config->xoops_trust_path)
420                echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_TRUST_PATH</span></strong></td>';
421        else
422                echo '<td>XOOPS_TRUST_PATH</td>';       
423        echo '<td>' . XOOPS_TRUST_PATH . '</td>';
424        echo '<td>' . $xoops_config->xoops_trust_path . '</td>';
425        echo '</tr>';
426
427        echo '<tr>';
428        if(XOOPS_URL !== $xoops_config->xoops_url)
429                echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_URL</span></strong></td>';
430        else
431                echo '<td>XOOPS_URL</td>';     
432        echo '<td>' . XOOPS_URL . '</td>';
433        echo '<td>' . $xoops_config->xoops_url . '</td>';
434        echo '</tr>';
435
436        if (defined('XOOPS_SALT')){
437                echo '<tr>';
438                if(XOOPS_SALT !== $xoops_config->xoops_salt)
439                        echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_SALT</span></strong></td>';
440                else
441                        echo '<td>XOOPS_SALT</td>';
442                echo '<td>' . XOOPS_SALT . '</td>';
443                echo '<td>' . $xoops_config->xoops_salt . '</td>';
444                echo '</tr>';
445        }
446
447        if (defined('XOOPS_DB_SALT')){
448                echo '<tr>';
449                if(XOOPS_DB_SALT !== $xoops_config->xoops_db_salt)
450                        echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_DB_SALT</span></strong></td>';
451                else
452                        echo '<td>XOOPS_DB_SALT</td>';
453                echo '<td>' . XOOPS_DB_SALT . '</td>';
454                echo '<td>' . $xoops_config->xoops_db_salt . '</td>';
455                echo '</tr>';
456        }
457
458        echo '<tr>';
459        if(XOOPS_DB_HOST !== $xoops_config->xoops_db_host)
460                echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_DB_HOST</span></strong></td>';
461        else
462                echo '<td>XOOPS_DB_HOST</td>';
463        echo '<td>' . XOOPS_DB_HOST . '</td>';
464        echo '<td>' . $xoops_config->xoops_db_host . '</td>';
465        echo '</tr>';
466
467        echo '<tr>';
468        if(XOOPS_DB_USER !== $xoops_config->xoops_db_user)
469                echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_DB_USER</span></strong></td>';
470        else
471                echo '<td>XOOPS_DB_USER</td>';
472        echo '<td>' . XOOPS_DB_USER . '</td>';
473        echo '<td>' . $xoops_config->xoops_db_user . '</td>';
474        echo '</tr>';
475
476        echo '<tr>';
477        if(XOOPS_DB_PASS !== $xoops_config->xoops_db_pass)
478                echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_DB_PASS</span></strong></td>';
479        else
480                echo '<td>XOOPS_DB_PASS</td>';
481        echo '<td>' . XOOPS_DB_PASS . '</td>';
482        echo '<td>' . $xoops_config->xoops_db_pass . '</td>';
483        echo '</tr>';
484
485        echo '<tr>';
486        if(XOOPS_DB_NAME !== $xoops_config->xoops_db_name)
487                echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_DB_NAME</span></strong></td>';
488        else
489                echo '<td>XOOPS_DB_NAME</td>';
490        echo '<td>' . XOOPS_DB_NAME . '</td>';
491        echo '<td>' . $xoops_config->xoops_db_name . '</td>';
492        echo '</tr>';
493
494        echo '<tr>';
495        if(XOOPS_DB_PREFIX !== $xoops_config->xoops_db_prefix)
496                echo '<td><strong><span style="color: rgb(255, 0, 0);">XOOPS_DB_PREFIX</span></strong></td>';
497        else
498                echo '<td>XOOPS_DB_PREFIX</td>';
499        echo '<td>' . XOOPS_DB_PREFIX . '</td>';
500        echo '<td>' . $xoops_config->xoops_db_prefix . '</td>';
501        echo '</tr>';
502        echo '</tbody>';
503        echo '</table>';
504}
505function xpress_config_from_xoops_view($is_report = false)
506{
507        global $xoopsUserIsAdmin,$xoopsUser;
508
509        $user_groups = $xoopsUser->_groups;
510        $is_admin_group = in_array('1',$user_groups);
511       
512        require_once dirname(dirname( __FILE__ )).'/class/config_from_xoops.class.php' ;
513        $xoops_config = new ConfigFromXoops;
514        if ($is_report) {
515                echo "******** "  . _AM_XP2_XOOPS_CONFIG_INFO . "********" . "<br />\n";
516                xpress_config_report_view();
517                echo "<br />\n";
518        } else {
519                echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_XP2_XOOPS_CONFIG_INFO . "</legend>";
520                echo "<div style='padding: 8px;'>";
521                if ($xoopsUserIsAdmin && $is_admin_group){
522                        xpress_config_nomal_view();
523                } else {
524                        xpress_config_report_view();
525                }
526                echo "</div>";
527                echo "</fieldset><br />";
528        }
529}
530
531function xpress_state($is_report = false)
532{
533        global $xoopsModule;
534        include(dirname(__FILE__) . '/../wp-includes/version.php');
535        include_once(dirname(__FILE__) . '/../include/general_functions.php');
536
537        $xoopsDB =& Database::getInstance();
538       
539        $xp_prefix = $GLOBALS['xoopsModule']->getInfo('dirname');
540        if ($xp_prefix == 'wordpress'){
541                $xp_prefix = 'wp';
542        }
543
544        $prefix = $xoopsDB->prefix($xp_prefix . '_');
545       
546        $posts_tables = get_table_list($prefix,'posts');
547        $blogname = array();
548        $count_article = array();
549        $count_author = array();
550        $count_category = array();
551        $array_index = 0;
552        foreach( $posts_tables as $posts_table){
553                $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')";
554                $result = $xoopsDB->query($sql);
555                if($myrow = $xoopsDB->fetchArray($result)){
556                        $count_article[$array_index] = $myrow["count_article"];
557                        $count_author[$array_index] = $myrow["count_author"];
558                } else {
559                        $count_article[$array_index] = 0;
560                        $count_author[$array_index] = 0;
561                }
562                $mid_prefix = get_multi_mid_prefix($prefix,'posts' , $posts_table);
563               
564                $sql = "SELECT option_value AS blogname FROM ".$prefix. $mid_prefix . "options" . " WHERE option_name = 'blogname'";
565                $result = $xoopsDB->query($sql);
566                if($myrow = $xoopsDB->fetchArray($result)){
567                        $blogname[$array_index] = $myrow["blogname"];
568                } else {
569                        $blogname[$array_index] = 'none name';
570                }
571               
572                if ($wp_db_version < 6124){
573                       
574                        $sql = "SELECT COUNT(*) AS count_category FROM ".$prefix. $mid_prefix . "categories";
575                } else {
576                        $sql = "SELECT COUNT(*) AS count_category FROM ".$prefix. $mid_prefix . "term_taxonomy" . " WHERE taxonomy = 'category'";
577                }
578                $result = $xoopsDB->query($sql);
579                if($myrow = $xoopsDB->fetchArray($result)){
580                        $count_category[$array_index] = $myrow["count_category"];
581                } else {
582                        $count_category[$array_index] = 0;
583                }
584                $array_index++;
585        }
586        for ($i = 0 ; $i < $array_index ; $i++){
587                if ($is_report){
588                        echo "******** " . $blogname[$i] . _AM_XP2_STATS . "********" . "<br />\n";
589                        echo _AM_XP2_CATEGORIES .":  ".@$count_category[$i]. "<br />\n";
590                        echo _AM_XP2_ARTICLES .":  ". $count_article[$i]. "<br />\n";
591                        echo _AM_XP2_AUTHORS .":  ". $count_author[$i]. "<br />\n";
592                       
593                } else {
594                        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . $blogname[$i] . _AM_XP2_STATS . "</legend>";
595                        echo "<div style='padding: 8px;'>";
596                        echo "<label>" . _AM_XP2_CATEGORIES .":</label><text>".@$count_category[$i];
597                        echo "</text><br />";
598                        echo "<label>" . _AM_XP2_ARTICLES .":</label><text>". $count_article[$i];
599                        echo "</text><br />";
600                        echo "<label>" . _AM_XP2_AUTHORS .":</label><text>". $count_author[$i];
601                        echo "</text>";
602                        echo "</div>";
603                        echo "</fieldset>";
604                }
605        }
606}
607function xpress_block_state($is_report = false)
608{
609        $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
610
611        include_once(dirname(dirname(__FILE__) ). '/class/check_blocks_class.php');
612        $xoops_block_check =& xoops_block_check::getInstance();
613        $xoops_block_check->check_blocks($mydirname);
614        if ($is_report){
615                echo "******** " . _AM_XP2_BLOCK_STATS . "********" . "<br />\n";
616                echo $xoops_block_check->get_message();
617                echo "<br />\n";
618                echo "<br />\n";
619        } else {
620                echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_XP2_BLOCK_STATS . "</legend>";
621                echo "<div style='padding: 8px;'>";
622                echo $xoops_block_check->get_message();
623                echo "</div>";
624                echo "</fieldset>";
625        }               
626}
627       
628$mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
629$mydirpath = dirname( dirname( __FILE__ ) ) ;
630//require_once($mydirpath.'/wp-config.php');
631       
632require_once '../../../include/cp_header.php' ;
633//require_once '../include/gtickets.php' ;
634//define( '_MYMENU_CONSTANT_IN_MODINFO' , '_MI_XP2_NAME' ) ;
635
636// branch for altsys
637if( defined( 'XOOPS_TRUST_PATH' ) && ! empty( $_GET['lib'] ) ) {
638
639        // common libs (eg. altsys)
640        $lib = preg_replace( '/[^a-zA-Z0-9_-]/' , '' , $_GET['lib'] ) ;
641        $page = preg_replace( '/[^a-zA-Z0-9_-]/' , '' , @$_GET['page'] ) ;
642       
643        if( file_exists( XOOPS_TRUST_PATH.'/libs/'.$lib.'/'.$page.'.php' ) ) {
644                include XOOPS_TRUST_PATH.'/libs/'.$lib.'/'.$page.'.php' ;
645        } else if( file_exists( XOOPS_TRUST_PATH.'/libs/'.$lib.'/index.php' ) ) {
646                include XOOPS_TRUST_PATH.'/libs/'.$lib.'/index.php' ;
647        } else {
648                die( 'wrong request' ) ;
649        }
650        exit ;
651}
652
653// beggining of Output
654xoops_cp_header();
655include( './mymenu.php' ) ;
656
657echo "
658        <style type=\"text/css\">
659        label,text {
660                display: block;
661                float: left;
662                margin-bottom: 2px;
663        }
664        label {
665                text-align: right;
666                width: 200px;
667                padding-right: 20px;
668        }
669        br {
670                clear: left;
671        }
672        </style>
673";
674
675if (!empty($_POST['submit_report'])) $report = true; else $report = false;
676xpress_sys_info($report);
677xpress_config_from_xoops_view($report);
678xpress_active_plugin_list($report);
679xpress_block_state($report);
680admin_check_user_meta_prefix($report);
681xpress_state($report);
682echo '<form method="POST">'."\n";
683echo '<input type="submit" name="submit_report" value="' . _AM_XP2_SYS_REPORT .' " />'.'&emsp;';
684echo '<input type="submit" name="submit_normal" value="' . _AM_XP2_SYS_NORMAL .' " />'."<br />\n";
685echo "</form>\n";
686
687xoops_cp_footer();
688
689       
690?>
Note: See TracBrowser for help on using the repository browser.