= $warnings ) {
$warnings = 0;
}
if ( 0 === $warnings ) {
return;
}
if ( $warnings > 0 ) {
$dismissWarnings['warnings'] = 0;
}
MainWP_Helper::update_option( 'mainwp_child_dismiss_warnings', $dismissWarnings );
?>
0 ) {
$warning .= 'This site may not connect to your dashboard or may have other issues. Check your MainWP server information page. | Dismiss |
';
}
echo $warning;
?>
=', '3.4', 'get_wordpress_version' ) ) {
$i ++;
}
if ( ! self::check( '>=', '5.2.4', 'get_php_version' ) ) {
$i ++;
}
if ( ! self::check( '>=', '5.0', 'get_my_sql_version' ) ) {
$i ++;
}
if ( ! self::check( '>=', '30', 'get_max_execution_time', '=', '0' ) ) {
$i ++;
}
if ( ! self::check( '>=', '2M', 'get_upload_max_filesize', null, null, true ) ) {
$i ++;
}
if ( ! self::check( '>=', '2M', 'get_post_max_size', null, null, true ) ) {
$i ++;
}
if ( ! self::check( '>=', '10000', 'get_output_buffer_size' ) ) {
$i ++;
}
if ( ! self::check_directory_mainwp_directory( false ) ) {
$i ++;
}
return $i;
}
protected static function get_file_system_method() {
if ( defined( 'MAINWP_SAVE_FS_METHOD' ) ) {
return MAINWP_SAVE_FS_METHOD;
}
$fs = get_filesystem_method();
return $fs;
}
protected static function get_file_system_method_check() {
$fsmethod = self::get_file_system_method();
if ( 'direct' === $fsmethod ) {
echo ' Pass';
} else {
echo ' Warning';
}
}
public static function render() {
$branding_title = MainWP_Child_Branding::instance()->get_branding_title();
$isBranding = true;
if ( '' == $branding_title ) {
$branding_title = 'MainWP Child';
$isBranding = false;
}
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
=', '3.4', 'get_wordpress_version' ); ?>
=', '64M', 'get_wordpress_memory_limit' ); ?>
|
|
|
|
|
|
=', '5.6', 'get_php_version' ); ?>
|
|
|
=', '30', 'get_max_execution_time', 'seconds', '=', '0' );
self::render_row_sec( 'PHP Max Input Time', '>=', '30', 'get_max_input_time', 'seconds', '=', '0' );
self::render_row( 'PHP Memory Limit', '>=', '128M', 'get_php_memory_limit', '(256M+ best for big backups)', null, null, true );
self::render_row( 'PCRE Backtracking Limit', '>=', '10000', 'get_output_buffer_size' );
self::render_row( 'PHP Upload Max Filesize', '>=', '2M', 'get_upload_max_filesize', '(2MB+ best for upload of big plugins)', null, null, true );
self::render_row( 'PHP Post Max Size', '>=', '2M', 'get_post_max_size', '(2MB+ best for upload of big plugins)', null, null, true );
self::render_row( 'SSL Extension Enabled', '=', true, 'get_ssl_support' );
self::render_row_sec( 'SSL Warnings', '=', '', 'get_ssl_warning', 'empty', '' );
self::render_row_sec( 'cURL Extension Enabled', '=', true, 'get_curl_support', '', '', null, '', null, self::ERROR );
self::render_row_sec( 'cURL Timeout', '>=', '300', 'get_curl_timeout', 'seconds', '=', '0' );
if ( function_exists( 'curl_version' ) ) {
self::render_row_sec( 'cURL Version', '>=', '7.18.1', 'get_curl_version', '', '', null );
self::render_row_sec(
'cURL SSL Version',
'>=',
array(
'version_number' => 0x009080cf,
'version' => 'OpenSSL/0.9.8l',
),
'get_curl_ssl_version',
'',
'',
null,
'',
'curlssl'
);
}
?>
|
=', '5.0', 'get_my_sql_version' ); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$plugin ) {
if ( 'mainwp-child/mainwp-child.php' == $slug || 'mainwp-child-reports/mainwp-child-reports.php' == $slug ) {
if ( $isBranding ) {
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';
}
}
}
?>
|
|
|
|
|
'mainwp-child',
'fields' => array( 'sections' => false ),
'timeout' => 60,
)
);
if ( is_object( $api ) && isset( $api->version ) ) {
return $api->version;
}
return false;
}
protected static function get_mainwp_version_check() {
$current = get_option( 'mainwp_child_plugin_version' );
$latest = self::get_mainwp_version();
if ( $current === $latest ) {
echo ' Pass';
} else {
echo ' Warning';
}
}
public static function render_cron() {
$cron_array = _get_cron_array();
$schedules = wp_get_schedules();
?>
|
|
|
$cron ) {
foreach ( $cron as $hook => $cron_info ) {
foreach ( $cron_info as $key => $schedule ) {
?>
|
|
|
get_branding_title();
if ( '' == $branding_title ) {
$branding_title = 'MainWP';
}
$branding_title .= ' Upload Directory';
try {
$dirs = MainWP_Helper::get_mainwp_dir( null, false );
$path = $dirs[0];
} catch ( \Exception $e ) {
return self::render_directory_row( $branding_title, '', 'Writable', $e->getMessage(), false );
}
if ( ! is_dir( dirname( $path ) ) ) {
if ( $write ) {
return self::render_directory_row( $branding_title, $path, 'Writable', 'Directory not found', false );
} else {
return false;
}
}
$hasWPFileSystem = MainWP_Helper::get_wp_filesystem();
global $wp_filesystem;
if ( $hasWPFileSystem && ! empty( $wp_filesystem ) ) {
if ( ! $wp_filesystem->is_writable( $path ) ) {
if ( $write ) {
return self::render_directory_row( $branding_title, $path, 'Writable', 'Directory not writable', false );
} else {
return false;
}
}
} else {
if ( ! is_writable( $path ) ) {
if ( $write ) {
return self::render_directory_row( $branding_title, $path, 'Writable', 'Directory not writable', false );
} else {
return false;
}
}
}
if ( $write ) {
return self::render_directory_row( $branding_title, $path, 'Writable', 'Writable', true );
} else {
return true;
}
}
protected static function render_directory_row( $pName, $pDirectory, $pCheck, $pResult, $pPassed ) {
?>
|
is_branding() ) ? '' : $pDirectory ); ?> |
|
|
Pass' : ' Warning' ); ?> |
|
|
|
|
Pass' : ' Warning' ); ?> |
|
|
|
|
Pass' : self::get_warning_html( $errorType ) ); ?> |
Pass' : self::get_warning_html( $errorType ) ); ?> |
Pass'; ?> |
Pass' : self::get_warning_html( $errorType ) ); ?> |
Warning';
}
return ' Fail';
}
protected static function filesize_compare( $value1, $value2, $operator = null ) {
if ( false !== strpos( $value1, 'G' ) ) {
$value1 = preg_replace( '/[A-Za-z]/', '', $value1 );
$value1 = intval( $value1 ) * 1024;
} else {
$value1 = preg_replace( '/[A-Za-z]/', '', $value1 );
}
if ( false !== strpos( $value2, 'G' ) ) {
$value2 = preg_replace( '/[A-Za-z]/', '', $value2 );
$value2 = intval( $value2 ) * 1024;
} else {
$value2 = preg_replace( '/[A-Za-z]/', '', $value2 );
}
return version_compare( $value1, $value2, $operator );
}
protected static function check( $pCompare, $pVersion, $pGetter, $pExtraCompare = null, $pExtraVersion = null, $sizeCompare = false ) {
$currentVersion = call_user_func( array( self::get_class_name(), $pGetter ) );
if ( $sizeCompare ) {
return self::filesize_compare( $currentVersion, $pVersion, $pCompare );
} else {
return ( version_compare( $currentVersion, $pVersion, $pCompare ) || ( ( null !== $pExtraCompare ) && version_compare( $currentVersion, $pExtraVersion, $pExtraCompare ) ) );
}
}
protected static function get_zip_archive_enabled() {
return class_exists( '\ZipArchive' );
}
protected static function get_gzip_enabled() {
return function_exists( 'gzopen' );
}
protected static function get_bzip_enabled() {
return function_exists( 'bzopen' );
}
protected static function get_wordpress_version() {
global $wp_version;
return $wp_version;
}
protected static function get_wordpress_memory_limit() {
return WP_MEMORY_LIMIT;
}
public static function check_if_multisite() {
$isMultisite = ! is_multisite() ? true : false;
return $isMultisite;
}
protected static function get_ssl_support() {
return extension_loaded( 'openssl' );
}
protected static function get_ssl_warning() {
$conf = array( 'private_key_bits' => 2048 );
$str = '';
if ( function_exists( 'openssl_pkey_new' ) ) {
$res = openssl_pkey_new( $conf );
openssl_pkey_export( $res, $privkey );
$str = openssl_error_string();
}
return ( stristr( $str, 'NCONF_get_string:no value' ) ? '' : $str );
}
public static function get_php_version() {
return phpversion();
}
protected static function get_max_execution_time() {
return ini_get( 'max_execution_time' );
}
protected static function get_upload_max_filesize() {
return ini_get( 'upload_max_filesize' );
}
protected static function get_post_max_size() {
return ini_get( 'post_max_size' );
}
public static function get_my_sql_version() {
/** @var $wpdb wpdb */
global $wpdb;
return $wpdb->get_var( "SHOW VARIABLES LIKE 'version'", 1 );
}
protected static function get_max_input_time() {
return ini_get( 'max_input_time' );
}
public static function get_php_memory_limit() {
return ini_get( 'memory_limit' );
}
protected static function get_os() {
echo esc_html( PHP_OS );
}
protected static function get_architecture() {
echo esc_html( PHP_INT_SIZE * 8 ) . ' bit';
}
protected static function memory_usage() {
if ( function_exists( 'memory_get_usage' ) ) {
$memory_usage = round( memory_get_usage() / 1024 / 1024, 2 ) . ' MB';
} else {
$memory_usage = __( 'N/A', 'mainwp-child' );
}
echo esc_html( $memory_usage );
}
protected static function get_output_buffer_size() {
return ini_get( 'pcre.backtrack_limit' );
}
protected static function get_php_safe_mode() {
if ( version_compare( phpversion(), '5.3.0' ) < 0 && ini_get( 'safe_mode' ) ) {
$safe_mode = __( 'ON', 'mainwp-child' );
} else {
$safe_mode = __( 'OFF', 'mainwp-child' );
}
echo esc_html( $safe_mode );
}
protected static function get_sql_mode() {
global $wpdb;
$mysqlinfo = $wpdb->get_results( "SHOW VARIABLES LIKE 'sql_mode'" );
if ( is_array( $mysqlinfo ) ) {
$sql_mode = $mysqlinfo[0]->Value;
}
if ( empty( $sql_mode ) ) {
$sql_mode = __( 'NOT SET', 'mainwp-child' );
}
echo esc_html( $sql_mode );
}
protected static function get_php_allow_url_fopen() {
if ( ini_get( 'allow_url_fopen' ) ) {
$allow_url_fopen = __( 'ON', 'mainwp-child' );
} else {
$allow_url_fopen = __( 'OFF', 'mainwp-child' );
}
echo esc_html( $allow_url_fopen );
}
protected static function get_php_exif() {
if ( is_callable( 'exif_read_data' ) ) {
$exif = __( 'YES', 'mainwp-child' ) . ' ( V' . substr( phpversion( 'exif' ), 0, 4 ) . ')';
} else {
$exif = __( 'NO', 'mainwp-child' );
}
echo esc_html( $exif );
}
protected static function get_php_ip_tc() {
if ( is_callable( 'iptcparse' ) ) {
$iptc = __( 'YES', 'mainwp-child' );
} else {
$iptc = __( 'NO', 'mainwp-child' );
}
echo esc_html( $iptc );
}
protected static function get_php_xml() {
if ( is_callable( 'xml_parser_create' ) ) {
$xml = __( 'YES', 'mainwp-child' );
} else {
$xml = __( 'NO', 'mainwp-child' );
}
echo esc_html( $xml );
}
protected static function get_server_getaway_interface() {
$gate = isset( $_SERVER['GATEWAY_INTERFACE'] ) ? $_SERVER['GATEWAY_INTERFACE'] : '';
echo esc_html( $gate );
}
public static function get_server_ip() {
echo esc_html( $_SERVER['SERVER_ADDR'] );
}
protected static function get_server_name() {
echo esc_html( $_SERVER['SERVER_NAME'] );
}
protected static function get_server_software() {
echo esc_html( $_SERVER['SERVER_SOFTWARE'] );
}
protected static function get_server_protocol() {
echo esc_html( $_SERVER['SERVER_PROTOCOL'] );
}
protected static function get_server_request_time() {
echo esc_html( $_SERVER['REQUEST_TIME'] );
}
protected static function get_server_http_accept() {
echo esc_html( $_SERVER['HTTP_ACCEPT'] );
}
protected static function get_server_accept_charset() {
if ( ! isset( $_SERVER['HTTP_ACCEPT_CHARSET'] ) || ( '' === $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
esc_html_e( 'N/A', 'mainwp-child' );
} else {
echo esc_html( $_SERVER['HTTP_ACCEPT_CHARSET'] );
}
}
protected static function get_http_host() {
echo esc_html( $_SERVER['HTTP_HOST'] );
}
protected static function get_complete_url() {
echo isset( $_SERVER['HTTP_REFERER'] ) ? esc_html( $_SERVER['HTTP_REFERER'] ) : '';
}
protected static function get_user_agent() {
echo esc_html( $_SERVER['HTTP_USER_AGENT'] );
}
protected static function get_https() {
if ( isset( $_SERVER['HTTPS'] ) && '' !== $_SERVER['HTTPS'] ) {
echo esc_html( __( 'ON', 'mainwp-child' ) . ' - ' . $_SERVER['HTTPS'] );
} else {
esc_html_e( 'OFF', 'mainwp-child' );
}
}
protected static function server_self_connect() {
$url = site_url( 'wp-cron.php' );
$query_args = array( 'mainwp_child_run' => 'test' );
$url = add_query_arg( $query_args, $url );
$args = array(
'blocking' => true,
'sslverify' => apply_filters( 'https_local_ssl_verify', true ),
'timeout' => 15,
);
$response = wp_remote_post( $url, $args );
$test_result = '';
if ( is_wp_error( $response ) ) {
$test_result .= sprintf( __( 'The HTTP response test get an error "%s"', 'mainwp-child' ), $response->get_error_message() );
}
$response_code = wp_remote_retrieve_response_code( $response );
if ( $response_code < 200 && $response_code > 204 ) {
$test_result .= sprintf( __( 'The HTTP response test get a false http status (%s)', 'mainwp-child' ), wp_remote_retrieve_response_code( $response ) );
} else {
$response_body = wp_remote_retrieve_body( $response );
if ( false === strstr( $response_body, 'MainWP Test' ) ) {
$test_result .= sprintf( __( 'Not expected HTTP response body: %s', 'mainwp-child' ), esc_attr( wp_strip_all_tags( $response_body ) ) );
}
}
if ( empty( $test_result ) ) {
_e( 'Response Test O.K.', 'mainwp-child' );
} else {
echo $test_result;
}
}
protected static function get_remote_address() {
echo esc_html( $_SERVER['REMOTE_ADDR'] );
}
protected static function get_remote_host() {
if ( ! isset( $_SERVER['REMOTE_HOST'] ) || ( '' === $_SERVER['REMOTE_HOST'] ) ) {
esc_html_e( 'N/A', 'mainwp-child' );
} else {
echo esc_html( $_SERVER['REMOTE_HOST'] );
}
}
protected static function get_remote_port() {
echo esc_html( $_SERVER['REMOTE_PORT'] );
}
protected static function get_script_file_name() {
echo esc_html( $_SERVER['SCRIPT_FILENAME'] );
}
protected static function get_server_port() {
echo esc_html( $_SERVER['SERVER_PORT'] );
}
protected static function get_current_page_uri() {
echo esc_html( $_SERVER['REQUEST_URI'] );
}
protected static function get_wp_root() {
echo esc_html( ABSPATH );
}
/*
*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+
*/
public 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, self::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 = esc_html( stripslashes( $branding_title ) ) . ' is unable to find your error logs, please contact your host for server error logs.';
echo '' . $msg . ' |
';
return;
}
foreach ( $lines as $key => $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} |
" );
}
}
}
public static function time_compare( $a, $b ) {
if ( $a === $b ) {
return 0;
}
return ( strtotime( $a['time'] ) > strtotime( $b['time'] ) ) ? - 1 : 1;
}
public static function 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' );
// go to the end of the file.
fseek( $fh, 0, SEEK_END );
$count_lines = count( $lines );
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 ];
} 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 );
}
public static function render_wp_config() {
?>
get_branding_title();
if ( '' == $branding_title ) {
$branding_title = 'MainWP';
}
global $current_user;
$uniqueId = get_option( 'mainwp_child_uniqueId' );
$details = array(
'siteurl' => array(
'title' => __( 'Site URL', 'mainwp-child' ),
'value' => get_bloginfo( 'url' ),
'desc' => get_bloginfo( 'url' ),
),
'adminuser' => array(
'title' => __( 'Administrator name', 'mainwp-child' ),
'value' => $current_user->user_login,
'desc' => __( 'This is your Administrator username, however, you can use any existing Administrator username.', 'mainwp-child' ),
),
'friendly_name' => array(
'title' => __( 'Friendly site name', 'mainwp-child' ),
'value' => get_bloginfo( 'name' ),
'desc' => __( 'For the friendly site name, you can use any name, this is just a suggestion.', 'mainwp-child' ),
),
'uniqueid' => array(
'title' => __( 'Child unique security id', 'mainwp-child' ),
'value' => ! empty( $uniqueId ) ? $uniqueId : __( 'Leave the field blank', 'mainwp-child' ),
'desc' => sprintf( __( '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' => __( 'Verify certificate', 'mainwp-child' ),
'value' => __( 'Yes', 'mainwp-child' ),
'desc' => __( 'If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child' ),
),
'ssl_version' => array(
'title' => __( 'SSL version', 'mainwp-child' ),
'value' => __( 'Auto Detect', 'mainwp-child' ),
'desc' => __( 'Auto Detect', 'mainwp-child' ),
),
);
?>