base, 'mainwp_' ) !== false && strpos( $screen->base, 'mainwp_child_tab' ) === false ) { return true; } return false; } /** * Render JavaScrip code for the Server Information page. * * @used-by MainWP_Child_Server_Information::render_page() Render the Server Information page. */ private static function render_page_js() { ?>

|


get_branding_title(); if ( '' === $branding_title ) { $branding_title = 'MainWP Child'; } ?>

=', '3.4', 'get_wordpress_version' ); ?> =', '64M', 'get_wordpress_memory_limit' ); ?> Pass'; } else { echo ' Warning'; } } /** * Render PHP settings information rows. * * @uses MainWP_Child_Server_Information::render_row() Render the server information row. * @uses MainWP_Child_Server_Information::render_row_sec() Render the server information secondary row. * @uses MainWP_Child_Server_Information_Base::get_php_safe_mode() Check if PHP is in Safe Mode. * * @used-by MainWP_Child_Server_Information::render_system_infor_rows() Render system information rows. */ private static function render_php_settings_rows() { ?> =', '7.4', 'get_php_version' ); ?> =', '30', 'get_max_execution_time', 'seconds', '=', '0' ); static::render_row_sec( 'PHP Max Input Time', '>=', '30', 'get_max_input_time', 'seconds', '=', '0' ); static::render_row( 'PHP Memory Limit', '>=', '128M', 'get_php_memory_limit', '(256M+ best for big backups)', null, null, true ); static::render_row( 'PCRE Backtracking Limit', '>=', '10000', 'get_output_buffer_size' ); static::render_row( 'PHP Upload Max Filesize', '>=', '2M', 'get_upload_max_filesize', '(2MB+ best for upload of big plugins)', null, null, true ); static::render_row( 'PHP Post Max Size', '>=', '2M', 'get_post_max_size', '(2MB+ best for upload of big plugins)', null, null, true ); static::render_row( 'SSL Extension Enabled', '=', true, 'get_ssl_support' ); static::render_row_sec( 'SSL Warnings', '=', '', 'get_ssl_warning', 'empty', '' ); static::render_row_sec( 'cURL Extension Enabled', '=', true, 'get_curl_support', '', '', null, '', null, static::ERROR ); static::render_row_sec( 'cURL Timeout', '>=', '300', 'get_curl_timeout', 'seconds', '=', '0' ); // phpcs:disable WordPress.Security.EscapeOutput if ( function_exists( 'curl_version' ) ) { static::render_row_sec( 'cURL Version', '>=', '7.18.1', 'get_curl_version', '', '', null ); $openssl_version = 'OpenSSL/1.1.0'; static::render_row_sec( 'cURL SSL Version', '>=', $openssl_version, 'get_curl_ssl_version', '', '', null, '', 'curlssl' ); $wk = static::get_openssl_working_status(); ?> OpenSSL Working Status Yes Pass' : static::render_warning_text(); ?> =' ) ) { echo "" . sprintf( esc_html__( 'Your host needs to update OpenSSL to at least version 1.1.0 which is already over 4 years old and contains patches for over 60 vulnerabilities.%1$sThese range from Denial of Service to Remote Code Execution. %2$sClick here for more information.%3$s', 'mainwp' ), '
', '', '' ) . '
'; } } // phpcs:enable } /** * Render MySQL settings information rows. * * @uses MainWP_Child_Server_Information::render_row() Render the server information row. * * @used-by MainWP_Child_Server_Information::render_server_infor() Render server information content. */ private static function render_mysql_infor_rows() { ?> =', '5.0', 'get_my_sql_version' ); ?> $plugin ) { if ( ! empty( $branding_title ) && ( 'mainwp-child/mainwp-child.php' === $slug || 'mainwp-child-reports/mainwp-child-reports.php' === $slug ) ) { if ( 'mainwp-child/mainwp-child.php' === $slug ) { $plugin['Name'] = esc_html( stripslashes( $branding_title ) ); } elseif ( 'mainwp-child-reports/mainwp-child-reports.php' === $slug ) { $plugin['Name'] = esc_html( stripslashes( $branding_title ) ) . ' reports'; } } ?> Pass'; } else { echo ' Warning'; } } /** * Render cron schedules. * * @uses _get_cron_array() Retrieve cron info array option. * @see https://developer.wordpress.org/reference/functions/_get_cron_array/ * * @uses wp_get_schedules() Retrieve supported event recurrence schedules. * @see https://developer.wordpress.org/reference/functions/wp_get_schedules/ * * @uses \MainWP\Child\MainWP_Helper::format_timestamp() Format timestamp as per the WordPress general settings. * * @used-by \MainWP\Child\MainWP_Child_Server_Information::render_page() Render the Server Information page. */ private static function render_cron() { $cron_array = _get_cron_array(); $schedules = wp_get_schedules(); ?> $cron ) { foreach ( $cron as $hook => $cron_info ) { foreach ( $cron_info as $schedule ) { ?>
get_branding_title(); if ( '' === $branding_title ) { $branding_title = 'MainWP'; } $branding_title .= ' Upload Directory'; $path = ''; $message = 'Writable'; static::check_mainwp_directory( $message, $path ); static::render_directory_row( $branding_title, $path, 'Writable', $message, true ); } /** * Render the directroy check row. * * @param string $name Check name. * @param string $directory Directory to check. * @param string $check Check condition. * @param string $result Check result. * @param string $passed Show correct label depending on passed status. * * @used-by \MainWP\Child\MainWP_Child_Server_Information::render_mainwp_directory() Render the MainWP directory check. * * @uses \MainWP\Child\MainWP_Child_Branding::is_branding() */ protected static function render_directory_row( $name, $directory, $check, $result, $passed ) { ?>
is_branding() ) ? '' : $directory ); ?> Pass' : ' Warning'; ?> Pass' : ' Warning'; ?> Pass' : static::render_warning_text( $errorType ); ?> Pass' : static::render_warning_text( $errorType ); ?> Pass'; ?> Pass' : static::render_warning_text( $errorType ); ?> Warning'; } return ' Fail'; } /** * Render the Error log page. * * @uses MainWP_Child_Server_Information::render_error_log() Render the error log content. * * @used-by MainWP_Child_Server_Information::render_page() Rener the Server Information page. * * Credits * * Plugin-Name: Error Log Dashboard Widget * Plugin URI: http://wordpress.org/extend/plugins/error-log-dashboard-widget/ * Description: Robust zero-configuration and low-memory way to keep an eye on error log. * Author: Andrey "Rarst" Savchenko * Author URI: http://www.rarst.net/ * Version: 1.0.2 * License: GPLv2 or later * Includes last_lines() function by phant0m, licensed under cc-wiki and GPLv2+ */ private static function render_error_page() { ?>
' . esc_html__( 'Error logging disabled.', 'mainwp-child' ) . ''; } $error_log = ini_get( 'error_log' ); $logs = apply_filters( 'error_log_mainwp_logs', array( $error_log ) ); $count = apply_filters( 'error_log_mainwp_lines', 10 ); $lines = array(); foreach ( $logs as $log ) { if ( is_readable( $log ) ) { $lines = array_merge( $lines, static::render_last_lines( $log, $count ) ); } } $lines = array_map( 'trim', $lines ); $lines = array_filter( $lines ); if ( empty( $lines ) ) { $branding_title = MainWP_Child_Branding::instance()->get_branding_title(); if ( '' === $branding_title ) { $branding_title = 'MainWP'; } $msg = stripslashes( $branding_title ) . ' is unable to find your error logs, please contact your host for server error logs.'; ?> $line ) { if ( false !== strpos( $line, ']' ) ) { list( $time, $error ) = explode( ']', $line, 2 ); } else { list( $time, $error ) = array( '', $line ); } $time = trim( $time, '[]' ); $error = trim( $error ); $lines[ $key ] = compact( 'time', 'error' ); } if ( is_array( $error_log ) && count( $error_log ) > 1 ) { uasort( $lines, array( __CLASS__, 'time_compare' ) ); $lines = array_slice( $lines, 0, $count ); } foreach ( $lines as $line ) { $error = esc_html( $line['error'] ); $time = esc_html( $line['time'] ); if ( ! empty( $error ) ) { echo wp_kses_post( "{$time}{$error}" ); } } } /** * Render the error log last lines. * * @param string $path Error log path. * @param int $line_count Line count. * @param int $block_size Block size. * * @return array Selected number of error log records to show. */ protected static function render_last_lines( $path, $line_count, $block_size = 512 ) { $lines = array(); // we will always have a fragment of a non-complete line. // keep this in here till we have our next entire line. $leftover = ''; // phpcs:disable WordPress.WP.AlternativeFunctions -- to custom read file. $fh = fopen( $path, 'r' ); if ( false === $fh || ! is_resource( $fh ) ) { return $lines; } // go to the end of the file. fseek( $fh, 0, SEEK_END ); $count_lines = 0; do { // need to know whether we can actually go back. $can_read = $block_size; if ( ftell( $fh ) <= $block_size ) { $can_read = ftell( $fh ); } if ( empty( $can_read ) ) { break; } // go back as many bytes as we can. // read them to $data and then move the file pointer. // back to where we were. fseek( $fh, - $can_read, SEEK_CUR ); $data = fread( $fh, $can_read ); $data .= $leftover; fseek( $fh, - $can_read, SEEK_CUR ); // split lines by \n. Then reverse them, now the last line is most likely not a complete line which is why we do not directly add it, but append it to the data read the next time. $split_data = array_reverse( explode( "\n", $data ) ); $new_lines = array_slice( $split_data, 0, - 1 ); $lines = array_merge( $lines, $new_lines ); $leftover = $split_data[ count( $split_data ) - 1 ]; $count_lines = count( $lines ); } while ( $count_lines < $line_count && 0 !== ftell( $fh ) ); if ( 0 === ftell( $fh ) ) { $lines[] = $leftover; } fclose( $fh ); // phpcs:enable // Usually, we will read too many lines, correct that here. return array_slice( $lines, 0, $line_count ); } /** * Render the connection details page content. * * @uses \MainWP\Child\MainWP_Child_Branding::get_branding_title() */ public static function render_connection_details() { $branding_title = MainWP_Child_Branding::instance()->get_branding_title(); if ( '' === $branding_title ) { $branding_title = 'MainWP'; } /** * Current user global. * * @global string */ global $current_user; $uniqueId = MainWP_Helper::get_site_unique_id(); $details = array( 'siteurl' => array( 'title' => esc_html__( 'Site URL', 'mainwp-child' ), 'value' => get_bloginfo( 'url' ), 'desc' => get_bloginfo( 'url' ), ), 'adminuser' => array( 'title' => esc_html__( 'Administrator name', 'mainwp-child' ), 'value' => $current_user->user_login, 'desc' => esc_html__( 'This is your Administrator username, however, you can use any existing Administrator username.', 'mainwp-child' ), ), 'friendly_name' => array( 'title' => esc_html__( 'Friendly site name', 'mainwp-child' ), 'value' => get_bloginfo( 'name' ), 'desc' => esc_html__( 'For the friendly site name, you can use any name, this is just a suggestion.', 'mainwp-child' ), ), 'uniqueid' => array( 'title' => esc_html__( 'Child unique security id', 'mainwp-child' ), 'value' => ! empty( $uniqueId ) ? $uniqueId : esc_html__( 'Leave the field blank', 'mainwp-child' ), 'desc' => sprintf( esc_html__( 'Child unique security id is not required, however, since you have enabled it, you need to add it to your %s dashboard.', 'mainwp-child' ), stripslashes( $branding_title ) ), ), 'verify_ssl' => array( 'title' => esc_html__( 'Verify certificate', 'mainwp-child' ), 'value' => esc_html__( 'Yes', 'mainwp-child' ), 'desc' => esc_html__( 'If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child' ), ), 'ssl_version' => array( 'title' => esc_html__( 'SSL version', 'mainwp-child' ), 'value' => esc_html__( 'Auto Detect', 'mainwp-child' ), 'desc' => esc_html__( 'Auto Detect', 'mainwp-child' ), ), ); // phpcs:disable WordPress.Security.EscapeOutput ?>