merge with branch01

This commit is contained in:
ruben- 2017-12-04 21:55:05 +01:00
parent ded863d160
commit 23bc358959
8 changed files with 719 additions and 128 deletions

View file

@ -92,71 +92,53 @@ class MainWP_Child_Back_Up_Buddy {
require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' );
}
$backups = array();
$backup_sort_dates = array();
$files = glob( backupbuddy_core::getBackupDirectory() . 'backup*.zip' );
if ( ! is_array( $files ) ) {
$files = array();
}
$files2 = glob( backupbuddy_core::getBackupDirectory() . 'snapshot*.zip' );
if ( ! is_array( $files2 ) ) {
$files2 = array();
}
$files = array_merge( $files, $files2 );
if ( is_array( $files ) && !empty( $files ) ) { // For robustness. Without open_basedir the glob() function returns an empty array for no match. With open_basedir in effect the glob() function returns a boolean false for no match.
foreach( $files as $file_id => $file ) {
$serial = backupbuddy_core::get_serial_from_file( $file );
$options = array();
if ( file_exists( backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt' ) ) {
require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' );
//pb_backupbuddy::status( 'details', 'Fileoptions instance #33.' );
$backup_options = new pb_backupbuddy_fileoptions( backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = false, $ignore_lock = false, $create_file = true ); // Will create file to hold integrity data if nothing exists.
} else {
$backup_options = '';
}
$backup_integrity = backupbuddy_core::backup_integrity_check( $file, $backup_options, $options );
// Backup type.
$pretty_type = array(
'full' => 'Full',
'db' => 'Database',
'files' => 'Files',
'themes' => 'Themes',
'plugins' => 'Plugins',
);
$recentBackups_list = glob( backupbuddy_core::getLogDirectory() . 'fileoptions/*.txt' );
// Defaults...
$detected_type = '';
$modified_time = 0;
foreach( $recentBackups_list as $backup_fileoptions ) {
if ( is_array( $backup_integrity ) ) {
// Calculate time ago.
$time_ago = '';
if ( isset( $backup_integrity['modified'] ) ) {
$time_ago = pb_backupbuddy::$format->time_ago( $backup_integrity['modified'] ) . ' ago';
require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' );
pb_backupbuddy::status( 'details', 'Fileoptions instance #1.' );
$backup = new pb_backupbuddy_fileoptions( $backup_fileoptions, $read_only = true );
if ( true !== ( $result = $backup->is_ok() ) ) {
continue;
}
$detected_type = pb_backupbuddy::$format->prettify( $backup_integrity['detected_type'], $pretty_type );
if ( $detected_type == '' ) {
$detected_type = backupbuddy_core::pretty_backup_type( backupbuddy_core::getBackupTypeFromFile( $file ) );
$backup = &$backup->options;
if ( !isset( $backup['serial'] ) || ( $backup['serial'] == '' ) ) {
continue;
}
$modified_time = $backup_integrity['modified'];
$message = 'BackupBuddy ' . $detected_type . ' finished';
$backup_type = $detected_type;
if (!empty($modified_time)) {
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backup_type, $modified_time);
MainWP_Helper::update_lasttime_backup('backupbuddy', $modified_time); // to support backup before update feature
}
}
}
if ( ( $backup['finish_time'] >= $backup['start_time'] ) && ( 0 != $backup['start_time'] ) ) {
// it is ok
} else {
continue;
}
if ( isset( $backup['profile'] ) && isset( $backup['profile']['type'] ) ) {
$backupType = pb_backupbuddy::$format->prettify( $backup['profile']['type'], $pretty_type );
} else {
$backupType = backupbuddy_core::pretty_backup_type( backupbuddy_core::getBackupTypeFromFile( $backup['archive_file'] ) );
}
if ( '' == $backupType ) {
$backupType = 'Unknown';
}
$finish_time = $backup['finish_time'];
$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
}
}
}
public function action() {
@ -692,6 +674,16 @@ class MainWP_Child_Back_Up_Buddy {
public function get_sync_data() {
if ( ! class_exists( 'backupbuddy_core' ) ) {
if (class_exists( 'pb_backupbuddy' ) && file_exists(pb_backupbuddy::plugin_path() . '/classes/core.php'))
require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' );
else
return false;
}
if (!function_exists('backupbuddy_core::get_plugins_root'))
return false;
$information = array();
$information['plugins_root'] = backupbuddy_core::get_plugins_root();
$information['themes_root'] = backupbuddy_core::get_themes_root();
@ -1821,6 +1813,29 @@ class MainWP_Child_Back_Up_Buddy {
function remote_save() {
$data = isset($_POST['data']) ? $_POST['data'] : false;
$destination_id = isset($_POST['destination_id']) ? $_POST['destination_id'] : 0;
if (is_array($data) && isset($data['do_not_override'])) {
if (true == $data['do_not_override']) {
if (($data['type'] == 's32' || $data['type'] == 's33')) {
$not_override = array(
'accesskey',
'secretkey',
'bucket',
'region'
);
foreach($not_override as $opt) {
if (isset($data[$opt])) {
unset($data[$opt]);
}
}
}
}
unset($data['do_not_override']);
}
if (is_array($data)) {
if (isset(pb_backupbuddy::$options['remote_destinations'][$destination_id])) { // update
pb_backupbuddy::$options['remote_destinations'][$destination_id] = array_merge( pb_backupbuddy::$options['remote_destinations'][$destination_id], $data );

View file

@ -1246,6 +1246,9 @@ class MainWP_Child_Back_WP_Up {
$url = BackWPup_Job::get_jobrun_url( 'runnowlink', $job_id );
BackWPup_Admin::message( sprintf( __( 'Changes for job <i>%s</i> saved.', 'backwpup' ), BackWPup_Option::get( $job_id, 'name' ) ) . ' <a href="' . network_admin_url( 'admin.php' ) . '?page=backwpupjobs">' . __( 'Jobs overview', 'backwpup' ) . '</a> | <a href="' . $url['url'] . '">' . __( 'Run now', 'backwpup' ) . '</a>' );
}
} else if ($settings['tab'] == 'dest-DROPBOX') {
unset($settings['value']); // do not save dropbox settings
BackWPup_Page_Editjob::save_post_form( $settings['tab'], $job_id );
} else {
BackWPup_Page_Editjob::save_post_form( $settings['tab'], $job_id );
}

View file

@ -2,6 +2,7 @@
class MainWP_Child_iThemes_Security {
public static $instance = null;
public $is_plugin_installed = false;
static function Instance() {
if ( null === MainWP_Child_iThemes_Security::$instance ) {
@ -12,14 +13,27 @@ class MainWP_Child_iThemes_Security {
}
public function __construct() {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if ( is_plugin_active( 'better-wp-security/better-wp-security.php') || is_plugin_active( 'ithemes-security-pro/ithemes-security-pro.php' ) ) {
$this->is_plugin_installed = true;
}
if (!$this->is_plugin_installed)
return;
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
}
function syncOthersData( $information, $data = array() ) {
if ( is_array( $data ) && isset( $data['ithemeExtActivated'] ) && ( 'yes' === $data['ithemeExtActivated'] ) ) {
MainWP_Helper::update_option( 'mainwp_ithemes_ext_activated', 'Y' );
$information['syncIThemeData'] = array(
'users_and_roles' => $this->get_available_admin_users_and_roles()
);
//MainWP_Helper::update_option( 'mainwp_ithemes_ext_activated', 'Y' );
return $information;
} else {
MainWP_Helper::update_option( 'mainwp_ithemes_ext_activated', '' );
//MainWP_Helper::update_option( 'mainwp_ithemes_ext_activated', '' );
}
return $information;
}
@ -164,6 +178,7 @@ class MainWP_Child_iThemes_Security {
'system-tweaks',
'wordpress-tweaks',
'multisite-tweaks',
'notification-center'
//'salts',
//'content-directory',
);
@ -240,7 +255,26 @@ class MainWP_Child_iThemes_Security {
}
}
$settings = $nbf_settings;
} else if ($module == 'notification-center') {
$current_settings = ITSEC_Modules::get_settings( $module );
if (isset($settings['notifications'])) {
$update_fields = array( 'schedule', 'enabled', 'subject');
if (isset($_POST['is_individual']) && $_POST['is_individual']) {
$update_fields = array_merge($update_fields, array('user_list', 'email_list'));
}
foreach ($settings['notifications'] as $key => $val) {
foreach ($update_fields as $field) {
if(isset($val[$field])) {
$current_settings['notifications'][$key][$field] = $val[$field];
}
}
}
$updated = true;
ITSEC_Modules::set_settings( $module, $current_settings );
}
continue;
}
if ( !$do_not_save ) {
ITSEC_Modules::set_settings( $module, $settings );
$updated = true;
@ -249,7 +283,11 @@ class MainWP_Child_iThemes_Security {
}
if ( isset( $update_settings['itsec_active_modules'] ) ) {
update_site_option( 'itsec_active_modules', $update_settings['itsec_active_modules'] );
$current_val = get_site_option( 'itsec_active_modules', array() );
foreach ($update_settings['itsec_active_modules'] as $mod => $val) {
$current_val[$mod] = $val;
}
update_site_option( 'itsec_active_modules', $current_val );
}
require_once( ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php' );
@ -259,9 +297,8 @@ class MainWP_Child_iThemes_Security {
'is_multisite' => is_multisite() ? 1 : 0,
'users_can_register' => get_site_option( 'users_can_register' ) ? 1 : 0,
'server_nginx' => ( ITSEC_Lib::get_server() === 'nginx' ) ? 1 : 0,
'has_ssl' => ITSEC_Lib::get_ssl() ? 1 : 0,
'has_ssl' => ITSEC_Lib::get_ssl_support_probability(),
'jquery_version' => ITSEC_Modules::get_setting( 'wordpress-tweaks', 'jquery_version' ),
'is_jquery_version_safe'=> ITSEC_Lib::is_jquery_version_safe(),
'server_rules' => ITSEC_Lib_Config_File::get_server_config(),
'config_rules' => ITSEC_Lib_Config_File::get_wp_config(),
'lockouts_host' => $this->get_lockouts( 'host', true ),
@ -270,6 +307,7 @@ class MainWP_Child_iThemes_Security {
'default_log_location' => ITSEC_Modules::get_default( 'global', 'log_location' ),
'default_location' => ITSEC_Modules::get_default( 'backup', 'location' ),
'excludable_tables' => $this->get_excludable_tables(),
'users_and_roles' => $this->get_available_admin_users_and_roles()
);
$return = array(
@ -648,9 +686,16 @@ class MainWP_Child_iThemes_Security {
$username_exists = username_exists( 'admin' );
$user_id_exists = ITSEC_Lib::user_id_exists( 1 );
$msg = '';
if ( strlen( $new_username ) >= 1 && ! $username_exists ) {
if ( strlen( $new_username ) >= 1) {
global $current_user;
if ( ! $username_exists ) {
$msg = __( 'Admin user already changes.', 'mainwp-child' );
} else if ($current_user->user_login == 'admin') {
$return['result'] = 'CHILD_ADMIN';
return $return;
}
}
if ( true === $change_id && ! $user_id_exists ) {
if ( ! empty( $msg ) ) {
@ -659,13 +704,13 @@ class MainWP_Child_iThemes_Security {
$msg .= __( 'Admin user ID already changes.', 'mainwp-child' );
}
if ( $change_id ) {
$user = get_user_by( 'login', $new_username );
if ( $user && 1 === (int) $user->ID ) {
$return['result'] = 'CHILD_ADMIN';
return $return;
}
}
// if ( $change_id ) {
// $user = get_user_by( 'login', $new_username );
// if ( $user && 1 === (int) $user->ID ) {
// $return['result'] = 'CHILD_ADMIN';
// return $return;
// }
// }
$admin_success = true;
$return = array();
@ -690,7 +735,8 @@ class MainWP_Child_iThemes_Security {
global $wpdb;
$itsec_files = ITSEC_Core::get_itsec_files();
if ( $itsec_files->get_file_lock( 'admin_user' ) ) { //make sure it isn't already running
// do not need to check this
//if ( $itsec_files->get_file_lock( 'admin_user' ) ) { //make sure it isn't already running
//sanitize the username
$new_user = sanitize_text_field( $username );
@ -771,7 +817,7 @@ class MainWP_Child_iThemes_Security {
return true;
}
}
//}
return false;
@ -1047,7 +1093,12 @@ class MainWP_Child_iThemes_Security {
if (!is_array($active_modules))
$active_modules = array();
update_site_option( 'itsec_active_modules', $active_modules );
$current_val = get_site_option( 'itsec_active_modules', array() );
foreach ($active_modules as $mod => $val) {
$current_val[$mod] = $val;
}
update_site_option( 'itsec_active_modules', $current_val );
return array('result' => 'success');
}
@ -1102,9 +1153,47 @@ class MainWP_Child_iThemes_Security {
private function security_site() {
global $mainwp_itsec_modules_path;
require_once( $mainwp_itsec_modules_path . 'security-check/scanner.php' );
ITSEC_Security_Check_Scanner::run();
$response = ITSEC_Response::get_response();
require_once( $mainwp_itsec_modules_path . 'security-check/feedback-renderer.php' );
// ITSEC_Security_Check_Scanner::run();
// $response = ITSEC_Response::get_response();
$results = ITSEC_Security_Check_Scanner::get_results();
ob_start();
ITSEC_Security_Check_Feedback_Renderer::render( $results );
$response = ob_get_clean();
return array('result' => 'success' , 'response' => $response);
}
// source from itheme plugin
public function get_available_admin_users_and_roles() {
if ( is_callable( 'wp_roles' ) ) {
$roles = wp_roles();
} else {
$roles = new WP_Roles();
}
$available_roles = array();
$available_users = array();
foreach ( $roles->roles as $role => $details ) {
if ( isset( $details['capabilities']['manage_options'] ) && ( true === $details['capabilities']['manage_options'] ) ) {
$available_roles["role:$role"] = translate_user_role( $details['name'] );
$users = get_users( array( 'role' => $role ) );
foreach ( $users as $user ) {
/* translators: 1: user display name, 2: user login */
$available_users[ $user->ID ] = sprintf( __( '%1$s (%2$s)', 'better-wp-security' ), $user->display_name, $user->user_login );
}
}
}
natcasesort( $available_users );
return array(
'users' => $available_users,
'roles' => $available_roles,
);
}
}

View file

@ -0,0 +1,367 @@
<?php
class MainWP_Child_Staging {
public static $instance = null;
public $is_plugin_installed = false;
static function Instance() {
if ( null === MainWP_Child_Staging::$instance ) {
MainWP_Child_Staging::$instance = new MainWP_Child_Staging();
}
return MainWP_Child_Staging::$instance;
}
public function __construct() {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if ( is_plugin_active( 'wp-staging/wp-staging.php' ) && defined('WPSTG_PLUGIN_DIR')) {
$this->is_plugin_installed = true;
}
if (!$this->is_plugin_installed)
return;
}
public function init() {
if ( get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y' )
return;
if (!$this->is_plugin_installed)
return;
//add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
if ( get_option( 'mainwp_wp_staging_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
add_action( 'admin_menu', array( $this, 'remove_menu' ) );
add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
}
}
public function get_sync_data() {
return $this->get_overview();
}
public function action() {
if (!$this->is_plugin_installed) {
MainWP_Helper::write( array('error' => 'Please install WP Staging plugin on child website') );
}
if (!class_exists( 'WPStaging\WPStaging' )){
require_once WPSTG_PLUGIN_DIR . "apps/Core/WPStaging.php";
}
\WPStaging\WPStaging::getInstance();
$information = array();
if (get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y') {
MainWP_Helper::update_option( 'mainwp_wp_staging_ext_enabled', 'Y', 'yes' );
}
if ( isset( $_POST['mwp_action'] ) ) {
switch ( $_POST['mwp_action'] ) {
case 'set_showhide':
$information = $this->set_showhide();
break;
case 'save_settings':
$information = $this->save_settings();
break;
case 'get_overview':
$information = $this->get_overview();
break;
case 'get_scan':
$information = $this->get_scan();
break;
case 'check_disk_space':
$information = $this->ajaxCheckFreeSpace();
break;
case 'check_clone':
$information = $this->ajaxCheckCloneName();
break;
case 'start_clone':
$information = $this->ajaxStartClone();
break;
case 'clone_database':
$information = $this->ajaxCloneDatabase();
break;
case 'prepare_directories':
$information = $this->ajaxPrepareDirectories();
break;
case 'copy_files':
$information = $this->ajaxCopyFiles();
break;
case 'replace_data':
$information = $this->ajaxReplaceData();
break;
case 'clone_finish':
$information = $this->ajaxFinish();
break;
case 'delete_confirmation':
$information = $this->ajaxDeleteConfirmation();
break;
case 'delete_clone':
$information = $this->ajaxDeleteClone();
break;
case 'cancel_clone':
$information = $this->ajaxCancelClone();
break;
}
}
MainWP_Helper::write( $information );
}
function set_showhide() {
$hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
MainWP_Helper::update_option( 'mainwp_wp_staging_hide_plugin', $hide, 'yes' );
$information['result'] = 'SUCCESS';
return $information;
}
function save_settings() {
$settings = $_POST['settings'];
$filters = array(
'queryLimit',
'fileLimit',
'batchSize',
'cpuLoad',
'disableAdminLogin',
'wpSubDirectory',
'debugMode',
'unInstallOnDelete',
'checkDirectorySize'
);
$save_fields = array();
foreach($filters as $field) {
if (isset($settings[$field])) {
$save_fields[$field] = $settings[$field];
}
}
update_option('wpstg_settings', $save_fields );
return array('result' => 'success');
}
public function get_overview() {
$return = array(
'availableClones' => get_option( "wpstg_existing_clones_beta", array())
);
return $return;
}
public function get_scan() {
// Scan
$scan = new WPStaging\Backend\Modules\Jobs\Scan();
$scan->start();
// Get Options
$options = $scan->getOptions();
$return = array(
'options' => serialize($options),
'directoryListing' => $scan->directoryListing(),
'prefix' => WPStaging\WPStaging::getTablePrefix()
);
return $return;
}
public function ajaxCheckCloneName() {
$cloneName = sanitize_key( $_POST["cloneID"] );
$cloneNameLength = strlen( $cloneName );
$clones = get_option( "wpstg_existing_clones_beta", array() );
// Check clone name length
if( $cloneNameLength < 1 || $cloneNameLength > 16 ) {
echo array(
"status" => "failed",
"message" => "Clone name must be between 1 - 16 characters"
);
} elseif( array_key_exists( $cloneName, $clones ) ) {
return array(
"status" => "failed",
"message" => "Clone name is already in use, please choose an another clone name"
);
}
return array("status" => "success");
}
public function ajaxStartClone() {
$cloning = new WPStaging\Backend\Modules\Jobs\Cloning();
if( !$cloning->save() ) {
return;
}
ob_start();
require_once WPSTG_PLUGIN_DIR . "apps/Backend/views/clone/ajax/start.php";
$result = ob_get_clean();
return $result;
}
public function ajaxCloneDatabase() {
$cloning = new WPStaging\Backend\Modules\Jobs\Cloning();
return $cloning->start();
}
/**
* Ajax Prepare Directories (get listing of files)
*/
public function ajaxPrepareDirectories() {
$cloning = new WPStaging\Backend\Modules\Jobs\Cloning();
return $cloning->start();
}
/**
* Ajax Clone Files
*/
public function ajaxCopyFiles() {
$cloning = new WPStaging\Backend\Modules\Jobs\Cloning();
return $cloning->start();
}
/**
* Ajax Replace Data
*/
public function ajaxReplaceData() {
$cloning = new WPStaging\Backend\Modules\Jobs\Cloning();
return $cloning->start();
}
/**
* Ajax Finish
*/
public function ajaxFinish() {
$cloning = new WPStaging\Backend\Modules\Jobs\Cloning();
$this->url = ''; // to fix warning
$return = $cloning->start();
$return->blogInfoName = get_bloginfo("name");
return $return;
}
/**
* Ajax Delete Confirmation
*/
public function ajaxDeleteConfirmation() {
$delete = new WPStaging\Backend\Modules\Jobs\Delete();
$delete->setData();
$clone = $delete->getClone();
$result = array(
'clone' => $clone,
'deleteTables' => $delete->getTables()
);
return $result;
}
/**
* Delete clone
*/
public function ajaxDeleteClone() {
$delete = new WPStaging\Backend\Modules\Jobs\Delete();
return $delete->start();
}
/**
* Delete clone
*/
public function ajaxCancelClone() {
$cancel = new WPStaging\Backend\Modules\Jobs\Cancel();
return $cancel->start();
}
public function ajaxCheckFreeSpace() {
return $this->hasFreeDiskSpace();
}
// from wp-staging plugin
public function hasFreeDiskSpace() {
if( !function_exists( "disk_free_space" ) ) {
return null;
}
$freeSpace = @disk_free_space( ABSPATH );
if( false === $freeSpace ) {
$data = array(
'freespace' => false,
'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH))
);
return $data;
}
$data = array(
'freespace' => $this->formatSize($freeSpace),
'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH))
);
return $data;
}
// from wp-staging plugin
function getDirectorySizeInclSubdirs( $dir ) {
$size = 0;
foreach ( glob( rtrim( $dir, '/' ) . '/*', GLOB_NOSORT ) as $each ) {
$size += is_file( $each ) ? filesize( $each ) : $this->getDirectorySizeInclSubdirs( $each );
}
return $size;
}
// from wp-staging plugin
public function formatSize($bytes, $precision = 2)
{
if ((double) $bytes < 1)
{
return '';
}
$units = array('B', "KB", "MB", "GB", "TB");
$bytes = (double) $bytes;
$base = log($bytes) / log(1000); // 1024 would be for MiB KiB etc
$pow = pow(1000, $base - floor($base)); // Same rule for 1000
return round($pow, $precision) . ' ' . $units[(int) floor($base)];
}
public function all_plugins( $plugins ) {
foreach ( $plugins as $key => $value ) {
$plugin_slug = basename( $key, '.php' );
if ( 'wp-staging' === $plugin_slug ) {
unset( $plugins[ $key ] );
}
}
return $plugins;
}
public function remove_menu() {
remove_menu_page( 'wpstg_clone' );
$pos = stripos( $_SERVER['REQUEST_URI'], 'admin.php?page=wpstg_clone' );
if ( false !== $pos ) {
wp_redirect( get_option( 'siteurl' ) . '/wp-admin/index.php' );
exit();
}
}
function remove_update_nag( $value ) {
if ( isset( $_POST['mainwpsignature'] ) ) {
return $value;
}
if ( isset( $value->response['wp-staging/wp-staging.php'] ) ) {
unset( $value->response['wp-staging/wp-staging.php'] );
}
return $value;
}
}

View file

@ -168,7 +168,7 @@ class MainWP_Child_Updraft_Plus_Backups {
'updraft_retain',
'updraft_retain_db',
'updraft_encryptionphrase',
'updraft_service',
//'updraft_service', // will check override to save
'updraft_dir',
'updraft_email',
'updraft_delete_local',
@ -462,8 +462,8 @@ class MainWP_Child_Updraft_Plus_Backups {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3' );
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
// $opts['settings'][$settings_key]['accesskey'] = $settings[ $key ]['accesskey'];
// $opts['settings'][$settings_key]['secretkey'] = $settings[ $key ]['secretkey'];
$opts['settings'][$settings_key]['accesskey'] = $settings[ $key ]['accesskey'];
$opts['settings'][$settings_key]['secretkey'] = $settings[ $key ]['secretkey'];
$opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']);
if (!empty($opts['settings'][$settings_key]['path']) && '/' == substr($opts['settings'][$settings_key]['path'], 0, 1)) {
$opts['settings'][$settings_key]['path'] = substr($opts['settings'][$settings_key]['path'], 1);
@ -473,8 +473,8 @@ class MainWP_Child_Updraft_Plus_Backups {
$opts['settings'][$settings_key]['server_side_encryption'] = $settings[ $key ]['server_side_encryption'];
}
} else {
// $opts['accesskey'] = $settings[ $key ]['accesskey'];
// $opts['secretkey'] = $settings[ $key ]['secretkey'];
$opts['accesskey'] = $settings[ $key ]['accesskey'];
$opts['secretkey'] = $settings[ $key ]['secretkey'];
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
if (!empty($opts['path']) && '/' == substr($opts['path'], 0, 1)) {
$opts['path'] = substr($opts['path'], 1);
@ -490,14 +490,14 @@ class MainWP_Child_Updraft_Plus_Backups {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3generic' );
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
// $opts['settings'][$settings_key]['endpoint'] = $settings[ $key ]['endpoint'];
// $opts['settings'][$settings_key]['accesskey'] = $settings[ $key ]['accesskey'];
// $opts['settings'][$settings_key]['secretkey'] = $settings[ $key ]['secretkey'];
$opts['settings'][$settings_key]['endpoint'] = $settings[ $key ]['endpoint'];
$opts['settings'][$settings_key]['accesskey'] = $settings[ $key ]['accesskey'];
$opts['settings'][$settings_key]['secretkey'] = $settings[ $key ]['secretkey'];
$opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']);
} else {
// $opts['endpoint'] = $settings[ $key ]['endpoint'];
// $opts['accesskey'] = $settings[ $key ]['accesskey'];
// $opts['secretkey'] = $settings[ $key ]['secretkey'];
$opts['endpoint'] = $settings[ $key ]['endpoint'];
$opts['accesskey'] = $settings[ $key ]['accesskey'];
$opts['secretkey'] = $settings[ $key ]['secretkey'];
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
}
@ -564,6 +564,13 @@ class MainWP_Child_Updraft_Plus_Backups {
$updated = true;
}
}
if (!isset($settings['do_not_save_remote_settings']) || empty($settings['do_not_save_remote_settings'])) {
UpdraftPlus_Options::update_updraft_option( 'updraft_service', $settings['updraft_service'] );
}
global $updraftplus;
if ( isset( $settings['updraft_interval'] ) ) {
// fix for premium version
@ -1098,7 +1105,11 @@ class MainWP_Child_Updraft_Plus_Backups {
private function deleteset() {
global $updraftplus;
if (method_exists($updraftplus, 'get_backup_history')) {
$backups = $updraftplus->get_backup_history();
} else if (class_exists('UpdraftPlus_Backup_History')) {
$backups = UpdraftPlus_Backup_History::get_history();
}
$timestamp = $_POST['backup_timestamp'];
if ( ! isset( $backups[ $timestamp ] ) ) {
$bh = $this->build_historystatus();
@ -1316,7 +1327,12 @@ class MainWP_Child_Updraft_Plus_Backups {
$updraftplus->jobdata_set( 'job_time_ms', $updraftplus->job_time_ms );
// Retrieve the information from our backup history
if (method_exists($updraftplus, 'get_backup_history')) {
$backup_history = $updraftplus->get_backup_history();
} else if (class_exists('UpdraftPlus_Backup_History')) {
$backup_history = UpdraftPlus_Backup_History::get_history();
}
// Base name
$file = $backup_history[ $timestamp ][ $type ];
@ -1472,7 +1488,13 @@ class MainWP_Child_Updraft_Plus_Backups {
public function restore_alldownloaded() {
global $updraftplus;
if (method_exists($updraftplus, 'get_backup_history')) {
$backups = $updraftplus->get_backup_history();
} else if (class_exists('UpdraftPlus_Backup_History')) {
$backups = UpdraftPlus_Backup_History::get_history();
}
$updraft_dir = $updraftplus->backups_dir_location();
$timestamp = (int) $_POST['timestamp'];
@ -2174,7 +2196,12 @@ class MainWP_Child_Updraft_Plus_Backups {
# This attempts to raise the maximum packet size. This can't be done within the session, only globally. Therefore, it has to be done before the session starts; in our case, during the pre-analysis.
$updraftplus->get_max_packet_size();
$backup = $updraftplus->get_backup_history( $timestamp );
if (method_exists($updraftplus, 'get_backup_history')) {
$backup = $updraftplus->get_backup_history($timestamp);
} else if (class_exists('UpdraftPlus_Backup_History')) {
$backup = UpdraftPlus_Backup_History::get_history($timestamp);
}
if ( ! isset( $backup['nonce'] ) || ! isset( $backup['db'] ) ) {
return array( $mess, $warn, $err, $info );
}

View file

@ -22,7 +22,7 @@ class MainWP_Child_WooCommerce_Status {
public function action() {
$information = array();
if ( ! class_exists( 'WooCommerce' ) ) {
if ( ! class_exists( 'WooCommerce' ) || !defined('WC_VERSION')) {
$information['error'] = 'NO_WOOCOMMERCE';
MainWP_Helper::write( $information );
}
@ -36,6 +36,9 @@ class MainWP_Child_WooCommerce_Status {
case 'report_data':
$information = ! $is_ver220 ? $this->report_data() : $this->report_data_two();
break;
case 'update_wc_db':
$information = $this->update_wc_db();
break;
}
}
MainWP_Helper::write( $information );
@ -281,6 +284,7 @@ class MainWP_Child_WooCommerce_Status {
}
function sync_data_two() {
// sync data at current time
$start_date = current_time( 'timestamp' );
$end_date = current_time( 'timestamp' );
@ -294,6 +298,13 @@ class MainWP_Child_WooCommerce_Status {
return $this->get_woocom_data( $start_date, $end_date );
}
function check_db_update() {
if ( version_compare( get_option( 'woocommerce_db_version' ), WC_VERSION, '<' ) ) {
return true;
}
return false;
}
function get_woocom_data( $start_date, $end_date ) {
global $wpdb;
$file = WP_PLUGIN_DIR . '/woocommerce/includes/admin/reports/class-wc-admin-report.php';
@ -402,11 +413,40 @@ class MainWP_Child_WooCommerce_Status {
'stock' => $stock,
'nostock' => $nostock,
'lowstock' => $lowinstock_count,
'outstock' => $outofstock_count,
'outstock' => $outofstock_count
);
$information['data'] = $data;
$information['need_db_update'] = $this->check_db_update();
return $information;
}
private static function update_wc_db() {
include_once( WC()->plugin_path() . '/includes/class-wc-background-updater.php' );
$background_updater = new WC_Background_Updater();
$current_db_version = get_option( 'woocommerce_db_version' );
$logger = wc_get_logger();
$update_queued = false;
foreach ( WC_Install::get_db_update_callbacks() as $version => $update_callbacks ) {
if ( version_compare( $current_db_version, $version, '<' ) ) {
foreach ( $update_callbacks as $update_callback ) {
$logger->info(
sprintf( 'Queuing %s - %s', $version, $update_callback ),
array( 'source' => 'wc_db_updates' )
);
$background_updater->push_to_queue( $update_callback );
$update_queued = true;
}
}
}
if ( $update_queued ) {
$background_updater->save()->dispatch();
}
return array('result' => 'success');
}
}

View file

@ -84,7 +84,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
}
class MainWP_Child {
public static $version = '3.4.3';
public static $version = '3.4.4';
private $update_version = '1.3';
private $callableFunctions = array(
@ -149,7 +149,8 @@ class MainWP_Child {
'custom_post_type' => 'custom_post_type',
'backup_buddy' => 'backup_buddy',
'get_site_icon' => 'get_site_icon',
'vulner_checker' => 'vulner_checker'
'vulner_checker' => 'vulner_checker',
'wp_staging' => 'wp_staging'
);
private $FTP_ERROR = 'Failed! Please, add FTP details for automatic updates.';
@ -496,7 +497,7 @@ class MainWP_Child {
$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') ) ) {
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;
}
}
@ -1390,6 +1391,7 @@ class MainWP_Child {
new MainWP_Child_Back_Up_Buddy();
MainWP_Child_Wordfence::Instance()->wordfence_init();
MainWP_Child_Staging::Instance()->init();
global $_wp_submenu_nopriv;
if ($_wp_submenu_nopriv === null)
@ -1609,7 +1611,12 @@ class MainWP_Child {
if ( ! empty( $fileName ) ) {
do_action( 'mainwp_child_installPluginTheme', $args );
if ( isset( $_POST['activatePlugin'] ) && 'yes' === $_POST['activatePlugin'] ) {
// to fix activate issue
if ('quotes-collection/quotes-collection.php' == $args['slug']) {
activate_plugin( $path . $fileName, '', false, true );
} else {
activate_plugin( $path . $fileName, '' /* false, true */ );
}
do_action( 'activate_plugin', $args['slug'], null );
}
}
@ -3610,7 +3617,10 @@ class MainWP_Child {
$categories[] = $cat->name;
}
$information['categories'] = $categories;
$get_file_size = apply_filters('mainwp-child-get-total-size', true);
if ($get_file_size) {
$information['totalsize'] = $this->getTotalFileSize();
}
$information['dbsize'] = MainWP_Child_DB::get_size();
$auths = get_option( 'mainwp_child_auth' );
@ -3641,6 +3651,14 @@ class MainWP_Child {
}
}
if ( isset( $othersData['syncWPStaging'] ) && !empty( $othersData['syncWPStaging'] ) ) {
if ( MainWP_Child_Staging::Instance()->is_plugin_installed ) {
$information['syncWPStaging'] = MainWP_Child_Staging::Instance()->get_sync_data();
}
}
if ( isset( $othersData['syncBackupBuddy'] ) && !empty( $othersData['syncBackupBuddy'] ) ) {
if ( MainWP_Child_Back_Up_Buddy::Instance()->is_backupbuddy_installed ) {
$information['syncBackupBuddy'] = MainWP_Child_Back_Up_Buddy::Instance()->get_sync_data();
@ -3883,7 +3901,7 @@ class MainWP_Child {
$wp_seo_enabled = false;
if ( isset( $_POST['WPSEOEnabled'] ) && $_POST['WPSEOEnabled']) {
if (is_plugin_active('wordpress-seo/wp-seo.php') && class_exists('WPSEO_Link_Column_Count')) {
if (is_plugin_active('wordpress-seo/wp-seo.php') && class_exists('WPSEO_Link_Column_Count') && class_exists('WPSEO_Meta')) {
$wp_seo_enabled = true;
}
}
@ -3906,11 +3924,17 @@ class MainWP_Child {
$outPost['title'] = $post->post_title;
$outPost['content'] = $post->post_content;
$outPost['comment_count'] = $post->comment_count;
// to support extract urls extension
if ( isset( $extra['where_post_date'] ) && !empty( $extra['where_post_date'] ) ) {
$outPost['dts'] = strtotime( $post->post_date_gmt );
} else {
$outPost['dts'] = strtotime( $post->post_modified_gmt );
}
if ($post->post_status == 'future') {
$outPost['dts'] = strtotime( $post->post_date_gmt );
}
$usr = get_user_by( 'id', $post->post_author );
$outPost['author'] = ! empty( $usr ) ? $usr->user_nicename : 'removed';
$categoryObjects = get_the_category( $post->ID );
@ -4151,14 +4175,20 @@ class MainWP_Child {
add_filter( 'posts_where', array( &$this, 'posts_where' ) );
$where_post_date = isset($_POST['where_post_date']) && !empty($_POST['where_post_date']) ? true : false;
if ( isset( $_POST['postId'] ) ) {
$this->posts_where_suffix .= " AND $wpdb->posts.ID = " . $_POST['postId'];
} else if ( isset( $_POST['userId'] ) ) {
$this->posts_where_suffix .= " AND $wpdb->posts.post_author = " . $_POST['userId'];
} else {
if ( isset( $_POST['keyword'] ) ) {
$search_on = isset($_POST['search_on']) ? $_POST['search_on'] : '';
if ($search_on == 'title') {
$this->posts_where_suffix .= " AND ( $wpdb->posts.post_title LIKE '%" . $_POST['keyword'] . "%' )";
} else if ($search_on == 'content') {
$this->posts_where_suffix .= " AND ($wpdb->posts.post_content LIKE '%" . $_POST['keyword'] . "%' )";
} else {
$this->posts_where_suffix .= " AND ($wpdb->posts.post_content LIKE '%" . $_POST['keyword'] . "%' OR $wpdb->posts.post_title LIKE '%" . $_POST['keyword'] . "%' )";
}
}
if ( isset( $_POST['dtsstart'] ) && '' !== $_POST['dtsstart'] ) {
if ($where_post_date) {
@ -4398,10 +4428,16 @@ class MainWP_Child {
if ( $plugin !== $this->plugin_slug ) {
$thePlugin = get_plugin_data( $plugin );
if ( null !== $thePlugin && '' !== $thePlugin ) {
// to fix activate issue
if ('quotes-collection/quotes-collection.php' == $plugin) {
activate_plugin( $plugin, '', false, true );
do_action( 'activate_plugin', $plugin, null );
} else {
activate_plugin( $plugin );
}
}
}
}
} else if ( 'deactivate' === $action ) {
include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
@ -4779,7 +4815,7 @@ class MainWP_Child {
$size = @fread( $popenHandle, 1024 );
@pclose( $popenHandle );
$size = substr( $size, 0, strpos( $size, "\t" ) );
if ( MainWP_Helper::ctype_digit( $size ) ) {
if ( $size && MainWP_Helper::ctype_digit( $size ) ) {
return $size / 1024;
}
}
@ -4791,7 +4827,7 @@ class MainWP_Child {
$size = @shell_exec( 'du -s ' . $directory . ' --exclude "' . str_replace( ABSPATH, '', $uploadDir ) . '"' );
if ( null !== $size ) {
$size = substr( $size, 0, strpos( $size, "\t" ) );
if ( MainWP_Helper::ctype_digit( $size ) ) {
if ( $size && MainWP_Helper::ctype_digit( $size ) ) {
return $size / 1024;
}
}
@ -4810,6 +4846,16 @@ class MainWP_Child {
}
}
}
// to fix for window host, performance not good?
if ( class_exists( 'RecursiveIteratorIterator' ) ) {
$size = 0;
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file){
$size+=$file->getSize();
}
if ( $size && MainWP_Helper::ctype_digit( $size ) ) {
return $size / 1024 / 1024;
}
}
// function dirsize( $dir ) {
// $dirs = array( $dir );
@ -5404,6 +5450,10 @@ class MainWP_Child {
MainWP_Child_Vulnerability_Checker::Instance()->action();
}
function wp_staging() {
MainWP_Child_Staging::Instance()->action();
}
static function fix_for_custom_themes() {
if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) {
include_once( ABSPATH . '/wp-admin/includes/screen.php' );

View file

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