uwp_get_environment_info(); $database = $this->uwp_get_database_info(); $active_plugins = $this->uwp_get_active_plugins(); $theme = $this->uwp_get_theme_info(); $security = $this->uwp_get_security_info(); $pages = $this->uwp_get_pages(); ?>

:
:
:
:
: ' : '–'; ?>
: ' . sprintf( __( '%1$s - We recommend setting memory to at least 64MB. See: %2$s', 'userswp' ), size_format( $environment['wp_memory_limit'] ), '' . __( 'Increasing memory allocated to PHP', 'userswp' ) . '' ) . ''; } else { echo '' . size_format( $environment['wp_memory_limit'] ) . ''; } ?>
:
:
:
:
use_mysqli ) { $ver = mysqli_get_server_info( $wpdb->dbh ); } else { $ver = mysql_get_server_info(); } if ( ! empty( $wpdb->is_mysql ) && ! stristr( $ver, 'MariaDB' ) ) : ?> 0) { foreach ($rows as $row) { if (!empty($row['success'])) { $css_class = 'yes'; $icon = ''; } else { $css_class = 'error'; $icon = ''; } ?>

:
: ' . sprintf( __( '%1$s - We recommend a minimum PHP version of 5.6.', 'userswp' ), esc_html( $environment['php_version'] ) ) . ''; } else { echo '' . esc_html( $environment['php_version'] ) . ''; } ?>
:
:
:
:
: ' : '–'; ?>
: ' . sprintf( __( '%1$s - We recommend a minimum MySQL version of 5.6. See: %2$s', 'userswp' ), esc_html( $environment['mysql_version'] ), '' . __( 'WordPress requirements', 'userswp' ) . '' ) . ''; } else { echo '' . esc_html( $environment['mysql_version'] ) . ''; } ?>
:
: ' . sprintf( __( 'Default timezone is %s - it should be UTC', 'userswp' ), $environment['default_timezone'] ) . ''; } else { echo ''; } ?>
: '; } else { echo ' ' . __( 'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'userswp' ) . ''; } ?>
: '; } else { echo ' ' . sprintf( __( 'Your server does not have the %s class enabled - some gateway plugins which use SOAP may not work as expected.', 'userswp' ), 'SoapClient' ) . ''; } ?>
: '; } else { echo ' ' . sprintf( __( 'Your server does not have the %s class enabled - HTML/Multipart emails, and also some extensions, will not work without DOMDocument.', 'userswp' ), 'DOMDocument' ) . ''; } ?>
: '; } else { echo ' ' . sprintf( __( 'Your server does not support the %s function - this is required to use the GeoIP database from MaxMind.', 'userswp' ), 'gzopen' ) . ''; } ?>
: '; } else { echo ' ' . sprintf( __( 'Your server does not have enabled %s - this is required for image processing.', 'userswp' ), 'GD Library' ) . ''; } ?>
: '; } else { echo ' ' . sprintf( __( 'Your server does not support the %s functions - this is required for better character encoding. Some fallbacks will be used instead for it.', 'userswp' ), 'mbstring' ) . ''; } ?>
: '; } else { echo ' ' . sprintf( __( '%s failed. Contact your hosting provider.', 'userswp' ), 'wp_remote_post()' ) . ' ' . esc_html( $environment['remote_post_response'] ) . ''; } ?>
: '; } else { echo ' ' . sprintf( __( '%s failed. Contact your hosting provider.', 'userswp' ), 'wp_remote_get()' ) . ' ' . esc_html( $environment['remote_get_response'] ) . ''; } ?>
:

:
:
:
:
$table_data ) { ?> $table_data ) { ?>

:
20 ) { echo ' ' . sprintf( __( '%1$s - We recommend using a prefix with less than 20 characters.', 'userswp' ), esc_html( $database['database_prefix'] ) ) . ''; } else { echo '' . esc_html( $database['database_prefix'] ) . ''; } ?>
' . __( 'Table does not exist', 'userswp' ) . ''; } else { printf( __( 'Data: %.2fMB + Index: %.2fMB', 'userswp' ), uwp_format_decimal( $table_data['data'], 2 ), uwp_format_decimal( $table_data['index'], 2 ) ); } ?>

