new version

This commit is contained in:
ruben- 2018-06-26 19:52:53 +02:00
parent f6699c4a0d
commit 61ad07a152
18 changed files with 2659 additions and 533 deletions

View file

@ -27,6 +27,8 @@ class MainWP_Child_Back_Up_Buddy {
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' ) );
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
@ -79,7 +81,7 @@ class MainWP_Child_Back_Up_Buddy {
$this->do_reports_log('backupbuddy');
}
}
// ok
function do_reports_log($ext = '') {
if ($ext !== 'backupbuddy')
return;
@ -88,10 +90,21 @@ class MainWP_Child_Back_Up_Buddy {
return;
}
try {
MainWP_Helper::check_methods( 'pb_backupbuddy', array( 'plugin_path' ));
if ( ! class_exists( 'backupbuddy_core' ) ) {
if ( file_exists(pb_backupbuddy::plugin_path() . '/classes/core.php') )
require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' );
}
if (file_exists(pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'))
require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' );
MainWP_Helper::check_classes_exists(array( 'backupbuddy_core', 'pb_backupbuddy_fileoptions' ));
MainWP_Helper::check_methods('backupbuddy_core', 'getLogDirectory');
// Backup type.
$pretty_type = array(
'full' => 'Full',
@ -101,12 +114,11 @@ class MainWP_Child_Back_Up_Buddy {
$recentBackups_list = glob( backupbuddy_core::getLogDirectory() . 'fileoptions/*.txt' );
foreach( $recentBackups_list as $backup_fileoptions ) {
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() ) ) {
if ( method_exists($backup, 'is_ok') && true !== ( $result = $backup->is_ok() ) ) {
continue;
}
@ -122,11 +134,18 @@ class MainWP_Child_Back_Up_Buddy {
continue;
}
$backupType = '';
if ( isset( $backup['profile'] ) && isset( $backup['profile']['type'] ) ) {
if (true === MainWP_Helper::check_properties('pb_backupbuddy', 'format', true)) {
if (true === MainWP_Helper::check_methods(pb_backupbuddy::$format, array( 'prettify' ), true)) {
$backupType = pb_backupbuddy::$format->prettify( $backup['profile']['type'], $pretty_type );
}
}
} else {
if (true === MainWP_Helper::check_methods('backupbuddy_core', array( 'pretty_backup_type', 'getBackupTypeFromFile' ), true)) {
$backupType = backupbuddy_core::pretty_backup_type( backupbuddy_core::getBackupTypeFromFile( $backup['archive_file'] ) );
}
}
if ( '' == $backupType ) {
$backupType = 'Unknown';
@ -143,6 +162,9 @@ class MainWP_Child_Back_Up_Buddy {
if ( file_exists(pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php') ) {
require_once( pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php' );
MainWP_Helper::check_classes_exists(array( 'backupbuddy_live_periodic' ));
MainWP_Helper::check_methods('backupbuddy_live_periodic', 'get_stats');
$state = backupbuddy_live_periodic::get_stats();
if (is_array($state) && isset($state['stats'])) {
@ -164,6 +186,9 @@ class MainWP_Child_Back_Up_Buddy {
}
}
} catch( Exception $e ) {
}
}
public function action() {
@ -341,7 +366,7 @@ class MainWP_Child_Back_Up_Buddy {
$type = isset($_POST['type']) ? $_POST['type'] : '';
if ($type !== 'general_settings' && $type !== 'advanced_settings' && $type !== 'all' ) {
return array('error' => __('Invalid data!'), 'extra' => 'Invalid settings data!');
return array('error' => __('Invalid data. Please check and try again.') );
}
$filter_advanced_settings = array(
@ -697,25 +722,46 @@ class MainWP_Child_Back_Up_Buddy {
return $information;
}
// ok
public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncBackupBuddy'] ) && $data['syncBackupBuddy'] ) {
try {
$information['syncBackupBuddy'] = $this->get_sync_data();
} catch(Exception $e) {
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;
}
}
return $information;
}
if (!function_exists('backupbuddy_core::get_plugins_root'))
return false;
// ok
public function get_sync_data() {
$information = array();
$information['plugins_root'] = backupbuddy_core::get_plugins_root();
$information['themes_root'] = backupbuddy_core::get_themes_root();
$information['media_root'] = backupbuddy_core::get_media_root();
$information['additional_tables'] = $this->pb_additional_tables();
$information['abspath'] = ABSPATH;
return $information;
try {
if ( ! class_exists( 'backupbuddy_core' ) ) {
MainWP_Helper::check_classes_exists('pb_backupbuddy');
MainWP_Helper::check_methods('pb_backupbuddy', array( 'plugin_path' ) );
$plugin_path = pb_backupbuddy::plugin_path();
if (file_exists($plugin_path . '/classes/core.php'))
require_once( $plugin_path . '/classes/core.php' );
}
MainWP_Helper::check_classes_exists('backupbuddy_core');
MainWP_Helper::check_methods('backupbuddy_core', array( 'get_plugins_root', 'get_themes_root', 'get_media_root' ) );
$data = array();
$data['plugins_root'] = backupbuddy_core::get_plugins_root();
$data['themes_root'] = backupbuddy_core::get_themes_root();
$data['media_root'] = backupbuddy_core::get_media_root();
$data['additional_tables'] = $this->pb_additional_tables();
$data['abspath'] = ABSPATH;
return $data;
} catch(Exception $e) {
// not exit here
}
return false;
}
function backup_list() {
@ -970,9 +1016,15 @@ class MainWP_Child_Back_Up_Buddy {
}
// ok
function pb_additional_tables( $display_size = false ) {
MainWP_Helper::check_classes_exists('pb_backupbuddy');
MainWP_Helper::check_methods('pb_backupbuddy', 'plugin_url');
MainWP_Helper::check_properties('pb_backupbuddy', 'format');
MainWP_Helper::check_methods(pb_backupbuddy::$format, 'file_size');
$return = '';
$size_string = '';
@ -2456,7 +2508,7 @@ class MainWP_Child_Back_Up_Buddy {
backupbuddy_live::send_trim_settings();
return array('ok' => 1);
} else {
$error = 'Invalid data.';
$error = 'Invalid data. Please check and try again.';
}
return array('error' => $error);
}
@ -2475,7 +2527,7 @@ class MainWP_Child_Back_Up_Buddy {
require_once( pb_backupbuddy::plugin_path() . '/destinations/live/init.php' );
delete_transient( pb_backupbuddy_destination_live::LIVE_ACTION_TRANSIENT_NAME );
} else {
$error = 'Error: Not found.';
$error = 'Error: destination not found.';
}
$return['ok'] = 1;
} else {

View file

@ -15,10 +15,17 @@ class MainWP_Child_Back_Up_Wordpress {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if ( is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) {
$this->is_plugin_installed = true;
if ( version_compare( phpversion(), '5.3', '>=' ) ) {
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
}
}
}
public function init() {
if ( version_compare( phpversion(), '5.3', '<' ) ) {
return;
}
if ( get_option( 'mainwp_backupwordpress_ext_enabled' ) !== 'Y' ) return;
if (!$this->is_plugin_installed) return;
@ -115,24 +122,37 @@ class MainWP_Child_Back_Up_Wordpress {
return $schedule_id;
}
// ok
public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncBackUpWordPress'] ) && $data['syncBackUpWordPress'] ) {
try {
$information['syncBackUpWordPress'] = $this->get_sync_data();
} catch(Exception $e) {
public function syncData() {
if ( ! self::isActivated() ) {
return '';
}
return $this->get_sync_data();
}
}
return $information;
}
// ok
private function get_sync_data() {
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
MainWP_Helper::check_methods('HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ) );
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
$backups_time = array();
if (is_array($schedules) && count($schedules)) {
$check = current($schedules);
MainWP_Helper::check_methods($check, array( 'get_backups' ) );
foreach ( $schedules as $sche ) {
$existing_backup = $sche->get_backups();
if ( ! empty( $existing_backup ) ) {
$backups_time = array_merge( $backups_time, array_keys( $existing_backup ) );
}
}
}
$lasttime_backup = 0;
@ -153,13 +173,22 @@ class MainWP_Child_Back_Up_Wordpress {
}
}
// ok
public function do_reports_log($ext = '') {
if ( $ext !== 'backupwordpress' ) return;
if (!$this->is_plugin_installed) return;
try {
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
MainWP_Helper::check_methods('HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ));
// Refresh the schedules from the database to make sure we have the latest changes
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
if (is_array($schedules) && count($schedules) > 0) {
$check = current($schedules);
MainWP_Helper::check_methods($check, array( 'get_backups', 'get_type' ));
foreach($schedules as $schedule) {
foreach ( $schedule->get_backups() as $file ) {
$backup_type = $schedule->get_type();
@ -175,6 +204,10 @@ class MainWP_Child_Back_Up_Wordpress {
}
}
}
} catch(Exception $e) {
}
}
function set_showhide() {
$hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
@ -348,7 +381,7 @@ class MainWP_Child_Back_Up_Wordpress {
function hmbkp_request_delete_backup() {
if ( ! isset( $_POST['hmbkp_backuparchive'] ) || empty( $_POST['hmbkp_backuparchive'] ) ) {
return array( 'error' => __( 'Invalid data!', 'mainwp-child' ) );
return array( 'error' => __( 'Invalid data. Please check and try again.', 'mainwp-child' ) );
}
$schedule_id = $this->check_schedule();

View file

@ -52,22 +52,35 @@ class MainWP_Child_Back_WP_Up {
public function __construct() {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
try {
if ( is_plugin_active( 'backwpup-pro/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php' ) ) {
require_once( plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php' );
require_once( plugin_dir_path( __FILE__ ) . '../../backwpup-pro/inc/pro/class-pro.php' );
BackWPup::get_instance();
$file_path1 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php';
$file_path2 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/inc/pro/class-pro.php';
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
require_once( $file_path1 );
require_once( $file_path2 );
$this->is_backwpup_installed = true;
$this->is_backwpup_pro = true;
} else if ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) {
require_once( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' );
BackWPup::get_instance();
$file_path = plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php';
MainWP_Helper::check_files_exists(array( $file_path ));
require_once( $file_path );
$this->is_backwpup_installed = true;
}
if ( $this->is_backwpup_installed ) {
if ($this->is_backwpup_installed) {
MainWP_Helper::check_classes_exists('BackWPup');
MainWP_Helper::check_methods('get_instance');
BackWPup::get_instance();
add_action( 'wp_ajax_mainwp_backwpup_download_backup', array( $this, 'download_backup' ) );
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
}
} catch ( Exception $e) {
// do not exit()
$this->is_backwpup_installed = false;
}
}
public function action() {
@ -203,12 +216,16 @@ class MainWP_Child_Back_WP_Up {
$this->do_reports_log('backwpup');
}
}
// ok
public function do_reports_log($ext = '') {
if ( $ext !== 'backwpup' ) return;
if (!$this->is_backwpup_installed)
return;
try {
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();
@ -236,19 +253,30 @@ class MainWP_Child_Back_WP_Up {
}
}
}
} catch (Exception $ex) {
}
}
// ok
function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncBackwpupData'] ) ) {
if ( isset( $data['syncBackwpupData'] ) && $data['syncBackwpupData'] ) {
try{
$lastbackup = MainWP_Helper::get_lasttime_backup('backwpup');
$information['syncBackwpupData'] = array(
'lastbackup' => $lastbackup
);
} catch(Exception $e) {
}
}
return $information;
}
function get_destinations_list() {
MainWP_Helper::check_classes_exists(array('BackWPup', 'BackWPup_Option'));
MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' ));
MainWP_Helper::check_methods('BackWPup_Option', array( 'get_job_ids', 'get' ));
$jobdest = array();
$jobids = BackWPup_Option::get_job_ids();
@ -262,13 +290,16 @@ class MainWP_Child_Back_WP_Up {
if ( ! $destinations[ $dest ][ 'class' ] ) {
continue;
}
$dest_class = BackWPup::get_destination( $dest );
if ($dest_class && method_exists($dest_class, 'file_get_list')) {
$can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest );
if ( ! empty( $can_do_dest ) ) {
$jobdest[ ] = $jobid . '_' . $dest;
}
}
}
}
return $jobdest;
}

View file

@ -132,6 +132,8 @@ class MainWP_Child_Branding {
'remove_widget_activity' => $settings['child_remove_widget_activity'],
'remove_widget_quick' => $settings['child_remove_widget_quick'],
'remove_widget_news' => $settings['child_remove_widget_news'],
'login_image_link' => $settings['child_login_image_link'],
'login_image_title' => $settings['child_login_image_title'],
'site_generator' => $settings['child_site_generator'],
'generator_link' => $settings['child_generator_link'],
'admin_css' => $settings['child_admin_css'],
@ -339,6 +341,8 @@ class MainWP_Child_Branding {
add_action( 'login_enqueue_scripts', array( &$this, 'custom_login_css' ) );
add_filter( 'gettext', array( &$this, 'custom_gettext' ), 99, 3 );
add_action( 'login_head', array( &$this, 'custom_login_logo' ) );
add_filter( 'login_headerurl', array( &$this, 'custom_login_headerurl' ) );
add_filter( 'login_headertitle', array( &$this, 'custom_login_headertitle' ) );
add_action( 'wp_head', array( &$this, 'custom_favicon_frontend' ) );
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
//remove_filter( 'update_footer', 'core_update_footer' );
@ -564,6 +568,26 @@ class MainWP_Child_Branding {
}
}
function custom_login_headerurl( $value ) {
$extra_setting = $this->settings['extra_settings'];
if ( isset( $extra_setting['login_image_link'] ) && ! empty( $extra_setting['login_image_link'] ) ) {
return $extra_setting['login_image_link'];
}
return $value;
}
function custom_login_headertitle( $value ) {
$extra_setting = $this->settings['extra_settings'];
if ( isset( $extra_setting['login_image_title'] ) && ! empty( $extra_setting['login_image_title'] ) ) {
return $extra_setting['login_image_title'];
}
return $value;
}
function custom_gettext( $translations, $text, $domain = 'default' ) {
$extra_setting = $this->settings['extra_settings'];
$texts_replace = $extra_setting['texts_replace'];

View file

@ -23,17 +23,16 @@ class MainWP_Child_iThemes_Security {
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
}
// ok
function syncOthersData( $information, $data = array() ) {
if ( is_array( $data ) && isset( $data['ithemeExtActivated'] ) && ( 'yes' === $data['ithemeExtActivated'] ) ) {
try{
$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', '' );
} catch(Exception $e) {
error_log($e->getMessage());
}
}
return $information;
}
@ -58,9 +57,6 @@ class MainWP_Child_iThemes_Security {
case 'save_settings':
$information = $this->save_settings();
break;
// case 'whitelist':
// $information = $this->whitelist();
// break;
case 'whitelist_release':
$information = $this->whitelist_release();
break;
@ -73,18 +69,12 @@ class MainWP_Child_iThemes_Security {
case 'database_prefix':
$information = $this->change_database_prefix();
break;
// case 'api_key':
// $information = $this->api_key();
// break;
case 'reset_api_key':
$information = $this->reset_api_key();
break;
case 'malware_scan':
$information = $this->malware_scan();
break;
// case 'malware_get_scan_results':
// $information = $this->malware_get_scan_results();
// break;
case 'clear_all_logs':
$information = $this->purge_logs();
break;
@ -134,6 +124,11 @@ class MainWP_Child_iThemes_Security {
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
add_action( 'admin_menu', array( $this, 'remove_menu' ) );
add_action( 'admin_init', array( $this, 'admin_init' ) );
add_action( 'admin_head', array( &$this, 'custom_admin_css' ) );
if ( isset($_GET['page']) && ($_GET['page'] == 'itsec' || $_GET['page'] == 'itsec-logs' || $_GET['page'] == 'itsec-security-check') ) {
wp_redirect( get_option( 'siteurl' ) . '/wp-admin/index.php' );
exit();
}
}
}
@ -156,6 +151,16 @@ class MainWP_Child_iThemes_Security {
remove_menu_page( 'itsec' );
}
function custom_admin_css() {
?>
<style type="text/css">
#wp-admin-bar-itsec_admin_bar_menu{
display: none !important;
}
</style>
<?php
}
function save_settings() {
if ( ! class_exists( 'ITSEC_Lib' ) ) {
@ -1154,8 +1159,6 @@ class MainWP_Child_iThemes_Security {
global $mainwp_itsec_modules_path;
require_once( $mainwp_itsec_modules_path . 'security-check/scanner.php' );
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 );
@ -1164,6 +1167,7 @@ class MainWP_Child_iThemes_Security {
}
// source from itheme plugin
// ok
public function get_available_admin_users_and_roles() {
if ( is_callable( 'wp_roles' ) ) {
$roles = wp_roles();

View file

@ -18,6 +18,12 @@ class MainWP_Child_Links_Checker {
if ( is_plugin_active( 'broken-link-checker/broken-link-checker.php' ) ) {
$this->is_plugin_installed = true;
}
if ( !$this->is_plugin_installed )
return;
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
}
public function action() {
@ -27,16 +33,19 @@ class MainWP_Child_Links_Checker {
MainWP_Helper::write( $information );
}
blc_init();
// need this try()
try {
if ( isset( $_POST['mwp_action'] ) ) {
switch ( $_POST['mwp_action'] ) {
case 'set_showhide':
$information = $this->set_showhide();
break;
case 'sync_data':
$information = $this->sync_data();
$information = $this->get_sync_data();
break;
case 'sync_links_data':
$information = $this->sync_links_data();
$information = $this->get_links_data();
break;
case 'edit_link':
$information = $this->edit_link();
@ -59,6 +68,9 @@ class MainWP_Child_Links_Checker {
}
}
MainWP_Helper::write( $information );
} catch(Exception $e) {
MainWP_Helper::write( array('error' => $e->getMessage()) );
}
}
@ -182,7 +194,20 @@ class MainWP_Child_Links_Checker {
return $information;
}
function sync_data( $strategy = '' ) {
// ok
public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncBrokenLinksCheckerData'] ) && $data['syncBrokenLinksCheckerData'] ) {
try{
$information['syncBrokenLinksCheckerData'] = $this->get_sync_data();
} catch(Exception $e) {
}
}
return $information;
}
function get_sync_data( $strategy = '' ) {
$information = array();
$data = $this->get_count_links();
if (is_array($data))
@ -190,12 +215,24 @@ class MainWP_Child_Links_Checker {
return $information;
}
function sync_links_data() {
function get_links_data() {
if (!defined('BLC_DIRECTORY')) return;
require_once BLC_DIRECTORY . '/includes/link-query.php';
require_once BLC_DIRECTORY . '/includes/modules.php';
$file_path1 = BLC_DIRECTORY . '/includes/link-query.php';
$file_path2 = BLC_DIRECTORY . '/includes/modules.php';
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
require_once $file_path1;
require_once $file_path2;
MainWP_Helper::check_classes_exists('blcLinkQuery');
MainWP_Helper::check_methods('blcLinkQuery', 'getInstance');
$blc_link_query = blcLinkQuery::getInstance();
MainWP_Helper::check_methods($blc_link_query, 'get_filter_links');
$total = $blc_link_query->get_filter_links( 'all', array( 'count_only' => true ) );
@ -213,7 +250,7 @@ class MainWP_Child_Links_Checker {
$params['offset'] = $offset;
}
$link_data = $this->do_sync_links_data($params);
$link_data = $this->links_checker_data($params);
$total_sync = 0;
if ($offset){
@ -242,11 +279,22 @@ class MainWP_Child_Links_Checker {
function get_count_links() {
if (!defined('BLC_DIRECTORY')) return;
require_once BLC_DIRECTORY . '/includes/link-query.php';
require_once BLC_DIRECTORY . '/includes/modules.php';
$file_path1 = BLC_DIRECTORY . '/includes/link-query.php';
$file_path2 = BLC_DIRECTORY . '/includes/modules.php';
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
require_once $file_path1;
require_once $file_path2;
MainWP_Helper::check_classes_exists('blcLinkQuery');
MainWP_Helper::check_methods('blcLinkQuery', 'getInstance');
$data = array();
$blc_link_query = blcLinkQuery::getInstance();
MainWP_Helper::check_methods($blc_link_query, 'get_filter_links');
$data['broken'] = $blc_link_query->get_filter_links( 'broken', array( 'count_only' => true ) );
$data['redirects'] = $blc_link_query->get_filter_links( 'redirects', array( 'count_only' => true ) );
$data['dismissed'] = $blc_link_query->get_filter_links( 'dismissed', array( 'count_only' => true ) );
@ -255,7 +303,10 @@ class MainWP_Child_Links_Checker {
return $data;
}
function do_sync_links_data($params) {
function links_checker_data($params) {
MainWP_Helper::check_functions('blc_get_links');
MainWP_Helper::check_classes_exists('blcLink');
$links = blc_get_links( $params );
@ -320,12 +371,15 @@ class MainWP_Child_Links_Checker {
$get_link = new blcLink( intval( $link->link_id ) );
if ( $get_link->valid() ) {
MainWP_Helper::check_methods($get_link, 'get_instances');
$instances = $get_link->get_instances();
}
if ( ! empty( $instances ) ) {
$first_instance = reset( $instances );
MainWP_Helper::check_methods($first_instance, array( 'ui_get_link_text', 'get_container', 'is_link_text_editable', 'is_url_editable') );
$new_link->link_text = $first_instance->ui_get_link_text();
$extra_info['count_instance'] = count( $instances );
$container = $first_instance->get_container();
@ -333,10 +387,14 @@ class MainWP_Child_Links_Checker {
/** @var blcContainer $container */
if ( ! empty( $container ) /* && ($container instanceof blcAnyPostContainer) */ ) {
if (true === MainWP_Helper::check_properties($first_instance, array( 'container_field' ), true )) {
if (true === MainWP_Helper::check_properties($container, array( 'container_type', 'container_id' ), true )) {
$extra_info['container_type'] = $container->container_type;
$extra_info['container_id'] = $container->container_id;
$extra_info['source_data'] = $this->ui_get_source( $container, $first_instance->container_field );
}
}
}
$can_edit_text = false;
$can_edit_url = false;
@ -585,6 +643,9 @@ class MainWP_Child_Links_Checker {
$image = 'font-awesome/font-awesome-comment-alt.png';
}
if (true !== MainWP_Helper::check_methods($container, array( 'get_wrapped_object'), true ))
return false;
$comment = $container->get_wrapped_object();
//Display a small text sample from the comment

View file

@ -19,6 +19,11 @@ class MainWP_Child_Pagespeed {
$this->is_plugin_installed = true;
}
if (!$this->is_plugin_installed)
return;
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
add_action( 'mainwp_child_deactivation', array( $this, 'child_deactivation' ) );
}
@ -38,7 +43,7 @@ class MainWP_Child_Pagespeed {
$information = $this->set_showhide();
break;
case 'sync_data':
$information = $this->sync_data();
$information = $this->get_sync_data();
break;
case "check_pages":
$information = $this->check_pages();
@ -62,7 +67,6 @@ class MainWP_Child_Pagespeed {
if ( get_option( 'mainwp_pagespeed_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'hide_plugin' ) );
add_action('admin_menu', array($this, 'hide_menu'), 999);
//add_filter( 'update_footer', array( &$this, 'update_footer' ), 15 );
}
$this->init_cron();
}
@ -212,7 +216,7 @@ class MainWP_Child_Pagespeed {
$strategy = $current_values['strategy'];
$result = $this->sync_data( $strategy );
$result = $this->get_sync_data( $strategy );
if ( isset( $_POST['doaction'] ) && ( 'check_new_pages' === $_POST['doaction'] || 'recheck_all_pages' === $_POST['doaction'] ) ) {
if ( 'recheck_all_pages' === $_POST['doaction'] ) {
@ -257,7 +261,18 @@ class MainWP_Child_Pagespeed {
return $information;
}
public function sync_data( $strategy = '' ) {
public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncPageSpeedData'] ) && $data['syncPageSpeedData'] ) {
try{
$information['syncPageSpeedData'] = $this->get_sync_data();
} catch(Exception $e) {
}
}
return $information;
}
// ok
public function get_sync_data( $strategy = '' ) {
if ( empty( $strategy ) ) {
$strategy = 'both';
}

View file

@ -186,7 +186,7 @@ class MainWP_Child_Skeleton_Key {
$settings = isset($_POST['settings']) ? $_POST['settings'] : array();
if (!is_array($settings) || empty($settings))
return array('error' => 'Invalid data');
return array('error' => 'Invalid data. Please check and try again.');
$whitelist_options = array(
'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string', 'WPLANG' ),

View file

@ -21,6 +21,7 @@ class MainWP_Child_Staging {
if (!$this->is_plugin_installed)
return;
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
}
@ -31,8 +32,6 @@ class MainWP_Child_Staging {
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' ) );
@ -40,6 +39,17 @@ class MainWP_Child_Staging {
}
}
public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncWPStaging'] ) && $data['syncWPStaging'] ) {
try{
$information['syncWPStaging'] = $this->get_sync_data();
} catch(Exception $e) {
// do not exit
}
}
return $information;
}
// ok
public function get_sync_data() {
return $this->get_overview();
}

File diff suppressed because it is too large Load diff

View file

@ -2,7 +2,7 @@
class MainWP_Child_Updraft_Plus_Backups {
public static $instance = null;
public $is_plugin_installed = false;
static function Instance() {
if ( null === MainWP_Child_Updraft_Plus_Backups::$instance ) {
MainWP_Child_Updraft_Plus_Backups::$instance = new MainWP_Child_Updraft_Plus_Backups();
@ -12,6 +12,14 @@ class MainWP_Child_Updraft_Plus_Backups {
}
public function __construct() {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if ( is_plugin_active( 'updraftplus/updraftplus.php' ) && defined('UPDRAFTPLUS_DIR')) {
$this->is_plugin_installed = true;
}
if (!$this->is_plugin_installed)
return;
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
add_filter('updraftplus_save_last_backup', array( __CLASS__, 'hookUpdraftplusSaveLastBackup' ));
}
@ -26,34 +34,41 @@ class MainWP_Child_Updraft_Plus_Backups {
}
return $last_backup;
}
// ok
function syncOthersData( $information, $data = array() ) {
try{
if ( isset( $data['syncUpdraftData'] ) && $data['syncUpdraftData'] ) {
if ( self::isActivatedUpdraftplus() ) {
$information['syncUpdraftData'] = $this->syncData();
if ( $this->is_plugin_installed ) {
$information['syncUpdraftData'] = $this->get_sync_data();
}
}
if ( isset( $data['sync_Updraftvault_quota_text'] ) && $data['sync_Updraftvault_quota_text'] ) {
if ( self::isActivatedUpdraftplus() ) {
if ( $this->is_plugin_installed ) {
$information['sync_Updraftvault_quota_text'] = $this->connected_html();
}
}
} catch(Exception $e) {
}
return $information;
}
public function action() {
$information = array();
if ( ! self::isActivatedUpdraftplus() ) {
if ( ! $this->is_plugin_installed ) {
$information['error'] = 'NO_UPDRAFTPLUS';
MainWP_Helper::write( $information );
}
$this->required_files();
global $updraftplus;
if ( empty( $updraftplus ) && class_exists( 'UpdraftPlus' ) ) {
$updraftplus = new UpdraftPlus();
}
if ( empty( $updraftplus ) ) {
$information['error'] = 'Error empty object';
$information['error'] = 'Error empty updraftplus';
MainWP_Helper::write( $information );
}
@ -63,6 +78,7 @@ class MainWP_Child_Updraft_Plus_Backups {
MainWP_Helper::update_option( 'mainwp_updraftplus_ext_enabled', 'Y', 'yes' );
}
try {
switch ( $_POST['mwp_action'] ) {
case 'set_showhide':
$information = $this->set_showhide();
@ -112,7 +128,7 @@ class MainWP_Child_Updraft_Plus_Backups {
case 'restore_alldownloaded':
$information = $this->restore_alldownloaded();
break;
case 'restorebackup':
case 'restorebackup': // not used
$information = $this->restoreBackup();
break;
case 'extradbtestconnection':
@ -128,6 +144,9 @@ class MainWP_Child_Updraft_Plus_Backups {
$information = $this->vault_disconnect();
break;
}
} catch(Exception $e) {
$information = array('error' => $e->getMessage());
}
}
MainWP_Helper::write( $information );
}
@ -140,23 +159,6 @@ class MainWP_Child_Updraft_Plus_Backups {
return $information;
}
public static function isActivatedUpdraftplus() {
if ( ! defined( 'UPDRAFTPLUS_DIR' ) ) {
return false;
}
if ( ! class_exists( 'UpdraftPlus' ) ) {
require_once( UPDRAFTPLUS_DIR . '/class-updraftplus.php' );
}
if ( ! class_exists( 'UpdraftPlus_Options' ) ) {
require_once( UPDRAFTPLUS_DIR . '/options.php' );
}
return true;
}
private function get_settings_keys() {
return array(
'updraft_autobackup_default',
@ -245,6 +247,9 @@ class MainWP_Child_Updraft_Plus_Backups {
private function connected_html() {
MainWP_Helper::check_classes_exists('UpdraftPlus_Options');
MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option');
$vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' );
if ( !is_array( $vault_settings ) || empty( $vault_settings['token'] ) || empty( $vault_settings['email'] ) ) {
return '';
@ -372,6 +377,18 @@ class MainWP_Child_Updraft_Plus_Backups {
}
}
function required_files() {
if (defined('UPDRAFTPLUS_DIR')) {
if ( ! class_exists( 'UpdraftPlus' ) && file_exists( UPDRAFTPLUS_DIR . '/class-updraftplus.php') ) {
require_once( UPDRAFTPLUS_DIR . '/class-updraftplus.php' );
}
if ( ! class_exists( 'UpdraftPlus_Options' ) && file_exists( UPDRAFTPLUS_DIR . '/options.php' ) ) {
require_once( UPDRAFTPLUS_DIR . '/options.php' );
}
}
}
function save_settings() {
$settings = maybe_unserialize( base64_decode( $_POST['settings'] ) );
@ -385,6 +402,8 @@ class MainWP_Child_Updraft_Plus_Backups {
$settings_key = null;
if ( 'updraft_dropbox' === $key && is_array($settings[ $key ])) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dropbox' );
if (!is_array($opts))
$opts = array();
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
if (isset($settings['is_general']) && !empty($settings['is_general'])){
@ -406,6 +425,8 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else if ( 'updraft_googledrive' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_googledrive' );
if (!is_array($opts))
$opts = array();
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
@ -419,6 +440,8 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else if ( 'updraft_googlecloud' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( $key );
if (!is_array($opts))
$opts = array();
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
@ -438,6 +461,8 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else if ( 'updraft_onedrive' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_onedrive' );
if (!is_array($opts))
$opts = array();
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
@ -461,6 +486,8 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( $key, $value );
} else if ( 'updraft_s3' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3' );
if (!is_array($opts))
$opts = array();
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
$opts['settings'][$settings_key]['accesskey'] = $settings[ $key ]['accesskey'];
@ -489,6 +516,8 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else if ( 'updraft_s3generic' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3generic' );
if (!is_array($opts))
$opts = array();
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
$opts['settings'][$settings_key]['endpoint'] = $settings[ $key ]['endpoint'];
@ -505,6 +534,8 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else if ( 'updraft_dreamobjects' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dreamobjects' );
if (!is_array($opts))
$opts = array();
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
$opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']);
@ -514,6 +545,8 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else if ( 'updraft_ftp' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_ftp' );
if (!is_array($opts))
$opts = array();
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
if ( isset( $settings[ $key ]['path'] ) ) {
@ -536,6 +569,8 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else if ( 'updraft_sftp_settings' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_sftp' );
if (!is_array($opts))
$opts = array();
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
if ( isset( $settings[ $key ]['path'] ) ) {
@ -561,6 +596,8 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( 'updraft_sftp', $opts );
} else if ( 'updraft_backblaze' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_backblaze' );
if (!is_array($opts))
$opts = array();
if (is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
$opts['settings'][$settings_key]['account_id'] = $settings[ $key ]['account_id'];
@ -1000,6 +1037,11 @@ class MainWP_Child_Updraft_Plus_Backups {
$next_scheduled_backup = 'Nothing currently scheduled';
}
MainWP_Helper::check_classes_exists('UpdraftPlus_Options');
MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option');
MainWP_Helper::check_methods($updraftplus, array( 'backups_dir_location', 'really_is_writable' ));
$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' ) ) {
$next_scheduled_backup_database = ( 'Nothing currently scheduled' === $next_scheduled_backup ) ? $next_scheduled_backup : __( 'At the same time as the files backup', 'updraftplus' );
@ -1259,8 +1301,12 @@ class MainWP_Child_Updraft_Plus_Backups {
}
public function build_historystatus() {
$backup_history = UpdraftPlus_Options::get_updraft_option( 'updraft_backup_history' );
$backup_history = ( is_array( $backup_history ) ) ? $backup_history : array();
MainWP_Helper::check_classes_exists('UpdraftPlus_Backup_History');
MainWP_Helper::check_methods('UpdraftPlus_Backup_History', 'get_history');
$backup_history = UpdraftPlus_Backup_History::get_history();
$output = $this->existing_backup_table( $backup_history );
if ( ! empty( $messages ) && is_array( $messages ) ) {
@ -1285,8 +1331,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$messages = $this->rebuildBackupHistory( $remotescan );
}
$backup_history = UpdraftPlus_Options::get_updraft_option( 'updraft_backup_history' );
$backup_history = ( is_array( $backup_history ) ) ? $backup_history : array();
$backup_history = UpdraftPlus_Backup_History::get_history();
$output = $this->existing_backup_table( $backup_history );
if ( ! empty( $messages ) && is_array( $messages ) ) {
@ -1547,7 +1592,11 @@ class MainWP_Child_Updraft_Plus_Backups {
if ( isset( $elements['db'] ) ) {
// Analyse the header of the database file + display results
list ( $mess2, $warn2, $err2, $info ) = $this->analyse_db_file( $timestamp, $res );
if ( class_exists( 'UpdraftPlus_Encryption' )) {
list ( $mess2, $warn2, $err2, $info ) = $updraftplus->analyse_db_file( $timestamp, $res );
} else {
list ( $mess2, $warn2, $err2, $info ) = $this->analyse_db_file_old( $timestamp, $res );
}
$mess = array_merge( $mess, $mess2 );
$warn = array_merge( $warn, $warn2 );
$err = array_merge( $err, $err2 );
@ -1653,6 +1702,7 @@ class MainWP_Child_Updraft_Plus_Backups {
}
}
// not used
public function restoreBackup() {
global $updraftplus_admin, $updraftplus;
@ -1699,13 +1749,15 @@ class MainWP_Child_Updraft_Plus_Backups {
}
// not used
// Return values: false = 'not yet' (not necessarily terminal); WP_Error = terminal failure; true = success
private function restore_backup( $timestamp ) {
@set_time_limit( 900 );
global $wp_filesystem, $updraftplus;
$backup_history = UpdraftPlus_Options::get_updraft_option( 'updraft_backup_history' );
// $backup_history = UpdraftPlus_Options::get_updraft_option( 'updraft_backup_history' );
$backup_history = UpdraftPlus_Backup_History::get_history();
if ( ! is_array( $backup_history[ $timestamp ] ) ) {
echo wp_kses_post( '<p>' . esc_html__( 'This backup does not exist in the backup history - restoration aborted. Timestamp:', 'updraftplus' ) . " $timestamp</p><br/>" );
@ -2065,7 +2117,6 @@ class MainWP_Child_Updraft_Plus_Backups {
return true;
}
public function option_filter_template( $val ) {
global $updraftplus;
@ -2201,7 +2252,7 @@ class MainWP_Child_Updraft_Plus_Backups {
echo '<div class="updraftmessage ' . $class . '">' . "<p>$message</p></div>";
}
private function analyse_db_file( $timestamp, $res, $db_file = false, $header_only = false ) {
private function analyse_db_file_old( $timestamp, $res, $db_file = false, $header_only = false ) {
$mess = array();
$warn = array();
@ -2437,6 +2488,440 @@ class MainWP_Child_Updraft_Plus_Backups {
}
public function analyse_db_file($timestamp, $res, $db_file = false, $header_only = false) {
global $updraftplus;
$mess = array();
$warn = array();
$err = array();
$info = array();
$wp_version = $updraftplus->get_wordpress_version();
global $wpdb;
$updraft_dir = $updraftplus->backups_dir_location();
if (false === $db_file) {
// 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_Backup_History::get_history($timestamp);
if (!isset($backup['nonce']) || !isset($backup['db'])) return array($mess, $warn, $err, $info);
$db_file = (is_string($backup['db'])) ? $updraft_dir.'/'.$backup['db'] : $updraft_dir.'/'.$backup['db'][0];
}
if (!is_readable($db_file)) return array($mess, $warn, $err, $info);
// Encrypted - decrypt it
if (UpdraftPlus_Encryption::is_file_encrypted($db_file)) {
$encryption = empty($res['updraft_encryptionphrase']) ? UpdraftPlus_Options::get_updraft_option('updraft_encryptionphrase') : $res['updraft_encryptionphrase'];
if (!$encryption) {
if (class_exists('UpdraftPlus_Addon_MoreDatabase')) {
$err[] = sprintf(__('Error: %s', 'updraftplus'), __('Decryption failed. The database file is encrypted, but you have no encryption key entered.', 'updraftplus'));
} else {
$err[] = sprintf(__('Error: %s', 'updraftplus'), __('Decryption failed. The database file is encrypted.', 'updraftplus'));
}
return array($mess, $warn, $err, $info);
}
$decrypted_file = UpdraftPlus_Encryption::decrypt($db_file, $encryption);
if (is_array($decrypted_file)) {
$db_file = $decrypted_file['fullpath'];
} else {
$err[] = __('Decryption failed. The most likely cause is that you used the wrong key.', 'updraftplus');
return array($mess, $warn, $err, $info);
}
}
// Even the empty schema when gzipped comes to 1565 bytes; a blank WP 3.6 install at 5158. But we go low, in case someone wants to share single tables.
if (filesize($db_file) < 1000) {
$err[] = sprintf(__('The database is too small to be a valid WordPress database (size: %s Kb).', 'updraftplus'), round(filesize($db_file)/1024, 1));
return array($mess, $warn, $err, $info);
}
$is_plain = ('.gz' == substr($db_file, -3, 3)) ? false : true;
$dbhandle = ($is_plain) ? fopen($db_file, 'r') : $this->gzopen_for_read($db_file, $warn, $err);
if (!is_resource($dbhandle)) {
$err[] = __('Failed to open database file.', 'updraftplus');
return array($mess, $warn, $err, $info);
}
$info['timestamp'] = $timestamp;
// Analyse the file, print the results.
$line = 0;
$old_siteurl = '';
$old_home = '';
$old_table_prefix = '';
$old_siteinfo = array();
$gathering_siteinfo = true;
$old_wp_version = '';
$old_php_version = '';
$tables_found = array();
$db_charsets_found = array();
// TODO: If the backup is the right size/checksum, then we could restore the $line <= 100 in the 'while' condition and not bother scanning the whole thing? Or better: sort the core tables to be first so that this usually terminates early
$wanted_tables = array('terms', 'term_taxonomy', 'term_relationships', 'commentmeta', 'comments', 'links', 'options', 'postmeta', 'posts', 'users', 'usermeta');
$migration_warning = false;
$processing_create = false;
$db_version = $wpdb->db_version();
// Don't set too high - we want a timely response returned to the browser
// Until April 2015, this was always 90. But we've seen a few people with ~1GB databases (uncompressed), and 90s is not enough. Note that we don't bother checking here if it's compressed - having a too-large timeout when unexpected is harmless, as it won't be hit. On very large dbs, they're expecting it to take a while.
// "120 or 240" is a first attempt at something more useful than just fixed at 90 - but should be sufficient (as 90 was for everyone without ~1GB databases)
$default_dbscan_timeout = (filesize($db_file) < 31457280) ? 120 : 240;
$dbscan_timeout = (defined('UPDRAFTPLUS_DBSCAN_TIMEOUT') && is_numeric(UPDRAFTPLUS_DBSCAN_TIMEOUT)) ? UPDRAFTPLUS_DBSCAN_TIMEOUT : $default_dbscan_timeout;
@set_time_limit($dbscan_timeout);
// We limit the time that we spend scanning the file for character sets
$db_charset_collate_scan_timeout = (defined('UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT') && is_numeric(UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT)) ? UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT : 10;
$charset_scan_start_time = microtime(true);
$db_supported_character_sets_res = $GLOBALS['wpdb']->get_results('SHOW CHARACTER SET', OBJECT_K);
$db_supported_character_sets = (null !== $db_supported_character_sets_res) ? $db_supported_character_sets_res : array();
$db_charsets_found = array();
$db_supported_collations_res = $GLOBALS['wpdb']->get_results('SHOW COLLATION', OBJECT_K);
$db_supported_collations = (null !== $db_supported_collations_res) ? $db_supported_collations_res : array();
$db_charsets_found = array();
$db_collates_found = array();
$db_supported_charset_related_to_unsupported_collation = false;
$db_supported_charsets_related_to_unsupported_collations = array();
while ((($is_plain && !feof($dbhandle)) || (!$is_plain && !gzeof($dbhandle))) && ($line<100 || (!$header_only && count($wanted_tables)>0) || ((microtime(true) - $charset_scan_start_time) < $db_charset_collate_scan_timeout && !empty($db_supported_character_sets)))) {
$line++;
// Up to 1MB
$buffer = ($is_plain) ? rtrim(fgets($dbhandle, 1048576)) : rtrim(gzgets($dbhandle, 1048576));
// Comments are what we are interested in
if (substr($buffer, 0, 1) == '#') {
$processing_create = false;
if ('' == $old_siteurl && preg_match('/^\# Backup of: (http(.*))$/', $buffer, $matches)) {
$old_siteurl = untrailingslashit($matches[1]);
$mess[] = __('Backup of:', 'updraftplus').' '.htmlspecialchars($old_siteurl).((!empty($old_wp_version)) ? ' '.sprintf(__('(version: %s)', 'updraftplus'), $old_wp_version) : '');
// Check for should-be migration
if (untrailingslashit(site_url()) != $old_siteurl) {
if (!$migration_warning) {
$migration_warning = true;
$info['migration'] = true;
// && !class_exists('UpdraftPlus_Addons_Migrator')
if (UpdraftPlus_Manipulation_Functions::normalise_url($old_siteurl) == UpdraftPlus_Manipulation_Functions::normalise_url(site_url())) {
// Same site migration with only http/https difference
$info['same_url'] = false;
$old_siteurl_parsed = parse_url($old_siteurl);
$actual_siteurl_parsed = parse_url(site_url());
if ((stripos($old_siteurl_parsed['host'], 'www.') === 0 && stripos($actual_siteurl_parsed['host'], 'www.') !== 0) || (stripos($old_siteurl_parsed['host'], 'www.') !== 0 && stripos($actual_siteurl_parsed['host'], 'www.') === 0)) {
$powarn = sprintf(__('The website address in the backup set (%s) is slightly different from that of the site now (%s). This is not expected to be a problem for restoring the site, as long as visits to the former address still reach the site.', 'updraftplus'), $old_siteurl, site_url()).' ';
} else {
$powarn = '';
}
if (('https' == $old_siteurl_parsed['scheme'] && 'http' == $actual_siteurl_parsed['scheme']) || ('http' == $old_siteurl_parsed['scheme'] && 'https' == $actual_siteurl_parsed['scheme'])) {
$powarn .= sprintf(__('This backup set is of this site, but at the time of the backup you were using %s, whereas the site now uses %s.', 'updraftplus'), $old_siteurl_parsed['scheme'], $actual_siteurl_parsed['scheme']);
if ('https' == $old_siteurl_parsed['scheme']) {
$powarn .= ' '.apply_filters('updraftplus_https_to_http_additional_warning', sprintf(__('This restoration will work if you still have an SSL certificate (i.e. can use https) to access the site. Otherwise, you will want to use %s to search/replace the site address so that the site can be visited without https.', 'updraftplus'), '<a href="https://updraftplus.com/shop/migrator/">'.__('the migrator add-on', 'updraftplus').'</a>'));
} else {
$powarn .= ' '.apply_filters('updraftplus_http_to_https_additional_warning', sprintf(__('As long as your web hosting allows http (i.e. non-SSL access) or will forward requests to https (which is almost always the case), this is no problem. If that is not yet set up, then you should set it up, or use %s so that the non-https links are automatically replaced.', 'updraftplus'), apply_filters('updraftplus_migrator_addon_link', '<a href="https://updraftplus.com/shop/migrator/">'.__('the migrator add-on', 'updraftplus').'</a>')));
}
} else {
$powarn .= apply_filters('updraftplus_dbscan_urlchange_www_append_warning', '');
}
$warn[] = $powarn;
} else {
// For completely different site migration
$info['same_url'] = false;
$warn[] = apply_filters('updraftplus_dbscan_urlchange', '<a href="https://updraftplus.com/shop/migrator/">'.__('This backup set is from a different site - this is not a restoration, but a migration. You need the Migrator add-on in order to make this work.', 'updraftplus').'</a>', $old_siteurl, $res);
}
if (!class_exists('UpdraftPlus_Addons_Migrator')) {
$warn[] .= '<strong><a href="'.apply_filters('updraftplus_com_link', "https://updraftplus.com/faqs/tell-me-more-about-the-search-and-replace-site-location-in-the-database-option/").'">'.__('You can search and replace your database (for migrating a website to a new location/URL) with the Migrator add-on - follow this link for more information', 'updraftplus').'</a></strong>';
}
}
if ($updraftplus->mod_rewrite_unavailable(false)) {
$warn[] = sprintf(__('You are using the %s webserver, but do not seem to have the %s module loaded.', 'updraftplus'), 'Apache', 'mod_rewrite').' '.sprintf(__('You should enable %s to make any pretty permalinks (e.g. %s) work', 'updraftplus'), 'mod_rewrite', 'http://example.com/my-page/');
}
} else {
// For exactly same URL site restoration
$info['same_url'] = true;
}
} elseif ('' == $old_home && preg_match('/^\# Home URL: (http(.*))$/', $buffer, $matches)) {
$old_home = untrailingslashit($matches[1]);
// Check for should-be migration
if (!$migration_warning && home_url() != $old_home) {
$migration_warning = true;
$powarn = apply_filters('updraftplus_dbscan_urlchange', '<a href="https://updraftplus.com/shop/migrator/">'.__('This backup set is from a different site - this is not a restoration, but a migration. You need the Migrator add-on in order to make this work.', 'updraftplus').'</a>', $old_home, $res);
if (!empty($powarn)) $warn[] = $powarn;
}
} elseif (!isset($info['created_by_version']) && preg_match('/^\# Created by UpdraftPlus version ([\d\.]+)/', $buffer, $matches)) {
$info['created_by_version'] = trim($matches[1]);
} elseif ('' == $old_wp_version && preg_match('/^\# WordPress Version: ([0-9]+(\.[0-9]+)+)(-[-a-z0-9]+,)?(.*)$/', $buffer, $matches)) {
$old_wp_version = $matches[1];
if (!empty($matches[3])) $old_wp_version .= substr($matches[3], 0, strlen($matches[3])-1);
if (version_compare($old_wp_version, $wp_version, '>')) {
// $mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version);
$warn[] = sprintf(__('You are importing from a newer version of WordPress (%s) into an older one (%s). There are no guarantees that WordPress can handle this.', 'updraftplus'), $old_wp_version, $wp_version);
}
if (preg_match('/running on PHP ([0-9]+\.[0-9]+)(\s|\.)/', $matches[4], $nmatches) && preg_match('/^([0-9]+\.[0-9]+)(\s|\.)/', PHP_VERSION, $cmatches)) {
$old_php_version = $nmatches[1];
$current_php_version = $cmatches[1];
if (version_compare($old_php_version, $current_php_version, '>')) {
// $mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version);
$warn[] = sprintf(__('The site in this backup was running on a webserver with version %s of %s. ', 'updraftplus'), $old_php_version, 'PHP').' '.sprintf(__('This is significantly newer than the server which you are now restoring onto (version %s).', 'updraftplus'), PHP_VERSION).' '.sprintf(__('You should only proceed if you cannot update the current server and are confident (or willing to risk) that your plugins/themes/etc. are compatible with the older %s version.', 'updraftplus'), 'PHP').' '.sprintf(__('Any support requests to do with %s should be raised with your web hosting company.', 'updraftplus'), 'PHP');
}
}
} elseif ('' == $old_table_prefix && (preg_match('/^\# Table prefix: (\S+)$/', $buffer, $matches) || preg_match('/^-- Table prefix: (\S+)$/i', $buffer, $matches))) {
$old_table_prefix = $matches[1];
// echo '<strong>'.__('Old table prefix:', 'updraftplus').'</strong> '.htmlspecialchars($old_table_prefix).'<br>';
} elseif (empty($info['label']) && preg_match('/^\# Label: (.*)$/', $buffer, $matches)) {
$info['label'] = $matches[1];
$mess[] = __('Backup label:', 'updraftplus').' '.htmlspecialchars($info['label']);
} elseif ($gathering_siteinfo && preg_match('/^\# Site info: (\S+)$/', $buffer, $matches)) {
if ('end' == $matches[1]) {
$gathering_siteinfo = false;
// Sanity checks
if (isset($old_siteinfo['multisite']) && !$old_siteinfo['multisite'] && is_multisite()) {
// Just need to check that you're crazy
// if (!defined('UPDRAFTPLUS_EXPERIMENTAL_IMPORTINTOMULTISITE') || !UPDRAFTPLUS_EXPERIMENTAL_IMPORTINTOMULTISITE) {
// $err[] = sprintf(__('Error: %s', 'updraftplus'), __('You are running on WordPress multisite - but your backup is not of a multisite site.', 'updraftplus'));
// return array($mess, $warn, $err, $info);
// } else {
$warn[] = __('You are running on WordPress multisite - but your backup is not of a multisite site.', 'updraftplus').' '.__('It will be imported as a new site.', 'updraftplus').' <a href="https://updraftplus.com/information-on-importing-a-single-site-wordpress-backup-into-a-wordpress-network-i-e-multisite/">'.__('Please read this link for important information on this process.', 'updraftplus').'</a>';
// }
// Got the needed code?
if (!class_exists('UpdraftPlusAddOn_MultiSite') || !class_exists('UpdraftPlus_Addons_Migrator')) {
$err[] = sprintf(__('Error: %s', 'updraftplus'), sprintf(__('To import an ordinary WordPress site into a multisite installation requires %s.', 'updraftplus'), 'UpdraftPlus Premium'));
return array($mess, $warn, $err, $info);
}
} elseif (isset($old_siteinfo['multisite']) && $old_siteinfo['multisite'] && !is_multisite()) {
$warn[] = __('Warning:', 'updraftplus').' '.__('Your backup is of a WordPress multisite install; but this site is not. Only the first site of the network will be accessible.', 'updraftplus').' <a href="https://codex.wordpress.org/Create_A_Network">'.__('If you want to restore a multisite backup, you should first set up your WordPress installation as a multisite.', 'updraftplus').'</a>';
}
} elseif (preg_match('/^([^=]+)=(.*)$/', $matches[1], $kvmatches)) {
$key = $kvmatches[1];
$val = $kvmatches[2];
if ('multisite' == $key) {
$info['multisite'] = $val ? true : false;
if ($val) $mess[] = '<strong>'.__('Site information:', 'updraftplus').'</strong> '.'backup is of a WordPress Network';
}
$old_siteinfo[$key] = $val;
}
} elseif (preg_match('/^\# Skipped tables: (.*)$/', $buffer, $matches)) {
$skipped_tables = explode(',', $matches[1]);
}
} elseif (preg_match('/^\s*create table \`?([^\`\(]*)\`?\s*\(/i', $buffer, $matches)) {
$table = $matches[1];
$tables_found[] = $table;
if ($old_table_prefix) {
// Remove prefix
$table = UpdraftPlus_Manipulation_Functions::str_replace_once($old_table_prefix, '', $table);
if (in_array($table, $wanted_tables)) {
$wanted_tables = array_diff($wanted_tables, array($table));
}
}
if (';' != substr($buffer, -1, 1)) {
$processing_create = true;
$db_supported_charset_related_to_unsupported_collation = true;
}
} elseif ($processing_create) {
if (!empty($db_supported_collations)) {
if (preg_match('/ COLLATE=([^\s;]+)/i', $buffer, $collate_match)) {
$db_collates_found[] = $collate_match[1];
if (!isset($db_supported_collations[$collate_match[1]])) {
$db_supported_charset_related_to_unsupported_collation = true;
}
}
if (preg_match('/ COLLATE ([a-zA-Z0-9._-]+),/i', $buffer, $collate_match)) {
$db_collates_found[] = $collate_match[1];
if (!isset($db_supported_collations[$collate_match[1]])) {
$db_supported_charset_related_to_unsupported_collation = true;
}
}
if (preg_match('/ COLLATE ([a-zA-Z0-9._-]+) /i', $buffer, $collate_match)) {
$db_collates_found[] = $collate_match[1];
if (!isset($db_supported_collations[$collate_match[1]])) {
$db_supported_charset_related_to_unsupported_collation = true;
}
}
}
if (!empty($db_supported_character_sets)) {
if (preg_match('/ CHARSET=([^\s;]+)/i', $buffer, $charset_match)) {
$db_charsets_found[] = $charset_match[1];
if ($db_supported_charset_related_to_unsupported_collation && !in_array($charset_match[1], $db_supported_charsets_related_to_unsupported_collations)) {
$db_supported_charsets_related_to_unsupported_collations[] = $charset_match[1];
}
}
}
if (';' == substr($buffer, -1, 1)) {
$processing_create = false;
$db_supported_charset_related_to_unsupported_collation = false;
}
static $mysql_version_warned = false;
if (!$mysql_version_warned && version_compare($db_version, '5.2.0', '<') && preg_match('/(CHARSET|COLLATE)[= ]utf8mb4/', $buffer)) {
$mysql_version_warned = true;
$err[] = sprintf(__('Error: %s', 'updraftplus'), sprintf(__('The database backup uses MySQL features not available in the old MySQL version (%s) that this site is running on.', 'updraftplus'), $db_version).' '.__('You must upgrade MySQL to be able to use this database.', 'updraftplus'));
}
}
}
if ($is_plain) {
@fclose($dbhandle);
} else {
@gzclose($dbhandle);
}
if (!empty($db_supported_character_sets)) {
$db_charsets_found_unique = array_unique($db_charsets_found);
$db_unsupported_charset = array();
$db_charset_forbidden = false;
foreach ($db_charsets_found_unique as $db_charset) {
if (!isset($db_supported_character_sets[$db_charset])) {
$db_unsupported_charset[] = $db_charset;
$db_charset_forbidden = true;
}
}
if ($db_charset_forbidden) {
$db_unsupported_charset_unique = array_unique($db_unsupported_charset);
$warn[] = sprintf(_n("The database server that this WordPress site is running on doesn't support the character set (%s) which you are trying to import.", "The database server that this WordPress site is running on doesn't support the character sets (%s) which you are trying to import.", count($db_unsupported_charset_unique), 'updraftplus'), implode(', ', $db_unsupported_charset_unique)).' '.__('You can choose another suitable character set instead and continue with the restoration at your own risk.', 'updraftplus').' <a target="_blank" href="https://updraftplus.com/faqs/implications-changing-tables-character-set/">'.__('Go here for more information.', 'updraftplus').'</a>'.' <a target="_blank" href="https://updraftplus.com/faqs/implications-changing-tables-character-set/">'.__('Go here for more information.', 'updraftplus').'</a>';
$db_supported_character_sets = array_keys($db_supported_character_sets);
$similar_type_charset = UpdraftPlus_Manipulation_Functions::get_matching_str_from_array_elems($db_unsupported_charset_unique, $db_supported_character_sets, true);
if (empty($similar_type_charset)) {
$row = $GLOBALS['wpdb']->get_row('show variables like "character_set_database"');
$similar_type_charset = (null !== $row) ? $row->Value : '';
}
if (empty($similar_type_charset) && !empty($db_supported_character_sets[0])) {
$similar_type_charset = $db_supported_character_sets[0];
}
$charset_select_html = '<label>'.__('Your chosen character set to use instead:', 'updraftplus').'</label> ';
$charset_select_html .= '<select name="updraft_restorer_charset" id="updraft_restorer_charset">';
if (is_array($db_supported_character_sets)) {
foreach ($db_supported_character_sets as $character_set) {
$charset_select_html .= '<option value="'.esc_attr($character_set).'" '.selected($character_set, $similar_type_charset, false).'>'.esc_html($character_set).'</option>';
}
}
$charset_select_html .= '</select>';
if (empty($info['addui'])) $info['addui'] = '';
$info['addui'] .= $charset_select_html;
}
}
if (!empty($db_supported_collations)) {
$db_collates_found_unique = array_unique($db_collates_found);
$db_unsupported_collate = array();
$db_collate_forbidden = false;
foreach ($db_collates_found_unique as $db_collate) {
if (!isset($db_supported_collations[$db_collate])) {
$db_unsupported_collate[] = $db_collate;
$db_collate_forbidden = true;
}
}
if ($db_collate_forbidden) {
$db_unsupported_collate_unique = array_unique($db_unsupported_collate);
$warn[] = sprintf(_n("The database server that this WordPress site is running on doesn't support the collation (%s) used in the database which you are trying to import.", "The database server that this WordPress site is running on doesn't support multiple collations (%s) used in the database which you are trying to import.", count($db_unsupported_collate_unique), 'updraftplus'), implode(', ', $db_unsupported_collate_unique)).' '.__('You can choose another suitable collation instead and continue with the restoration (at your own risk).', 'updraftplus');
$similar_type_collate = '';
if ($db_charset_forbidden && !empty($similar_type_charset)) {
$similar_type_collate = $updraftplus->get_similar_collate_related_to_charset($db_supported_collations, $db_unsupported_collate_unique, $similar_type_charset);
}
if (empty($similar_type_collate) && !empty($db_supported_charsets_related_to_unsupported_collations)) {
$db_supported_collations_related_to_charset = array();
foreach ($db_supported_collations as $db_supported_collation => $db_supported_collations_info_obj) {
if (isset($db_supported_collations_info_obj->Charset) && in_array($db_supported_collations_info_obj->Charset, $db_supported_charsets_related_to_unsupported_collations)) {
$db_supported_collations_related_to_charset[] = $db_supported_collation;
}
}
if (!empty($db_supported_collations_related_to_charset)) {
$similar_type_collate = UpdraftPlus_Manipulation_Functions::get_matching_str_from_array_elems($db_unsupported_collate_unique, $db_supported_collations_related_to_charset, false);
}
}
if (empty($similar_type_collate)) {
$similar_type_collate = $updraftplus->get_similar_collate_based_on_ocuurence_count($db_collates_found, $db_supported_collations, $db_supported_charsets_related_to_unsupported_collations);
}
if (empty($similar_type_collate)) {
$similar_type_collate = UpdraftPlus_Manipulation_Functions::get_matching_str_from_array_elems($db_unsupported_collate_unique, array_keys($db_supported_collations), false);
}
$collate_select_html = '<label>'.__('Your chosen replacement collation', 'updraftplus').':</label>';
$collate_select_html .= '<select name="updraft_restorer_collate" id="updraft_restorer_collate">';
foreach ($db_supported_collations as $collate => $collate_info_obj) {
$option_other_attr = array();
if ($db_charset_forbidden && isset($collate_info_obj->Charset)) {
$option_other_attr[] = 'data-charset='.esc_attr($collate_info_obj->Charset);
if ($similar_type_charset != $collate_info_obj->Charset) {
$option_other_attr[] = 'style="display:none;"';
}
}
$collate_select_html .= '<option value="'.esc_attr($collate).'" '.selected($collate, $similar_type_collate, $echo = false).' '.implode(' ', $option_other_attr).'>'.esc_html($collate).'</option>';
}
$collate_select_html .= '</select>';
$info['addui'] = empty($info['addui']) ? $collate_select_html : $info['addui'].'<br>'.$collate_select_html;
if ($db_charset_forbidden) {
$collate_change_on_charset_selection_data = array(
'db_supported_collations' => $db_supported_collations,
'db_unsupported_collate_unique' => $db_unsupported_collate_unique,
'db_collates_found' => $db_collates_found,
);
$info['addui'] .= '<input type="hidden" name="collate_change_on_charset_selection_data" id="collate_change_on_charset_selection_data" value="'.esc_attr(json_encode($collate_change_on_charset_selection_data)).'">';
}
}
}
/* $blog_tables = "CREATE TABLE $wpdb->terms (
CREATE TABLE $wpdb->term_taxonomy (
CREATE TABLE $wpdb->term_relationships (
CREATE TABLE $wpdb->commentmeta (
CREATE TABLE $wpdb->comments (
CREATE TABLE $wpdb->links (
CREATE TABLE $wpdb->options (
CREATE TABLE $wpdb->postmeta (
CREATE TABLE $wpdb->posts (
$users_single_table = "CREATE TABLE $wpdb->users (
$users_multi_table = "CREATE TABLE $wpdb->users (
$usermeta_table = "CREATE TABLE $wpdb->usermeta (
$ms_global_tables = "CREATE TABLE $wpdb->blogs (
CREATE TABLE $wpdb->blog_versions (
CREATE TABLE $wpdb->registration_log (
CREATE TABLE $wpdb->site (
CREATE TABLE $wpdb->sitemeta (
CREATE TABLE $wpdb->signups (
*/
if (!isset($skipped_tables)) $skipped_tables = array();
$missing_tables = array();
if ($old_table_prefix) {
if (!$header_only) {
foreach ($wanted_tables as $table) {
if (!in_array($old_table_prefix.$table, $tables_found)) {
$missing_tables[] = $table;
}
}
foreach ($missing_tables as $key => $value) {
if (in_array($old_table_prefix.$value, $skipped_tables)) {
unset($missing_tables[$key]);
}
}
if (count($missing_tables)>0) {
$warn[] = sprintf(__('This database backup is missing core WordPress tables: %s', 'updraftplus'), implode(', ', $missing_tables));
}
if (count($skipped_tables)>0) {
$warn[] = sprintf(__('This database backup has the following WordPress tables excluded: %s', 'updraftplus'), implode(', ', $skipped_tables));
}
}
} else {
if (empty($backup['meta_foreign'])) {
$warn[] = __('UpdraftPlus was unable to find the table prefix when scanning the database backup.', 'updraftplus');
}
}
// //need to make sure that we reset the file back to .crypt before clean temp files
// $db_file = $decrypted_file['fullpath'].'.crypt';
// unlink($decrypted_file['fullpath']);
return array($mess, $warn, $err, $info);
}
private function gzopen_for_read( $file, &$warn, &$err ) {
if ( ! function_exists( 'gzopen' ) || ! function_exists( 'gzread' ) ) {
$missing = '';
@ -2527,15 +3012,15 @@ class MainWP_Child_Updraft_Plus_Backups {
global $updraftplus;
if ( false === $backup_history ) {
$backup_history = UpdraftPlus_Options::get_updraft_option( 'updraft_backup_history' );
}
if ( ! is_array( $backup_history ) ) {
$backup_history = array();
$backup_history = UpdraftPlus_Backup_History::get_history();
}
if ( empty( $backup_history ) ) {
return '<p><em>' . __( 'You have not yet made any backups.', 'updraftplus' ) . '</em></p>';
}
MainWP_Helper::check_methods($updraftplus, array( 'backups_dir_location', 'get_backupable_file_entities' ));
$updraft_dir = $updraftplus->backups_dir_location();
$backupable_entities = $updraftplus->get_backupable_file_entities( true, true );
@ -2547,7 +3032,6 @@ class MainWP_Child_Updraft_Plus_Backups {
$ret = '<table style="margin-top: 20px; margin-left: 20px;">';
$nonce_field = wp_nonce_field( 'updraftplus_download', '_wpnonce', true, false );
//".__('Actions', 'updraftplus')."
$ret .= '<thead>
<tr style="margin-bottom: 4px;">
<th style="padding:0px 10px 6px; width: 172px;">' . __( 'Backup date', 'updraftplus' ) . '</th>
@ -2559,9 +3043,6 @@ class MainWP_Child_Updraft_Plus_Backups {
</tr>
</thead>
<tbody>';
// $ret .= "<thead>
// </thead>
// <tbody>";
krsort( $backup_history );
foreach ( $backup_history as $key => $backup ) {
@ -2607,13 +3088,14 @@ ENDHERE;
// Set a flag according to whether or not $backup['db'] ends in .crypt, then pick this up in the display of the decrypt field.
$db = is_array( $backup['db'] ) ? $backup['db'][0] : $backup['db'];
if ( $updraftplus->is_db_encrypted( $db ) ) {
if ( class_exists( 'UpdraftPlus_Encryption')) {
if ( method_exists('UpdraftPlus_Encryption', 'is_file_encrypted'))
if (UpdraftPlus_Encryption::is_file_encrypted($db)) $entities .= '/dbcrypted=1/';
} else if ( method_exists($updraftplus, 'is_db_encrypted') && $updraftplus->is_db_encrypted( $db ) ) {
$entities .= '/dbcrypted=1/';
}
$ret .= $this->download_db_button( 'db', $key, $esc_pretty_date, $nonce_field, $backup, $accept );
} else {
// $ret .= sprintf(_x('(No %s)','Message shown when no such object is available','updraftplus'), __('database', 'updraftplus'));
}
# External databases
@ -2679,9 +3161,7 @@ ENDHERE;
$show_data .= ' ' . __( '(backup set imported from remote storage)', 'updraftplus' );
}
# jQuery('#updraft_restore_label_wpcore').html('".esc_js($wpcore_restore_descrip)."');
$ret .= '<button title="' . __( 'After pressing this button, you will be given the option to choose which components you wish to restore', 'updraftplus' ) . '" type="button" class="button-primary" onclick="' . "mainwp_updraft_restore_setoptions('$entities', this);
jQuery('#updraft_restore_timestamp').val('$key'); jQuery('.updraft_restore_date').html('$show_data'); ";
$ret .= "mwp_updraft_restore_stage = 1; jQuery('#mwp-updraft-restore-modal').dialog('open'); jQuery('#mwp-updraft-restore-modal-stage1').show();jQuery('#mwp-updraft-restore-modal-stage2').hide(); jQuery('#mwp-updraft-restore-modal-stage2a').html(''); mainwp_updraft_activejobs_update(true);\">" . __( 'Restore', 'updraftplus' ) . '</button>';
$ret .= '<button title="' . __( 'Go to Restore', 'updraftplus' ) . '" type="button" class="button-primary mwp-updraftplus-restore-btn" >' . __( 'Restore', 'updraftplus' ) . '</button>';
}
$ret .= "</form></div>\n";
@ -3429,20 +3909,6 @@ ENDHERE;
function remove_notices() {
$remove_hooks['all_admin_notices'] = array(
// 'UpdraftPlus_Admin' => array(
// 'show_admin_notice_upgradead' => 10,
// 'show_admin_warning_googledrive' => 10,
// 'show_admin_warning_dropbox' => 10,
// 'show_admin_warning_bitcasa' => 10,
// 'show_admin_warning_copycom' => 10,
// 'show_admin_warning_onedrive' => 10,
// 'show_admin_warning_updraftvault' => 10,
// 'show_admin_warning_diskspace' => 10,
// 'show_admin_warning_disabledcron' => 10,
// 'show_admin_nosettings_warning' => 10,
// 'show_admin_warning_execution_time' => 10,
// 'show_admin_warning_litespeed' => 10,
// ),
'UpdraftPlus' => array(
'show_admin_warning_unreadablelog' => 10,
'show_admin_warning_nolog' => 10,
@ -3454,9 +3920,6 @@ ENDHERE;
'UpdraftPlus_BackupModule_googledrive' => array(
'show_authed_admin_success' => 10,
),
// 'UpdraftPlus_Options' => array(
// 'show_admin_warning_multisite' => 10
// )
);
foreach ( $remove_hooks as $hook_name => $hooks ) {
@ -3496,11 +3959,8 @@ ENDHERE;
return $value;
}
public function syncData() {
if ( ! self::isActivatedUpdraftplus() ) {
return '';
}
public function get_sync_data() {
$this->required_files();
return $this->get_updraft_data();
}

View file

@ -22,6 +22,7 @@ class MainWP_Child_Wordfence {
'alertOn_block',
'alertOn_critical',
'alertOn_loginLockout',
'alertOn_breachLogin',
'alertOn_lostPasswdForm',
'alertOn_nonAdminLogin',
'alertOn_firstNonAdminLoginOnly',
@ -43,10 +44,13 @@ class MainWP_Child_Wordfence {
"notification_productUpdates",
"notification_scanStatus",
'loginSec_lockInvalidUsers',
'loginSec_breachPasswds_enabled',
'loginSec_breachPasswds',
'loginSec_lockoutMins',
'loginSec_maskLoginErrors',
'loginSec_maxFailures',
'loginSec_maxForgotPasswd',
'loginSec_strongPasswds_enabled',
'loginSec_strongPasswds',
'loginSec_userBlacklist',
'loginSecurityEnabled',
@ -114,6 +118,7 @@ class MainWP_Child_Wordfence {
'debugOn',
'deleteTablesOnDeact',
'disableCookies',
'liveActivityPauseEnabled',
'startScansRemotely',
//'disableConfigCaching',
//'addCacheComment', // removed
@ -178,6 +183,7 @@ class MainWP_Child_Wordfence {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
// ok
if ( is_plugin_active( 'wordfence/wordfence.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../wordfence/wordfence.php' ) ) {
require_once( plugin_dir_path( __FILE__ ) . '../../wordfence/wordfence.php' );
$this->is_wordfence_installed = true;
@ -437,6 +443,7 @@ class MainWP_Child_Wordfence {
'other_hideWPVersion',
'disableCodeExecutionUploads',
'disableCookies',
'liveActivityPauseEnabled',
'actUpdateInterval',
'other_bypassLitespeedNoabort',
'deleteTablesOnDeact',
@ -452,6 +459,7 @@ class MainWP_Child_Wordfence {
'alertOn_warnings',
'alertOn_block',
'alertOn_loginLockout',
'alertOn_breachLogin',
'alertOn_lostPasswdForm',
'alertOn_adminLogin',
'alertOn_firstAdminLoginOnly',
@ -507,7 +515,10 @@ class MainWP_Child_Wordfence {
'loginSec_countFailMins',
'loginSec_lockoutMins',
'loginSec_lockInvalidUsers',
'loginSec_breachPasswds_enabled',
'loginSec_breachPasswds',
'loginSec_userBlacklist',
'loginSec_strongPasswds_enabled',
'loginSec_strongPasswds',
'loginSec_maskLoginErrors',
'loginSec_blockAdminReg',
@ -646,7 +657,7 @@ class MainWP_Child_Wordfence {
function do_site_stats() {
do_action( 'mainwp_child_reports_log', 'wordfence' );
}
// ok
public function do_reports_log($ext = '') {
if ( $ext !== 'wordfence' ) return;
if ( ! $this->is_wordfence_installed ) return;

View file

@ -20,6 +20,8 @@ class MainWP_Child_WP_Rocket {
return;
}
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
if ( get_option( 'mainwp_wprocket_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
add_action( 'admin_menu', array( $this, 'remove_menu' ) );
@ -29,6 +31,18 @@ class MainWP_Child_WP_Rocket {
}
}
// ok
public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncWPRocketData'] ) && ( 'yes' === $data['syncWPRocketData'] ) ) {
try{
$data = array( 'rocket_boxes' => get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true ));
$information['syncWPRocketData'] = $data;
} catch(Exception $e) {
}
}
return $information;
}
function remove_notices() {
$remove_hooks['admin_notices'] = array(
'rocket_bad_deactivations' => 10,
@ -183,19 +197,25 @@ class MainWP_Child_WP_Rocket {
function purge_cache_all() {
if ( function_exists( 'rocket_clean_domain' ) || function_exists( 'rocket_clean_minify' ) || function_exists( 'create_rocket_uniqid' ) ) {
set_transient( 'rocket_clear_cache', 'all', HOUR_IN_SECONDS );
// Remove all cache files
rocket_clean_domain();
// Remove all minify cache files
rocket_clean_minify();
// Remove cache busting files.
if ( function_exists( 'rocket_clean_cache_busting' )) {
rocket_clean_cache_busting();
}
// Generate a new random key for minify cache file
$options = get_option( WP_ROCKET_SLUG );
$options['minify_css_key'] = create_rocket_uniqid();
$options['minify_js_key'] = create_rocket_uniqid();
remove_all_filters( 'update_option_' . WP_ROCKET_SLUG );
update_option( WP_ROCKET_SLUG, $options );
//rocket_dismiss_box( 'rocket_warning_plugin_modification' );
rocket_dismiss_box( 'rocket_warning_plugin_modification' );
return array( 'result' => 'SUCCESS' );
} else {
@ -301,15 +321,18 @@ class MainWP_Child_WP_Rocket {
'purge_cron_unit' => 'HOUR_IN_SECONDS',
'exclude_css' => array(),
'exclude_js' => array(),
'async_css' => 0,
'defer_all_js' => 0,
'defer_all_js_safe' => 1,
'critical_css' => '',
'deferred_js_files' => array(),
'lazyload' => 0,
'lazyload_iframes' => 0,
'lazyload_youtube' =>0,
'minify_css' => 0,
// 'minify_css_key' => $minify_css_key,
'minify_concatenate_css' => 0,
'minify_css_combine_all' => 0,
//'minify_css_combine_all' => 0,
'minify_css_legacy' => 0,
'minify_js' => 0,
// 'minify_js_key' => $minify_js_key,
@ -324,7 +347,7 @@ class MainWP_Child_WP_Rocket {
'cdn' => 0,
'cdn_cnames' => array(),
'cdn_zone' => array(),
'cdn_ssl' => 0,
//'cdn_ssl' => 0,
'cdn_reject_files' => array(),
'do_cloudflare' => 0,
'cloudflare_email' => '',
@ -336,6 +359,7 @@ class MainWP_Child_WP_Rocket {
'cloudflare_auto_settings' => 0,
'cloudflare_old_settings' => 0,
'do_beta' => 0,
'analytics_enabled' => 1,
);
}
}

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.7';
public static $version = '3.4.8';
private $update_version = '1.3';
private $callableFunctions = array(
@ -150,7 +150,9 @@ class MainWP_Child {
'backup_buddy' => 'backup_buddy',
'get_site_icon' => 'get_site_icon',
'vulner_checker' => 'vulner_checker',
'wp_staging' => 'wp_staging'
'wp_staging' => 'wp_staging',
'disconnect' => 'disconnect',
'time_capsule' => 'time_capsule',
);
private $FTP_ERROR = 'Failed! Please, add FTP details for automatic updates.';
@ -206,7 +208,7 @@ class MainWP_Child {
MainWP_Clone::get()->init();
MainWP_Child_Server_Information::init();
MainWP_Client_Report::init();
MainWP_Client_Report::Instance()->init();
MainWP_Child_Plugins_Check::Instance();
MainWP_Child_Themes_Check::Instance();
@ -1384,32 +1386,35 @@ class MainWP_Child {
}
}
new MainWP_Child_iThemes_Security();
new MainWP_Child_Updraft_Plus_Backups();
// Init extensions
// Handle fatal errors for those init if needed
// OK
MainWP_Child_iThemes_Security::Instance()->ithemes_init();
MainWP_Child_Updraft_Plus_Backups::Instance()->updraftplus_init();
if ( version_compare( phpversion(), '5.3', '>=' ) ) {
MainWP_Child_Back_Up_Wordpress::Instance()->init();
}
MainWP_Child_WP_Rocket::Instance()->init();
MainWP_Child_Back_WP_Up::Instance()->init();
new MainWP_Child_Back_Up_Buddy();
MainWP_Child_Back_Up_Buddy::Instance();
MainWP_Child_Wordfence::Instance()->wordfence_init();
MainWP_Child_Timecapsule::Instance()->init();
MainWP_Child_Staging::Instance()->init();
MainWP_Child_Branding::Instance()->branding_init();
MainWP_Client_Report::Instance()->creport_init();
MainWP_Child_Pagespeed::Instance()->init();
MainWP_Child_Links_Checker::Instance()->init();
global $_wp_submenu_nopriv;
if ($_wp_submenu_nopriv === null)
$_wp_submenu_nopriv = array(); // fix warning
//
//Call the function required
if ( $auth && isset( $_POST['function'] ) && isset( $this->callableFunctions[ $_POST['function'] ] ) ) {
define( 'DOING_CRON', true );
// ob_start();
// require_once( ABSPATH . 'wp-admin/admin.php' );
// ob_end_clean();
MainWP_Helper::handle_fatal_error();
MainWP_Child::fix_for_custom_themes();
call_user_func( array( $this, $this->callableFunctions[ $_POST['function'] ] ) );
} else if ( isset( $_POST['function'] ) && isset( $this->callableFunctionsNoAuth[ $_POST['function'] ] ) ) {
@ -1420,6 +1425,7 @@ class MainWP_Child {
MainWP_Helper::error( __( 'Required version has not been detected. Please, make sure that you are using the latest version of the MainWP Child plugin on your site.', 'mainwp-child' ) );
}
// going to retire soon
if ( 1 === (int) get_option( 'mainwpKeywordLinks' ) ) {
new MainWP_Keyword_Links();
if ( ! is_admin() ) {
@ -1431,13 +1437,6 @@ class MainWP_Child {
MainWP_Keyword_Links::clear_htaccess(); // force clear
}
// Branding extension
MainWP_Child_Branding::Instance()->branding_init();
MainWP_Client_Report::Instance()->creport_init();
MainWP_Child_Pagespeed::Instance()->init();
MainWP_Child_Links_Checker::Instance()->init();
MainWP_Child_Wordfence::Instance()->wordfence_init();
MainWP_Child_iThemes_Security::Instance()->ithemes_init();
}
function default_option_active_plugins( $default ) {
@ -1858,6 +1857,11 @@ class MainWP_Child {
global $wp_current_filter;
$wp_current_filter[] = 'load-plugins.php';
@wp_update_plugins();
// 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'] ) );
@ -3667,7 +3671,11 @@ class MainWP_Child {
$information['plugins_outdate_info'] = MainWP_Child_Plugins_Check::Instance()->get_plugins_outdate_info();
$information['themes_outdate_info'] = MainWP_Child_Themes_Check::Instance()->get_themes_outdate_info();
try {
do_action('mainwp_child_site_stats');
} catch(Exception $e) {
}
if ( isset( $_POST['othersData'] ) ) {
$othersData = json_decode( stripslashes( $_POST['othersData'] ), true );
@ -3675,63 +3683,12 @@ class MainWP_Child {
$othersData = array();
}
try{
$information = apply_filters( 'mainwp-site-sync-others-data', $information, $othersData );
if ( version_compare( phpversion(), '5.3', '>=' ) ) {
if ( isset( $othersData['syncBackUpWordPress'] ) && $othersData['syncBackUpWordPress'] ) {
if ( MainWP_Child_Back_Up_Wordpress::isActivated() ) {
$information['syncBackUpWordPress'] = MainWP_Child_Back_Up_Wordpress::Instance()->syncData();
} catch(Exception $e) {
// do not exit
}
}
}
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();
}
}
if ( isset( $othersData['syncWPRocketData'] ) && ( 'yes' === $othersData['syncWPRocketData'] ) ) {
$data = array();
if ( MainWP_Child_WP_Rocket::isActivated() ) {
$boxes = get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true );
$data['rocket_boxes'] = $boxes;
}
$information['syncWPRocketData'] = $data;
}
if ( isset( $othersData['syncPageSpeedData'] ) && !empty( $othersData['syncPageSpeedData'] ) ) {
if ( MainWP_Child_Pagespeed::Instance()->is_plugin_installed ) {
$information['syncPageSpeedData'] = MainWP_Child_Pagespeed::Instance()->sync_data();
}
}
if ( isset( $othersData['syncBrokenLinksCheckerData'] ) && !empty( $othersData['syncBrokenLinksCheckerData'] ) ) {
if ( MainWP_Child_Links_Checker::Instance()->is_plugin_installed ) {
$information['syncBrokenLinksCheckerData'] = MainWP_Child_Links_Checker::Instance()->sync_data();
}
}
if ( isset( $othersData['syncClientReportData'] ) && !empty( $othersData['syncClientReportData'] ) ) {
$creport_sync_data = array();
if ( ( $firsttime = get_option( 'mainwp_creport_first_time_activated' ) ) !== false ) {
$creport_sync_data['firsttime_activated'] = $firsttime;
}
if ( !empty( $creport_sync_data ) ) {
$information['syncClientReportData'] = $creport_sync_data;
}
}
}
if ( $exit ) {
MainWP_Helper::write( $information );
@ -4334,7 +4291,7 @@ class MainWP_Child {
if ( 'activate' === $action ) {
include_once( ABSPATH . '/wp-admin/includes/theme.php' );
$theTheme = get_theme( $theme );
$theTheme = wp_get_theme( $theme );
if ( null !== $theTheme && '' !== $theTheme ) {
switch_theme( $theTheme['Template'], $theTheme['Stylesheet'] );
}
@ -4371,7 +4328,7 @@ class MainWP_Child {
foreach ( $themes as $idx => $themeToDelete ) {
if ( $themeToDelete !== $theme_name ) {
$theTheme = get_theme( $themeToDelete );
$theTheme = wp_get_theme( $themeToDelete );
if ( null !== $theTheme && '' !== $theTheme ) {
$tmp['theme'] = $theTheme['Template'];
if ( true === $themeUpgrader->delete_old_theme( null, null, null, $tmp ) ) {
@ -4743,7 +4700,7 @@ class MainWP_Child {
}
}
function deactivation() {
function deactivation( $deact = true) {
$to_delete = array(
'mainwp_child_pubkey',
'mainwp_child_nonce',
@ -4761,6 +4718,8 @@ class MainWP_Child {
wp_cache_delete( $delete, 'options' );
}
}
if ($deact)
do_action( 'mainwp_child_deactivation' );
}
@ -5470,10 +5429,19 @@ class MainWP_Child {
MainWP_Child_Vulnerability_Checker::Instance()->action();
}
function time_capsule() {
MainWP_Child_Timecapsule::Instance()->action();
}
function wp_staging() {
MainWP_Child_Staging::Instance()->action();
}
function disconnect() {
$this->deactivation(false);
MainWP_Helper::write( array( 'result' => 'success' ) );
}
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

@ -11,12 +11,28 @@ class MainWP_Client_Report {
return MainWP_Client_Report::$instance;
}
public static function init() {
public function init() {
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
add_filter( 'wp_stream_connectors', array( 'MainWP_Client_Report', 'init_stream_connectors' ), 10, 1 );
add_filter( 'mainwp_client_reports_connectors', array( 'MainWP_Client_Report', 'init_report_connectors' ), 10, 1 );
add_action( 'mainwp_child_log', array( 'MainWP_Client_Report', 'do_reports_log' ) );
}
// ok
public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncClientReportData'] ) && $data['syncClientReportData'] ) {
$creport_sync_data = array();
if ( ( $firsttime = get_option( 'mainwp_creport_first_time_activated' ) ) !== false ) {
$creport_sync_data['firsttime_activated'] = $firsttime;
}
if ( !empty( $creport_sync_data ) ) {
$information['syncClientReportData'] = $creport_sync_data;
}
}
return $information;
}
public static function init_stream_connectors( $classes ) {
$connectors = array(
'Backups',
@ -71,9 +87,6 @@ class MainWP_Client_Report {
case 'wordfence':
MainWP_Child_Wordfence::Instance()->do_reports_log( $ext );
break;
// case 'wptimecapsule':
// MainWP_Child_WP_Time_Capsule::Instance()->do_reports_log( $ext );
// break;
}
}

View file

@ -211,7 +211,32 @@ class MainWP_Helper {
static function createPost( $new_post, $post_custom, $post_category, $post_featured_image, $upload_dir, $post_tags, $others = array() ) {
global $current_user;
$wprocket_fields = array( 'lazyload', 'lazyload_iframes', 'minify_html', 'minify_css', 'minify_js', 'cdn' );
/**
* Hook: `mainwp_before_post_update`
*
* Runs before creating or updating a post via MainWP dashboard.
*
* @param array $new_post Post data array.
* @param array $post_custom Post custom meta data.
* @param string $post_category Post categories.
* @param string $post_tags Post tags.
*/
do_action( 'mainwp_before_post_update', $new_post, $post_custom, $post_category, $post_tags );
// Options fields.
$wprocket_fields = array(
'lazyload',
'lazyload_iframes',
'minify_html',
'minify_css',
'minify_js',
'cdn',
'async_css',
'defer_all_js',
);
$wprocket_activated = false;
if ( MainWP_Child_WP_Rocket::isActivated() ) {
if ( function_exists( 'get_rocket_option' ) ) {
@ -1387,4 +1412,160 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name =
if ( defined( 'MAINWP_NOSSL' ) ) return !MAINWP_NOSSL;
return function_exists( 'openssl_verify' );
}
public static function check_files_exists( $files = array(), $return = false ) {
$missing = array();
if (is_array($files)) {
foreach($files as $name) {
if (!file_exists( $name )) {
$missing[] = $name;
}
}
} else {
if (!file_exists( $files )) {
$missing[] = $files;
}
}
if (!empty($missing)) {
$message = 'Missing file(s): ' . implode(',', $missing);
if ($return)
return $message;
else
throw new Exception( $message );
}
return true;
}
public static function check_classes_exists($classes = array(), $return = false) {
$missing = array();
if (is_array($classes)) {
foreach($classes as $name) {
if (!class_exists( $name )) {
$missing[] = $name;
}
}
} else {
if ( !class_exists($classes) )
$missing[] = $classes;
}
if ( !empty($missing) ) {
$message = 'Missing classes: ' . implode(',', $missing);
if ($return) {
return $message;
} else {
throw new Exception( $message );
}
}
return true;
}
public static function check_methods($object, $methods = array(), $return = false) {
$missing = array();
if (is_array($methods)) {
$missing = array();
foreach($methods as $name) {
if ( !method_exists($object, $name) ) {
$missing[] = $name;
}
}
} else if (!empty($methods)) {
if ( !method_exists($object, $methods) )
$missing[] = $methods;
}
if ( !empty($missing) ) {
$message = 'Missing method: ' . implode(',', $missing);
if ($return) {
return $message;
} else {
throw new Exception( $message );
}
}
return true;
}
public static function check_properties($object, $properties = array(), $return = false) {
$missing = array();
if (is_array($properties)) {
foreach($properties as $name) {
if ( !property_exists($object, $name) ) {
$missing[] = $name;
}
}
} else if (!empty($properties)) {
if ( !property_exists($object, $properties) )
$missing[] = $properties;
}
if ( !empty($missing) ) {
$message = 'Missing properties: ' . implode(',', $missing);
if ($return) {
return $message;
} else {
throw new Exception( $message );
}
}
return true;
}
public static function check_functions($funcs = array(), $return = false) {
$missing = array();
if (is_array($funcs)) {
foreach($funcs as $name) {
if ( !function_exists( $name) ) {
$missing[] = $name;
}
}
} else if (!empty($funcs)) {
if ( !function_exists($funcs) )
$missing[] = $funcs;
}
if ( !empty($missing) ) {
$message = 'Missing functions: ' . implode(',', $missing);
if ($return) {
return $message;
} else {
throw new Exception( $message );
}
}
return true;
}
/**
* Handle fatal error for requests from the dashboard
* mwp_action requests
* wordpress_seo requests
* This will do not handle fatal error for sync request from the dashboard
*/
public static function handle_fatal_error() {
function handle_shutdown() {
// handle fatal errors and compile errors
$error = error_get_last();
if ( isset( $error['type'] ) && isset( $error['message'] ) &&
( E_ERROR === $error['type'] || E_COMPILE_ERROR === $error['type'] )
)
{
MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
}
}
if (isset($_POST['function']) && isset($_POST['mainwpsignature']) &&
(isset($_POST['mwp_action']) || 'wordpress_seo' == $_POST['function']) // wordpress_seo for Wordpress SEO
) {
register_shutdown_function( 'handle_shutdown' );
}
}
}

View file

@ -6,7 +6,7 @@
Author: MainWP
Author URI: https://mainwp.com
Text Domain: mainwp-child
Version: 3.4.7
Version: 3.4.8
*/
if ( ( isset( $_REQUEST['heatmap'] ) && '1' === $_REQUEST['heatmap'] ) || ( isset( $_REQUEST['mainwpsignature'] ) && ( ! empty( $_REQUEST['mainwpsignature'] ) ) ) ) {
header( 'X-Frame-Options: ALLOWALL' );
@ -35,10 +35,6 @@ function mainwp_child_autoload( $class_name ) {
if ( function_exists( 'spl_autoload_register' ) ) {
spl_autoload_register( 'mainwp_child_autoload' );
} else {
function __autoload( $class_name ) {
mainwp_child_autoload( $class_name );
}
}
$mainWPChild = new MainWP_Child( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . plugin_basename( __FILE__ ) );

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.5
Stable tag: 3.4.7.1
Tested up to: 4.9.6
Stable tag: 3.4.8
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -71,6 +71,14 @@ To see full documentation and FAQs please visit [MainWP Documentation](https://m
== Changelog ==
= 3.4.8 - 6-26-18 =
* Fixed: issues caused by deprecated functions
* Added: mainwp_before_post_update hook
* Added: support for the new extension
* Added: conditional checks to prevent possible conflicts with certain plugins 
* Added: support for the new MainWP Branding Extension feature
* Improved: PHP 7.2 compatibility
= 3.4.7.1 - 5-25-18 =
* Fixed: UpdraftPlus 1.14.10 compatibility issue that caused child sites to disconnect
* Added: support for the new MainWP Branding Extension option