Merge with branch01

This commit is contained in:
ruben- 2018-09-27 19:52:32 +02:00
parent 5cdbc74c9b
commit 214ac3046a
16 changed files with 1200 additions and 1082 deletions

View file

@ -155,7 +155,6 @@ class MainWP_Child_Back_Up_Buddy {
$message = 'BackupBuddy ' . $backupType . ' finished';
if (!empty($finish_time)) {
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time);
MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support backup before update feature
}
}
@ -177,7 +176,6 @@ class MainWP_Child_Back_Up_Buddy {
$message = 'BackupBuddy ' . $backupType . ' finished';
if (!empty($finish_time)) {
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time);
MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support backup before update feature
}
}
@ -747,8 +745,11 @@ class MainWP_Child_Back_Up_Buddy {
require_once( $plugin_path . '/classes/core.php' );
}
MainWP_Helper::check_classes_exists('backupbuddy_core');
MainWP_Helper::check_classes_exists(array( 'backupbuddy_core', 'backupbuddy_api' ));
MainWP_Helper::check_methods('backupbuddy_core', array( 'get_plugins_root', 'get_themes_root', 'get_media_root' ) );
MainWP_Helper::check_methods('backupbuddy_api', array( 'getOverview' ) );
$data = array();
$data['plugins_root'] = backupbuddy_core::get_plugins_root();
@ -756,6 +757,20 @@ class MainWP_Child_Back_Up_Buddy {
$data['media_root'] = backupbuddy_core::get_media_root();
$data['additional_tables'] = $this->pb_additional_tables();
$data['abspath'] = ABSPATH;
$getOverview = backupbuddy_api::getOverview();
$data['editsSinceLastBackup'] = $getOverview['editsSinceLastBackup'] ;
if ( isset( $getOverview['lastBackupStats']['finish'] ) ) {
$finish_time = $getOverview['lastBackupStats']['finish'] ;
$time = $this->localize_time( $finish_time );
$data['lastBackupStats'] = date("M j - g:i A", $time);
$data['lasttime_backup'] = $finish_time;
MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support Require Backup Before Update feature
} else {
$data['lastBackupStats'] = 'Unknown';
}
return $data;
} catch(Exception $e) {
// not exit here
@ -764,6 +779,15 @@ class MainWP_Child_Back_Up_Buddy {
return false;
}
function localize_time( $timestamp ) {
if ( function_exists( 'get_option' ) ) {
$gmt_offset = get_option( 'gmt_offset' );
} else {
$gmt_offset = 0;
}
return $timestamp + ( $gmt_offset * 3600 );
}
function backup_list() {
require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' );
$information = array();

View file

@ -100,6 +100,9 @@ class MainWP_Child_Back_Up_Wordpress {
case 'exclude_remove_rule':
$information = $this->hmbkp_remove_exclude_rule();
break;
case 'general_exclude_add_rule':
$information = $this->general_exclude_add_rule();
break;
}
}
MainWP_Helper::write( $information );
@ -1047,28 +1050,58 @@ class MainWP_Child_Back_Up_Wordpress {
return $out;
}
function remove_exclude_rule() {
check_admin_referer( 'hmbkp_remove_exclude_rule', 'hmbkp-remove_exclude_rule_nonce' );
function general_exclude_add_rule() {
if ( ! isset( $_GET['hmbkp_remove_exclude'] ) ) {
die;
$sch_id = $this->check_schedule();
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $sch_id ) );
$exclude_paths = urldecode( $_POST['exclude_paths'] );
$exclude_paths = explode("\n", $exclude_paths);
if (is_array($exclude_paths) && count($exclude_paths) > 0) {
foreach ( $exclude_paths as $excl_rule ) {
$excl_rule = trim($excl_rule);
$excl_rule = trim($excl_rule, '/');
if (empty($excl_rule))
continue;
$exclude_rule = ABSPATH . $excl_rule;
$path = realpath($exclude_rule);
// If it exist
if($path !== false)
{
$schedule->set_excludes( $exclude_rule, true );
$schedule->save();
}
}
}
$schedule = new Scheduled_Backup( sanitize_text_field( $_GET['hmbkp_schedule_id'] ) );
$un_exclude_paths = urldecode( $_POST['un_exclude_paths'] );
$un_exclude_paths = explode("\n", $un_exclude_paths);
if (is_array($un_exclude_paths) && count(get_user_excludes) > 0) {
foreach ( $un_exclude_paths as $exclude_rule_to_remove ) {
$exclude_rule_to_remove = trim($exclude_rule_to_remove);
$exclude_rule_to_remove = trim($exclude_rule_to_remove, '/');
if (empty($exclude_rule_to_remove))
continue;
$excludes = $schedule->get_excludes();
$exclude_rule_to_remove = stripslashes( sanitize_text_field( $_GET['hmbkp_remove_exclude'] ) );
if (method_exists($excludes, 'get_user_excludes')) {
$schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) );
$schedule->save();
wp_safe_redirect( wp_get_referer(), '303' );
die;
} else {
$schedule->set_excludes( array_diff( $excludes, $exclude_rule_to_remove ) );
}
$schedule->save();
}
}
return array('result' => 'SUCCESS');
}
function update_schedule() {
$sch_id = isset( $_POST['schedule_id'] ) ? $_POST['schedule_id'] : 0;

View file

@ -226,13 +226,37 @@ class MainWP_Child_Back_WP_Up {
MainWP_Helper::check_classes_exists(array('BackWPup'));
MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' ));
$destinations = BackWPup::get_registered_destinations();
$jobdests = $this->get_destinations_list();
if ( !empty( $jobdests ) ) {
$job_types = array(
'DBDUMP' => __('Database backup', 'mainwp-child'),
'FILE' => __('File backup', 'mainwp-child'),
'WPEXP' => __('WordPress XML export', 'mainwp-child'),
'WPPLUGIN' => __('Installed plugins list', 'mainwp-child'),
'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' );
$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 {
$backup_type = ltrim($backup_type, ' + ');
}
$dest_object = BackWPup::get_destination( $dest );
$items = $dest_object->file_get_list( $jobdest );
//if no items brake
@ -240,8 +264,7 @@ class MainWP_Child_Back_WP_Up {
foreach ( $items as $ma ) {
if (isset($ma['time'])) {
$backup_time = $ma[ "time" ];
$message = 'BackWPup backup finished';
$backup_type = 'BackWPup';
$message = 'BackWPup backup finished (' . $backup_type . ')';
$destination = "N/A";
if (!empty($backup_time)) {
do_action( 'mainwp_backwpup_backup', $message, $backup_type, $backup_time );

View file

@ -310,25 +310,7 @@ class MainWP_Child_Branding {
}
// to fix
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
// if ( 'T' === get_option( 'mainwp_branding_show_support' ) ) {
// $title = $this->settings['contact_support_label'];
// if ( isset( $extra_setting['show_button_in'] ) && ( 2 === (int) $extra_setting['show_button_in'] || 3 === (int) $extra_setting['show_button_in'] ) ) {
// $title = $this->settings['contact_support_label'];
// add_menu_page( $title, $title, 'read', 'ContactSupport2', array(
// $this,
// 'contact_support',
// ), '', '2.0001' );
// }
//
// if ( isset( $extra_setting['show_button_in'] ) && ( 1 === $extra_setting['show_button_in'] || 3 === $extra_setting['show_button_in'] ) ) {
// add_submenu_page( null, $title, $this->settings['contact_support_label'], 'read', 'ContactSupport', array(
// $this,
// 'contact_support',
// ) );
// add_action( 'admin_bar_menu', array( $this, 'add_support_button_in_top_admin_bar' ), 100 );
// }
// }
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );//
if ( get_option( 'mainwp_branding_disable_wp_branding' ) !== 'Y' ) {
add_filter( 'wp_footer', array( &$this, 'branding_global_footer' ), 15 );
add_action( 'wp_dashboard_setup', array( &$this, 'custom_dashboard_widgets' ), 999 );
@ -366,7 +348,10 @@ class MainWP_Child_Branding {
// to fix conflict with other plugin
function admin_menu() {
if ( !current_user_can( 'administrator' ) ) {
$allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false);
if ( $allow_contact ) {
; // ok
} else if ( !current_user_can( 'administrator' ) ) {
return false;
}
$extra_setting = $this->settings['extra_settings'];
@ -725,9 +710,6 @@ class MainWP_Child_Branding {
}
function contact_support() {
if ( !current_user_can('administrator') ) {
return false;
}
?>
<style>
.mainwp_info-box-yellow {
@ -756,10 +738,10 @@ class MainWP_Child_Branding {
if ( ! empty( $send_email_message ) ) {
$send_email_message = stripslashes( $send_email_message );
} else {
$send_email_message = 'Message has been submitted successfully.';
$send_email_message = __( 'Message has been submitted successfully.', 'mainwp-child' );
}
} else {
$send_email_message = __( 'Sending email failed!' );
$send_email_message = __( 'Sending email failed!', 'mainwp-child' );
}
?>
<div

View file

@ -179,11 +179,12 @@ class MainWP_Child_iThemes_Security {
'404-detection',
'network-brute-force',
'ssl',
'strong-passwords',
//'strong-passwords',
'password-requirements',
'system-tweaks',
'wordpress-tweaks',
'multisite-tweaks',
'notification-center'
'notification-center',
//'salts',
//'content-directory',
);

View file

@ -257,16 +257,8 @@ class MainWP_Child_Plugins_Check {
}
}
if ( ! defined( 'MINUTE_IN_SECONDS' ) ) {
define( 'MINUTE_IN_SECONDS', 60 );
}
if ( ! defined( 'HOUR_IN_SECONDS' ) ) {
define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
}
if ( ! defined( 'DAY_IN_SECONDS' ) ) {
define( 'DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS );
define( 'DAY_IN_SECONDS', 24 * 60 * 60 );
}
//Store the master response for usage in the plugin table
@ -274,7 +266,6 @@ class MainWP_Child_Plugins_Check {
if ( 0 === count( $all_plugins ) ) {
delete_transient( $this->tran_name_plugins_to_batch );
//wp_schedule_single_event( time() + DAY_IN_SECONDS, $this->cron_name_daily );
} else {
set_transient( $this->tran_name_plugins_to_batch, $all_plugins, DAY_IN_SECONDS );
wp_schedule_single_event( time(), $this->cron_name_batching );
@ -287,18 +278,11 @@ class MainWP_Child_Plugins_Check {
//Get the WordPress current version to be polite in the API call
include( ABSPATH . WPINC . '/version.php' );
if ( ! defined( 'MINUTE_IN_SECONDS' ) ) {
define( 'MINUTE_IN_SECONDS', 60 );
}
if ( ! defined( 'HOUR_IN_SECONDS' ) ) {
define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
}
global $wp_version;
//General options to be passed to wp_remote_get
$options = array(
'timeout' => HOUR_IN_SECONDS,
'timeout' => 60 * 60, //HOUR_IN_SECONDS
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
);

View file

@ -202,16 +202,8 @@ class MainWP_Child_Themes_Check {
}
}
if ( ! defined( 'MINUTE_IN_SECONDS' ) ) {
define( 'MINUTE_IN_SECONDS', 60 );
}
if ( ! defined( 'HOUR_IN_SECONDS' ) ) {
define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
}
if ( ! defined( 'DAY_IN_SECONDS' ) ) {
define( 'DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS );
define( 'DAY_IN_SECONDS', 24 * 60 * 60 );
}
//Store the master response for usage in the plugin table
@ -219,7 +211,6 @@ class MainWP_Child_Themes_Check {
if ( 0 === count( $all_themes ) ) {
delete_transient( $this->tran_name_themes_to_batch );
//wp_schedule_single_event( time() + DAY_IN_SECONDS, $this->cron_name_daily );
} else {
set_transient( $this->tran_name_themes_to_batch, $all_themes, DAY_IN_SECONDS );
wp_schedule_single_event( time(), $this->cron_name_batching );
@ -229,19 +220,9 @@ class MainWP_Child_Themes_Check {
private function try_get_response_body( $theme ) {
//Some of this code is lifted from class-wp-upgrader
//Get the WordPress current version to be polite in the API call
include( ABSPATH . WPINC . '/version.php' );
if ( ! defined( 'MINUTE_IN_SECONDS' ) ) {
define( 'MINUTE_IN_SECONDS', 60 );
}
if ( ! defined( 'HOUR_IN_SECONDS' ) ) {
define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
}
$url = $http_url = 'http://api.wordpress.org/themes/info/1.0/';
if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
$url = set_url_scheme( $url, 'https' );

View file

@ -33,7 +33,6 @@ class MainWP_Child_Timecapsule {
return;
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
add_action( 'record_auto_backup_complete', array( $this, 'do_report_backups_logging' ) );
if ( get_option( 'mainwp_time_capsule_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
@ -253,13 +252,25 @@ class MainWP_Child_Timecapsule {
MainWP_Helper::check_methods($options_helper, array( 'get_plan_interval_from_subs_info', 'get_is_user_logged_in'));
MainWP_Helper::check_methods($wptc_settings, array( 'get_connected_cloud_info'));
$all_backups = $this->getBackups();
$backups_count = 0;
if (is_array($all_backups)) {
$formatted_backups = array();
foreach ($all_backups as $key => $value) {
$value_array = (array) $value;
$formatted_backups[$value_array['backupID']][] = $value_array;
}
$backups_count = count($formatted_backups);
}
$return = array(
'main_account_email' => $main_account_email_var,
'signed_in_repos' => $wptc_settings->get_connected_cloud_info(),
'plan_name' => $options_helper->get_plan_interval_from_subs_info(),
'plan_interval' => $options_helper->get_plan_interval_from_subs_info(),
'lastbackup_time' => !empty($last_backup_time) ? $last_backup_time : 0,
'is_user_logged_in' => $options_helper->get_is_user_logged_in()
'is_user_logged_in' => $options_helper->get_is_user_logged_in(),
'backups_count' => $backups_count
);
return $return;
} catch ( Exception $e) {
@ -268,6 +279,21 @@ class MainWP_Child_Timecapsule {
return false;
}
protected function getBackups( $last_time = false ) {
if (empty($last_time)) {
$last_time = strtotime(date('Y-m-d', strtotime(date('Y-m-01'))));
}
global $wpdb;
$all_backups = $wpdb->get_results(
$wpdb->prepare("
SELECT *
FROM {$wpdb->base_prefix}wptc_processed_files
WHERE backupID > %s ", $last_time)
);
return $all_backups;
}
public function get_tables() {
$category = $_POST['category'];
$exclude_class_obj = new Wptc_ExcludeOption($category);
@ -653,13 +679,6 @@ function get_sibling_files_callback_wptc() {
die();
}
function do_report_backups_logging($backup_id) {
$backup_time = time(); // may be difference a bit with WTC logging
$message = 'WP Time Capsule backup finished';
$backup_type = 'WP Time Capsule';
do_action( 'mainwp_wptimecapsule_backup', $message, $backup_type, $backup_time );
}
function do_site_stats() {
if (has_action('mainwp_child_reports_log')) {
do_action( 'mainwp_child_reports_log', 'wptimecapsule');
@ -670,20 +689,45 @@ function get_sibling_files_callback_wptc() {
// ok
public function do_reports_log($ext = '') {
if ( $ext !== 'wptimecapsule' ) return;
if (!$this->is_plugin_installed)
return;
try {
MainWP_Helper::check_classes_exists(array( 'WPTC_Base_Factory', 'Wptc_Exclude_Config'));
$config = WPTC_Base_Factory::get('Wptc_Exclude_Config');
try {
MainWP_Helper::check_classes_exists(array( 'WPTC_Factory'));
$config = WPTC_Factory::get('config');
MainWP_Helper::check_methods($config, 'get_option');
$backup_time = $config->get_option('last_backup_time');
if (!empty($backup_time)) {
MainWP_Helper::update_lasttime_backup( 'wptimecapsule', $backup_time ); // to support backup before update feature
}
$last_time = time() - 24 * 7 * 2 * 60 * 60; // 2 weeks ago
$all_last_backups = $this->getBackups( $last_time );
if (is_array($all_last_backups)) {
$formatted_backups = array();
foreach ($all_last_backups as $key => $value) {
$value_array = (array) $value;
$formatted_backups[$value_array['backupID']][] = $value_array;
}
$message = 'WP Time Capsule backup finished';
$backup_type = 'WP Time Capsule backup';
if (count($formatted_backups) > 0) {
foreach($formatted_backups as $key => $value) {
$backup_time = $key;
do_action( 'mainwp_wptimecapsule_backup', $message, $backup_type, $backup_time );
}
}
}
} catch(Exception $e) {
}
@ -907,7 +951,8 @@ function get_sibling_files_callback_wptc() {
if ( $tabName == 'backup' ) { // save_backup_settings_wptc()
$config->set_option('user_excluded_extenstions', $data['user_excluded_extenstions']);
$config->set_option('user_excluded_files_more_than_size', $data['user_excluded_files_more_than_size']);
$config->set_option('user_excluded_files_more_than_size_settings', $data['user_excluded_files_more_than_size_settings']);
if (!empty($data['backup_slot'])) {
$config->set_option('old_backup_slot', $config->get_option('backup_slot'));
@ -1015,7 +1060,10 @@ function get_sibling_files_callback_wptc() {
$config->set_option('internal_staging_file_copy_limit', $data['internal_staging_file_copy_limit']);
$config->set_option('internal_staging_deep_link_limit', $data['internal_staging_deep_link_limit']);
$config->set_option('internal_staging_enable_admin_login', $data['internal_staging_enable_admin_login']);
$config->set_option('staging_is_reset_permalink', $data['staging_is_reset_permalink']);
if (!$is_general) {
$config->set_option('staging_login_custom_link', $data['staging_login_custom_link']);
}
$saved = true;
}
@ -1175,32 +1223,6 @@ function get_sibling_files_callback_wptc() {
die();
}
function send_response_wptc($status = null, $type = null, $data = null, $is_log =0) {
if (!is_wptc_server_req() && !is_wptc_node_server_req()) {
return false;
}
$config = WPTC_Factory::get('config');
if (empty($is_log)) {
$post_arr['status'] = $status;
$post_arr['type'] = $type;
$post_arr['version'] = WPTC_VERSION;
$post_arr['source'] = 'WPTC';
$post_arr['scheduled_time'] = $config->get_option('schedule_time_str');
$post_arr['timezone'] = $config->get_option('wptc_timezone');
$post_arr['last_backup_time'] = $config->get_option('last_backup_time');
if (!empty($data)) {
$post_arr['progress'] = $data;
}
} else {
$post_arr = $data;
}
return array( 'result' => 'success', 'data' => "<WPTC_START>".json_encode($post_arr)."<WPTC_END>" );
}
public function all_plugins( $plugins ) {
foreach ( $plugins as $key => $value ) {
$plugin_slug = basename( $key, '.php' );

View file

@ -30,7 +30,9 @@ class MainWP_Child_Updraft_Plus_Backups {
if (isset($last_backup['backup_time'])) {
$backup_time = $last_backup['backup_time'];
if ($last_backup['success']) {
MainWP_Helper::update_lasttime_backup('updraftplus', $backup_time);
}
}
return $last_backup;
}
@ -539,8 +541,10 @@ class MainWP_Child_Updraft_Plus_Backups {
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
$opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']);
$opts['settings'][$settings_key]['endpoint'] = $settings[ $key ]['endpoint'];
} else {
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
$opts['endpoint'] = $settings[ $key ]['endpoint'];
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else if ( 'updraft_ftp' === $key ) {
@ -665,8 +669,11 @@ class MainWP_Child_Updraft_Plus_Backups {
}
function addons_connect() {
if ( ! defined( 'UDADDONS2_SLUG' ) ) {
if (is_file(UPDRAFTPLUS_DIR.'/udaddons/updraftplus-addons.php')) require_once(UPDRAFTPLUS_DIR.'/udaddons/updraftplus-addons.php');
if ( ! defined( 'UDADDONS2_SLUG' ) ) {
return array( 'error' => 'NO_PREMIUM' );
}
}
$addons_options = maybe_unserialize( base64_decode( $_POST['addons_options'] ) );
@ -742,8 +749,6 @@ class MainWP_Child_Updraft_Plus_Backups {
$ehash = substr( md5( $input['email'] ), 0, 23 );
delete_site_transient( 'udaddons_connect_' . $ehash );
// add_settings_error( UDADDONS2_SLUG."_options", UDADDONS2_SLUG."_options_nodb", "Whinge, whinge", "error" );
return $input;
}
@ -829,7 +834,9 @@ class MainWP_Child_Updraft_Plus_Backups {
$ret_info = '';
if ( ! $failed ) {
$all_tables = $wpdb_obj->get_results( 'SHOW TABLES', ARRAY_N );
$all_tables = array_map( create_function( '$a', 'return $a[0];' ), $all_tables );
//$all_tables = array_map( create_function( '$a', 'return $a[0];' ), $all_tables );
$all_tables = array_map(array($this, 'cb_get_name_base_type'), $all_tables);
if ( empty( $_POST['prefix'] ) ) {
$ret_info .= sprintf( __( '%s table(s) found.', 'updraftplus' ), count( $all_tables ) );
} else {
@ -869,6 +876,9 @@ class MainWP_Child_Updraft_Plus_Backups {
return array( 'r' => $_POST['row'], 'm' => $ret . $ret_after );
}
private function cb_get_name_base_type($a) {
return $a[0];
}
function backup_now() {
global $updraftplus;
@ -1038,9 +1048,10 @@ class MainWP_Child_Updraft_Plus_Backups {
}
MainWP_Helper::check_classes_exists('UpdraftPlus_Options');
MainWP_Helper::check_classes_exists( array( 'UpdraftPlus_Options', 'UpdraftPlus_Filesystem_Functions' )) ;
MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option');
MainWP_Helper::check_methods($updraftplus, array( 'backups_dir_location', 'really_is_writable' ));
MainWP_Helper::check_methods('UpdraftPlus_Filesystem_Functions', 'really_is_writable');
MainWP_Helper::check_methods($updraftplus, array( 'backups_dir_location' ));
$next_scheduled_backup_database = wp_next_scheduled( 'updraft_backup_database' );
if ( UpdraftPlus_Options::get_updraft_option( 'updraft_interval_database', UpdraftPlus_Options::get_updraft_option( 'updraft_interval' ) ) === UpdraftPlus_Options::get_updraft_option( 'updraft_interval' ) ) {
@ -1057,7 +1068,7 @@ class MainWP_Child_Updraft_Plus_Backups {
}
$updraft_dir = $updraftplus->backups_dir_location();
$backup_disabled = ( $updraftplus->really_is_writable( $updraft_dir ) ) ? 0 : 1;
$backup_disabled = (UpdraftPlus_Filesystem_Functions::really_is_writable($updraft_dir)) ? 0 : 1;
$current_timegmt = time();
$current_time = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $current_timegmt ), 'D, F j, Y H:i' );
@ -1142,8 +1153,11 @@ class MainWP_Child_Updraft_Plus_Backups {
<td style="width: 124px; vertical-align:top; margin: 0px; padding: 0px;">' . __( 'Time now', 'updraftplus' ) . ': </td><td style="color:blue; margin: 0px; padding: 0px;">' . $current_time . '</td>
</table>';
MainWP_Helper::check_classes_exists( array( 'UpdraftPlus_Filesystem_Functions' ) ) ;
MainWP_Helper::check_methods('UpdraftPlus_Filesystem_Functions', 'really_is_writable');
$updraft_dir = $updraftplus->backups_dir_location();
$backup_disabled = ( $updraftplus->really_is_writable( $updraft_dir ) ) ? 0 : 1;
$backup_disabled = (UpdraftPlus_Filesystem_Functions::really_is_writable($updraft_dir)) ? 0 : 1;
$out = array(
'n' => $html,

View file

@ -178,6 +178,10 @@ class MainWP_Child_WooCommerce_Status {
$reports = new WC_Admin_Report();
$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];
$start_date = date( 'Y-m-d H:i:s', $start_date );
$end_date = date( 'Y-m-d H:i:s', $end_date );
// Get sales
$sales = $wpdb->get_var( "SELECT SUM( postmeta.meta_value ) FROM {$wpdb->posts} as posts
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID
@ -193,10 +197,13 @@ class MainWP_Child_WooCommerce_Status {
'on-hold',
) ) ) . "' )
AND postmeta.meta_key = '_order_total'
AND posts.post_date >= '" . date( 'Y-m-01', $start_date ) . "'
AND posts.post_date <= '" . date( 'Y-m-d H:i:s', $end_date ) . "'
AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s')
AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s')
" );
// Get top seller
$top_seller = $wpdb->get_row( "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id
FROM {$wpdb->posts} as posts
@ -216,8 +223,8 @@ class MainWP_Child_WooCommerce_Status {
) ) ) . "' )
AND order_item_meta.meta_key = '_qty'
AND order_item_meta_2.meta_key = '_product_id'
AND posts.post_date >= '" . date( 'Y-m-01', $start_date ) . "'
AND posts.post_date <= '" . date( 'Y-m-d H:i:s', $end_date ) . "'
AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s')
AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s')
GROUP BY product_id
ORDER BY qty DESC
LIMIT 1
@ -284,9 +291,12 @@ class MainWP_Child_WooCommerce_Status {
}
function sync_data_two() {
// sync data at current time
$start_date = current_time( 'timestamp' );
$end_date = current_time( 'timestamp' );
// sync data for current month
$start_date = date( 'Y-m-01 00:00:00', time() );
$end_date = date( 'Y-m-d H:i:s', time() );
$start_date = strtotime( $start_date );
$end_date = strtotime( $end_date );
return $this->get_woocom_data( $start_date, $end_date );
}
@ -313,6 +323,10 @@ class MainWP_Child_WooCommerce_Status {
} else {
return false;
}
$start_date = date( 'Y-m-d H:i:s', $start_date );
$end_date = date( 'Y-m-d H:i:s', $end_date );
$reports = new WC_Admin_Report();
// Sales
$query = array();
@ -325,8 +339,8 @@ class MainWP_Child_WooCommerce_Status {
'on-hold',
) ) ) . "' ) ";
$query['where'] .= "AND postmeta.meta_key = '_order_total' ";
$query['where'] .= "AND posts.post_date >= '" . date( 'Y-m-01', $start_date ) . "' ";
$query['where'] .= "AND posts.post_date <= '" . date( 'Y-m-d H:i:s', $end_date ) . "' ";
$query['where'] .= "AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') ";
$query['where'] .= "AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') ";
$sales = $wpdb->get_var( implode( ' ', apply_filters( 'woocommerce_dashboard_status_widget_sales_query', $query ) ) );
@ -345,13 +359,13 @@ class MainWP_Child_WooCommerce_Status {
) ) ) . "' ) ";
$query['where'] .= "AND order_item_meta.meta_key = '_qty' ";
$query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' ";
$query['where'] .= "AND posts.post_date >= %s ";
$query['where'] .= "AND posts.post_date <= %s ";
$query['where'] .= "AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') ";
$query['where'] .= "AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') ";
$query['groupby'] = 'GROUP BY product_id';
$query['orderby'] = 'ORDER BY qty DESC';
$query['limits'] = 'LIMIT 1';
$top_seller = $wpdb->get_row( $wpdb->prepare( implode( ' ', $query ), date( 'Y-m-01', $start_date ), date( 'Y-m-d H:i:s', $end_date ) ) );
$top_seller = $wpdb->get_row( implode( ' ', $query ) );
if ( ! empty( $top_seller ) ) {

View file

@ -60,6 +60,14 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'You dont send nonce: ' . $action ) ) ) . '</mainwp>' );
}
// To fix verify nonce conflict #1
// this is fake nonce to fix some conflict of wp_verify_nonce
// just return false to unverify nonce, does not exit
if ($nonce == 'mainwp-bsm-unverify-nonce') {
return false;
}
$token = wp_get_session_token();
$i = wp_nonce_tick();
@ -75,8 +83,19 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
return 2;
}
// To fix verify nonce conflict #2
// this is fake post field to fix some conflict of wp_verify_nonce
// just return false to unverify nonce, does not exit
if ( isset($_POST[$action]) && ($_POST[$action] == 'mainwp-bsm-unverify-nonce')) {
return false;
}
@ob_start();
@debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$stackTrace = "\n" . @ob_get_clean();
// Invalid nonce
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'Invalid nonce! Try to use: ' . $action ) ) ) . '</mainwp>' );
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'Invalid nonce! Try to use: ' . $action . '<br/>Trace: ' .$stackTrace) ) ) . '</mainwp>' );
}
endif;
}
@ -84,7 +103,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
}
class MainWP_Child {
public static $version = '3.4.8';
public static $version = '3.5';
private $update_version = '1.3';
private $callableFunctions = array(
@ -153,6 +172,7 @@ class MainWP_Child {
'wp_staging' => 'wp_staging',
'disconnect' => 'disconnect',
'time_capsule' => 'time_capsule',
'extra_excution' => 'extra_execution',
);
private $FTP_ERROR = 'Failed! Please, add FTP details for automatic updates.';
@ -503,17 +523,15 @@ class MainWP_Child {
}
public function pre_current_active_plugins() {
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 );
$plugin_updates = get_plugin_updates();
$fix_update_plugins = array();
if ( is_array( $plugin_updates ) ) {
foreach ( $plugin_updates as $slug => $plugin_update ) {
if ( in_array( $slug, array( 'ithemes-security-pro/ithemes-security-pro.php', 'monarch/monarch.php', 'cornerstone/cornerstone.php', 'updraftplus/updraftplus.php', 'wp-all-import-pro/wp-all-import-pro.php') ) ) {
$fix_update_plugins[ $slug ] = $plugin_update;
set_site_transient( 'mainwp_update_plugins_cached', $plugin_updates, DAY_IN_SECONDS);
}
}
}
set_site_transient( 'tofix_update_plugins', $fix_update_plugins);
}
function checkOtherAuth() {
$auths = get_option( 'mainwp_child_auth' );
@ -1766,6 +1784,11 @@ class MainWP_Child {
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
// to fix
@wp_version_check();
@wp_update_themes();
@wp_update_plugins();
$upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
$translations = explode( ',', urldecode( $_POST['list'] ) );
$all_language_updates = wp_get_translation_updates();
@ -1818,6 +1841,8 @@ class MainWP_Child {
}
include_once( ABSPATH . '/wp-admin/includes/file.php' );
include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
include_once( ABSPATH . '/wp-admin/includes/plugin-install.php' );
$information = array();
$information['upgrades'] = array();
$mwp_premium_updates_todo = array();
@ -1861,7 +1886,6 @@ class MainWP_Child {
// trick to prevent some premium plugins re-create update info
remove_all_filters('pre_set_site_transient_update_plugins');
$information['plugin_updates'] = get_plugin_updates();
$plugins = explode( ',', urldecode( $_POST['list'] ) );
@ -1882,13 +1906,30 @@ class MainWP_Child {
if ( count( $plugins ) > 0 ) {
//@see wp-admin/update.php
$failed = true;
// to fix update of Yithemes premiums plugins that hooked to upgrader_pre_download
$url = 'update.php?action=update-selected&amp;plugins=' . urlencode(implode(',', $plugins));
$nonce = 'bulk-update-plugins';
$upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
$result = $upgrader->bulk_upgrade( $plugins );
if ( ! empty( $result ) ) {
foreach ( $result as $plugin => $info ) {
if ( empty( $info ) ) {
$information['upgrades'][ $plugin ] = false;
// try to fix if that is premiums update
$api = apply_filters( 'plugins_api', false, 'plugin_information', array( 'slug' => $plugin ) );
if ( !is_wp_error( $api ) && !empty($api)) {
if ( isset($api->download_link) ) {
$res = $upgrader->install($api->download_link);
if ( !is_wp_error( $res ) && !(is_null( $res )) ) {
$information['upgrades'][ $plugin ] = true;
}
}
}
} else {
$information['upgrades'][ $plugin ] = true;
// to fix logging update
@ -1896,6 +1937,7 @@ class MainWP_Child {
$plugin_info = $information['plugin_updates'][$plugin];
$args = array();
$args['type'] = 'plugin';
$args['slug'] = $plugin;
$args['name'] = $plugin_info->Name;
$args['version'] = $plugin_info->update->new_version;
$args['old_version'] = $plugin_info->Version;
@ -3221,12 +3263,15 @@ class MainWP_Child {
$security['scripts_version'] = true;
$security['styles_version'] = true;
$security['generator_version'] = true;
MainWP_Security::remove_scripts_version( true );
MainWP_Security::remove_styles_version( true );
MainWP_Security::remove_generator_version( true );
$information['versions'] = 'Y';
}
if ( 'all' === $_POST['feature'] || 'registered_versions' === $_POST['feature'] ) {
$security['registered_versions'] = true;
$information['registered_versions'] = 'Y';
}
if ( 'all' === $_POST['feature'] || 'admin' === $_POST['feature'] ) {
$information['admin'] = ( ! MainWP_Security::admin_user_ok() ? 'N' : 'Y' );
}
@ -3282,6 +3327,10 @@ class MainWP_Child {
$information['versions'] = 'N';
}
if ( 'all' === $_POST['feature'] || 'registered_versions' === $_POST['feature'] ) {
$security['registered_versions'] = false;
$information['registered_versions'] = 'N';
}
if ( 'all' === $_POST['feature'] || 'readme' === $_POST['feature'] ) {
$security['readme'] = false;
$information['readme'] = MainWP_Security::remove_readme_ok();
@ -3311,6 +3360,7 @@ class MainWP_Child {
$information['php_reporting'] = ( ! MainWP_Security::remove_php_reporting_ok() ? 'N' : 'Y' );
$information['versions'] = ( ! MainWP_Security::remove_scripts_version_ok() || ! MainWP_Security::remove_styles_version_ok() || ! MainWP_Security::remove_generator_version_ok()
? 'N' : 'Y' );
$information['registered_versions'] = ( MainWP_Security::remove_registered_versions_ok() ? 'Y' : 'N' );
$information['admin'] = ( MainWP_Security::admin_user_ok() ? 'Y' : 'N' );
$information['readme'] = ( MainWP_Security::remove_readme_ok() ? 'Y' : 'N' );
@ -3507,6 +3557,7 @@ class MainWP_Child {
@wp_update_plugins();
include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
$plugin_updates = get_plugin_updates();
if ( is_array( $plugin_updates ) ) {
$information['plugin_updates'] = array();
@ -3518,18 +3569,21 @@ class MainWP_Child {
$information['plugin_updates'][ $slug ] = $plugin_update;
}
}
// to fix bug
$fix_update_plugins = get_site_transient( 'tofix_update_plugins' );
if ( is_array( $fix_update_plugins ) && ( count( $fix_update_plugins ) > 0 ) ) {
foreach( $fix_update_plugins as $slug => $plugin_update ) {
$info_update_plugins_cached = get_site_transient( 'mainwp_update_plugins_cached' );
if ( is_array( $info_update_plugins_cached ) && ( count( $info_update_plugins_cached ) > 0 ) ) {
if (!isset($information['plugin_updates'])) {
$information['plugin_updates'] = array();
}
foreach( $info_update_plugins_cached as $slug => $plugin_update ) {
if ( !isset( $information['plugin_updates'][ $slug ] ) ) {
$information['plugin_updates'][ $slug ] = $plugin_update;
}
}
}
// end fix
}
if ( null !== $this->filterFunction ) {
remove_filter( 'pre_site_transient_update_plugins', $this->filterFunction, 99 );
@ -3619,6 +3673,9 @@ class MainWP_Child {
if ( ! MainWP_Security::remove_scripts_version_ok() || ! MainWP_Security::remove_styles_version_ok() || ! MainWP_Security::remove_generator_version_ok() ) {
$securityIssuess ++;
}
if ( ! MainWP_Security::remove_registered_versions_ok() ) {
$securityIssuess ++;
}
if ( ! MainWP_Security::admin_user_ok() ) {
$securityIssuess ++;
}
@ -3638,7 +3695,10 @@ class MainWP_Child {
$information['categories'] = $categories;
$get_file_size = apply_filters('mainwp-child-get-total-size', true);
if ($get_file_size) {
$max_exe = ini_get( 'max_execution_time' ); // to fix issue of some hosts have limit of execution time
if ($max_exe > 20) {
$information['totalsize'] = $this->getTotalFileSize();
}
}
$information['dbsize'] = MainWP_Child_DB::get_size();
@ -4679,6 +4739,10 @@ class MainWP_Child {
}
function activation() {
$mu_plugin_enabled = apply_filters('mainwp_child_mu_plugin_enabled', false);
if ($mu_plugin_enabled)
return;
$to_delete = array(
'mainwp_child_pubkey',
'mainwp_child_nonce',
@ -4701,6 +4765,11 @@ class MainWP_Child {
}
function deactivation( $deact = true) {
$mu_plugin_enabled = apply_filters('mainwp_child_mu_plugin_enabled', false);
if ($mu_plugin_enabled)
return;
$to_delete = array(
'mainwp_child_pubkey',
'mainwp_child_nonce',
@ -5437,6 +5506,13 @@ class MainWP_Child {
MainWP_Child_Staging::Instance()->action();
}
function extra_execution() {
$post = $_POST;
$information = array();
$information = apply_filters('mainwp_child_extra_execution', $information, $post);
MainWP_Helper::write( $information );
}
function disconnect() {
$this->deactivation(false);
MainWP_Helper::write( array( 'result' => 'success' ) );

View file

@ -87,6 +87,9 @@ class MainWP_Client_Report {
case 'wordfence':
MainWP_Child_Wordfence::Instance()->do_reports_log( $ext );
break;
case 'wptimecapsule':
MainWP_Child_Timecapsule::Instance()->do_reports_log( $ext );
break;
}
}
@ -377,7 +380,7 @@ class MainWP_Client_Report {
continue;
}
} else if ( 'mainwp_backups' === $context ) {
if ( $record->context !== 'mainwp_backups' && $record->context !== 'backwpup_backups' && $record->context !== 'updraftplus_backups' && $record->context !== 'backupwordpress_backups' && $record->context !== 'backupbuddy_backups' ) {
if ( $record->context !== 'mainwp_backups' && $record->context !== 'backwpup_backups' && $record->context !== 'updraftplus_backups' && $record->context !== 'backupwordpress_backups' && $record->context !== 'backupbuddy_backups' && $record->context !== 'wptimecapsule_backups') {
continue;
}
} else if ( 'mainwp_sucuri' === $context ) {

View file

@ -343,7 +343,8 @@ class MainWP_Keyword_Links {
$this->link_exact_match = $link->exact_match;
$this->link_case_sensitive = $link->case_sensitive;
$keywords = $this->explode_multi( $link->keyword );
usort( $keywords, create_function( '$a,$b', 'return strlen($a)<strlen($b);' ) );
//usort( $keywords, create_function( '$a,$b', 'return strlen($a)<strlen($b);' ) );
usort( $keywords, array($this, 'usort_callback_func') );
$replace_cs = $link->case_sensitive ? 's' : 'is';
//print_r($keywords);
foreach ( $keywords as $keyword ) {
@ -386,6 +387,10 @@ class MainWP_Keyword_Links {
return $content;
}
private function usort_callback_func($a, $b) {
return strlen($a)<strlen($b);
}
public function keyword_mark( $matches ) {
if ( preg_match( '/^[<{].*?[>}]$/is', $matches[1] ) ) {

View file

@ -9,8 +9,7 @@ class MainWP_Security {
// MainWP_Security::remove_plugin_update();
// MainWP_Security::remove_theme_update();
MainWP_Security::remove_php_reporting();
MainWP_Security::remove_scripts_version();
MainWP_Security::remove_styles_version();
MainWP_Security::remove_registered_versions();
MainWP_Security::remove_generator_version();
MainWP_Security::remove_readme();
@ -256,20 +255,6 @@ class MainWP_Security {
//Removed version information for scripts/stylesheets
public static function remove_scripts_version_ok() {
return self::get_security_option( 'scripts_version' );
// global $wp_scripts;
// if (!is_a($wp_scripts, 'WP_Scripts'))
// {
// return true;
// }
// foreach ($wp_scripts->registered as $handle => $script)
// {
// if ($wp_scripts->registered[$handle]->ver != null)
// {
// return false;
// }
// }
// return true;
}
public static function remove_script_versions( $src ) {
@ -280,13 +265,29 @@ class MainWP_Security {
return $src;
}
// else if ( false === strpos( $src, '?ver=' ) ) {
// self::update_security_option('scripts_version', true);
// }
return $src;
}
public static function remove_registered_versions_ok() {
return self::get_security_option( 'registered_versions' );
}
public static function remove_registered_versions() {
if ( self::get_security_option( 'registered_versions' ) ) {
global $wp_styles;
if ( $wp_styles instanceof WP_Styles ) {
foreach ( $wp_styles->registered as $handle => $style ) {
$wp_styles->registered[ $handle ]->ver = null;
}
}
global $wp_scripts;
if ( $wp_scripts instanceof WP_Scripts ) {
foreach ( $wp_scripts->registered as $handle => $script ) {
$wp_scripts->registered[ $handle ]->ver = null;
}
}
}
}
public static function remove_generator_version_ok() {
return self::get_security_option( 'generator_version' );
@ -313,26 +314,9 @@ class MainWP_Security {
return $src;
}
// else if ( false === strpos( $src, '?ver=' ) ) {
// self::update_security_option('styles_version', true);
// }
return $src;
}
public static function remove_scripts_version( $force = false ) {
if ( $force || self::get_security_option( 'scripts_version' ) ) {
global $wp_scripts;
if ( !( $wp_scripts instanceof WP_Scripts ) ) {
return;
}
foreach ( $wp_scripts->registered as $handle => $script ) {
$wp_scripts->registered[ $handle ]->ver = null;
}
}
}
public static function remove_readme( $force = false ) {
if ( $force || self::get_security_option( 'readme' ) ) {
if ( @file_exists( ABSPATH . 'readme.html' ) ) {
@ -357,34 +341,6 @@ class MainWP_Security {
public static function remove_styles_version_ok() {
return self::get_security_option( 'styles_version' );
// global $wp_styles;
// if (!is_a($wp_styles, 'WP_Styles'))
// {
// return true;
// }
//
// foreach ($wp_styles->registered as $handle => $style)
// {
// if ($wp_styles->registered[$handle]->ver != null)
// {
// return false;
// }
// }
// return true;
}
public static function remove_styles_version( $force = true ) {
if ( $force || self::get_security_option( 'styles_version' ) ) {
global $wp_styles;
if ( !( $wp_styles instanceof WP_Styles ) ) {
return;
}
foreach ( $wp_styles->registered as $handle => $style ) {
$wp_styles->registered[ $handle ]->ver = null;
}
}
}
//Admin user name is not admin

View file

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