:
' . $plugin_name . ''; } $version_string = ''; $network_string = ''; if ( ! empty( $plugin['latest_verison'] ) && version_compare( $plugin['latest_verison'], $plugin['version'], '>' ) ) { /* translators: %s: plugin latest version */ $version_string = ' – ' . sprintf( esc_html__( '%s is available', 'userswp' ), $plugin['latest_verison'] ) . ''; } if ( false != $plugin['network_activated'] ) { $network_string = ' – ' . __( 'Network enabled', 'userswp' ) . ''; } ?>

()

' . esc_html( $page['page_name'] ) . ''; } else { $page_name = esc_html( $page['page_name'] ); } echo ''; } ?>

' . $page_name . ':'; // Page ID check. if ( ! $page['page_set'] ) { echo ' ' . __( 'Page not set', 'userswp' ) . ''; $error = true; } elseif ( ! $page['page_exists'] ) { echo ' ' . __( 'Page ID is set, but the page does not exist', 'userswp' ) . ''; $error = true; } elseif ( ! $page['page_visible'] ) { echo ' ' . sprintf( __( 'Page visibility should be public', 'userswp' ), 'https://codex.wordpress.org/Content_Visibility' ) . ''; $error = true; } else { // Shortcode check if ( $page['shortcode_required'] ) { if ( ! $page['shortcode_present'] ) { echo ' ' . sprintf( __( 'Page does not contains the shortcode.', 'userswp' ), $page['shortcode'] ) . ''; $error = true; } } } if ( ! $error ) { echo '#' . absint( $page['page_id'] ) . ' - ' . str_replace( home_url(), '', get_permalink( $page['page_id'] ) ) . ''; } echo '

:
: ' . sprintf( __( '%s is available', 'userswp' ), esc_html( $theme['latest_verison'] ) ) . ''; } ?>
:
: ' : ' – ' . sprintf( __( 'If you are modifying userswp on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme', 'userswp' ), 'https://codex.wordpress.org/Child_Themes' ); ?>
:
: ' . sprintf( __( '%s is available', 'userswp' ), esc_html( $theme['parent_latest_verison'] ) ) . ''; } ?>
:

