2015-10-15 22:52:37 +10:00
< ? php
2020-05-05 20:13:38 +07:00
namespace MainWP\Child ;
2015-10-15 22:52:37 +10:00
class MainWP_Child_Server_Information {
2016-03-03 20:28:07 +01:00
const WARNING = 1 ;
2020-03-26 19:45:07 +00:00
const ERROR = 2 ;
2016-03-03 20:28:07 +01:00
2020-05-06 20:22:11 +07:00
/**
* Method get_class_name ()
*
* Get Class Name .
*
* @ return object
*/
public static function get_class_name () {
return __CLASS__ ;
}
2020-05-06 13:24:04 +00:00
2015-10-15 22:52:37 +10:00
public static function init () {
2020-04-17 18:44:58 +02:00
add_action (
'wp_ajax_mainwp-child_dismiss_warnings' ,
array (
2020-05-06 13:24:04 +00:00
self :: get_class_name (),
2020-05-06 00:47:59 +07:00
'dismiss_warnings' ,
2020-04-17 18:44:58 +02:00
)
);
2015-10-15 22:52:37 +10:00
}
2020-05-06 00:47:59 +07:00
public static function dismiss_warnings () {
2015-10-15 22:52:37 +10:00
if ( isset ( $_POST [ 'what' ] ) ) {
$dismissWarnings = get_option ( 'mainwp_child_dismiss_warnings' );
if ( ! is_array ( $dismissWarnings ) ) {
$dismissWarnings = array ();
}
2020-04-17 18:44:58 +02:00
if ( 'warning' == $_POST [ 'what' ] ) {
if ( isset ( $_POST [ 'warnings' ] ) ) {
$warnings = intval ( $_POST [ 'warnings' ] );
2020-03-26 19:51:58 +00:00
} else {
2020-05-06 20:22:11 +07:00
$warnings = self :: get_warnings ();
2020-03-26 19:51:58 +00:00
}
2020-04-17 18:44:58 +02:00
$dismissWarnings [ 'warnings' ] = $warnings ;
2018-11-27 15:07:40 +07:00
}
2015-10-15 22:52:37 +10:00
MainWP_Helper :: update_option ( 'mainwp_child_dismiss_warnings' , $dismissWarnings );
}
}
2020-05-06 20:22:11 +07:00
public static function show_warnings () {
2020-03-27 14:11:21 +00:00
if ( stristr ( $_SERVER [ 'REQUEST_URI' ], 'mainwp_child_tab' ) || stristr ( $_SERVER [ 'REQUEST_URI' ], 'mainwp-reports-page' ) || stristr ( $_SERVER [ 'REQUEST_URI' ], 'mainwp-reports-settings' ) ) {
2015-10-15 22:52:37 +10:00
return ;
}
2020-05-06 20:22:11 +07:00
$warnings = self :: get_warnings ();
2015-10-15 22:52:37 +10:00
$dismissWarnings = get_option ( 'mainwp_child_dismiss_warnings' );
if ( ! is_array ( $dismissWarnings ) ) {
$dismissWarnings = array ();
}
if ( isset ( $dismissWarnings [ 'warnings' ] ) && $dismissWarnings [ 'warnings' ] >= $warnings ) {
$warnings = 0 ;
}
2016-04-27 21:54:28 +02:00
if ( 0 === $warnings ) {
2015-10-15 22:52:37 +10:00
return ;
}
if ( $warnings > 0 ) {
$dismissWarnings [ 'warnings' ] = 0 ;
}
MainWP_Helper :: update_option ( 'mainwp_child_dismiss_warnings' , $dismissWarnings );
?>
< script language = " javascript " >
dismiss_warnings = function ( pElement , pAction ) {
var table = jQuery ( pElement . parents ( 'table' )[ 0 ] );
pElement . parents ( 'tr' )[ 0 ] . remove ();
if ( table . find ( 'tr' ) . length == 0 ) {
jQuery ( '#mainwp-child_server_warnings' ) . hide ();
}
var data = {
action : 'mainwp-child_dismiss_warnings' ,
2016-10-24 20:33:37 +02:00
what : pAction ,
2020-04-17 18:44:58 +02:00
warnings : < ? php echo intval ( $warnings ); ?>
2015-10-15 22:52:37 +10:00
};
jQuery . ajax ( {
type : " POST " ,
url : ajaxurl ,
data : data ,
2020-04-17 18:44:58 +02:00
success : function ( resp ) {},
error : function () {},
2015-10-15 22:52:37 +10:00
dataType : 'json'
} );
return false ;
};
jQuery ( document ) . on ( 'click' , '#mainwp-child-connect-warning-dismiss' , function () {
return dismiss_warnings ( jQuery ( this ), 'warning' );
} );
jQuery ( document ) . on ( 'click' , '#mainwp-child-all-pages-warning-dismiss' , function () {
return dismiss_warnings ( jQuery ( this ), 'conflict' );
} );
</ script >
< style type = " text/css " >
. mainwp - child_info - box - red - warning {
background - color : rgba ( 187 , 114 , 57 , 0.2 ) ! important ;
border - bottom : 4 px solid #bb7239 !important;
border - top : 1 px solid #bb7239 !important;
border - left : 1 px solid #bb7239 !important;
border - right : 1 px solid #bb7239 !important;
- webkit - border - radius : 3 px ;
- moz - border - radius : 3 px ;
border - radius : 3 px ;
margin : 1 em 0 ! important ;
2020-04-17 18:44:58 +02:00
background - image : url ( '<?php echo esc_url( plugins_url( ' images / mainwp - icon - orange . png ', dirname( __FILE__ ) ) ); ?>' ) ! important ;
2015-10-15 22:52:37 +10:00
background - position : 1.5 em 50 % ! important ;
background - repeat : no - repeat ! important ;
background - size : 30 px ! important ;
}
. mainwp - child_info - box - red - warning table {
background - color : rgba ( 187 , 114 , 57 , 0 ) ! important ;
border : 0 px ;
padding - left : 4.5 em ;
background - position : 1.5 em 50 % ! important ;
background - repeat : no - repeat ! important ;
background - size : 30 px ! important ;
}
</ style >
< div class = " updated mainwp-child_info-box-red-warning " id = " mainwp-child_server_warnings " >
< table id = " mainwp-table " class = " wp-list-table widefat " cellspacing = " 0 " >
< tbody id = " the-sites-list " class = " list:sites " >
< ? php
$warning = '' ;
if ( $warnings > 0 ) {
2020-04-17 18:44:58 +02:00
$warning .= '<tr><td colspan="2">This site may not connect to your dashboard or may have other issues. Check your <a href="options-general.php?page=mainwp_child_tab">MainWP server information page</a>.</td><td style="text-align: right;"><a href="#" id="mainwp-child-connect-warning-dismiss">Dismiss</a></td></tr>' ;
2015-10-15 22:52:37 +10:00
}
echo $warning ;
?>
</ tbody >
</ table >
</ div >
< ? php
}
2020-05-06 20:22:11 +07:00
public static function render_page () {
2015-10-15 22:52:37 +10:00
?>
2016-03-03 20:28:07 +01:00
< script language = " javascript " >
/* FileSaver . js
* A saveAs () FileSaver implementation .
* 2013 - 01 - 23
*
* By Eli Grey , http :// eligrey . com
* License : X11 / MIT
2020-04-17 18:44:58 +02:00
* See LICENSE . md
2016-03-03 20:28:07 +01:00
*/
/*global self */
2020-04-17 18:44:58 +02:00
/*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true, plusplus: true */
2016-03-03 20:28:07 +01:00
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
var childSaveAs = childSaveAs
2020-04-17 18:44:58 +02:00
|| ( navigator . msSaveBlob && navigator . msSaveBlob . bind ( navigator ) )
|| ( function ( view ) {
2016-03-03 20:28:07 +01:00
" use strict " ;
2020-04-17 18:44:58 +02:00
var doc = view . document
2016-03-03 20:28:07 +01:00
, get_URL = function () {
return view . URL || view . webkitURL || view ;
}
, URL = view . URL || view . webkitURL || view
, save_link = doc . createElementNS ( " http://www.w3.org/1999/xhtml " , " a " )
, can_use_save_link = " download " in save_link
, click = function ( node ) {
var event = doc . createEvent ( " MouseEvents " );
event . initMouseEvent (
" click " , true , false , view , 0 , 0 , 0 , 0 , 0
, false , false , false , false , 0 , null
);
return node . dispatchEvent ( event ); // false if event was cancelled
}
, webkit_req_fs = view . webkitRequestFileSystem
, req_fs = view . requestFileSystem || webkit_req_fs || view . mozRequestFileSystem
, throw_outside = function ( ex ) {
( view . setImmediate || view . setTimeout )( function () {
throw ex ;
}, 0 );
}
, force_saveable_type = " application/octet-stream "
, fs_min_size = 0
, deletion_queue = []
, process_deletion_queue = function () {
var i = deletion_queue . length ;
while ( i -- ) {
var file = deletion_queue [ i ];
2020-04-17 18:44:58 +02:00
if ( typeof file === " string " ) {
2016-03-03 20:28:07 +01:00
URL . revokeObjectURL ( file );
2020-04-17 18:44:58 +02:00
} else {
2016-03-03 20:28:07 +01:00
file . remove ();
}
}
2020-04-17 18:44:58 +02:00
deletion_queue . length = 0 ;
2016-03-03 20:28:07 +01:00
}
, dispatch = function ( filesaver , event_types , event ) {
event_types = [] . concat ( event_types );
var i = event_types . length ;
while ( i -- ) {
var listener = filesaver [ " on " + event_types [ i ]];
if ( typeof listener === " function " ) {
try {
listener . call ( filesaver , event || filesaver );
} catch ( ex ) {
throw_outside ( ex );
}
}
}
}
2020-04-17 18:44:58 +02:00
, FileSaver = function ( blob , name ) {
2016-03-03 20:28:07 +01:00
var
filesaver = this
, type = blob . type
, blob_changed = false
, object_url
, target_view
, get_object_url = function () {
var object_url = get_URL () . createObjectURL ( blob );
deletion_queue . push ( object_url );
return object_url ;
}
, dispatch_all = function () {
2020-04-17 18:44:58 +02:00
dispatch ( filesaver , " writestart progress write writeend " . split ( " " ) );
2016-03-03 20:28:07 +01:00
}
, fs_error = function () {
2020-04-17 18:44:58 +02:00
if ( blob_changed || ! object_url ) {
object_url = get_object_url ( blob );
2016-03-03 20:28:07 +01:00
}
if ( target_view ) {
target_view . location . href = object_url ;
}
filesaver . readyState = filesaver . DONE ;
dispatch_all ();
}
, abortable = function ( func ) {
return function () {
if ( filesaver . readyState !== filesaver . DONE ) {
return func . apply ( this , arguments );
}
};
}
, create_if_not_found = { create : true , exclusive : false }
, slice
;
filesaver . readyState = filesaver . INIT ;
2020-04-17 18:44:58 +02:00
if ( ! name ) {
2016-03-03 20:28:07 +01:00
name = " download " ;
}
2020-04-17 18:44:58 +02:00
if ( can_use_save_link ) {
object_url = get_object_url ( blob );
2016-03-03 20:28:07 +01:00
save_link . href = object_url ;
save_link . download = name ;
2020-04-17 18:44:58 +02:00
if ( click ( save_link ) ) {
2016-03-03 20:28:07 +01:00
filesaver . readyState = filesaver . DONE ;
dispatch_all ();
return ;
}
}
2020-04-17 18:44:58 +02:00
if ( view . chrome && type && type !== force_saveable_type ) {
2016-03-03 20:28:07 +01:00
slice = blob . slice || blob . webkitSlice ;
2020-04-17 18:44:58 +02:00
blob = slice . call ( blob , 0 , blob . size , force_saveable_type );
2016-03-03 20:28:07 +01:00
blob_changed = true ;
}
if ( webkit_req_fs && name !== " download " ) {
name += " .download " ;
}
2020-04-17 18:44:58 +02:00
if ( type === force_saveable_type || webkit_req_fs ) {
2016-03-03 20:28:07 +01:00
target_view = view ;
} else {
target_view = view . open ();
}
if ( ! req_fs ) {
fs_error ();
return ;
}
fs_min_size += blob . size ;
req_fs ( view . TEMPORARY , fs_min_size , abortable ( function ( fs ) {
fs . root . getDirectory ( " saved " , create_if_not_found , abortable ( function ( dir ) {
var save = function () {
dir . getFile ( name , create_if_not_found , abortable ( function ( file ) {
file . createWriter ( abortable ( function ( writer ) {
writer . onwriteend = function ( event ) {
target_view . location . href = file . toURL ();
deletion_queue . push ( file );
filesaver . readyState = filesaver . DONE ;
dispatch ( filesaver , " writeend " , event );
};
writer . onerror = function () {
var error = writer . error ;
if ( error . code !== error . ABORT_ERR ) {
fs_error ();
}
};
" writestart progress write abort " . split ( " " ) . forEach ( function ( event ) {
writer [ " on " + event ] = filesaver [ " on " + event ];
});
writer . write ( blob );
filesaver . abort = function () {
writer . abort ();
filesaver . readyState = filesaver . DONE ;
};
filesaver . readyState = filesaver . WRITING ;
}), fs_error );
}), fs_error );
};
dir . getFile ( name , { create : false }, abortable ( function ( file ) {
file . remove ();
save ();
}), abortable ( function ( ex ) {
if ( ex . code === ex . NOT_FOUND_ERR ) {
save ();
} else {
fs_error ();
}
}));
}), fs_error );
}), fs_error );
}
, FS_proto = FileSaver . prototype
, childSaveAs = function ( blob , name ) {
return new FileSaver ( blob , name );
}
;
FS_proto . abort = function () {
var filesaver = this ;
filesaver . readyState = filesaver . DONE ;
dispatch ( filesaver , " abort " );
};
FS_proto . readyState = FS_proto . INIT = 0 ;
FS_proto . WRITING = 1 ;
FS_proto . DONE = 2 ;
FS_proto . error =
FS_proto . onwritestart =
FS_proto . onprogress =
FS_proto . onwrite =
FS_proto . onabort =
FS_proto . onerror =
FS_proto . onwriteend =
null ;
view . addEventListener ( " unload " , process_deletion_queue , false );
return childSaveAs ;
}( self ));
mwp_child_strCut = function ( i , l , s , w ) {
var o = i . toString ();
if ( ! s ) { s = '0' ; }
while ( o . length < parseInt ( l )) {
2020-04-17 18:44:58 +02:00
if ( w == 'undefined' ){
2016-03-03 20:28:07 +01:00
o = s + o ;
} else {
o = o + s ;
}
}
return o ;
};
2020-04-17 18:44:58 +02:00
jQuery ( 'a.mwp-child-get-system-report-btn' ) . live ( 'click' , function () {
2016-03-03 20:28:07 +01:00
var report = " " ;
2020-04-17 18:44:58 +02:00
jQuery ( '.mwp_server_info_box thead, .mwp_server_info_box tbody' ) . each ( function () {
2016-03-03 20:28:07 +01:00
var td_len = [ 35 , 55 , 45 , 12 , 12 ];
var th_count = 0 ;
var i ;
2020-04-17 18:44:58 +02:00
if ( jQuery ( this ) . is ( 'thead' ) ) {
2016-03-03 20:28:07 +01:00
i = 0 ;
report = report + " \n ### " ;
2020-04-17 18:44:58 +02:00
th_count = jQuery ( this ) . find ( 'th:not(".mwp-not-generate-row")' ) . length ;
jQuery ( this ) . find ( 'th:not(".mwp-not-generate-row")' ) . each ( function () {
2016-03-03 20:28:07 +01:00
var len = td_len [ i ];
2020-04-17 18:44:58 +02:00
if ( i == 0 || i == th_count - 1 )
2016-03-03 20:28:07 +01:00
len = len - 4 ;
2020-04-17 18:44:58 +02:00
report = report + mwp_child_strCut ( jQuery . trim ( jQuery ( this ) . text () ), len , ' ' );
2016-03-03 20:28:07 +01:00
i ++ ;
2020-04-17 18:44:58 +02:00
} );
2016-03-03 20:28:07 +01:00
report = report + " ### \n \n " ;
} else {
2020-04-17 18:44:58 +02:00
jQuery ( 'tr' , jQuery ( this ) ) . each ( function () {
if ( jQuery ( this ) . hasClass ( 'mwp-not-generate-row' ) )
2016-03-03 20:28:07 +01:00
return ;
i = 0 ;
2020-04-17 18:44:58 +02:00
jQuery ( this ) . find ( 'td:not(".mwp-not-generate-row")' ) . each ( function () {
if ( jQuery ( this ) . hasClass ( 'mwp-hide-generate-row' ) ) {
report = report + mwp_child_strCut ( ' ' , td_len [ i ], ' ' );
2016-03-03 20:28:07 +01:00
i ++ ;
return ;
}
2020-04-17 18:44:58 +02:00
report = report + mwp_child_strCut ( jQuery . trim ( jQuery ( this ) . text () ), td_len [ i ], ' ' );
2016-03-03 20:28:07 +01:00
i ++ ;
2020-04-17 18:44:58 +02:00
} );
2016-03-03 20:28:07 +01:00
report = report + " \n " ;
2020-04-17 18:44:58 +02:00
} );
2016-03-03 20:28:07 +01:00
}
} );
try {
2020-04-17 18:44:58 +02:00
jQuery ( " #mwp-server-information " ) . slideDown ();
jQuery ( " #mwp-server-information textarea " ) . val ( report ) . focus () . select ();
jQuery ( this ) . fadeOut ();
jQuery ( '.mwp_child_close_srv_info' ) . show ();
2016-03-03 20:28:07 +01:00
return false ;
} catch ( e ){ }
2020-04-17 18:44:58 +02:00
} );
2016-03-03 20:28:07 +01:00
2020-04-17 18:44:58 +02:00
jQuery ( 'a#mwp_child_close_srv_info' ) . live ( 'click' , function () {
jQuery ( '#mwp-server-information' ) . hide ();
jQuery ( '.mwp_child_close_srv_info' ) . hide ();
jQuery ( 'a.mwp-child-get-system-report-btn' ) . show ();
2016-03-03 20:28:07 +01:00
return false ;
2020-04-17 18:44:58 +02:00
} );
jQuery ( '#mwp_child_download_srv_info' ) . live ( 'click' , function () {
var server_info = jQuery ( '#mwp-server-information textarea' ) . val ();
var blob = new Blob ( [ server_info ], { type : " text/plain;charset=utf-8 " } );
childSaveAs ( blob , " server_child_information.txt " );
} );
2016-03-03 20:28:07 +01:00
</ script >
< style type = " text/css " >
#mwp-server-information {
display : none ;
margin : 10 px 0 ;
padding : 0 ;
position : relative ;
}
#mwp-server-information textarea {
border - radius : 0 ;
font - family : monospace ;
font - size : 12 px ;
height : 300 px ;
line - height : 20 px ;
margin : 0 ;
outline : 0 none ;
padding : 20 px ;
resize : none ;
width : 100 % ;
- moz - border - radius : 0 ;
- webkit - border - radius : 0 ;
}
. mwp_child_close_srv_info {
display : none ;
float : right ;
margin : 5 px 0 5 px ;
}
</ style >
2015-10-15 22:52:37 +10:00
< div class = " wrap " >
2016-03-03 20:28:07 +01:00
< div class = " updated below-h2 " >
2020-04-17 18:44:58 +02:00
< p >< ? php esc_html_e ( 'Please include this information when requesting support:' , 'mainwp-child' ); ?> </p>
< span class = " mwp_child_close_srv_info " >
< a href = " # " id = " mwp_child_download_srv_info " >< ? php esc_html_e ( 'Download' , 'mainwp-child' ); ?> </a> | <a href="#" id="mwp_child_close_srv_info"><i class="fa fa-eye-slash"></i> <?php _e( 'Hide', 'mainwp-child' ); ?></a>
</ span >
2016-03-03 20:28:07 +01:00
< p class = " submit " >
2020-04-17 18:44:58 +02:00
< a class = " button-primary mwp-child-get-system-report-btn " href = " # " >< ? php esc_html_e ( 'Get system report' , 'mainwp-child' ); ?> </a>
2016-03-03 20:28:07 +01:00
</ p >
< div id = " mwp-server-information " >< textarea readonly = " readonly " wrap = " off " ></ textarea ></ div >
</ div >
< br />
< div class = " mwp_server_info_box " >
2020-04-17 18:44:58 +02:00
< h2 >< ? php esc_html_e ( 'Server Information' , 'mainwp-child' ); ?> </h2>
< ? php self :: render (); ?>
< h2 >< ? php esc_html_e ( 'Cron Schedules' , 'mainwp-child' ); ?> </h2>
2020-05-06 20:22:11 +07:00
< ? php self :: render_cron (); ?>
2020-04-17 18:44:58 +02:00
< h2 >< ? php esc_html_e ( 'Error Log' , 'mainwp-child' ); ?> </h2>
2020-05-06 20:22:11 +07:00
< ? php self :: render_error_log_page (); ?>
2016-03-03 20:28:07 +01:00
</ div >
2015-10-15 22:52:37 +10:00
</ div >
< ? php
}
2020-05-06 20:22:11 +07:00
public static function get_warnings () {
2015-10-15 22:52:37 +10:00
$i = 0 ;
2020-05-06 20:22:11 +07:00
if ( ! self :: check ( '>=' , '3.4' , 'get_wordpress_version' ) ) {
2015-10-15 22:52:37 +10:00
$i ++ ;
}
2020-05-06 20:22:11 +07:00
if ( ! self :: check ( '>=' , '5.2.4' , 'get_php_version' ) ) {
2015-10-15 22:52:37 +10:00
$i ++ ;
}
2020-05-06 20:22:11 +07:00
if ( ! self :: check ( '>=' , '5.0' , 'get_my_sql_version' ) ) {
2015-10-15 22:52:37 +10:00
$i ++ ;
}
2020-05-06 20:22:11 +07:00
if ( ! self :: check ( '>=' , '30' , 'get_max_execution_time' , '=' , '0' ) ) {
2015-10-15 22:52:37 +10:00
$i ++ ;
}
2020-05-06 20:22:11 +07:00
if ( ! self :: check ( '>=' , '2M' , 'get_upload_max_filesize' , null , null , true ) ) {
2015-10-15 22:52:37 +10:00
$i ++ ;
}
2020-05-06 20:22:11 +07:00
if ( ! self :: check ( '>=' , '2M' , 'get_post_max_size' , null , null , true ) ) {
2015-10-15 22:52:37 +10:00
$i ++ ;
}
2020-05-06 20:22:11 +07:00
if ( ! self :: check ( '>=' , '10000' , 'get_output_buffer_size' ) ) {
2015-10-15 22:52:37 +10:00
$i ++ ;
}
2020-05-06 20:22:11 +07:00
if ( ! self :: check_directory_mainwp_directory ( false ) ) {
2015-10-15 22:52:37 +10:00
$i ++ ;
}
return $i ;
}
2020-05-06 20:22:11 +07:00
protected static function get_file_system_method () {
2015-10-15 22:52:37 +10:00
if ( defined ( 'MAINWP_SAVE_FS_METHOD' ) ) {
return MAINWP_SAVE_FS_METHOD ;
}
$fs = get_filesystem_method ();
return $fs ;
}
2020-05-06 20:22:11 +07:00
protected static function get_file_system_method_check () {
$fsmethod = self :: get_file_system_method ();
2015-10-15 22:52:37 +10:00
if ( 'direct' === $fsmethod ) {
echo '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' ;
} else {
echo '<span class="mainwp-warning"><i class="fa fa-exclamation-circle"></i> Warning</span>' ;
}
}
public static function render () {
2020-05-06 20:22:11 +07:00
$branding_title = MainWP_Child_Branding :: instance () -> get_branding_title ();
2020-03-27 15:13:11 +00:00
$isBranding = true ;
2020-04-17 18:44:58 +02:00
if ( '' == $branding_title ) {
2020-03-27 15:13:11 +00:00
$branding_title = 'MainWP Child' ;
$isBranding = false ;
2015-10-15 22:52:37 +10:00
}
?>
2016-03-03 20:28:07 +01:00
2015-10-15 22:52:37 +10:00
< table id = " mainwp-table " class = " wp-list-table widefat " cellspacing = " 0 " >
< thead >
2020-04-17 18:44:58 +02:00
< tr >
< th scope = " col " class = " manage-column column-posts mwp-not-generate-row " style = " width: 1px; " ></ th >
< th scope = " col " class = " manage-column column-posts " style = " " >< span >< ? php esc_html_e ( 'Server configuration' , 'mainwp-child' ); ?> </span></th>
< th scope = " col " class = " manage-column column-posts " style = " " >< ? php esc_html_e ( 'Required value' , 'mainwp-child' ); ?> </th>
< th scope = " col " class = " manage-column column-posts " style = " " >< ? php esc_html_e ( 'Value' , 'mainwp-child' ); ?> </th>
< th scope = " col " class = " manage-column column-posts " style = " " >< ? php esc_html_e ( 'Status' , 'mainwp-child' ); ?> </th>
</ tr >
2015-10-15 22:52:37 +10:00
</ thead >
< tbody id = " the-sites-list " class = " list:sites " >
2020-04-17 18:44:58 +02:00
< tr >
< td style = " background: #333; color: #fff; " colspan = " 5 " >< ? php echo esc_html ( strtoupper ( stripslashes ( $branding_title ) ) ); ?> </td>
</ tr >
< tr >
< td ></ td >
< td >< ? php echo esc_html ( stripslashes ( $branding_title ) ) . ' ' . __ ( 'Version' , 'mainwp-chil' ); ?> </td>
2020-05-07 01:03:56 +07:00
< td >< ? php echo esc_html ( self :: get_mainwp_version () ); ?> </td>
2020-05-06 20:22:11 +07:00
< td >< ? php echo esc_html ( self :: get_current_version () ); ?> </td>
< td >< ? php echo esc_html ( self :: get_mainwp_version_check () ); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
2020-05-06 20:22:11 +07:00
< ? php self :: check_directory_mainwp_directory (); ?>
2020-04-17 18:44:58 +02:00
< ? php $server = get_option ( 'mainwp_child_server' ); ?>
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Currently connected to dashboard URL' , 'mainwp-child' ); ?> </td>
< td >< ? php echo esc_html ( $server ); ?> </td>
< td ></ td >
< td ></ td >
</ tr >
< tr >
< td style = " background: #333; color: #fff; " colspan = " 5 " >< ? php esc_html_e ( 'WordPress' , 'mainwp-child' ); ?> </td>
</ tr >
2020-05-06 20:22:11 +07:00
< ? php self :: render_row ( 'WordPress Version' , '>=' , '3.4' , 'get_wordpress_version' ); ?>
< ? php self :: render_row ( 'WordPress Memory Limit' , '>=' , '64M' , 'get_wordpress_memory_limit' ); ?>
< ? php self :: render_row ( 'MultiSite Disabled' , '=' , true , 'check_if_multisite' ); ?>
2020-04-17 18:44:58 +02:00
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'FileSystem Method' , 'mainwp-child' ); ?> </td>
< td >< ? php echo esc_html ( '= direct' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td >< ? php echo esc_html ( self :: get_file_system_method () ); ?> </td>
< td >< ? php echo esc_html ( self :: get_file_system_method_check () ); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td style = " background: #333; color: #fff; "
colspan = " 5 " >< ? php esc_html_e ( 'PHP SETTINGS' , 'mainwp-child' ); ?> </td>
</ tr >
2020-05-06 20:22:11 +07:00
< ? php self :: render_row ( 'PHP Version' , '>=' , '5.6' , 'get_php_version' ); ?>
2020-04-17 18:44:58 +02:00
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'PHP Safe Mode Disabled' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_php_safe_mode (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< ? php
2020-05-06 20:22:11 +07:00
self :: render_row_sec ( 'PHP Max Execution Time' , '>=' , '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' );
2020-04-17 18:44:58 +02:00
if ( function_exists ( 'curl_version' ) ) {
2020-05-06 20:22:11 +07:00
self :: render_row_sec ( 'cURL Version' , '>=' , '7.18.1' , 'get_curl_version' , '' , '' , null );
self :: render_row_sec (
2020-04-17 18:49:06 +02:00
'cURL SSL Version' ,
'>=' ,
array (
'version_number' => 0x009080cf ,
'version' => 'OpenSSL/0.9.8l' ,
),
2020-05-06 00:47:59 +07:00
'get_curl_ssl_version' ,
2020-04-17 18:49:06 +02:00
'' ,
'' ,
null ,
'' ,
'curlssl'
);
2020-03-27 15:13:11 +00:00
}
2016-06-08 21:47:49 +02:00
?>
< tr >
2020-04-17 18:44:58 +02:00
< td style = " background: #333; color: #fff; " colspan = " 5 " >< ? php esc_html_e ( 'MySQL SETTINGS' , 'mainwp-child' ); ?> </td>
</ tr >
2020-05-06 20:22:11 +07:00
< ? php self :: render_row ( 'MySQL Version' , '>=' , '5.0' , 'get_my_sql_version' ); ?>
2020-04-17 18:44:58 +02:00
< tr >
< td style = " background: #333; color: #fff; " colspan = " 5 " >< ? php esc_html_e ( 'BACKUP ARCHIVE INFORMATION' , 'mainwp-child' ); ?> </td>
</ tr >
2020-05-06 20:22:11 +07:00
< ? php self :: render_row ( 'ZipArchive enabled in PHP' , '=' , true , 'get_zip_archive_enabled' ); ?>
< ? php self :: render_row ( 'Tar GZip supported' , '=' , true , 'get_gzip_enabled' ); ?>
< ? php self :: render_row ( 'Tar BZip2 supported' , '=' , true , 'get_bzip_enabled' ); ?>
2020-04-17 18:44:58 +02:00
< tr >
< td style = " background: #333; color: #fff; " colspan = " 5 " >< ? php esc_html_e ( 'SERVER INFORMATION' , 'mainwp-child' ); ?> </td>
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'WordPress Root Directory' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_wp_root (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Server Name' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_server_name (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Server Software' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_server_software (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Operating System' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_os (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Architecture' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_architecture (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Server IP' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_server_ip (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Server Protocol' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_server_protocol (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'HTTP Host' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_http_host (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'HTTPS' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_https (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Server self connect' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: server_self_connect (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'User Agent' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_user_agent (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Server Port' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_server_port (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Gateway Interface' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_server_getaway_interface (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Memory Usage' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: memory_usage (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Complete URL' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_complete_url (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Request Time' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_server_request_time (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Accept Content' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_server_http_accept (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Accept-Charset Content' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_server_accept_charset (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Currently Executing Script Pathname' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_script_file_name (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Current Page URI' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_current_page_uri (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Remote Address' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_remote_address (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Remote Host' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_remote_host (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'Remote Port' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_remote_port (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td style = " background: #333; color: #fff; " colspan = " 5 " >< ? php esc_html_e ( 'PHP INFORMATION' , 'mainwp-child' ); ?> </td>
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'PHP Allow URL fopen' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_php_allow_url_fopen (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'PHP Exif Support' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_php_exif (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'PHP IPTC Support' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_php_ip_tc (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'PHP XML Support' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_php_xml (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'PHP Disabled Functions' , 'mainwp-child' ); ?> </td>
2020-05-06 00:47:59 +07:00
< td colspan = " 3 " >< ? php self :: mainwp_required_functions (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'PHP Loaded Extensions' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " style = " width: 73% !important; " >< ? php self :: get_loaded_php_extensions (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td style = " background: #333; color: #fff; "
colspan = " 5 " >< ? php esc_html_e ( 'MySQL INFORMATION' , 'mainwp-child' ); ?> </td>
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'MySQL Mode' , 'mainwp-child' ); ?> </td>
2020-05-06 20:22:11 +07:00
< td colspan = " 3 " >< ? php self :: get_sql_mode (); ?> </td>
2020-04-17 18:44:58 +02:00
</ tr >
< tr >
< td ></ td >
< td >< ? php esc_html_e ( 'MySQL Client Encoding' , 'mainwp-child' ); ?> </td>
< td colspan = " 3 " >< ? php echo esc_html ( defined ( 'DB_CHARSET' ) ? DB_CHARSET : '' ); ?> </td>
</ tr >
< tr >
< td style = " background: #333; color: #fff; " colspan = " 5 " >< ? php _e ( 'WordPress PLUGINS' , 'mainwp-child' ); ?> </td>
2016-06-08 21:47:49 +02:00
</ tr >
< ? php
2020-04-17 18:44:58 +02:00
$all_plugins = get_plugins ();
foreach ( $all_plugins as $slug => $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' ;
}
}
}
?>
< tr >
< td ></ td >
< td >< ? php echo esc_html ( $plugin [ 'Name' ] ); ?> </td>
< td >< ? php echo esc_html ( $plugin [ 'Version' ] ); ?> </td>
< td >< ? php echo is_plugin_active ( $slug ) ? __ ( 'Active' , 'mainwp-child' ) : __ ( 'Inactive' , 'mainwp-child' ); ?> </td>
< td ></ td >
</ tr >
< ? php
}
?>
2015-10-15 22:52:37 +10:00
</ tbody >
</ table >
< br />
< ? php
}
2020-05-06 20:22:11 +07:00
protected static function get_curl_support () {
2016-03-03 20:28:07 +01:00
return function_exists ( 'curl_version' );
}
2020-05-06 20:22:11 +07:00
protected static function get_curl_timeout () {
2016-03-03 20:28:07 +01:00
return ini_get ( 'default_socket_timeout' );
}
2020-05-06 00:47:59 +07:00
protected static function get_curl_version () {
2016-03-03 20:28:07 +01:00
$curlversion = curl_version ();
return $curlversion [ 'version' ];
}
protected static function curlssl_compare ( $value , $operator = null ) {
if ( isset ( $value [ 'version_number' ] ) && defined ( 'OPENSSL_VERSION_NUMBER' ) ) {
return version_compare ( OPENSSL_VERSION_NUMBER , $value [ 'version_number' ], $operator );
}
return false ;
}
2020-05-06 00:47:59 +07:00
protected static function get_curl_ssl_version () {
2016-03-03 20:28:07 +01:00
$curlversion = curl_version ();
return $curlversion [ 'ssl_version' ];
}
2015-10-15 22:52:37 +10:00
2020-05-06 00:47:59 +07:00
public static function mainwp_required_functions () {
2015-10-15 22:52:37 +10:00
$disabled_functions = ini_get ( 'disable_functions' );
if ( '' !== $disabled_functions ) {
$arr = explode ( ',' , $disabled_functions );
sort ( $arr );
$arr_length = count ( $arr );
for ( $i = 0 ; $i < $arr_length ; $i ++ ) {
echo esc_html ( $arr [ $i ] . ', ' );
}
} else {
2017-01-14 13:16:52 +01:00
echo esc_html__ ( 'No functions disabled' , 'mainwp-child' );
2015-10-15 22:52:37 +10:00
}
}
2020-05-06 20:22:11 +07:00
protected static function get_loaded_php_extensions () {
2015-10-15 22:52:37 +10:00
$extensions = get_loaded_extensions ();
sort ( $extensions );
echo esc_html ( implode ( ', ' , $extensions ) );
}
2020-05-06 20:22:11 +07:00
protected static function get_current_version () {
2015-10-15 22:52:37 +10:00
$currentVersion = get_option ( 'mainwp_child_plugin_version' );
return $currentVersion ;
}
2020-05-06 20:22:11 +07:00
protected static function get_mainwp_version () {
2020-03-26 14:11:33 +00:00
include_once ABSPATH . '/wp-admin/includes/plugin-install.php' ;
2020-04-17 18:44:58 +02:00
$api = plugins_api (
'plugin_information' ,
array (
'slug' => 'mainwp-child' ,
'fields' => array ( 'sections' => false ),
'timeout' => 60 ,
)
);
2015-10-15 22:52:37 +10:00
if ( is_object ( $api ) && isset ( $api -> version ) ) {
return $api -> version ;
}
return false ;
}
2020-05-06 20:22:11 +07:00
protected static function get_mainwp_version_check () {
2015-10-15 22:52:37 +10:00
$current = get_option ( 'mainwp_child_plugin_version' );
2020-05-06 20:22:11 +07:00
$latest = self :: get_mainwp_version ();
2015-10-15 22:52:37 +10:00
if ( $current === $latest ) {
echo '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' ;
} else {
echo '<span class="mainwp-warning"><i class="fa fa-exclamation-circle"></i> Warning</span>' ;
}
}
2020-05-06 20:22:11 +07:00
public static function render_cron () {
2015-10-15 22:52:37 +10:00
$cron_array = _get_cron_array ();
$schedules = wp_get_schedules ();
?>
< table id = " mainwp-table " class = " wp-list-table widefat " cellspacing = " 0 " >
< thead >
2020-04-17 18:44:58 +02:00
< tr >
< th scope = " col " class = " manage-column column-posts " >< span >< ? php esc_html_e ( 'Next due' , 'mainwp-child' ); ?> </span></th>
< th scope = " col " class = " manage-column column-posts " >< span >< ? php esc_html_e ( 'Schedule' , 'mainwp-child' ); ?> </span></th>
< th scope = " col " class = " manage-column column-posts " >< span >< ? php esc_html_e ( 'Hook' , 'mainwp-child' ); ?> </span></th>
</ tr >
2015-10-15 22:52:37 +10:00
</ thead >
< tbody id = " the-sites-list " class = " list:sites " >
< ? php
foreach ( $cron_array as $time => $cron ) {
foreach ( $cron as $hook => $cron_info ) {
foreach ( $cron_info as $key => $schedule ) {
?>
< tr >
2020-05-06 00:47:59 +07:00
< td >< ? php echo esc_html ( MainWP_Helper :: format_timestamp ( MainWP_Helper :: get_timestamp ( $time ) ) ); ?> </td>
2015-10-15 22:52:37 +10:00
< td >< ? php echo esc_html ( ( isset ( $schedule [ 'schedule' ] ) && isset ( $schedules [ $schedule [ 'schedule' ] ] ) && isset ( $schedules [ $schedule [ 'schedule' ] ][ 'display' ] ) ) ? $schedules [ $schedule [ 'schedule' ] ][ 'display' ] : '' ); ?> </td>
< td >< ? php echo esc_html ( $hook ); ?> </td>
</ tr >
< ? php
}
}
}
?>
</ tbody >
</ table >
< ? php
}
2020-05-06 20:22:11 +07:00
protected static function check_directory_mainwp_directory ( $write = true ) {
$branding_title = MainWP_Child_Branding :: instance () -> get_branding_title ();
2020-04-17 18:44:58 +02:00
if ( '' == $branding_title ) {
2020-03-27 15:13:11 +00:00
$branding_title = 'MainWP' ;
}
2019-02-14 22:38:14 +07:00
2016-03-03 20:28:07 +01:00
$branding_title .= ' Upload Directory' ;
2015-10-15 22:52:37 +10:00
try {
2020-05-06 00:47:59 +07:00
$dirs = MainWP_Helper :: get_mainwp_dir ( null , false );
2015-10-15 22:52:37 +10:00
$path = $dirs [ 0 ];
2020-05-07 01:03:56 +07:00
} catch ( \Exception $e ) {
2020-05-06 20:22:11 +07:00
return self :: render_directory_row ( $branding_title , '' , 'Writable' , $e -> getMessage (), false );
2015-10-15 22:52:37 +10:00
}
if ( ! is_dir ( dirname ( $path ) ) ) {
if ( $write ) {
2020-05-06 20:22:11 +07:00
return self :: render_directory_row ( $branding_title , $path , 'Writable' , 'Directory not found' , false );
2015-10-15 22:52:37 +10:00
} else {
return false ;
}
}
2020-05-06 00:47:59 +07:00
$hasWPFileSystem = MainWP_Helper :: get_wp_filesystem ();
2020-04-17 18:44:58 +02:00
2015-10-15 22:52:37 +10:00
global $wp_filesystem ;
if ( $hasWPFileSystem && ! empty ( $wp_filesystem ) ) {
if ( ! $wp_filesystem -> is_writable ( $path ) ) {
if ( $write ) {
2020-05-06 20:22:11 +07:00
return self :: render_directory_row ( $branding_title , $path , 'Writable' , 'Directory not writable' , false );
2015-10-15 22:52:37 +10:00
} else {
return false ;
}
}
} else {
if ( ! is_writable ( $path ) ) {
if ( $write ) {
2020-05-06 20:22:11 +07:00
return self :: render_directory_row ( $branding_title , $path , 'Writable' , 'Directory not writable' , false );
2015-10-15 22:52:37 +10:00
} else {
return false ;
}
}
}
if ( $write ) {
2020-05-06 20:22:11 +07:00
return self :: render_directory_row ( $branding_title , $path , 'Writable' , 'Writable' , true );
2015-10-15 22:52:37 +10:00
} else {
return true ;
}
}
2020-05-06 20:22:11 +07:00
protected static function render_directory_row ( $pName , $pDirectory , $pCheck , $pResult , $pPassed ) {
2015-10-15 22:52:37 +10:00
?>
2016-03-03 20:28:07 +01:00
< tr class = " mwp-not-generate-row " >
2015-10-15 22:52:37 +10:00
< td ></ td >
2020-05-06 20:22:11 +07:00
< td >< ? php echo esc_html ( stripslashes ( $pName ) ); ?> <br/><?php echo esc_html( ( MainWP_Child_Branding::instance()->is_branding() ) ? '' : $pDirectory ); ?></td>
2015-10-15 22:52:37 +10:00
< td >< ? php echo esc_html ( $pCheck ); ?> </td>
< td >< ? php echo esc_html ( $pResult ); ?> </td>
2015-12-06 19:05:27 +01:00
< td >< ? php echo ( $pPassed ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : '<span class="mainwp-warning"><i class="fa fa-exclamation-circle"></i> Warning</span>' ); ?> </td>
2015-10-15 22:52:37 +10:00
</ tr >
< ? php
return true ;
}
2020-05-06 20:22:11 +07:00
protected static function render_row ( $pConfig , $pCompare , $pVersion , $pGetter , $pExtraText = '' , $pExtraCompare = null , $pExtraVersion = null , $sizeCompare = false ) {
2020-05-06 13:24:04 +00:00
$currentVersion = call_user_func ( array ( self :: get_class_name (), $pGetter ) );
2015-10-15 22:52:37 +10:00
?>
< tr >
< td ></ td >
2015-12-05 17:38:52 +01:00
< td >< ? php echo esc_html ( esc_html ( $pConfig ) ); ?> </td>
< td >< ? php echo esc_html ( esc_html ( $pCompare ) ); ?> <?php echo esc_html( ( true === $pVersion ? 'true' : $pVersion ) . ' ' . $pExtraText ); ?></td>
2015-10-15 22:52:37 +10:00
< td >< ? php echo esc_html ( true === $currentVersion ? 'true' : $currentVersion ); ?> </td>
2016-03-15 20:54:21 +01:00
< td >< ? php echo ( self :: check ( $pCompare , $pVersion , $pGetter , $pExtraCompare , $pExtraVersion , $sizeCompare ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : '<span class="mainwp-warning"><i class="fa fa-exclamation-circle"></i> Warning</span>' ); ?> </td>
2015-10-15 22:52:37 +10:00
</ tr >
< ? php
}
2020-05-06 20:22:11 +07:00
protected static function render_row_sec ( $pConfig , $pCompare , $pVersion , $pGetter , $pExtraText = '' , $pExtraCompare = null , $pExtraVersion = null , $toolTip = null , $whatType = null , $errorType = self :: WARNING ) {
2020-05-06 13:24:04 +00:00
$currentVersion = call_user_func ( array ( self :: get_class_name (), $pGetter ) );
2016-03-03 20:28:07 +01:00
?>
< tr >
< td ></ td >
< td >< ? php echo $pConfig ; ?> </td>
2020-04-17 18:44:58 +02:00
< td >< ? php echo $pCompare ; ?> <?php echo ( true === $pVersion ? 'true' : ( is_array( $pVersion ) && isset( $pVersion['version'] ) ? $pVersion['version'] : $pVersion ) ) . ' ' . $pExtraText; ?></td>
< td >< ? php echo ( true === $currentVersion ? 'true' : $currentVersion ); ?> </td>
< ? php if ( 'filesize' === $whatType ) { ?>
2020-05-06 20:22:11 +07:00
< td >< ? php echo ( self :: filesize_compare ( $currentVersion , $pVersion , $pCompare ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self :: get_warning_html ( $errorType ) ); ?> </td>
2020-04-17 18:44:58 +02:00
< ? php } elseif ( 'curlssl' === $whatType ) { ?>
2020-05-06 20:22:11 +07:00
< td >< ? php echo ( self :: curlssl_compare ( $pVersion , $pCompare ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self :: get_warning_html ( $errorType ) ); ?> </td>
< ? php } elseif ( ( 'get_max_input_time' === $pGetter || 'get_max_execution_time' === $pGetter ) && - 1 == $currentVersion ) { ?>
2016-03-03 20:28:07 +01:00
< td >< ? php echo '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' ; ?> </td>
< ? php } else { ?>
2020-05-06 20:22:11 +07:00
< td >< ? php echo ( version_compare ( $currentVersion , $pVersion , $pCompare ) || ( ( null != $pExtraCompare ) && version_compare ( $currentVersion , $pExtraVersion , $pExtraCompare ) ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self :: get_warning_html ( $errorType ) ); ?> </td>
2016-03-03 20:28:07 +01:00
< ? php } ?>
</ tr >
< ? php
}
2020-05-06 20:22:11 +07:00
private static function get_warning_html ( $errorType = self :: WARNING ) {
2020-03-27 14:11:21 +00:00
if ( self :: WARNING == $errorType ) {
2016-03-03 20:28:07 +01:00
return '<span class="mainwp-warning"><i class="fa fa-exclamation-circle"></i> Warning</span>' ;
}
return '<span class="mainwp-fail"><i class="fa fa-exclamation-circle"></i> Fail</span>' ;
}
2015-10-15 22:52:37 +10:00
protected static function filesize_compare ( $value1 , $value2 , $operator = null ) {
2020-04-17 18:44:58 +02:00
if ( false !== strpos ( $value1 , 'G' ) ) {
2015-10-15 22:52:37 +10:00
$value1 = preg_replace ( '/[A-Za-z]/' , '' , $value1 );
2020-04-17 18:44:58 +02:00
$value1 = intval ( $value1 ) * 1024 ;
2015-10-15 22:52:37 +10:00
} else {
2020-04-17 18:44:58 +02:00
$value1 = preg_replace ( '/[A-Za-z]/' , '' , $value1 );
2015-10-15 22:52:37 +10:00
}
2020-04-17 18:44:58 +02:00
if ( false !== strpos ( $value2 , 'G' ) ) {
2015-10-15 22:52:37 +10:00
$value2 = preg_replace ( '/[A-Za-z]/' , '' , $value2 );
2020-04-17 18:44:58 +02:00
$value2 = intval ( $value2 ) * 1024 ;
2015-10-15 22:52:37 +10:00
} else {
2020-04-17 18:44:58 +02:00
$value2 = preg_replace ( '/[A-Za-z]/' , '' , $value2 );
2015-10-15 22:52:37 +10:00
}
return version_compare ( $value1 , $value2 , $operator );
}
2020-03-27 14:11:21 +00:00
protected static function check ( $pCompare , $pVersion , $pGetter , $pExtraCompare = null , $pExtraVersion = null , $sizeCompare = false ) {
2020-05-06 13:24:04 +00:00
$currentVersion = call_user_func ( array ( self :: get_class_name (), $pGetter ) );
2015-10-15 22:52:37 +10:00
2020-03-27 14:11:21 +00:00
if ( $sizeCompare ) {
2016-03-15 20:54:21 +01:00
return self :: filesize_compare ( $currentVersion , $pVersion , $pCompare );
} else {
return ( version_compare ( $currentVersion , $pVersion , $pCompare ) || ( ( null !== $pExtraCompare ) && version_compare ( $currentVersion , $pExtraVersion , $pExtraCompare ) ) );
}
2015-10-15 22:52:37 +10:00
}
2020-05-06 20:22:11 +07:00
protected static function get_zip_archive_enabled () {
2015-10-15 22:52:37 +10:00
return class_exists ( 'ZipArchive' );
}
2020-05-06 20:22:11 +07:00
protected static function get_gzip_enabled () {
2015-10-15 22:52:37 +10:00
return function_exists ( 'gzopen' );
}
2020-05-06 20:22:11 +07:00
protected static function get_bzip_enabled () {
2015-10-15 22:52:37 +10:00
return function_exists ( 'bzopen' );
}
2020-05-06 20:22:11 +07:00
protected static function get_wordpress_version () {
2015-10-15 22:52:37 +10:00
global $wp_version ;
return $wp_version ;
}
2020-05-06 20:22:11 +07:00
protected static function get_wordpress_memory_limit () {
2016-03-03 20:28:07 +01:00
return WP_MEMORY_LIMIT ;
}
2020-05-06 20:22:11 +07:00
public static function check_if_multisite () {
2016-03-03 20:28:07 +01:00
$isMultisite = ! is_multisite () ? true : false ;
return $isMultisite ;
}
2020-05-06 20:22:11 +07:00
protected static function get_ssl_support () {
2015-10-15 22:52:37 +10:00
return extension_loaded ( 'openssl' );
}
2020-05-06 20:22:11 +07:00
protected static function get_ssl_warning () {
2018-11-27 15:07:40 +07:00
$conf = array ( 'private_key_bits' => 2048 );
2020-03-26 19:45:07 +00:00
$str = '' ;
2016-03-03 20:28:07 +01:00
if ( function_exists ( 'openssl_pkey_new' ) ) {
2020-04-23 19:53:22 +02:00
$res = openssl_pkey_new ( $conf );
openssl_pkey_export ( $res , $privkey );
2016-03-03 20:28:07 +01:00
$str = openssl_error_string ();
}
return ( stristr ( $str , 'NCONF_get_string:no value' ) ? '' : $str );
}
2020-05-06 20:22:11 +07:00
public static function get_php_version () {
2015-10-15 22:52:37 +10:00
return phpversion ();
}
2020-05-06 20:22:11 +07:00
protected static function get_max_execution_time () {
2015-10-15 22:52:37 +10:00
return ini_get ( 'max_execution_time' );
}
2020-05-06 20:22:11 +07:00
protected static function get_upload_max_filesize () {
2015-10-15 22:52:37 +10:00
return ini_get ( 'upload_max_filesize' );
}
2020-05-06 20:22:11 +07:00
protected static function get_post_max_size () {
2015-10-15 22:52:37 +10:00
return ini_get ( 'post_max_size' );
}
2020-05-06 20:22:11 +07:00
public static function get_my_sql_version () {
2015-10-15 22:52:37 +10:00
/** @var $wpdb wpdb */
global $wpdb ;
2020-03-27 19:18:06 +07:00
return $wpdb -> get_var ( " SHOW VARIABLES LIKE 'version' " , 1 );
2015-10-15 22:52:37 +10:00
}
2020-05-06 20:22:11 +07:00
protected static function get_max_input_time () {
2016-03-03 20:28:07 +01:00
return ini_get ( 'max_input_time' );
}
2020-05-06 20:22:11 +07:00
public static function get_php_memory_limit () {
2015-10-15 22:52:37 +10:00
return ini_get ( 'memory_limit' );
}
2020-05-06 20:22:11 +07:00
protected static function get_os () {
2015-10-15 22:52:37 +10:00
echo esc_html ( PHP_OS );
}
2020-05-06 20:22:11 +07:00
protected static function get_architecture () {
2020-04-17 18:44:58 +02:00
echo esc_html ( PHP_INT_SIZE * 8 ) . ' bit' ;
2015-10-15 22:52:37 +10:00
}
2020-05-06 20:22:11 +07:00
protected static function memory_usage () {
2015-10-15 22:52:37 +10:00
if ( function_exists ( 'memory_get_usage' ) ) {
2020-04-17 18:44:58 +02:00
$memory_usage = round ( memory_get_usage () / 1024 / 1024 , 2 ) . ' MB' ;
2015-10-15 22:52:37 +10:00
} else {
2020-04-17 18:44:58 +02:00
$memory_usage = __ ( 'N/A' , 'mainwp-child' );
2015-10-15 22:52:37 +10:00
}
echo esc_html ( $memory_usage );
}
2020-05-06 20:22:11 +07:00
protected static function get_output_buffer_size () {
2015-10-15 22:52:37 +10:00
return ini_get ( 'pcre.backtrack_limit' );
}
2020-05-06 20:22:11 +07:00
protected static function get_php_safe_mode () {
2020-04-17 18:49:06 +02:00
if ( version_compare ( phpversion (), '5.3.0' ) < 0 && ini_get ( 'safe_mode' ) ) {
2020-04-17 18:44:58 +02:00
$safe_mode = __ ( 'ON' , 'mainwp-child' );
2015-10-15 22:52:37 +10:00
} else {
2020-04-17 18:44:58 +02:00
$safe_mode = __ ( 'OFF' , 'mainwp-child' );
2015-10-15 22:52:37 +10:00
}
echo esc_html ( $safe_mode );
}
2020-05-06 20:22:11 +07:00
protected static function get_sql_mode () {
2015-10-15 22:52:37 +10:00
global $wpdb ;
$mysqlinfo = $wpdb -> get_results ( " SHOW VARIABLES LIKE 'sql_mode' " );
if ( is_array ( $mysqlinfo ) ) {
$sql_mode = $mysqlinfo [ 0 ] -> Value ;
}
if ( empty ( $sql_mode ) ) {
2020-04-17 18:44:58 +02:00
$sql_mode = __ ( 'NOT SET' , 'mainwp-child' );
2015-10-15 22:52:37 +10:00
}
echo esc_html ( $sql_mode );
}
2020-05-06 20:22:11 +07:00
protected static function get_php_allow_url_fopen () {
2015-10-15 22:52:37 +10:00
if ( ini_get ( 'allow_url_fopen' ) ) {
2020-04-17 18:44:58 +02:00
$allow_url_fopen = __ ( 'ON' , 'mainwp-child' );
2015-10-15 22:52:37 +10:00
} else {
2020-04-17 18:44:58 +02:00
$allow_url_fopen = __ ( 'OFF' , 'mainwp-child' );
2015-10-15 22:52:37 +10:00
}
echo esc_html ( $allow_url_fopen );
}
2020-05-06 20:22:11 +07:00
protected static function get_php_exif () {
2015-10-15 22:52:37 +10:00
if ( is_callable ( 'exif_read_data' ) ) {
2020-04-17 18:44:58 +02:00
$exif = __ ( 'YES' , 'mainwp-child' ) . ' ( V' . substr ( phpversion ( 'exif' ), 0 , 4 ) . ')' ;
2015-10-15 22:52:37 +10:00
} else {
2020-04-17 18:44:58 +02:00
$exif = __ ( 'NO' , 'mainwp-child' );
2015-10-15 22:52:37 +10:00
}
echo esc_html ( $exif );
}
2020-05-06 20:22:11 +07:00
protected static function get_php_ip_tc () {
2015-10-15 22:52:37 +10:00
if ( is_callable ( 'iptcparse' ) ) {
2020-04-17 18:44:58 +02:00
$iptc = __ ( 'YES' , 'mainwp-child' );
2015-10-15 22:52:37 +10:00
} else {
2020-04-17 18:44:58 +02:00
$iptc = __ ( 'NO' , 'mainwp-child' );
2015-10-15 22:52:37 +10:00
}
echo esc_html ( $iptc );
}
2020-05-06 20:22:11 +07:00
protected static function get_php_xml () {
2015-10-15 22:52:37 +10:00
if ( is_callable ( 'xml_parser_create' ) ) {
2020-04-17 18:44:58 +02:00
$xml = __ ( 'YES' , 'mainwp-child' );
2015-10-15 22:52:37 +10:00
} else {
2020-04-17 18:44:58 +02:00
$xml = __ ( 'NO' , 'mainwp-child' );
2015-10-15 22:52:37 +10:00
}
echo esc_html ( $xml );
}
2020-05-06 20:22:11 +07:00
protected static function get_server_getaway_interface () {
2020-04-17 18:44:58 +02:00
$gate = isset ( $_SERVER [ 'GATEWAY_INTERFACE' ] ) ? $_SERVER [ 'GATEWAY_INTERFACE' ] : '' ;
2018-12-19 17:01:08 +07:00
echo esc_html ( $gate );
2015-10-15 22:52:37 +10:00
}
2020-05-06 20:22:11 +07:00
public static function get_server_ip () {
2015-10-15 22:52:37 +10:00
echo esc_html ( $_SERVER [ 'SERVER_ADDR' ] );
}
2020-05-06 20:22:11 +07:00
protected static function get_server_name () {
2015-10-15 22:52:37 +10:00
echo esc_html ( $_SERVER [ 'SERVER_NAME' ] );
}
2020-05-06 20:22:11 +07:00
protected static function get_server_software () {
2015-10-15 22:52:37 +10:00
echo esc_html ( $_SERVER [ 'SERVER_SOFTWARE' ] );
}
2020-05-06 20:22:11 +07:00
protected static function get_server_protocol () {
2015-10-15 22:52:37 +10:00
echo esc_html ( $_SERVER [ 'SERVER_PROTOCOL' ] );
}
2020-05-06 20:22:11 +07:00
protected static function get_server_request_time () {
2015-10-15 22:52:37 +10:00
echo esc_html ( $_SERVER [ 'REQUEST_TIME' ] );
}
2020-05-06 20:22:11 +07:00
protected static function get_server_http_accept () {
2015-10-15 22:52:37 +10:00
echo esc_html ( $_SERVER [ 'HTTP_ACCEPT' ] );
}
2020-05-06 20:22:11 +07:00
protected static function get_server_accept_charset () {
2015-10-15 22:52:37 +10:00
if ( ! isset ( $_SERVER [ 'HTTP_ACCEPT_CHARSET' ] ) || ( '' === $_SERVER [ 'HTTP_ACCEPT_CHARSET' ] ) ) {
2017-01-14 13:16:52 +01:00
esc_html_e ( 'N/A' , 'mainwp-child' );
2015-10-15 22:52:37 +10:00
} else {
echo esc_html ( $_SERVER [ 'HTTP_ACCEPT_CHARSET' ] );
}
}
2020-05-06 20:22:11 +07:00
protected static function get_http_host () {
2015-10-15 22:52:37 +10:00
echo esc_html ( $_SERVER [ 'HTTP_HOST' ] );
}
2020-05-06 20:22:11 +07:00
protected static function get_complete_url () {
2016-06-06 19:47:12 +02:00
echo isset ( $_SERVER [ 'HTTP_REFERER' ] ) ? esc_html ( $_SERVER [ 'HTTP_REFERER' ] ) : '' ;
2015-10-15 22:52:37 +10:00
}
2020-05-06 20:22:11 +07:00
protected static function get_user_agent () {
2015-10-15 22:52:37 +10:00
echo esc_html ( $_SERVER [ 'HTTP_USER_AGENT' ] );
}
2020-05-06 20:22:11 +07:00
protected static function get_https () {
2015-10-15 22:52:37 +10:00
if ( isset ( $_SERVER [ 'HTTPS' ] ) && '' !== $_SERVER [ 'HTTPS' ] ) {
2017-01-14 13:16:52 +01:00
echo esc_html ( __ ( 'ON' , 'mainwp-child' ) . ' - ' . $_SERVER [ 'HTTPS' ] );
2015-10-15 22:52:37 +10:00
} else {
2017-01-14 13:16:52 +01:00
esc_html_e ( 'OFF' , 'mainwp-child' );
2015-10-15 22:52:37 +10:00
}
}
2020-05-06 20:22:11 +07:00
protected static function server_self_connect () {
2020-03-26 19:45:07 +00:00
$url = site_url ( 'wp-cron.php' );
$query_args = array ( 'mainwp_child_run' => 'test' );
$url = add_query_arg ( $query_args , $url );
$args = array (
2020-03-26 15:29:54 +00:00
'blocking' => true ,
'sslverify' => apply_filters ( 'https_local_ssl_verify' , true ),
'timeout' => 15 ,
2016-03-03 20:28:07 +01:00
);
2020-03-26 19:45:07 +00:00
$response = wp_remote_post ( $url , $args );
2016-03-03 20:28:07 +01:00
$test_result = '' ;
if ( is_wp_error ( $response ) ) {
2020-03-26 14:05:04 +00:00
$test_result .= sprintf ( __ ( 'The HTTP response test get an error "%s"' , 'mainwp-child' ), $response -> get_error_message () );
2016-03-03 20:28:07 +01:00
}
$response_code = wp_remote_retrieve_response_code ( $response );
2020-03-26 17:03:00 +00:00
if ( $response_code < 200 && $response_code > 204 ) {
2020-03-26 14:05:04 +00:00
$test_result .= sprintf ( __ ( 'The HTTP response test get a false http status (%s)' , 'mainwp-child' ), wp_remote_retrieve_response_code ( $response ) );
2016-03-03 20:28:07 +01:00
} else {
$response_body = wp_remote_retrieve_body ( $response );
2020-03-26 14:05:04 +00:00
if ( false === strstr ( $response_body , 'MainWP Test' ) ) {
2020-04-22 18:41:51 +02:00
$test_result .= sprintf ( __ ( 'Not expected HTTP response body: %s' , 'mainwp-child' ), esc_attr ( wp_strip_all_tags ( $response_body ) ) );
2016-03-03 20:28:07 +01:00
}
}
if ( empty ( $test_result ) ) {
2017-01-14 13:16:52 +01:00
_e ( 'Response Test O.K.' , 'mainwp-child' );
2020-03-26 14:11:33 +00:00
} else {
2016-03-03 20:28:07 +01:00
echo $test_result ;
2020-03-27 15:13:11 +00:00
}
2016-03-03 20:28:07 +01:00
}
2020-05-06 20:22:11 +07:00
protected static function get_remote_address () {
2015-10-15 22:52:37 +10:00
echo esc_html ( $_SERVER [ 'REMOTE_ADDR' ] );
}
2020-05-06 20:22:11 +07:00
protected static function get_remote_host () {
2015-10-15 22:52:37 +10:00
if ( ! isset ( $_SERVER [ 'REMOTE_HOST' ] ) || ( '' === $_SERVER [ 'REMOTE_HOST' ] ) ) {
2017-01-14 13:16:52 +01:00
esc_html_e ( 'N/A' , 'mainwp-child' );
2015-10-15 22:52:37 +10:00
} else {
echo esc_html ( $_SERVER [ 'REMOTE_HOST' ] );
}
}
2020-05-06 20:22:11 +07:00
protected static function get_remote_port () {
2015-10-15 22:52:37 +10:00
echo esc_html ( $_SERVER [ 'REMOTE_PORT' ] );
}
2020-05-06 20:22:11 +07:00
protected static function get_script_file_name () {
2015-10-15 22:52:37 +10:00
echo esc_html ( $_SERVER [ 'SCRIPT_FILENAME' ] );
}
2020-05-06 20:22:11 +07:00
protected static function get_server_port () {
2015-10-15 22:52:37 +10:00
echo esc_html ( $_SERVER [ 'SERVER_PORT' ] );
}
2020-05-06 20:22:11 +07:00
protected static function get_current_page_uri () {
2015-10-15 22:52:37 +10:00
echo esc_html ( $_SERVER [ 'REQUEST_URI' ] );
}
2020-05-06 20:22:11 +07:00
protected static function get_wp_root () {
2015-10-15 22:52:37 +10:00
echo esc_html ( ABSPATH );
}
/*
2020-03-27 15:13:11 +00:00
* 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 +
2015-10-15 22:52:37 +10:00
*/
2020-05-06 20:22:11 +07:00
public static function render_error_log_page () {
2015-10-15 22:52:37 +10:00
?>
< table id = " mainwp-table " class = " wp-list-table widefat " cellspacing = " 0 " >
< thead title = " Click to Toggle " style = " cursor: pointer; " >
2020-04-17 18:44:58 +02:00
< tr >
< th scope = " col " class = " manage-column column-posts " style = " width: 10% " >< ? php esc_html_e ( 'Time' , 'mainwp-child' ); ?> </th>
< th scope = " col " class = " manage-column column-posts " >< ? php esc_html_e ( 'Error' , 'mainwp-child' ); ?> </th>
</ tr >
2015-10-15 22:52:37 +10:00
</ thead >
< tbody class = " list:sites " id = " mainwp-error-log-table " >
2020-05-06 20:22:11 +07:00
< ? php self :: render_error_log (); ?>
2015-10-15 22:52:37 +10:00
</ tbody >
</ table >
< ? php
}
2020-05-06 20:22:11 +07:00
public static function render_error_log () {
2015-10-15 22:52:37 +10:00
$log_errors = ini_get ( 'log_errors' );
if ( ! $log_errors ) {
2017-01-14 13:16:52 +01:00
echo '<tr><td colspan="2">' . esc_html__ ( 'Error logging disabled.' , 'mainwp-child' ) . '</td></tr>' ;
2015-10-15 22:52:37 +10:00
}
$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 ) ) {
2020-05-06 20:22:11 +07:00
$branding_title = MainWP_Child_Branding :: instance () -> get_branding_title ();
2020-04-17 18:49:06 +02:00
if ( '' == $branding_title ) {
2020-03-27 15:13:11 +00:00
$branding_title = 'MainWP' ;
}
$msg = esc_html ( stripslashes ( $branding_title ) ) . ' is unable to find your error logs, please contact your host for server error logs.' ;
2020-03-26 14:05:04 +00:00
echo '<tr><td colspan="2">' . $msg . '</td></tr>' ;
2015-10-15 22:52:37 +10:00
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' );
}
2018-04-17 20:33:10 +02:00
if ( is_array ( $error_log ) && count ( $error_log ) > 1 ) {
2015-10-15 22:52:37 +10:00
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 ( " <tr><td> { $time } </td><td> { $error } </td></tr> " );
}
}
}
2020-04-17 18:44:58 +02:00
public static function time_compare ( $a , $b ) {
2015-10-15 22:52:37 +10:00
if ( $a === $b ) {
return 0 ;
}
return ( strtotime ( $a [ 'time' ] ) > strtotime ( $b [ 'time' ] ) ) ? - 1 : 1 ;
}
2020-04-17 18:44:58 +02:00
public static function last_lines ( $path , $line_count , $block_size = 512 ) {
2015-10-15 22:52:37 +10:00
$lines = array ();
2020-04-17 18:44:58 +02:00
// we will always have a fragment of a non-complete line.
2015-10-15 22:52:37 +10:00
// keep this in here till we have our next entire line.
$leftover = '' ;
2020-05-13 18:48:37 +07:00
// phpcs:disable WordPress.WP.AlternativeFunctions -- to custom read file.
2015-10-15 22:52:37 +10:00
$fh = fopen ( $path , 'r' );
2020-04-17 18:44:58 +02:00
// go to the end of the file.
2015-10-15 22:52:37 +10:00
fseek ( $fh , 0 , SEEK_END );
2020-04-17 18:44:58 +02:00
$count_lines = count ( $lines );
2015-10-15 22:52:37 +10:00
do {
2020-04-17 18:44:58 +02:00
// need to know whether we can actually go back.
2015-10-15 22:52:37 +10:00
$can_read = $block_size ;
if ( ftell ( $fh ) <= $block_size ) {
$can_read = ftell ( $fh );
}
if ( empty ( $can_read ) ) {
break ;
}
2020-04-17 18:44:58 +02:00
// go back as many bytes as we can.
// read them to $data and then move the file pointer.
2015-10-15 22:52:37 +10:00
// back to where we were.
fseek ( $fh , - $can_read , SEEK_CUR );
2020-03-26 19:45:07 +00:00
$data = fread ( $fh , $can_read );
2015-10-15 22:52:37 +10:00
$data .= $leftover ;
fseek ( $fh , - $can_read , SEEK_CUR );
2020-04-17 18:44:58 +02:00
// 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.
2015-10-15 22:52:37 +10:00
$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 ];
2020-04-17 18:44:58 +02:00
} while ( $count_lines < $line_count && 0 !== ftell ( $fh ) );
2015-10-15 22:52:37 +10:00
if ( 0 === ftell ( $fh ) ) {
$lines [] = $leftover ;
}
fclose ( $fh );
2020-05-13 18:48:37 +07:00
// phpcs:enable
2015-10-15 22:52:37 +10:00
// Usually, we will read too many lines, correct that here.
return array_slice ( $lines , 0 , $line_count );
}
2020-05-06 20:22:11 +07:00
public static function render_wp_config () {
2015-10-15 22:52:37 +10:00
?>
< div class = " postbox " id = " mainwp-code-display " >
< h3 class = " hndle " style = " padding: 8px 12px; font-size: 14px; " >< span > WP - Config . php </ span ></ h3 >
< div style = " padding: 1em; " >
< ? php
2017-01-01 20:43:26 +01:00
if ( file_exists ( ABSPATH . 'wp-config.php' ) ) {
2020-04-23 19:53:22 +02:00
show_source ( ABSPATH . 'wp-config.php' );
2017-01-01 20:43:26 +01:00
} else {
2020-04-23 19:53:22 +02:00
$files = get_included_files ();
2017-01-01 20:43:26 +01:00
$configFound = false ;
if ( is_array ( $files ) ) {
foreach ( $files as $file ) {
if ( stristr ( $file , 'wp-config.php' ) ) {
$configFound = true ;
2020-04-23 19:53:22 +02:00
show_source ( $file );
2017-01-01 20:43:26 +01:00
break ;
}
}
}
2020-03-26 17:03:00 +00:00
if ( ! $configFound ) {
2017-01-01 20:43:26 +01:00
_e ( 'wp-config.php not found' , 'mainwp' );
}
}
2015-10-15 22:52:37 +10:00
?>
</ div >
</ div >
< ? php
}
public static function renderhtaccess () {
?>
< div class = " postbox " id = " mainwp-code-display " >
2016-10-24 20:33:37 +02:00
< h3 class = " hndle " style = " padding: 8px 12px; font-size: 14px; " >< span >< ? php _e ( '.htaccess' , 'mainwp-child' ); ?> </span></h3>
2020-04-23 19:53:22 +02:00
< div style = " padding: 1em; " >< ? php show_source ( ABSPATH . '.htaccess' ); ?> </div>
2015-10-15 22:52:37 +10:00
</ div >
< ? php
}
2018-11-27 15:07:40 +07:00
2020-05-06 20:22:11 +07:00
public static function render_connection_details () {
$branding_title = MainWP_Child_Branding :: instance () -> get_branding_title ();
2020-04-17 18:44:58 +02:00
if ( '' == $branding_title ) {
2020-03-26 19:51:58 +00:00
$branding_title = 'MainWP' ;
}
global $current_user ;
2020-04-17 18:44:58 +02:00
$uniqueId = get_option ( 'mainwp_child_uniqueId' );
2020-03-26 19:51:58 +00:00
$details = array (
'siteurl' => array (
2020-04-17 18:44:58 +02:00
'title' => __ ( 'Site URL' , 'mainwp-child' ),
2020-03-26 19:51:58 +00:00
'value' => get_bloginfo ( 'url' ),
'desc' => get_bloginfo ( 'url' ),
),
'adminuser' => array (
2020-04-17 18:44:58 +02:00
'title' => __ ( 'Administrator name' , 'mainwp-child' ),
2020-03-26 19:51:58 +00:00
'value' => $current_user -> user_login ,
2020-04-17 18:44:58 +02:00
'desc' => __ ( 'This is your Administrator username, however, you can use any existing Administrator username.' , 'mainwp-child' ),
2020-03-26 19:51:58 +00:00
),
'friendly_name' => array (
2020-04-17 18:44:58 +02:00
'title' => __ ( 'Friendly site name' , 'mainwp-child' ),
2020-03-26 19:51:58 +00:00
'value' => get_bloginfo ( 'name' ),
2020-04-17 18:44:58 +02:00
'desc' => __ ( 'For the friendly site name, you can use any name, this is just a suggestion.' , 'mainwp-child' ),
2020-03-26 19:51:58 +00:00
),
'uniqueid' => array (
2020-04-17 18:44:58 +02:00
'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 ) ),
2020-03-26 19:51:58 +00:00
),
'verify_ssl' => array (
2020-04-17 18:44:58 +02:00
'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' ),
2020-03-26 19:51:58 +00:00
),
'ssl_version' => array (
2020-04-17 18:44:58 +02:00
'title' => __ ( 'SSL version' , 'mainwp-child' ),
'value' => __ ( 'Auto Detect' , 'mainwp-child' ),
'desc' => __ ( 'Auto Detect' , 'mainwp-child' ),
2020-03-26 19:51:58 +00:00
),
2018-11-27 15:07:40 +07:00
2020-03-26 19:51:58 +00:00
);
2016-10-24 20:33:37 +02:00
?>
< div class = " postbox " id = " connection_detail " >
< h3 class = " mainwp_box_title " >< span >< ? php _e ( 'Connection details' , 'mainwp-child' ); ?> </span></h3>
< div class = " inside " >
2020-04-17 18:44:58 +02:00
< div class = " mainwp-postbox-actions-top mainwp-padding-5 " >
< ? php echo sprintf ( __ ( 'If you are trying to connect this child site to your %s Dashboard, you can use following details to do that. Please note that these are only suggested values.' , 'mainwp-child' ), stripslashes ( $branding_title ) ); ?>
</ div >
< table id = " mainwp-table " class = " wp-list-table widefat " cellspacing = " 0 " style = " border: 0 " >
< tbody >
2020-03-26 19:51:58 +00:00
< ? php
2020-04-17 16:45:08 +00:00
foreach ( $details as $row ) {
2020-04-17 18:44:58 +02:00
?>
< tr >
< th style = " width: 20% " >< strong >< ? php echo esc_html ( $row [ 'title' ] ); ?> </strong></th>
< td style = " width: 20% " >< strong >< ? php echo esc_html ( $row [ 'value' ] ); ?> </strong></td>
< td >< ? php echo esc_html ( $row [ 'desc' ] ); ?> </td>
</ tr >
< ? php
2020-04-17 16:45:08 +00:00
}
2020-03-26 19:51:58 +00:00
?>
2020-04-17 18:44:58 +02:00
</ tbody >
</ table >
2016-10-24 20:33:37 +02:00
</ div >
</ div >
< ? php
}
2018-11-27 15:07:40 +07:00
2020-03-26 14:05:04 +00:00
}