Add new tool System Info

This commit is contained in:
champsupertramp
2016-08-04 18:36:26 +08:00
parent 10e3e8263a
commit 2128a96942
4 changed files with 1499 additions and 0 deletions
+320
View File
@@ -0,0 +1,320 @@
<?php
class UM_ADDON_system_info {
function __construct() {
add_action('admin_menu', array(&$this, 'admin_menu'), 1001);
add_action('admin_init', array(&$this, 'admin_init'), 1);
add_action('um_admin_addon_hook', array(&$this, 'um_admin_addon_hook') );
}
function admin_menu() {
global $ultimatemember;
$this->addon = $ultimatemember->addons['system_info'];
add_submenu_page('ultimatemember', "System Info","System Info", 'manage_options', 'system_info', array(&$this, 'content') );
}
function um_admin_addon_hook( $hook ) {
global $ultimatemember;
switch ( $hook ) {
case 'download_system_info':
// do something
break;
default:
break;
}
}
function admin_init() {
if ( isset( $_REQUEST['um-addon-hook'] ) ) {
$hook = $_REQUEST['um-addon-hook'];
do_action("um_admin_addon_hook", $hook );
}
}
function content() {
global $wpdb, $ultimatemember;
if( !class_exists( 'Browser' ) )
require_once um_path . 'core/lib/browser.php';
// Detect browser
$browser = new Browser();
// Get theme info
$theme_data = wp_get_theme();
$theme = $theme_data->Name . ' ' . $theme_data->Version;
// Identify Hosting Provider
$host = um_get_host();
?>
<div class="wrap">
<h2>Ultimate Member</h2>
<h3><?php echo $this->addon[0]; ?></h3>
<?php if ( isset( $this->content ) ) {
echo $this->content;
} else { ?>
<form action="<?php echo esc_url( admin_url( 'admin.php?page=system_info' ) ); ?>" method="post" dir="ltr">
<textarea style="width:100%; height:400px;" readonly="readonly" onclick="this.focus();this.select()" id="system-info-textarea" name="edd-sysinfo" title="<?php _e( 'To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'edd' ); ?>">
### Begin System Info ###
## Please include this information when posting support requests ##
<?php do_action( 'um_system_info_before' ); ?>
--- Site Info ---
Site URL: <?php echo site_url() . "\n"; ?>
Home URL: <?php echo home_url() . "\n"; ?>
Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
--- Hosting Provider ---
<?php if( $host ) : ?>
Host: <?php echo $host . "\n"; ?>
<?php endif; ?>
--- User Browser ---
<?php echo $browser ; ?>
--- WordPress Configurations ---
Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
Language: <?php echo get_locale()."\n"; ?>
Permalink Structure: <?php echo get_option( 'permalink_structure' ) . "\n"; ?>
Active Theme: <?php echo $theme . "\n"; ?>
<?php $show_on_front = get_option( 'show_on_front' ); ?>
<?php if( $show_on_front == "posts" ): ?>
Show On Front: <?php echo get_option( 'show_on_front' ) . "\n" ?>
<?php elseif( $show_on_front == "page" ): ?>
Page On Front: <?php $id = get_option( 'page_on_front' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
Page For Posts: <?php $id = get_option( 'page_for_posts' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
<?php endif; ?>
ABSPATH: <?php echo ABSPATH."\n"; ?>
<?php
$request['cmd'] = '_notify-validate';
$params = array(
'sslverify' => false,
'timeout' => 60,
'user-agent' => 'UltimateMember/' . ultimatemember_version,
'body' => $request
);
$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
$WP_REMOTE_POST = 'wp_remote_post() works' . "\n";
} else {
$WP_REMOTE_POST = 'wp_remote_post() does not work' . "\n";
}
?>
WP Remote Post: <?php echo $WP_REMOTE_POST; ?>
WP_DEBUG: <?php echo defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
WP Table Prefix: <?php echo "Length: ". strlen( $wpdb->prefix ); echo ", Status:"; if ( strlen( $wpdb->prefix )>16 ) {echo " ERROR: Too Long";} else {echo " Acceptable";} echo "\n"; ?>
Memory Limit: <?php echo ( um_let_to_num( WP_MEMORY_LIMIT )/( 1024 ) )."MB"; ?><?php echo "\n"; ?>
--- UM Configurations ---
Version: <?php echo ultimatemember_version . "\n"; ?>
Upgraded From: <?php echo get_option( 'um_version_upgraded_from', 'None' ) . "\n"; ?>
Current URL Method: <?php echo um_get_option( 'current_url_method' ). "\n"; ?>
Cache User Profile: <?php if( um_get_option( 'um_profile_object_cache_stop' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
Rewrite Rules: <?php if( um_get_option( 'um_flush_stop' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
Force UTF-8 Encoding: <?php if( um_get_option( 'um_force_utf8_strings' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
Time Check Security: <?php if( um_get_option( 'enable_timebot' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
JS/CSS Compression: <?php if( um_get_option( 'disable_minify' ) == 0 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
<?php if( is_multisite() ): ?>
Network Structure: <?php echo um_get_option( 'network_permalink_structure' ). "\n"; ?>
<?php endif; ?>
Nav Menu Settings: <?php if( um_get_option( 'disable_menu' ) == 0 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
Port Forwarding in URL: <?php if( um_get_option( 'um_port_forwarding_url' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
Exclude CSS/JS on Home: <?php if( um_get_option( 'js_css_exlcude_home' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
--- UM Page Configurations ---
<?php do_action("um_system_info_before_page_config") ?>
User: <?php echo get_permalink( um_get_option('core_user') ) . "\n"; ?>
Account: <?php echo get_permalink( um_get_option('core_account') ) . "\n"; ?>
Members: <?php echo get_permalink( um_get_option('core_members') ) . "\n"; ?>
Register: <?php echo get_permalink( um_get_option('core_register') ) . "\n"; ?>
Login: <?php echo get_permalink( um_get_option('core_login') ) . "\n"; ?>
Logout: <?php echo get_permalink( um_get_option('core_logout') ) . "\n"; ?>
Password Reset: <?php echo get_permalink( um_get_option('core_password-reset') ) . "\n"; ?>
<?php do_action("um_system_info_after_page_config") ?>
--- UM Total Users ---
<?php
$result = count_users();
echo 'All Users('.$result['total_users'].")\n";
foreach($result['avail_roles'] as $role => $count){
echo $role."(".$count.")\n";
}
?>
--- UM Roles ---
<?php
foreach( $ultimatemember->query->get_roles() as $role_id => $role ) {
echo $role." ({$role_id})\n";
}
?>
--- UM Custom Templates ---
<?php
// Show templates that have been copied to the theme's edd_templates dir
$dir = get_stylesheet_directory() . '/ultimate-member/templates/*.php';
echo "--Templates Directory: ".$dir."\n";
if ( ! empty( $dir ) ){
$found = glob( $dir );
if( ! empty( $found ) ){
foreach ( glob( $dir ) as $file ) {
echo "Filename: " . basename( $file ) . "\n";
}
}else {
echo 'N/A'."\n";
}
}
echo "\n\n";
$dir = get_stylesheet_directory() . '/ultimate-member/templates/emails/*.html';
echo "-- Email Templates Directory: ".$dir."\n";
if ( ! empty( $dir ) ){
$found = glob( $dir );
if( ! empty( $found ) ){
foreach ( glob( $dir ) as $file ) {
echo "Filename: " . basename( $file ) . "\n";
}
}else {
echo 'N/A'."\n";
}
}
?>
--- Web Server Configurations ---
PHP Version: <?php echo PHP_VERSION . "\n"; ?>
MySQL Version: <?php echo mysql_get_server_info() . "\n"; ?>
Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
--- PHP Configurations --
PHP Safe Mode: <?php echo ini_get( 'safe_mode' ) ? "Yes" : "No\n"; ?>
PHP Memory Limit: <?php echo ini_get( 'memory_limit' ) . "\n"; ?>
PHP Upload Max Size: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
PHP Post Max Size: <?php echo ini_get( 'post_max_size' ) . "\n"; ?>
PHP Upload Max Filesize: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
PHP Time Limit: <?php echo ini_get( 'max_execution_time' ) . "\n"; ?>
PHP Max Input Vars: <?php echo ini_get( 'max_input_vars' ) . "\n"; ?>
PHP Arg Separator: <?php echo ini_get( 'arg_separator.output' ) . "\n"; ?>
PHP Allow URL File Open: <?php echo ini_get( 'allow_url_fopen' ) ? "Yes\n" : "No\n"; ?>
--- Web Server Extensions/Modules ---
DISPLAY ERRORS: <?php echo ( ini_get( 'display_errors' ) ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A'; ?><?php echo "\n"; ?>
FSOCKOPEN: <?php echo ( function_exists( 'fsockopen' ) ) ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.'; ?><?php echo "\n"; ?>
cURL: <?php echo ( function_exists( 'curl_init' ) ) ? 'Your server supports cURL.' : 'Your server does not support cURL.'; ?><?php echo "\n"; ?>
SOAP Client: <?php echo ( class_exists( 'SoapClient' ) ) ? 'Your server has the SOAP Client enabled.' : 'Your server does not have the SOAP Client enabled.'; ?><?php echo "\n"; ?>
SUHOSIN: <?php echo ( extension_loaded( 'suhosin' ) ) ? 'Your server has SUHOSIN installed.' : 'Your server does not have SUHOSIN installed.'; ?><?php echo "\n"; ?>
--- Session Configurations ---
Session: <?php echo isset( $_SESSION ) ? 'Enabled' : 'Disabled'; ?><?php echo "\n"; ?>
Session Name: <?php echo esc_html( ini_get( 'session.name' ) ); ?><?php echo "\n"; ?>
Cookie Path: <?php echo esc_html( ini_get( 'session.cookie_path' ) ); ?><?php echo "\n"; ?>
Save Path: <?php echo esc_html( ini_get( 'session.save_path' ) ); ?><?php echo "\n"; ?>
Use Cookies: <?php echo ini_get( 'session.use_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
--- WordPress Active Plugins ---
<?php
$plugins = get_plugins();
$active_plugins = get_option( 'active_plugins', array() );
foreach ( $plugins as $plugin_path => $plugin ) {
// If the plugin isn't active, don't show it.
if ( ! in_array( $plugin_path, $active_plugins ) )
continue;
echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n";
}
if ( is_multisite() ) :
?>
--- WordPress Network Active Plugins ---
<?php
$plugins = wp_get_active_network_plugins();
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
foreach ( $plugins as $plugin_path ) {
$plugin_base = plugin_basename( $plugin_path );
// If the plugin isn't active, don't show it.
if ( ! array_key_exists( $plugin_base, $active_plugins ) )
continue;
$plugin = get_plugin_data( $plugin_path );
echo $plugin['Name'] . ' :' . $plugin['Version'] ."\n";
}
endif;
?>
<?php
do_action( 'um_system_info_after' );
?>
### End System Info ###</textarea>
<p class="submit">
<input type="hidden" name="um-addon-hook" value="download_sysinfo" />
<?php submit_button( 'Download System Info File', 'primary', 'download_system_info', false ); ?>
</p>
</form>
<?php } ?>
<?php
}
}
$UM_ADDON_system_info = new UM_ADDON_system_info();
+1103
View File
File diff suppressed because it is too large Load Diff
+71
View File
@@ -1743,4 +1743,75 @@ function um_fetch_user( $user_id ) {
|| substr($_SERVER['HTTP_HOST'],0,3) == '10.'
|| substr($_SERVER['HTTP_HOST'],0,7) == '192.168') return true;
return false;
}
/**
* Get user host
*
* Returns the webhost this site is using if possible
*
* @since 1.3.68
* @return mixed string $host if detected, false otherwise
*/
function um_get_host() {
$host = false;
if( defined( 'WPE_APIKEY' ) ) {
$host = 'WP Engine';
} elseif( defined( 'PAGELYBIN' ) ) {
$host = 'Pagely';
} elseif( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
$host = 'ICDSoft';
} elseif( DB_HOST == 'mysqlv5' ) {
$host = 'NetworkSolutions';
} elseif( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
$host = 'iPage';
} elseif( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
$host = 'IPower';
} elseif( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
$host = 'MediaTemple Grid';
} elseif( strpos( DB_HOST, '.pair.com' ) !== false ) {
$host = 'pair Networks';
} elseif( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
$host = 'Rackspace Cloud';
} elseif( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
$host = 'SysFix.eu Power Hosting';
} elseif( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
$host = 'Flywheel';
} else {
// Adding a general fallback for data gathering
$host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
}
return $host;
}
/**
* Let To Num
*
* Does Size Conversions
*
* @since 1.3.68
* @author Chris Christoff
*
* @param unknown $v
* @return int|string
*/
function um_let_to_num( $v ) {
$l = substr( $v, -1 );
$ret = substr( $v, 0, -1 );
switch ( strtoupper( $l ) ) {
case 'P': // fall-through
case 'T': // fall-through
case 'G': // fall-through
case 'M': // fall-through
case 'K': // fall-through
$ret *= 1024;
break;
default:
break;
}
return $ret;
}
+5
View File
@@ -63,6 +63,11 @@ class UM_API {
__('This add-on enables you to generate dummies.', 'ultimatemember'),
);
$this->addons['system_info'] = array(
__('System Info', 'ultimatemember'),
__('This add-on enables you to download system information file.', 'ultimatemember'),
);
// include widgets
require_once um_path . 'core/widgets/um-search-widget.php';