' . $override['file'] . '', '' . $current_version . '', $override['core_version'] ); } else { echo esc_html( $override['file'] ); } if ( ( count( $theme['overrides'] ) - 1 ) !== $i ) { echo ', '; } echo '
'; } ?>
:
:
10, 'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . home_url(), 'httpversion' => '1.1', 'body' => array( 'useragent' => $user_agent, ), ) ); $post_response_body = NULL; $post_response_successful = false; if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) { $post_response_successful = true; $post_response_body = json_decode( wp_remote_retrieve_body( $post_response ), true ); } // Test GET requests $get_response = wp_safe_remote_get( 'https://plugins.svn.wordpress.org/userswp/trunk/readme.txt', array( 'timeout' => 10, 'user-agent' => 'UsersWP/' . USERSWP_VERSION, 'httpversion' => '1.1' ) ); $get_response_successful = false; if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) { $get_response_successful = true; } // Return all environment info. Described by JSON Schema. return array( 'home_url' => get_option( 'home' ), 'site_url' => get_option( 'siteurl' ), 'version' => USERSWP_VERSION, 'wp_version' => get_bloginfo( 'version' ), 'wp_multisite' => is_multisite(), 'wp_memory_limit' => $wp_memory_limit, 'wp_debug_mode' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ), 'wp_cron' => ! ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ), 'language' => get_locale(), 'server_info' => $_SERVER['SERVER_SOFTWARE'], 'php_version' => phpversion(), 'php_post_max_size' => uwp_let_to_num( ini_get( 'post_max_size' ) ), 'php_max_execution_time' => ini_get( 'max_execution_time' ), 'php_max_input_vars' => ini_get( 'max_input_vars' ), 'curl_version' => $curl_version, 'suhosin_installed' => extension_loaded( 'suhosin' ), 'max_upload_size' => wp_max_upload_size(), 'mysql_version' => ( ! empty( $wpdb->is_mysql ) ? $wpdb->db_version() : '' ), 'default_timezone' => date_default_timezone_get(), 'fsockopen_or_curl_enabled' => ( function_exists( 'fsockopen' ) || function_exists( 'curl_init' ) ), 'soapclient_enabled' => class_exists( 'SoapClient' ), 'domdocument_enabled' => class_exists( 'DOMDocument' ), 'gzip_enabled' => is_callable( 'gzopen' ), 'gd_library' => extension_loaded( 'gd' ), 'mbstring_enabled' => extension_loaded( 'mbstring' ), 'remote_post_successful' => $post_response_successful, 'remote_post_response' => ( is_wp_error( $post_response ) ? $post_response->get_error_message() : $post_response['response']['code'] ), 'remote_get_successful' => $get_response_successful, 'remote_get_response' => ( is_wp_error( $get_response ) ? $get_response->get_error_message() : $get_response['response']['code'] ), 'platform' => ! empty( $post_response_body['platform'] ) ? $post_response_body['platform'] : '-', 'browser_name' => ! empty( $post_response_body['name'] ) ? $post_response_body['name'] : '-', 'browser_version' => ! empty( $post_response_body['version'] ) ? $post_response_body['version'] : '-', 'user_agent' => $user_agent ); } public function uwp_get_database_info(){ global $wpdb; $database_table_sizes = $wpdb->get_results( $wpdb->prepare( " SELECT table_name AS 'name', round( ( data_length / 1024 / 1024 ), 2 ) 'data', round( ( index_length / 1024 / 1024 ), 2 ) 'index' FROM information_schema.TABLES WHERE table_schema = %s ORDER BY name ASC; ", DB_NAME ) ); $core_tables = array( 'uwp_usermeta', 'uwp_form_fields', 'uwp_form_extras', 'uwp_activity', 'uwp_followers', 'uwp_friends', ); $core_tables = apply_filters( 'uwp_database_tables', $core_tables ); /** * Adding the prefix to the tables array, for backwards compatibility. * * If we changed the tables above to include the prefix, then any filters against that table could break. */ $core_tables = array_map( array( $this, 'uwp_add_db_table_prefix' ), $core_tables ); /** * Organize UWP and non-UWP tables separately for display purposes later. * * To ensure we include all UWP tables, even if they do not exist, pre-populate the UWP array with all the tables. */ $tables = array( 'userswp' => array_fill_keys( $core_tables, false ), 'other' => array() ); $database_size = array( 'data' => 0, 'index' => 0 ); foreach ( $database_table_sizes as $table ) { $table_type = in_array( $table->name, $core_tables ) ? 'userswp' : 'other'; $tables[ $table_type ][ $table->name ] = array( 'data' => $table->data, 'index' => $table->index ); $database_size[ 'data' ] += $table->data; $database_size[ 'index' ] += $table->index; } // Return all database info. Described by JSON Schema. return array( 'uwp_db_version' => get_option( 'uwp_db_version' ), 'database_prefix' => $wpdb->prefix, 'database_tables' => $tables, 'database_size' => $database_size, ); } public function uwp_get_active_plugins(){ require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); require_once( ABSPATH . 'wp-admin/includes/update.php' ); if ( ! function_exists( 'get_plugin_updates' ) ) { return array(); } // Get both site plugins and network plugins $active_plugins = (array) get_option( 'active_plugins', array() ); if ( is_multisite() ) { $network_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); $active_plugins = array_merge( $active_plugins, $network_activated_plugins ); } $active_plugins_data = array(); $available_updates = get_plugin_updates(); foreach ( $active_plugins as $plugin ) { $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); // convert plugin data to json response format. $active_plugins_data[] = array( 'plugin' => $plugin, 'name' => $data['Name'], 'version' => $data['Version'], 'url' => $data['PluginURI'], 'author_name' => $data['AuthorName'], 'author_url' => esc_url_raw( $data['AuthorURI'] ), 'network_activated' => $data['Network'], 'latest_verison' => ( array_key_exists( $plugin, $available_updates ) ) ? $available_updates[$plugin]->update->new_version : $data['Version'] ); } return $active_plugins_data; } public function uwp_get_theme_info(){ $active_theme = wp_get_theme(); // Get parent theme info if this theme is a child theme, otherwise // pass empty info in the response. if ( is_child_theme() ) { $parent_theme = wp_get_theme( $active_theme->Template ); $parent_theme_info = array( 'parent_name' => $parent_theme->Name, 'parent_version' => $parent_theme->Version, 'parent_latest_verison' => $this->get_latest_theme_version( $parent_theme ), 'parent_author_url' => $parent_theme->{'Author URI'}, ); } else { $parent_theme_info = array( 'parent_name' => '', 'parent_version' => '', 'parent_latest_verison' => '', 'parent_author_url' => '' ); } /** * Scan the theme directory for all UWP templates to see if our theme * overrides any of them. */ $override_files = array(); $outdated_templates = false; $scan_files = $this->scan_template_files( USERSWP_PATH . 'templates/' ); foreach ( $scan_files as $file ) { if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) { $theme_file = get_stylesheet_directory() . '/' . $file; } elseif ( file_exists( get_stylesheet_directory() . '/userswp/' . $file ) ) { $theme_file = get_stylesheet_directory() . '/userswp/' . $file; } elseif ( file_exists( get_template_directory() . '/' . $file ) ) { $theme_file = get_template_directory() . '/' . $file; } elseif ( file_exists( get_template_directory() . '/userswp/' . $file ) ) { $theme_file = get_template_directory() . '/userswp/' . $file; } else { $theme_file = false; } if ( ! empty( $theme_file ) ) { $core_version = $this->get_file_version( USERSWP_PATH . '/templates/' . $file ); $theme_version = $this->get_file_version( $theme_file ); if ( $core_version && ( empty( $theme_version ) || version_compare( $theme_version, $core_version, '<' ) ) ) { if ( ! $outdated_templates ) { $outdated_templates = true; } } $override_files[] = array( 'file' => str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ), 'version' => $theme_version, 'core_version' => $core_version, ); } } $active_theme_info = array( 'name' => $active_theme->Name, 'version' => $active_theme->Version, 'latest_verison' => $this->get_latest_theme_version( $active_theme ), 'author_url' => esc_url_raw( $active_theme->{'Author URI'} ), 'is_child_theme' => is_child_theme(), 'has_outdated_templates' => $outdated_templates, 'overrides' => $override_files, ); return array_merge( $active_theme_info, $parent_theme_info ); } public function uwp_get_security_info(){ $check_page = get_home_url(); return array( 'secure_connection' => 'https' === substr( $check_page, 0, 5 ), 'hide_errors' => ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), ); } public function uwp_get_pages(){ $check_pages = array( _x( 'Profile Page', 'Page setting', 'userswp' ) => array( 'option' => 'profile_page', 'shortcode' => '[uwp_profile]', ), _x( 'Register Page', 'Page setting', 'userswp' ) => array( 'option' => 'register_page', 'shortcode' => '[uwp_register]', ), _x( 'Login Page', 'Page setting', 'userswp' ) => array( 'option' => 'login_page', 'shortcode' => '[uwp_login]', ), _x( 'Account Page', 'Page setting', 'userswp' ) => array( 'option' => 'account_page', 'shortcode' => '[uwp_account]', ), _x( 'Change Password Page', 'Page setting', 'userswp' ) => array( 'option' => 'change_page', 'shortcode' => '[uwp_change]', ), _x( 'Forgot Password Page', 'Page setting', 'userswp' ) => array( 'option' => 'forgot_page', 'shortcode' => '[uwp_forgot]', ), _x( 'Reset Password Page', 'Page setting', 'userswp' ) => array( 'option' => 'reset_page', 'shortcode' => '[uwp_reset]', ), _x( 'Users List Page', 'Page setting', 'userswp' ) => array( 'option' => 'users_page', 'shortcode' => '[uwp_users]', ), ); $check_pages = apply_filters('uwp_status_check_pages', $check_pages); $pages_output = array(); foreach ( $check_pages as $page_name => $values ) { $page_id = uwp_get_page_id( $values['option'], '' ); $page_set = $page_exists = $page_visible = false; $shortcode_present = $shortcode_required = false; $page = get_post( $page_id ); // Page checks if ( $page_id ) { $page_set = true; } if ( $page ) { $page_exists = true; } if ( 'publish' === get_post_status( $page_id ) ) { $page_visible = true; } // Shortcode checks if ( $values['shortcode'] && $page ) { $shortcode_required = true; if ( strstr( $page->post_content, $values['shortcode'] ) ) { $shortcode_present = true; } } // Wrap up our findings into an output array $pages_output[] = array( 'page_name' => $page_name, 'page_id' => $page_id, 'page_set' => $page_set, 'page_exists' => $page_exists, 'page_visible' => $page_visible, 'shortcode' => $values['shortcode'], 'shortcode_required' => $shortcode_required, 'shortcode_present' => $shortcode_present, ); } return $pages_output; } /** * Add prefix to table. * * @param string $table table name * @return string */ protected function uwp_add_db_table_prefix( $table ) { return uwp_get_table_prefix() . $table; } /** * Get latest version of a theme by slug. * * @since 2.0.0 * * @param object $theme WP_Theme object. * @return string Version number if found. */ public function get_latest_theme_version( $theme ) { include_once( ABSPATH . 'wp-admin/includes/theme.php' ); $api = themes_api( 'theme_information', array( 'slug' => $theme->get_stylesheet(), 'fields' => array( 'sections' => false, 'tags' => false, ), ) ); $update_theme_version = 0; // Check .org for updates. if ( is_object( $api ) && ! is_wp_error( $api ) ) { $update_theme_version = $api->version; } return $update_theme_version; } /** * Scan the template files. * * @param string $template_path Path to the template directory. * @return array */ public function scan_template_files( $template_path ) { $files = @scandir( $template_path ); // @codingStandardsIgnoreLine. $result = array(); if ( ! empty( $files ) ) { foreach ( $files as $key => $value ) { if ( ! in_array( $value, array( '.', '..' ), true ) ) { if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) { $sub_files = $this->scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value ); foreach ( $sub_files as $sub_file ) { $result[] = $value . DIRECTORY_SEPARATOR . $sub_file; } } else { $result[] = $value; } } } } return $result; } /** * Retrieve metadata from a file. Based on WP Core's get_file_data function. * * @since 1.0.20 * @param string $file Path to the file. * @return string */ public function get_file_version( $file ) { // Avoid notices if file does not exist. if ( ! file_exists( $file ) ) { return ''; } // We don't need to write to the file, so just open for reading. $fp = fopen( $file, 'r' ); // @codingStandardsIgnoreLine. // Pull only the first 8kiB of the file in. $file_data = fread( $fp, 8192 ); // @codingStandardsIgnoreLine. // PHP will close file handle, but we are good citizens. fclose( $fp ); // @codingStandardsIgnoreLine. // Make sure we catch CR-only line endings. $file_data = str_replace( "\r", "\n", $file_data ); $version = ''; if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] ) { $version = _cleanup_header_comment( $match[1] ); } return $version; } }