Merge branch 'bogdan01' of https://github.com/mainwp/mainwp-child into thang

This commit is contained in:
thanghv 2020-05-19 20:22:41 +07:00
commit 253bf3d4f2
7 changed files with 62 additions and 59 deletions

View file

@ -350,7 +350,7 @@ class MainWP_Backup {
$this->add_file_from_string_to_zip( 'clone/config.txt', $string );
}
public function copy_dir( $nodes, $excludes, $backupfolder, $excludenonwp, $root ) {
if ( ! is_array( $nodes ) ) {
return;

View file

@ -590,7 +590,7 @@ class MainWP_Child_Back_Up_WordPress {
return $information;
}
private function render_table_excluded( $root_dir, $schedule, $excludes, $user_excludes, $new_version ){
private function render_table_excluded( $root_dir, $schedule, $excludes, $user_excludes, $new_version ) {
?>
<table class="widefat">
<tbody>
@ -630,7 +630,7 @@ class MainWP_Child_Back_Up_WordPress {
<?php
}
private function render_table_files( $files, $schedule, $directory, $root_dir, $new_version, $site_size, $is_size_calculated ){
private function render_table_files( $files, $schedule, $directory, $root_dir, $new_version, $site_size, $is_size_calculated ) {
?>
<table class="widefat">
<thead>
@ -647,7 +647,7 @@ class MainWP_Child_Back_Up_WordPress {
<?php
}
private function render_table_header_files( $root_dir, $directory, $schedule, $new_version, $site_size, $is_size_calculated ){
private function render_table_header_files( $root_dir, $directory, $schedule, $new_version, $site_size, $is_size_calculated ) {
?>
<tr>
<th></th>
@ -720,7 +720,7 @@ class MainWP_Child_Back_Up_WordPress {
<?php
}
private function render_table_body_files( $files, $schedule, $root_dir, $new_version, $site_size, $is_size_calculated ){ // phpcs:ignore -- ignore complex method notice.
private function render_table_body_files( $files, $schedule, $root_dir, $new_version, $site_size, $is_size_calculated ) { // phpcs:ignore -- ignore complex method notice.
foreach ( $files as $size => $file ) {
$is_excluded = false;
@ -838,9 +838,10 @@ class MainWP_Child_Back_Up_WordPress {
<?php endif; ?>
</td>
</tr>
<?php }
<?php
}
}
public function directory_browse() {
$browse_dir = $_POST['browse_dir'];
$out = array();

View file

@ -1062,7 +1062,7 @@ class MainWP_Child_Posts {
'_bulkpost_do_not_del',
'_mainwp_spin_me',
);
$not_allowed[] = '_mainwp_boilerplate_sites_posts';
$not_allowed[] = '_mainwp_boilerplate_sites_posts';
$not_allowed[] = '_mainwp_post_plus';
$not_allowed[] = '_saved_as_draft';
$not_allowed[] = '_saved_draft_categories';

View file

@ -946,7 +946,7 @@ class MainWP_Child_Timecapsule {
$tabName = $_POST['tabname'];
$is_general = $_POST['is_general'];
$saved = false;
$saved = false;
$config = WPTC_Factory::get( 'config' );
if ( 'backup' == $tabName ) {
$this->save_settings_backup_tab( $config, $data );
@ -958,7 +958,7 @@ class MainWP_Child_Timecapsule {
$this->save_settings_vulns_update_tab( $config, $data, $is_general );
$saved = true;
} elseif ( 'staging_opts' == $tabName ) {
$this->save_settings_staging_opts_tab( $config, $data, $is_general );
$this->save_settings_staging_opts_tab( $config, $data, $is_general );
$saved = true;
}
if ( ! $saved ) {
@ -967,8 +967,8 @@ class MainWP_Child_Timecapsule {
return array( 'result' => 'ok' );
}
private function save_settings_backup_tab( $config, $data ){
private function save_settings_backup_tab( $config, $data ) {
$config->set_option( 'user_excluded_extenstions', $data['user_excluded_extenstions'] );
$config->set_option( 'user_excluded_files_more_than_size_settings', $data['user_excluded_files_more_than_size_settings'] );
@ -993,15 +993,14 @@ class MainWP_Child_Timecapsule {
if ( ! empty( $data['revision_limit'] ) && ! $notice ) {
$notice = apply_filters( 'save_settings_revision_limit_wptc', $data['revision_limit'] );
}
}
private function save_settings_backup_auto_tab( $config, $data, $is_general ) {
private function save_settings_backup_auto_tab( $config, $data, $is_general ) {
$config->set_option( 'backup_before_update_setting', $data['backup_before_update_setting'] );
$current = $config->get_option( 'wptc_auto_update_settings' );
$current = $config->get_option( 'wptc_auto_update_settings' );
$current = unserialize( $current ); // phpcs:ignore -- third party credit.
$new = unserialize( $data['wptc_auto_update_settings'] ); // phpcs:ignore -- third party credit.
$current['update_settings']['status'] = $new['update_settings']['status'];
$current['update_settings']['status'] = $new['update_settings']['status'];
$current['update_settings']['schedule']['enabled'] = $new['update_settings']['schedule']['enabled'];
$current['update_settings']['schedule']['time'] = $new['update_settings']['schedule']['time'];
$current['update_settings']['core']['major']['status'] = $new['update_settings']['core']['major']['status'];
@ -1024,8 +1023,8 @@ class MainWP_Child_Timecapsule {
}
$config->set_option( 'wptc_auto_update_settings', serialize( $current ) ); // phpcs:ignore -- third party credit.
}
private function save_settings_vulns_update_tab( $config, $data, $is_general ){
private function save_settings_vulns_update_tab( $config, $data, $is_general ) {
$current = $config->get_option( 'vulns_settings' );
$current = unserialize( $current ); // phpcs:ignore -- third party credit.
$new = unserialize( $data['vulns_settings'] ); // phpcs:ignore -- third party credit.
@ -1066,8 +1065,8 @@ class MainWP_Child_Timecapsule {
}
$config->set_option( 'vulns_settings', serialize( $current ) ); // phpcs:ignore -- third party credit.
}
private function save_settings_staging_opts_tab( $config, $data, $is_general ){
private function save_settings_staging_opts_tab( $config, $data, $is_general ) {
$config->set_option( 'user_excluded_extenstions_staging', $data['user_excluded_extenstions_staging'] );
$config->set_option( 'internal_staging_db_rows_copy_limit', $data['internal_staging_db_rows_copy_limit'] );
$config->set_option( 'internal_staging_file_copy_limit', $data['internal_staging_file_copy_limit'] );
@ -1078,7 +1077,7 @@ class MainWP_Child_Timecapsule {
$config->set_option( 'staging_login_custom_link', $data['staging_login_custom_link'] );
}
}
private function filter_plugins( $included_plugins ) {
$app_functions = WPTC_Base_Factory::get( 'Wptc_App_Functions' );
$specific = true;

View file

@ -270,7 +270,7 @@ class MainWP_Client_Report {
unset( $args[ $arg ] );
}
}
$exclude_connector_posts = $this->get_stream_get_not_in_params( $sections, $other_tokens );
if ( $exclude_connector_posts ) {
$args['connector__not_in'] = array( 'posts' );
@ -297,12 +297,12 @@ class MainWP_Client_Report {
return $args;
}
private function get_stream_get_not_in_params( $sections, $other_tokens ){
$exclude_connector_posts = true;
private function get_stream_get_not_in_params( $sections, $other_tokens ) {
$exclude_connector_posts = true;
$parts = array( 'header', 'body', 'footer' );
foreach( $parts as $part) {
foreach ( $parts as $part ) {
if ( isset( $sections[ $part ] ) && isset( $sections[ $part ]['section_token'] ) && is_array( $sections[ $part ]['section_token'] ) ) {
foreach ( $sections[ $part ]['section_token'] as $sec ) {
if ( false !== strpos( $sec, '[section.posts' ) || false !== strpos( $sec, '[section.pages' ) ) {
@ -311,12 +311,13 @@ class MainWP_Client_Report {
}
}
}
if ( ! $exclude_connector_posts )
if ( ! $exclude_connector_posts ) {
break;
}
}
if ( $exclude_connector_posts ) {
foreach( $parts as $part) {
foreach ( $parts as $part ) {
if ( isset( $other_tokens[ $part ] ) && is_array( $other_tokens[ $part ] ) ) {
foreach ( $other_tokens[ $part ] as $sec ) {
if ( false !== strpos( $sec, '[post.' ) || false !== strpos( $sec, '[page.' ) ) {
@ -325,13 +326,14 @@ class MainWP_Client_Report {
}
}
}
if ( ! $exclude_connector_posts )
if ( ! $exclude_connector_posts ) {
break;
}
}
}
return $exclude_connector_posts;
}
private function get_stream_others_tokens( $records, $other_tokens, $skip_records ) {
$other_tokens_data = array();
$parts = array( 'header', 'body', 'footer' );
@ -420,7 +422,7 @@ class MainWP_Client_Report {
}
$backups_created_time_to_fix = array();
foreach ( $tokens as $token ) {
if ( isset( $token_values[ $token ] ) ) {
continue;
@ -440,7 +442,7 @@ class MainWP_Client_Report {
// to compatible with new version of child report.
// to check condition for grabbing report data.
$connector = $this->get_connector_by_compatible_context( $context );
$action = $this->get_compatible_action( $action, $context );
$action = $this->get_compatible_action( $action, $context );
// custom values.
if ( 'profiles' == $context ) {
if ( 'created' == $action || 'deleted' == $action ) {
@ -448,7 +450,7 @@ class MainWP_Client_Report {
}
}
switch ( $data ) {
case 'count':
case 'count':
$token_values[ $token ] = $this->get_other_tokens_count( $records, $connector, $context, $action, $skip_records, $backups_created_time_to_fix );
break;
}
@ -458,9 +460,9 @@ class MainWP_Client_Report {
return $token_values;
}
private function get_other_tokens_count( $records, $connector, $context, $action, &$skip_records, &$backups_created_time_to_fix ){ // phpcs:ignore -- ignore complex method notice.
private function get_other_tokens_count( $records, $connector, $context, $action, &$skip_records, &$backups_created_time_to_fix ) { // phpcs:ignore -- ignore complex method notice.
$count = 0;
foreach ( $records as $record ) {
// check connector.
if ( 'editor' == $record->connector ) {
@ -552,7 +554,7 @@ class MainWP_Client_Report {
}
return $count;
}
public function get_section_loop_data( $records, $tokens, $section, $skip_records = array() ) {
$context = '';
@ -645,8 +647,8 @@ class MainWP_Client_Report {
if ( 'draft' === $new_status ) { // avoid auto save post!
continue;
}
}
$token_values = $this->get_section_loop_token_values( $record, $context, $tokens );
}
$token_values = $this->get_section_loop_token_values( $record, $context, $tokens );
if ( ! empty( $token_values ) ) {
$loops[ $loop_count ] = $token_values;
$loop_count ++;
@ -655,8 +657,8 @@ class MainWP_Client_Report {
return $loops;
}
private function get_section_loop_token_values( $record, $context, $tokens ){
private function get_section_loop_token_values( $record, $context, $tokens ) {
$token_values = array();
foreach ( $tokens as $token ) {
$data = '';
@ -695,7 +697,7 @@ class MainWP_Client_Report {
$msg = 'MainWP Child Report:: skip empty value :: token :: ' . $token . ' :: record :: ' . print_r( $record, true ); // phpcs:ignore -- debug mode only.
MainWP_Helper::log_debug( $msg );
}
}
}
return $token_values;
}
@ -740,8 +742,9 @@ class MainWP_Client_Report {
$tok_value = $this->get_stream_meta_data( $record, $data );
}
break;
case 'author':
$tok_value = $this->get_author_data_token_value( $record, $connector, $context, $data );;
case 'author':
$tok_value = $this->get_author_data_token_value( $record, $connector, $context, $data );
break;
case 'status':
case 'webtrust':
@ -749,11 +752,11 @@ class MainWP_Client_Report {
if ( 'sucuri_scan' === $context ) {
$value = $this->get_sucuri_scan_token_value( $record, $data );
}
$tok_value = $value;
$tok_value = $value;
break;
case 'details':
case 'result':
$tok_value = $this->get_result_data_token_value( $record, $context, $data );
$tok_value = $this->get_result_data_token_value( $record, $context, $data );
break;
case 'type':
if ( 'backups' === $context ) {
@ -807,7 +810,7 @@ class MainWP_Client_Report {
return $value;
}
private function get_author_data_token_value( $record, $connector, $context, $data ){
private function get_author_data_token_value( $record, $connector, $context, $data ) {
if ( 'comment' == $connector ) {
$data = 'user_name';
} else {
@ -823,11 +826,11 @@ class MainWP_Client_Report {
if ( empty( $value ) ) {
$value = $this->get_stream_meta_data( $record, 'author_meta' );
}
return $value;
}
private function get_result_data_token_value( $record, $context, $data ){
private function get_result_data_token_value( $record, $context, $data ) {
if ( 'mainwp_maintenance' === $context && 'details' == $data ) {
$tok_value = $this->get_mainwp_maintenance_token_value( $record, $data );
} elseif ( 'wordfence_scan' === $context || 'mainwp_maintenance' === $context ) {
@ -847,10 +850,10 @@ class MainWP_Client_Report {
}
return $tok_value;
}
private function get_sucuri_scan_token_value( $record, $data ) {
$tok_value = '';
$scan_data = $this->get_stream_meta_data( $record, 'scan_data' );
$scan_data = $this->get_stream_meta_data( $record, 'scan_data' );
if ( ! empty( $scan_data ) ) {
$scan_data = maybe_unserialize( base64_decode( $scan_data ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for begin reasons.
if ( is_array( $scan_data ) ) {

View file

@ -651,8 +651,8 @@ class MainWP_Clone_Install {
}
return true;
}
private function create_clone_backup(){
private function create_clone_backup() {
MainWP_Helper::end_session();
$files = glob( WP_CONTENT_DIR . '/dbBackup*.sql' );
foreach ( $files as $file ) {

View file

@ -829,9 +829,9 @@ class Tar_Archiver {
}
}
private function read_next_bytes( $file ){
private function read_next_bytes( $file ) {
$previousFtell = ftell( $this->archive );
$bytes = $file['stat'][7] + ( 512 == ( 512 - $file['stat'][7] % 512 ) ? 0 : ( 512 - $file['stat'][7] % 512 ) );
$bytes = $file['stat'][7] + ( 512 == ( 512 - $file['stat'][7] % 512 ) ? 0 : ( 512 - $file['stat'][7] % 512 ) );
fseek( $this->archive, ftell( $this->archive ) + $bytes );
$ftell = ftell( $this->archive );
if ( 'tar.gz' == $this->type ) {
@ -876,7 +876,7 @@ class Tar_Archiver {
$this->log( 'Skipping file [' . $file['name'] . ']' );
return true;
}
public function log( $text ) {
if ( $this->logHandle ) {
fwrite( $this->logHandle, $text . "\n" );