Merge with branch01

This commit is contained in:
Thang Hoang Van 2018-11-14 21:33:36 +07:00
parent 214ac3046a
commit 6aa7538183
14 changed files with 583 additions and 509 deletions

View file

@ -23,10 +23,6 @@ class MainWP_Child_Back_Up_Buddy {
return;
}
if ( get_option( 'mainwp_backupbuddy_ext_enabled' ) !== 'Y' ) {
return;
}
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
add_action( 'wp_ajax_mainwp_backupbuddy_download_archive', array( $this, 'download_archive' ) );
@ -195,9 +191,6 @@ class MainWP_Child_Back_Up_Buddy {
MainWP_Helper::write( array( 'error' => __( 'Please install the BackupBuddy plugin on the child site.', $this->plugin_translate ) ) );
}
if (get_option( 'mainwp_backupbuddy_ext_enabled' ) !== 'Y')
MainWP_Helper::update_option( 'mainwp_backupbuddy_ext_enabled', 'Y' );
if ( ! class_exists( 'backupbuddy_core' ) ) {
require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' );
}

View file

@ -26,7 +26,7 @@ class MainWP_Child_Back_Up_Wordpress {
if ( version_compare( phpversion(), '5.3', '<' ) ) {
return;
}
if ( get_option( 'mainwp_backupwordpress_ext_enabled' ) !== 'Y' ) return;
if (!$this->is_plugin_installed) return;
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
@ -56,9 +56,6 @@ class MainWP_Child_Back_Up_Wordpress {
MainWP_Helper::write( $information );
}
if (false === get_option('mainwp_backupwordpress_ext_enabled'))
MainWP_Helper::update_option( 'mainwp_backupwordpress_ext_enabled', 'Y' );
if ( isset( $_POST['mwp_action'] ) ) {
switch ( $_POST['mwp_action'] ) {
case 'set_showhide':

View file

@ -110,7 +110,7 @@ class MainWP_Child_Back_WP_Up {
if ( ! isset( $_POST['action'] ) ) {
$information = array( 'error' => __( 'Missing action.', $this->plugin_translate ) );
} else {
MainWP_Helper::update_option( 'mainwp_backwpup_ext_enabled', 'Y' );
switch ( $_POST['action'] ) {
case 'backwpup_update_settings':
$information = $this->update_settings();
@ -194,9 +194,6 @@ class MainWP_Child_Back_WP_Up {
}
public function init() {
if ( get_option( 'mainwp_backwpup_ext_enabled' ) !== 'Y' ) {
return;
}
if (!$this->is_backwpup_installed)
return;
@ -223,14 +220,44 @@ class MainWP_Child_Back_WP_Up {
return;
try {
MainWP_Helper::check_classes_exists(array('BackWPup'));
MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' ));
MainWP_Helper::check_classes_exists(array('BackWPup_File', 'BackWPup_Job'));
MainWP_Helper::check_methods('BackWPup_File', array( 'get_absolute_path' ));
MainWP_Helper::check_methods('BackWPup_Job', array( 'read_logheader' ));
$destinations = BackWPup::get_registered_destinations();
$jobdests = $this->get_destinations_list();
$lasttime_logged = MainWP_Helper::get_lasttime_backup('backwpup');
if ( !empty( $jobdests ) ) {
$log_folder = get_site_option( 'backwpup_cfg_logfolder' );
$log_folder = BackWPup_File::get_absolute_path( $log_folder );
$log_folder = untrailingslashit( $log_folder );
//load logs
$logfiles = array();
if ( is_readable( $log_folder ) && $dir = opendir( $log_folder ) ) {
while ( ( $file = readdir( $dir ) ) !== FALSE ) {
$log_file = $log_folder . '/' . $file;
if ( is_file( $log_file ) && is_readable( $log_file ) && FALSE !== strpos( $file, 'backwpup_log_' ) && FALSE !== strpos( $file, '.html' ) ) {
$logfiles[] = $file;
}
}
closedir( $dir );
}
$log_items = array();
foreach ( $logfiles as $mtime => $logfile ) {
$meta = BackWPup_Job::read_logheader( $log_folder . '/' . $logfile );
if (!isset($meta['logtime']) || $meta['logtime'] < $lasttime_logged)
continue;
if (isset($meta['errors']) && !empty($meta['errors'])) {
continue; // do not logging backups have errors
}
$log_items[$mtime] = $meta;
$log_items[$mtime]['file'] = $logfile;
}
if ( !empty( $log_items ) ) {
$job_types = array(
'DBDUMP' => __('Database backup', 'mainwp-child'),
'FILE' => __('File backup', 'mainwp-child'),
@ -239,41 +266,36 @@ class MainWP_Child_Back_WP_Up {
'DBCHECK' => __('Check database tables', 'mainwp-child')
);
foreach ($jobdests as $jobdest) {
list( $jobid, $dest ) = explode( '_', $jobdest );
if ( ! empty( $destinations[ $dest ][ 'class' ] ) ) {
$job_job_types = BackWPup_Option::get( $jobid, 'type' );
$new_lasttime_logged = $lasttime_logged;
foreach ($log_items as $log) {
$backup_time = $log[ "logtime" ];
if ($backup_time < $lasttime_logged) {
// small than last backup time then skip
continue;
}
$job_job_types = explode('+', $log['type']);
$backup_type = '';
foreach($job_job_types as $typeid) {
if (isset( $job_types[$typeid] )) {
$backup_type .= ' + ' . $job_types[$typeid];
}
}
if (empty($backup_type))
$backup_type = 'BackWPup';
else {
if (empty($backup_type)) {
continue;
} else {
$backup_type = ltrim($backup_type, ' + ');
}
$dest_object = BackWPup::get_destination( $dest );
$items = $dest_object->file_get_list( $jobdest );
//if no items brake
if ( $items ) {
foreach ( $items as $ma ) {
if (isset($ma['time'])) {
$backup_time = $ma[ "time" ];
$message = 'BackWPup backup finished (' . $backup_type . ')';
$destination = "N/A";
if (!empty($backup_time)) {
do_action( 'mainwp_backwpup_backup', $message, $backup_type, $backup_time );
MainWP_Helper::update_lasttime_backup( 'backwpup', $backup_time ); // to support backup before update feature
}
}
}
}
if ($new_lasttime_logged < $backup_time)
$new_lasttime_logged = $backup_time;
}
if ($new_lasttime_logged > $lasttime_logged ) {
MainWP_Helper::update_lasttime_backup( 'backwpup', $new_lasttime_logged ); // to support backup before update feature
}
}
} catch (Exception $ex) {

View file

@ -47,7 +47,7 @@ class MainWP_Child_iThemes_Security {
global $mainwp_itsec_modules_path;
$mainwp_itsec_modules_path = ITSEC_Core::get_core_dir() . '/modules/';
MainWP_Helper::update_option( 'mainwp_ithemes_ext_enabled', 'Y', 'yes' );
if ( isset( $_POST['mwp_action'] ) ) {
switch ( $_POST['mwp_action'] ) {
@ -116,9 +116,8 @@ class MainWP_Child_iThemes_Security {
}
public function ithemes_init() {
if ( get_option( 'mainwp_ithemes_ext_enabled' ) !== 'Y' ) {
if (!$this->is_plugin_installed)
return;
}
if ( get_option( 'mainwp_ithemes_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );

View file

@ -34,7 +34,7 @@ class MainWP_Child_Pagespeed {
MainWP_Helper::write( $information );
}
if ( isset( $_POST['mwp_action'] ) ) {
MainWP_Helper::update_option('mainwp_pagespeed_ext_enabled', 'Y', 'yes');
switch ( $_POST['mwp_action'] ) {
case 'save_settings':
$information = $this->save_settings();
@ -60,9 +60,8 @@ class MainWP_Child_Pagespeed {
}
public function init() {
if ( get_option( 'mainwp_pagespeed_ext_enabled' ) !== 'Y' ) {
if (!$this->is_plugin_installed)
return;
}
if ( get_option( 'mainwp_pagespeed_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'hide_plugin' ) );

View file

@ -142,12 +142,14 @@ class MainWP_Child_Staging {
'batchSize',
'cpuLoad',
'disableAdminLogin',
'wpSubDirectory',
'querySRLimit',
'maxFileSize',
//'wpSubDirectory', // removed
'debugMode',
'unInstallOnDelete',
'checkDirectorySize',
'optimizer',
'loginSlug'
//'loginSlug' // removed
);
$save_fields = array();

View file

@ -531,7 +531,7 @@ function get_sibling_files_callback_wptc() {
$detailed = $this->get_activity_log($sub_records);
if (isset($load_more) && $load_more) {
$detailed .= '<tr><td></td><td><a style="cursor:pointer; position:relative" class="wptc_activity_log_load_more" action_id="'.$action_id.'" limit="'.$to_limit.'">Load more</a></td><td></td></tr>';
$detailed .= '<tr><td></td><td><a style="cursor:pointer; position:relative" class="wptc_activity_log_load_more" action_id="'. esc_attr( $action_id ).'" limit="'. esc_attr( $to_limit ) .'">Load more</a></td><td></td></tr>';
}
return array( 'result' => $detailed);

View file

@ -75,11 +75,6 @@ class MainWP_Child_Updraft_Plus_Backups {
}
if ( isset( $_POST['mwp_action'] ) ) {
if ( get_option( 'mainwp_updraftplus_ext_enabled' ) !== 'Y' ) {
MainWP_Helper::update_option( 'mainwp_updraftplus_ext_enabled', 'Y', 'yes' );
}
try {
switch ( $_POST['mwp_action'] ) {
case 'set_showhide':
@ -3071,14 +3066,19 @@ class MainWP_Child_Updraft_Plus_Backups {
$entities = '';
$non = $backup['nonce'];
$rawbackup = "<h2>$esc_pretty_date ($key)</h2><pre><p>" . esc_attr( print_r( $backup, true ) );
if ( ! empty( $non ) ) {
$jd = $updraftplus->jobdata_getarray( $non );
if ( ! empty( $jd ) && is_array( $jd ) ) {
$rawbackup .= '</p><p>' . esc_attr( print_r( $jd, true ) );
}
}
$rawbackup .= '</p></pre>';
// $rawbackup = "<h2>$esc_pretty_date ($key)</h2><pre><p>" . esc_attr( print_r( $backup, true ) );
// if ( ! empty( $non ) ) {
// $jd = $updraftplus->jobdata_getarray( $non );
// if ( ! empty( $jd ) && is_array( $jd ) ) {
// $rawbackup .= '</p><p>' . esc_attr( print_r( $jd, true ) );
// }
// }
// $rawbackup .= '</p></pre>';
// to fix
$rawbackup = '' ; //$updraftplus_admin->raw_backup_info($backup_history, $key, $non);
$jobdata = $updraftplus->jobdata_getarray( $non );
@ -3908,9 +3908,8 @@ ENDHERE;
}
public function updraftplus_init() {
if ( get_option( 'mainwp_updraftplus_ext_enabled' ) !== 'Y' ) {
if (!$this->is_plugin_installed)
return;
}
if ( get_option( 'mainwp_updraftplus_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );

View file

@ -214,7 +214,7 @@ class MainWP_Child_Wordfence {
MainWP_Helper::write( $information );
}
if ( isset( $_POST['mwp_action'] ) ) {
MainWP_Helper::update_option('mainwp_wordfence_ext_enabled', "Y", 'yes');
switch ( $_POST['mwp_action'] ) {
case 'start_scan':
$information = $this->start_scan();
@ -237,9 +237,6 @@ class MainWP_Child_Wordfence {
case 'update_log':
$information = $this->update_log();
break;
case 'get_summary':
$information = $this->get_summary();
break;
case 'load_issues': // not used in from version 2.0 of WF ext
$information = $this->load_issues();
break;
@ -642,7 +639,7 @@ class MainWP_Child_Wordfence {
}
public function wordfence_init() {
if ( get_option( 'mainwp_wordfence_ext_enabled' ) !== 'Y' ) return;
if ( ! $this->is_wordfence_installed ) return;
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
@ -769,6 +766,7 @@ class MainWP_Child_Wordfence {
return wordfence::ajax_activityLogUpdate_callback();
}
// not used
public function load_issues() {
$offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0;
$limit = isset($_POST['limit']) ? intval($_POST['limit']) : WORDFENCE_SCAN_ISSUES_PER_PAGE;
@ -809,6 +807,7 @@ class MainWP_Child_Wordfence {
'todayAttBlocked' => MainWP_Child_Wordfence::Instance()->count_attacks_blocked(1),
'weekAttBlocked' => MainWP_Child_Wordfence::Instance()->count_attacks_blocked(7),
'monthAttBlocked' => MainWP_Child_Wordfence::Instance()->count_attacks_blocked(30),
'issueCount' => $i->getIssueCount(),
);
return $return;
}

View file

@ -57,7 +57,11 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
}
if ( empty( $nonce ) ) {
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'You dont send nonce: ' . $action ) ) ) . '</mainwp>' );
// to help tracing the conflict verify nonce with other plugins
@ob_start();
@debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$stackTrace = "\n" . @ob_get_clean();
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'You dont send nonce: ' . $action . '<br/>Trace: ' .$stackTrace) ) ) . '</mainwp>' );
}
// To fix verify nonce conflict #1
@ -523,7 +527,7 @@ class MainWP_Child {
}
public function pre_current_active_plugins() {
if (isset($_GET['_detect_plugins_updates']) && $_GET['_detect_plugins_updates'] = 'yes') {
if (isset($_GET['_detect_plugins_updates']) && $_GET['_detect_plugins_updates'] == 'yes') {
// to fix some premium plugins update notification
$current = get_site_transient( 'update_plugins' );
set_site_transient( 'update_plugins', $current );
@ -852,7 +856,7 @@ class MainWP_Child {
if ( isset( self::$subPages ) && is_array( self::$subPages ) ) {
foreach ( self::$subPages as $subPage ) {
?>
<a class="nav-tab pos-nav-tab <?php if ( $shownPage == $subPage['slug'] ) { echo 'nav-tab-active'; } ?>" tab-slug="<?php echo $subPage['slug']; ?>" href="options-general.php?page=<?php echo $subPage['page']; ?>"><?php echo $subPage['title']; ?></a>
<a class="nav-tab pos-nav-tab <?php if ( $shownPage == $subPage['slug'] ) { echo 'nav-tab-active'; } ?>" tab-slug="<?php echo esc_attr($subPage['slug']); ?>" href="options-general.php?page=<?php echo rawurlencode($subPage['page']); ?>"><?php echo esc_html($subPage['title']); ?></a>
<?php
}
}
@ -1888,6 +1892,9 @@ class MainWP_Child {
$information['plugin_updates'] = get_plugin_updates();
// to support cached premium plugins update info, hooking in the bulk_upgrade()
add_filter( 'pre_site_transient_update_plugins', array( $this, 'set_cached_update_plugins' ) );
$plugins = explode( ',', urldecode( $_POST['list'] ) );
$premiumPlugins = array();
$premiumUpdates = get_option( 'mainwp_premium_updates' );
@ -1953,6 +1960,10 @@ class MainWP_Child {
MainWP_Helper::error( __( 'Invalid request!', 'mainwp-child' ) );
}
}
remove_filter( 'pre_site_transient_update_plugins', array( $this, 'set_cached_update_plugins' ), 10 );
delete_site_transient( 'mainwp_update_plugins_cached' ); // to fix cached update info
if ( count( $premiumPlugins ) > 0 ) {
$mwp_premium_updates = apply_filters( 'mwp_premium_perform_update', array() );
if ( is_array( $mwp_premium_updates ) && is_array( $premiumPlugins ) ) {
@ -2168,6 +2179,29 @@ class MainWP_Child {
MainWP_Helper::write( $information );
}
public function set_cached_update_plugins( $false = false, $_transient_data = null ) {
if ( ! is_object( $_transient_data ) ) {
$_transient_data = new stdClass;
}
$pre = false;
$cached_update_info = get_site_transient( 'mainwp_update_plugins_cached' );
if ( is_array($cached_update_info) && count($cached_update_info) > 0 ) {
foreach( $cached_update_info as $slug => $plugin_update ) {
if ( !isset( $_transient_data->response[ $slug ] ) && isset($plugin_update->update) ) {
$_transient_data->response[ $slug ] = $plugin_update->update;
$pre = true;
}
}
}
if ($pre == false)
return $false;
return $_transient_data;
}
function hookFixOptimizePressThemeUpdate( $transient ) {
if ( ! defined( 'OP_FUNC' ) ) {
return $transient;

View file

@ -747,6 +747,20 @@ class MainWP_Client_Report {
if ( 'author_meta' === $meta_key || 'user_meta' === $meta_key ) {
$value = maybe_unserialize( $value );
$value = $value['display_name'];
if ( 'author_meta' === $meta_key && $value == '' && $context == 'comments') {
$value = __( 'Guest', 'mainwp-child-reports' );
}
// to fix empty author value
if ( empty($value) ) {
if (isset($value['agent']) && !empty($value['agent'])) {
$value = $value['agent'];
}
}
if (!is_string($value)) {
$value = '';
}
}
}
}

View file

@ -176,7 +176,11 @@ class MainWP_Helper {
}
static function uploadFile( $file_url, $path, $file_name ) {
// to fix uploader extension rename htaccess file issue
if ( $file_name != '.htaccess' && $file_name != '.htpasswd' ) {
$file_name = sanitize_file_name( $file_name );
}
$full_file_name = $path . DIRECTORY_SEPARATOR . $file_name; //Local name
$response = wp_remote_get( $file_url, array(

View file

@ -6,7 +6,7 @@
Author: MainWP
Author URI: https://mainwp.com
Text Domain: mainwp-child
Version: 3.5
Version: 3.5.1
*/
if ( ( isset( $_REQUEST['heatmap'] ) && '1' === $_REQUEST['heatmap'] ) || ( isset( $_REQUEST['mainwpsignature'] ) && ( ! empty( $_REQUEST['mainwpsignature'] ) ) ) ) {
header( 'X-Frame-Options: ALLOWALL' );

View file

@ -6,8 +6,8 @@ Author: mainwp
Author URI: https://mainwp.com
Plugin URI: https://mainwp.com
Requires at least: 3.6
Tested up to: 4.9.8
Stable tag: 3.5
Tested up to: 5.0
Stable tag: 3.5.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -71,6 +71,18 @@ To see full documentation and FAQs please visit [MainWP Documentation](https://m
== Changelog ==
= 3.5.1 - 11-14-18 =
* Fixed: an issue with detecting the Wordfence status info
* Fixed: an issue with loading UpdraftPlus existing backups
* Fixed: the File Uploader extension issue with renaming special files
* Fixed: an issue with syncing BackupBuddy data
* Fixed: an issue with logging BackWPup backups
* Fixed: an issue with detecting premium plugin updates
* Added: new options for the MainWP Staging Extension
* Added: multiple security enhancements
* Added: support for the upcoming 3rd party extension
* Updated: improved updating process
= 3.5 - 9-27-18 =
* Fixed: compatibility issues caused by the recent UpdraftPlus update
* Fixed: issues with the WooCommerce Status information