= $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 to review and check here for more information on possible fixes | Dismiss |
';
}
echo $warning;
?>
=', '3.4', 'getWordpressVersion' ) ) {
$i ++;
}
if ( ! self::check( '>=', '5.2.4', 'getPHPVersion' ) ) {
$i ++;
}
if ( ! self::check( '>=', '5.0', 'getMySQLVersion' ) ) {
$i ++;
}
if ( ! self::check( '>=', '30', 'getMaxExecutionTime', '=', '0' ) ) {
$i ++;
}
if ( ! self::check( '>=', '2M', 'getUploadMaxFilesize', null, null, true ) ) {
$i ++;
}
if ( ! self::check( '>=', '2M', 'getPostMaxSize', null, null, true ) ) {
$i ++;
}
if ( ! self::check( '>=', '10000', 'getOutputBufferSize' ) ) {
$i ++;
}
// if (!self::check('=', true, 'getSSLSupport')) $i++;
if ( ! self::checkDirectoryMainWPDirectory( false ) ) {
$i ++;
}
return $i;
}
protected static function getFileSystemMethod() {
if ( defined( 'MAINWP_SAVE_FS_METHOD' ) ) {
return MAINWP_SAVE_FS_METHOD;
}
$fs = get_filesystem_method();
return $fs;
}
protected static function getFileSystemMethodCheck() {
$fsmethod = self::getFileSystemMethod();
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;
}
?>
|
|
|
|
|
|
|
Version |
|
|
|
|
|
|
|
|
|
=', '3.4', 'getWordpressVersion' );
self::renderRow( 'WordPress Memory Limit', '>=', '64M', 'getWordpressMemoryLimit' );
self::renderRow( 'MultiSite Disabled', '=', true, 'checkIfMultisite' );
?>
|
|
|
|
|
|
=', '5.6', 'getPHPVersion' );
?>
|
|
|
=', '30', 'getMaxExecutionTime', 'seconds', '=', '0' );
self::renderRowSec( 'PHP Max Input Time', '>=', '30', 'getMaxInputTime', 'seconds', '=', '0' );
self::renderRow( 'PHP Memory Limit', '>=', '128M', 'getPHPMemoryLimit', '(256M+ best for big backups)', null, null, true );
self::renderRow( 'PCRE Backtracking Limit', '>=', '10000', 'getOutputBufferSize' );
self::renderRow( 'PHP Upload Max Filesize', '>=', '2M', 'getUploadMaxFilesize', '(2MB+ best for upload of big plugins)', null, null, true );
self::renderRow( 'PHP Post Max Size', '>=', '2M', 'getPostMaxSize', '(2MB+ best for upload of big plugins)', null, null, true );
self::renderRow( 'SSL Extension Enabled', '=', true, 'getSSLSupport' );
self::renderRowSec( 'SSL Warnings', '=', '', 'getSSLWarning', 'empty', '' );
self::renderRowSec( 'cURL Extension Enabled', '=', true, 'getCurlSupport', '', '', null, '', null, self::ERROR );
self::renderRowSec( 'cURL Timeout', '>=', '300', 'getCurlTimeout', 'seconds', '=', '0' );
if ( function_exists( 'curl_version' ) ) {
self::renderRowSec( 'cURL Version', '>=', '7.18.1', 'getCurlVersion', '', '', null );
self::renderRowSec( 'cURL SSL Version', '>=', array(
'version_number' => 0x009080cf,
'version' => 'OpenSSL/0.9.8l',
), 'getCurlSSLVersion', '', '', null, '', 'curlssl' );
}
?>
|
=', '5.0', 'getMySQLVersion' );
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$plugin) {
if ( $slug == 'mainwp-child/mainwp-child.php' || $slug == 'mainwp-child-reports/mainwp-child-reports.php' ) {
if ( $isBranding ) {
if ( $slug == 'mainwp-child/mainwp-child.php' ) {
$plugin['Name'] = esc_html( stripslashes( $branding_title ) );
} elseif ($slug == 'mainwp-child-reports/mainwp-child-reports.php') {
$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 getMainWPVersionCheck() {
$current = get_option( 'mainwp_child_plugin_version' );
$latest = self::getMainwpVersion();
if ( $current === $latest ) {
echo ' Pass';
} else {
echo ' Warning';
}
}
public static function renderCron() {
$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::getMainWPDir( null, false );
$path = $dirs[0];
} catch ( Exception $e ) {
return self::renderDirectoryRow( $branding_title, '', 'Writable', $e->getMessage(), false );
}
if ( ! is_dir( dirname( $path ) ) ) {
if ( $write ) {
return self::renderDirectoryRow( $branding_title, $path, 'Writable', 'Directory not found', false );
} else {
return false;
}
}
$hasWPFileSystem = MainWP_Helper::getWPFilesystem();
global $wp_filesystem;
if ( $hasWPFileSystem && ! empty( $wp_filesystem ) ) {
if ( ! $wp_filesystem->is_writable( $path ) ) {
if ( $write ) {
return self::renderDirectoryRow( $branding_title, $path, 'Writable', 'Directory not writable', false );
} else {
return false;
}
}
} else {
if ( ! is_writable( $path ) ) {
if ( $write ) {
return self::renderDirectoryRow( $branding_title, $path, 'Writable', 'Directory not writable', false );
} else {
return false;
}
}
}
if ( $write ) {
return self::renderDirectoryRow( $branding_title, $path, 'Writable', 'Writable', true );
} else {
return true;
}
}
protected static function renderDirectoryRow( $pName, $pDirectory, $pCheck, $pResult, $pPassed ) {
?>
|
is_branding() ) ? '' : $pDirectory ); ?>
|
|
|
Pass' : ' Warning' ); ?> |
|
|
|
|
Pass' : ' Warning' ); ?> |
|
|
|
|
Pass' : self::getWarningHTML( $errorType ) ); ?> |
Pass' : self::getWarningHTML( $errorType ) ); ?> |
Pass'; ?> |
Pass' : self::getWarningHTML( $errorType ) ); ?> |
Warning';
}
return ' Fail';
}
protected static function filesize_compare( $value1, $value2, $operator = null ) {
if ( strpos( $value1, 'G' ) !== false ) {
$value1 = preg_replace( '/[A-Za-z]/', '', $value1 );
$value1 = intval( $value1 ) * 1024; // Megabyte number
} else {
$value1 = preg_replace( '/[A-Za-z]/', '', $value1 ); // Megabyte number
}
if ( strpos( $value2, 'G' ) !== false ) {
$value2 = preg_replace( '/[A-Za-z]/', '', $value2 );
$value2 = intval( $value2 ) * 1024; // Megabyte number
} else {
$value2 = preg_replace( '/[A-Za-z]/', '', $value2 ); // Megabyte number
}
return version_compare( $value1, $value2, $operator );
}
protected static function check( $pCompare, $pVersion, $pGetter, $pExtraCompare = null, $pExtraVersion = null, $sizeCompare = false) {
$currentVersion = call_user_func( array( 'MainWP_Child_Server_Information', $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 getZipArchiveEnabled() {
return class_exists( 'ZipArchive' );
}
protected static function getGZipEnabled() {
return function_exists( 'gzopen' );
}
protected static function getBZipEnabled() {
return function_exists( 'bzopen' );
}
protected static function getWordpressVersion() {
global $wp_version;
return $wp_version;
}
protected static function getWordpressMemoryLimit() {
return WP_MEMORY_LIMIT;
}
public static function checkIfMultisite() {
$isMultisite = ! is_multisite() ? true : false;
return $isMultisite;
}
protected static function getSSLSupport() {
return extension_loaded( 'openssl' );
}
protected static function getSSLWarning() {
$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 getPHPVersion() {
return phpversion();
}
protected static function getMaxExecutionTime() {
return ini_get( 'max_execution_time' );
}
protected static function getUploadMaxFilesize() {
return ini_get( 'upload_max_filesize' );
}
protected static function getPostMaxSize() {
return ini_get( 'post_max_size' );
}
public static function getMySQLVersion() {
/** @var $wpdb wpdb */
global $wpdb;
return $wpdb->get_var( "SHOW VARIABLES LIKE 'version'", 1 );
}
protected static function getMaxInputTime() {
return ini_get( 'max_input_time' );
}
public static function getPHPMemoryLimit() {
return ini_get( 'memory_limit' );
}
protected static function getOS() {
echo esc_html( PHP_OS );
}
protected static function getArchitecture() {
echo esc_html( PHP_INT_SIZE * 8 )
?>
bit
get_results( "SHOW VARIABLES LIKE 'sql_mode'" );
if ( is_array( $mysqlinfo ) ) {
$sql_mode = $mysqlinfo[0]->Value;
}
if ( empty( $sql_mode ) ) {
$sql_mode = __( 'NOT SET' );
}
echo esc_html( $sql_mode );
}
protected static function getPHPAllowUrlFopen() {
if ( ini_get( 'allow_url_fopen' ) ) {
$allow_url_fopen = __( 'ON' );
} else {
$allow_url_fopen = __( 'OFF' );
}
echo esc_html( $allow_url_fopen );
}
protected static function getPHPExif() {
if ( is_callable( 'exif_read_data' ) ) {
$exif = __( 'YES' ) . ' ( V' . substr( phpversion( 'exif' ), 0, 4 ) . ')';
} else {
$exif = __( 'NO' );
}
echo esc_html( $exif );
}
protected static function getPHPIPTC() {
if ( is_callable( 'iptcparse' ) ) {
$iptc = __( 'YES' );
} else {
$iptc = __( 'NO' );
}
echo esc_html( $iptc );
}
protected static function getPHPXML() {
if ( is_callable( 'xml_parser_create' ) ) {
$xml = __( 'YES' );
} else {
$xml = __( 'NO' );
}
echo esc_html( $xml );
}
// new
protected static function getCurrentlyExecutingScript() {
echo esc_html( $_SERVER['PHP_SELF'] );
}
protected static function getServerGetawayInterface() {
$gate = isset($_SERVER['GATEWAY_INTERFACE']) ? $_SERVER['GATEWAY_INTERFACE'] : '';
echo esc_html( $gate );
}
public static function getServerIP() {
echo esc_html( $_SERVER['SERVER_ADDR'] );
}
protected static function getServerName() {
echo esc_html( $_SERVER['SERVER_NAME'] );
}
protected static function getServerSoftware() {
echo esc_html( $_SERVER['SERVER_SOFTWARE'] );
}
protected static function getServerProtocol() {
echo esc_html( $_SERVER['SERVER_PROTOCOL'] );
}
protected static function getServerRequestMethod() {
echo esc_html( $_SERVER['REQUEST_METHOD'] );
}
protected static function getServerRequestTime() {
echo esc_html( $_SERVER['REQUEST_TIME'] );
}
protected static function getServerQueryString() {
echo esc_html( $_SERVER['QUERY_STRING'] );
}
protected static function getServerHTTPAccept() {
echo esc_html( $_SERVER['HTTP_ACCEPT'] );
}
protected static function getServerAcceptCharset() {
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 getHTTPHost() {
echo esc_html( $_SERVER['HTTP_HOST'] );
}
protected static function getCompleteURL() {
echo isset( $_SERVER['HTTP_REFERER'] ) ? esc_html( $_SERVER['HTTP_REFERER'] ) : '';
}
protected static function getUserAgent() {
echo esc_html( $_SERVER['HTTP_USER_AGENT'] );
}
protected static function getHTTPS() {
if ( isset( $_SERVER['HTTPS'] ) && '' !== $_SERVER['HTTPS'] ) {
echo esc_html( __( 'ON', 'mainwp-child' ) . ' - ' . $_SERVER['HTTPS'] );
} else {
esc_html_e( 'OFF', 'mainwp-child' );
}
}
protected static function serverSelfConnect() {
$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( strip_tags( $response_body ) ) );
}
}
if ( empty( $test_result ) ) {
_e( 'Response Test O.K.', 'mainwp-child' );
} else {
echo $test_result;
}
}
protected static function getRemoteAddress() {
echo esc_html( $_SERVER['REMOTE_ADDR'] );
}
protected static function getRemoteHost() {
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 getRemotePort() {
echo esc_html( $_SERVER['REMOTE_PORT'] );
}
protected static function getScriptFileName() {
echo esc_html( $_SERVER['SCRIPT_FILENAME'] );
}
protected static function getServerAdmin() {
echo esc_html( $_SERVER['SERVER_ADMIN'] );
}
protected static function getServerPort() {
echo esc_html( $_SERVER['SERVER_PORT'] );
}
protected static function getServerSignature() {
echo esc_html( $_SERVER['SERVER_SIGNATURE'] );
}
protected static function getServerPathTranslated() {
if ( ! isset( $_SERVER['PATH_TRANSLATED'] ) || ( '' === $_SERVER['PATH_TRANSLATED'] ) ) {
esc_html_e( 'N/A', 'mainwp-child' );
} else {
echo esc_html( $_SERVER['PATH_TRANSLATED'] );
}
}
protected static function getScriptName() {
echo esc_html( $_SERVER['SCRIPT_NAME'] );
}
protected static function getCurrentPageURI() {
echo esc_html( $_SERVER['REQUEST_URI'] );
}
protected static function getWPRoot() {
echo esc_html( ABSPATH );
}
function formatSizeUnits( $bytes ) {
if ( $bytes >= 1073741824 ) {
$bytes = number_format( $bytes / 1073741824, 2 ) . ' GB';
} elseif ( $bytes >= 1048576 ) {
$bytes = number_format( $bytes / 1048576, 2 ) . ' MB';
} elseif ( $bytes >= 1024 ) {
$bytes = number_format( $bytes / 1024, 2 ) . ' KB';
} elseif ( $bytes > 1 ) {
$bytes = $bytes . ' bytes';
} elseif ( 1 === $bytes ) {
$bytes = $bytes . ' byte';
} else {
$bytes = '0 bytes';
}
return $bytes;
}
/*
*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 renderErrorLogPage() {
?>
' . 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} |
" );
}
}
}
static function time_compare( $a, $b ) {
if ( $a === $b ) {
return 0;
}
return ( strtotime( $a['time'] ) > strtotime( $b['time'] ) ) ? - 1 : 1;
}
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 = '';
$fh = fopen( $path, 'r' );
// go to the end of the file
fseek( $fh, 0, SEEK_END );
do {
// need to know whether we can actually go back
// $block_size bytes
$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 );
// Usually, we will read too many lines, correct that here.
return array_slice( $lines, 0, $line_count );
}
public static function renderWPConfig() {
?>
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'),
),
);
?>