diff --git a/class/class-mainwp-child-back-up-buddy.php b/class/class-mainwp-child-back-up-buddy.php index 0da6ac8..3b4eb9d 100644 --- a/class/class-mainwp-child-back-up-buddy.php +++ b/class/class-mainwp-child-back-up-buddy.php @@ -23,10 +23,6 @@ class MainWP_Child_Back_Up_Buddy { return; } - if ( get_option( 'mainwp_backupbuddy_ext_enabled' ) !== 'Y' ) { - return; - } - add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); add_action( 'wp_ajax_mainwp_backupbuddy_download_archive', array( $this, 'download_archive' ) ); @@ -195,9 +191,6 @@ class MainWP_Child_Back_Up_Buddy { MainWP_Helper::write( array( 'error' => __( 'Please install the BackupBuddy plugin on the child site.', $this->plugin_translate ) ) ); } - if (get_option( 'mainwp_backupbuddy_ext_enabled' ) !== 'Y') - MainWP_Helper::update_option( 'mainwp_backupbuddy_ext_enabled', 'Y' ); - if ( ! class_exists( 'backupbuddy_core' ) ) { require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' ); } @@ -757,7 +750,7 @@ class MainWP_Child_Back_Up_Buddy { $data['media_root'] = backupbuddy_core::get_media_root(); $data['additional_tables'] = $this->pb_additional_tables(); $data['abspath'] = ABSPATH; - + $getOverview = backupbuddy_api::getOverview(); $data['editsSinceLastBackup'] = $getOverview['editsSinceLastBackup'] ; diff --git a/class/class-mainwp-child-back-up-wordpress.php b/class/class-mainwp-child-back-up-wordpress.php index d6e0b9e..f705534 100644 --- a/class/class-mainwp-child-back-up-wordpress.php +++ b/class/class-mainwp-child-back-up-wordpress.php @@ -26,7 +26,7 @@ class MainWP_Child_Back_Up_Wordpress { if ( version_compare( phpversion(), '5.3', '<' ) ) { return; } - if ( get_option( 'mainwp_backupwordpress_ext_enabled' ) !== 'Y' ) return; + if (!$this->is_plugin_installed) return; add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) ); @@ -56,9 +56,6 @@ class MainWP_Child_Back_Up_Wordpress { MainWP_Helper::write( $information ); } - if (false === get_option('mainwp_backupwordpress_ext_enabled')) - MainWP_Helper::update_option( 'mainwp_backupwordpress_ext_enabled', 'Y' ); - if ( isset( $_POST['mwp_action'] ) ) { switch ( $_POST['mwp_action'] ) { case 'set_showhide': diff --git a/class/class-mainwp-child-back-wp-up.php b/class/class-mainwp-child-back-wp-up.php index 8a15427..71772ad 100644 --- a/class/class-mainwp-child-back-wp-up.php +++ b/class/class-mainwp-child-back-wp-up.php @@ -110,7 +110,7 @@ class MainWP_Child_Back_WP_Up { if ( ! isset( $_POST['action'] ) ) { $information = array( 'error' => __( 'Missing action.', $this->plugin_translate ) ); } else { - MainWP_Helper::update_option( 'mainwp_backwpup_ext_enabled', 'Y' ); + switch ( $_POST['action'] ) { case 'backwpup_update_settings': $information = $this->update_settings(); @@ -194,9 +194,6 @@ class MainWP_Child_Back_WP_Up { } public function init() { - if ( get_option( 'mainwp_backwpup_ext_enabled' ) !== 'Y' ) { - return; - } if (!$this->is_backwpup_installed) return; @@ -223,14 +220,44 @@ class MainWP_Child_Back_WP_Up { return; try { - MainWP_Helper::check_classes_exists(array('BackWPup')); - MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' )); + MainWP_Helper::check_classes_exists(array('BackWPup_File', 'BackWPup_Job')); + MainWP_Helper::check_methods('BackWPup_File', array( 'get_absolute_path' )); + MainWP_Helper::check_methods('BackWPup_Job', array( 'read_logheader' )); - $destinations = BackWPup::get_registered_destinations(); - $jobdests = $this->get_destinations_list(); + $lasttime_logged = MainWP_Helper::get_lasttime_backup('backwpup'); - if ( !empty( $jobdests ) ) { + $log_folder = get_site_option( 'backwpup_cfg_logfolder' ); + $log_folder = BackWPup_File::get_absolute_path( $log_folder ); + $log_folder = untrailingslashit( $log_folder ); + + //load logs + $logfiles = array(); + if ( is_readable( $log_folder ) && $dir = opendir( $log_folder ) ) { + while ( ( $file = readdir( $dir ) ) !== FALSE ) { + $log_file = $log_folder . '/' . $file; + if ( is_file( $log_file ) && is_readable( $log_file ) && FALSE !== strpos( $file, 'backwpup_log_' ) && FALSE !== strpos( $file, '.html' ) ) { + $logfiles[] = $file; + } + } + closedir( $dir ); + } + + $log_items = array(); + foreach ( $logfiles as $mtime => $logfile ) { + $meta = BackWPup_Job::read_logheader( $log_folder . '/' . $logfile ); + if (!isset($meta['logtime']) || $meta['logtime'] < $lasttime_logged) + continue; + + if (isset($meta['errors']) && !empty($meta['errors'])) { + continue; // do not logging backups have errors + } + + $log_items[$mtime] = $meta; + $log_items[$mtime]['file'] = $logfile; + } + + if ( !empty( $log_items ) ) { $job_types = array( 'DBDUMP' => __('Database backup', 'mainwp-child'), 'FILE' => __('File backup', 'mainwp-child'), @@ -239,41 +266,36 @@ class MainWP_Child_Back_WP_Up { 'DBCHECK' => __('Check database tables', 'mainwp-child') ); - foreach ($jobdests as $jobdest) { - list( $jobid, $dest ) = explode( '_', $jobdest ); - if ( ! empty( $destinations[ $dest ][ 'class' ] ) ) { + $new_lasttime_logged = $lasttime_logged; - $job_job_types = BackWPup_Option::get( $jobid, 'type' ); - - $backup_type = ''; - foreach($job_job_types as $typeid) { - if (isset( $job_types[$typeid] )) { - $backup_type .= ' + ' . $job_types[$typeid]; - } - } - if (empty($backup_type)) - $backup_type = 'BackWPup'; - else { - $backup_type = ltrim($backup_type, ' + '); - } - - $dest_object = BackWPup::get_destination( $dest ); - $items = $dest_object->file_get_list( $jobdest ); - //if no items brake - if ( $items ) { - foreach ( $items as $ma ) { - if (isset($ma['time'])) { - $backup_time = $ma[ "time" ]; - $message = 'BackWPup backup finished (' . $backup_type . ')'; - $destination = "N/A"; - if (!empty($backup_time)) { - do_action( 'mainwp_backwpup_backup', $message, $backup_type, $backup_time ); - MainWP_Helper::update_lasttime_backup( 'backwpup', $backup_time ); // to support backup before update feature - } - } - } + foreach ($log_items as $log) { + $backup_time = $log[ "logtime" ]; + if ($backup_time < $lasttime_logged) { + // small than last backup time then skip + continue; + } + $job_job_types = explode('+', $log['type']); + $backup_type = ''; + foreach($job_job_types as $typeid) { + if (isset( $job_types[$typeid] )) { + $backup_type .= ' + ' . $job_types[$typeid]; } } + + if (empty($backup_type)) { + continue; + } else { + $backup_type = ltrim($backup_type, ' + '); + } + $message = 'BackWPup backup finished (' . $backup_type . ')'; + do_action( 'mainwp_backwpup_backup', $message, $backup_type, $backup_time ); + + if ($new_lasttime_logged < $backup_time) + $new_lasttime_logged = $backup_time; + } + + if ($new_lasttime_logged > $lasttime_logged ) { + MainWP_Helper::update_lasttime_backup( 'backwpup', $new_lasttime_logged ); // to support backup before update feature } } } catch (Exception $ex) { diff --git a/class/class-mainwp-child-ithemes-security.php b/class/class-mainwp-child-ithemes-security.php index f7268a3..609eb52 100644 --- a/class/class-mainwp-child-ithemes-security.php +++ b/class/class-mainwp-child-ithemes-security.php @@ -47,7 +47,7 @@ class MainWP_Child_iThemes_Security { global $mainwp_itsec_modules_path; $mainwp_itsec_modules_path = ITSEC_Core::get_core_dir() . '/modules/'; - MainWP_Helper::update_option( 'mainwp_ithemes_ext_enabled', 'Y', 'yes' ); + if ( isset( $_POST['mwp_action'] ) ) { switch ( $_POST['mwp_action'] ) { @@ -116,9 +116,8 @@ class MainWP_Child_iThemes_Security { } public function ithemes_init() { - if ( get_option( 'mainwp_ithemes_ext_enabled' ) !== 'Y' ) { + if (!$this->is_plugin_installed) return; - } if ( get_option( 'mainwp_ithemes_hide_plugin' ) === 'hide' ) { add_filter( 'all_plugins', array( $this, 'all_plugins' ) ); diff --git a/class/class-mainwp-child-pagespeed.php b/class/class-mainwp-child-pagespeed.php index e06a553..a87093d 100644 --- a/class/class-mainwp-child-pagespeed.php +++ b/class/class-mainwp-child-pagespeed.php @@ -18,12 +18,12 @@ class MainWP_Child_Pagespeed { if ( is_plugin_active( 'google-pagespeed-insights/google-pagespeed-insights.php' ) ) { $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' ) ); } @@ -34,7 +34,7 @@ class MainWP_Child_Pagespeed { MainWP_Helper::write( $information ); } if ( isset( $_POST['mwp_action'] ) ) { - MainWP_Helper::update_option('mainwp_pagespeed_ext_enabled', 'Y', 'yes'); + switch ( $_POST['mwp_action'] ) { case 'save_settings': $information = $this->save_settings(); @@ -60,13 +60,12 @@ class MainWP_Child_Pagespeed { } public function init() { - if ( get_option( 'mainwp_pagespeed_ext_enabled' ) !== 'Y' ) { - return; - } - + if (!$this->is_plugin_installed) + return; + 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_action('admin_menu', array($this, 'hide_menu'), 999); } $this->init_cron(); } @@ -261,14 +260,14 @@ class MainWP_Child_Pagespeed { return $information; } - public function syncOthersData( $information, $data = array() ) { - if ( isset( $data['syncPageSpeedData'] ) && $data['syncPageSpeedData'] ) { + 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 diff --git a/class/class-mainwp-child-staging.php b/class/class-mainwp-child-staging.php index 3666be2..a1f22df 100644 --- a/class/class-mainwp-child-staging.php +++ b/class/class-mainwp-child-staging.php @@ -1,10 +1,10 @@ is_plugin_installed = true; - } - + $this->is_plugin_installed = true; + } + if (!$this->is_plugin_installed) - return; - - add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); + return; + + add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); } - - public function init() { - if ( get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y' ) - return; - - 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; + 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' ) ); @@ -39,44 +39,44 @@ class MainWP_Child_Staging { } } - public function syncOthersData( $information, $data = array() ) { - if ( isset( $data['syncWPStaging'] ) && $data['syncWPStaging'] ) { + 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() { + 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(); + $information = array(); if (get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y') { - MainWP_Helper::update_option( 'mainwp_wp_staging_ext_enabled', 'Y', 'yes' ); + 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; + break; case 'save_settings': $information = $this->save_settings(); - break; + break; case 'get_overview': $information = $this->get_overview(); break; @@ -106,7 +106,7 @@ class MainWP_Child_Staging { break; case 'clone_finish': $information = $this->ajaxFinish(); - break; + break; case 'delete_confirmation': $information = $this->ajaxDeleteConfirmation(); break; @@ -121,35 +121,37 @@ class MainWP_Child_Staging { break; case 'cancel_update': $information = $this->ajaxCancelUpdate(); - break; + 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']; + $settings = $_POST['settings']; $filters = array( 'queryLimit', 'fileLimit', 'batchSize', 'cpuLoad', 'disableAdminLogin', - 'wpSubDirectory', + 'querySRLimit', + 'maxFileSize', + //'wpSubDirectory', // removed 'debugMode', 'unInstallOnDelete', 'checkDirectorySize', 'optimizer', - 'loginSlug' + //'loginSlug' // removed ); - + $save_fields = array(); foreach($filters as $field) { if (isset($settings[$field])) { @@ -158,15 +160,15 @@ class MainWP_Child_Staging { } update_option('wpstg_settings', $save_fields ); return array('result' => 'success'); - } - - public function get_overview() { + } + + 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(); @@ -178,12 +180,12 @@ class MainWP_Child_Staging { $return = array( 'options' => serialize($options), 'directoryListing' => $scan->directoryListing(), - 'prefix' => WPStaging\WPStaging::getTablePrefix() + 'prefix' => WPStaging\WPStaging::getTablePrefix() ); return $return; } - + public function ajaxCheckCloneName() { $cloneName = sanitize_key( $_POST["cloneID"] ); $cloneNameLength = strlen( $cloneName ); @@ -204,23 +206,23 @@ class MainWP_Child_Staging { return array("status" => "success"); } - + public function ajaxStartClone() { $this->url = ''; // to fix warning $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(); @@ -232,7 +234,7 @@ class MainWP_Child_Staging { * Ajax Prepare Directories (get listing of files) */ public function ajaxPrepareDirectories() { - + $cloning = new WPStaging\Backend\Modules\Jobs\Cloning(); return $cloning->start(); @@ -265,7 +267,7 @@ class MainWP_Child_Staging { $this->url = ''; // to fix warning $return = $cloning->start(); $return->blogInfoName = get_bloginfo("name"); - + return $return; } @@ -276,12 +278,12 @@ class MainWP_Child_Staging { $delete = new WPStaging\Backend\Modules\Jobs\Delete(); $delete->setData(); - $clone = $delete->getClone(); + $clone = $delete->getClone(); $result = array( 'clone' => $clone, 'deleteTables' => $delete->getTables() - ); - return $result; + ); + return $result; } /** @@ -300,15 +302,15 @@ class MainWP_Child_Staging { $cancel = new WPStaging\Backend\Modules\Jobs\Cancel(); return $cancel->start(); } - - public function ajaxCancelUpdate() { + + public function ajaxCancelUpdate() { $cancel = new WPStaging\Backend\Modules\Jobs\CancelUpdate(); return $cancel->start(); } public function ajaxUpdateProcess() { - - $cloning = new WPStaging\Backend\Modules\Jobs\Updating(); + + $cloning = new WPStaging\Backend\Modules\Jobs\Updating(); if( !$cloning->save() ) { return; @@ -317,13 +319,13 @@ class MainWP_Child_Staging { ob_start(); require_once WPSTG_PLUGIN_DIR . "apps/Backend/views/clone/ajax/update.php"; $result = ob_get_clean(); - return $result; + return $result; } - - public function ajaxCheckFreeSpace() { + + public function ajaxCheckFreeSpace() { return $this->hasFreeDiskSpace(); } - + // from wp-staging plugin public function hasFreeDiskSpace() { if( !function_exists( "disk_free_space" ) ) { @@ -335,15 +337,15 @@ class MainWP_Child_Staging { 'freespace' => false, 'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH)) ); - return $data; + return $data; } $data = array( 'freespace' => $this->formatSize($freeSpace), 'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH)) ); - return $data; + return $data; } - + // from wp-staging plugin function getDirectorySizeInclSubdirs( $dir ) { $size = 0; @@ -352,7 +354,7 @@ class MainWP_Child_Staging { } return $size; } - + // from wp-staging plugin public function formatSize($bytes, $precision = 2) { @@ -369,8 +371,8 @@ class MainWP_Child_Staging { return round($pow, $precision) . ' ' . $units[(int) floor($base)]; } - - + + public function all_plugins( $plugins ) { foreach ( $plugins as $key => $value ) { $plugin_slug = basename( $key, '.php' ); @@ -390,7 +392,7 @@ class MainWP_Child_Staging { exit(); } } - + function remove_update_nag( $value ) { if ( isset( $_POST['mainwpsignature'] ) ) { return $value; diff --git a/class/class-mainwp-child-timecapsule.php b/class/class-mainwp-child-timecapsule.php index 27e3532..67e0e0c 100644 --- a/class/class-mainwp-child-timecapsule.php +++ b/class/class-mainwp-child-timecapsule.php @@ -531,7 +531,7 @@ function get_sibling_files_callback_wptc() { $detailed = $this->get_activity_log($sub_records); if (isset($load_more) && $load_more) { - $detailed .= '
'; + + +// $rawbackup = "" . esc_attr( print_r( $backup, true ) ); - if ( ! empty( $non ) ) { - $jd = $updraftplus->jobdata_getarray( $non ); - if ( ! empty( $jd ) && is_array( $jd ) ) { - $rawbackup .= '
' . esc_attr( print_r( $jd, true ) ); - } - } - $rawbackup .= '
'; + + // to fix + $rawbackup = '' ; //$updraftplus_admin->raw_backup_info($backup_history, $key, $non); $jobdata = $updraftplus->jobdata_getarray( $non ); @@ -3908,9 +3908,8 @@ ENDHERE; } public function updraftplus_init() { - if ( get_option( 'mainwp_updraftplus_ext_enabled' ) !== 'Y' ) { - return; - } + if (!$this->is_plugin_installed) + return; if ( get_option( 'mainwp_updraftplus_hide_plugin' ) === 'hide' ) { add_filter( 'all_plugins', array( $this, 'all_plugins' ) ); diff --git a/class/class-mainwp-child-wordfence.php b/class/class-mainwp-child-wordfence.php index d2a3040..badb9d7 100644 --- a/class/class-mainwp-child-wordfence.php +++ b/class/class-mainwp-child-wordfence.php @@ -1,10 +1,10 @@ start_scan(); @@ -227,25 +227,22 @@ class MainWP_Child_Wordfence { break; case 'killScan': $information = $this->killScan(); - break; + break; case 'set_showhide': $information = $this->set_showhide(); break; case 'get_log': $information = $this->get_log(); - break; + break; case 'update_log': $information = $this->update_log(); break; - case 'get_summary': - $information = $this->get_summary(); - break; case 'load_issues': // not used in from version 2.0 of WF ext $information = $this->load_issues(); break; case 'loadIssues': $information = $this->ajax_loadIssues_callback(); - break; + break; case 'load_wafData': $information = $this->load_wafData(); break; @@ -266,7 +263,7 @@ class MainWP_Child_Wordfence { break; case 'bulkOperation': // new $information = $this->bulkOperation(); - break; + break; case 'delete_file': $information = $this->delete_file(); break; @@ -281,10 +278,10 @@ class MainWP_Child_Wordfence { break; case 'saveOptions': $information = $this->saveOptions(); - break; + break; case 'recentTraffic': $information = $this->recentTraffic(); - break; + break; case 'ticker': $information = $this->ticker(); break; @@ -296,10 +293,10 @@ class MainWP_Child_Wordfence { break; case 'whois': $information = $this->whois(); - break; - case 'createBlock': // new version blockIP, blockIPUARange + break; + case 'createBlock': // new version blockIP, blockIPUARange $information = $this->ajax_createBlock_callback(); - break; + break; case 'getBlocks': $information = $this->ajax_getBlocks_callback(); break; @@ -308,7 +305,7 @@ class MainWP_Child_Wordfence { break; case 'makePermanentBlocks': $information = $this->ajax_makePermanentBlocks_callback(); - break; + break; case 'unblock_ip': $information = $this->unblock_ip(); break; @@ -359,7 +356,7 @@ class MainWP_Child_Wordfence { break; case 'update_waf_rules_new': $information = $this->updateWAFRules_New(); - break; + break; case 'save_debugging_config': $information = $this->save_debugging_config(); break; @@ -368,10 +365,10 @@ class MainWP_Child_Wordfence { break; case 'white_list_waf': $information = $this->whitelistWAFParamKey(); - break; + break; case 'hide_file_htaccess': $information = $this->hideFileHtaccess(); - break; + break; case 'fix_fpd': $information = $this->fixFPD(); break; @@ -383,7 +380,7 @@ class MainWP_Child_Wordfence { break; case 'misconfigured_howget_ips_choice': $information = $this->misconfiguredHowGetIPsChoice(); - break; + break; case 'delete_admin_user': $information = $this->deleteAdminUser(); break; @@ -401,7 +398,7 @@ class MainWP_Child_Wordfence { break; case 'unblock_range': $information = $this->unblockRange(); - break; + break; case 'block_ip_ua_range': $information = $this->blockIPUARange(); break; @@ -419,7 +416,7 @@ class MainWP_Child_Wordfence { break; case 'whitelist_bulk_disable': $information = $this->whitelistBulkDisable(); - break; + break; case 'update_config': $information = $this->updateConfig(); break; @@ -429,9 +426,9 @@ class MainWP_Child_Wordfence { } } MainWP_Helper::write( $information ); - } - - + } + + public static function getSectionSettings($section) { $general_opts = array( 'scheduleScan', @@ -473,9 +470,9 @@ class MainWP_Child_Wordfence { 'email_summary_dashboard_widget_enabled', 'other_noAnonMemberComments', 'other_scanComments', - 'advancedCommentScanning' // paid + 'advancedCommentScanning' // paid ); - + $traffic_opts = array( 'liveTrafficEnabled', 'liveTraf_ignorePublishers', @@ -486,7 +483,7 @@ class MainWP_Child_Wordfence { 'liveTraf_maxRows', 'displayTopLevelLiveTraffic' ); - + $firewall_opts = array( 'disableWAFIPBlocking', 'whitelisted', @@ -516,10 +513,10 @@ class MainWP_Child_Wordfence { 'loginSec_lockoutMins', 'loginSec_lockInvalidUsers', 'loginSec_breachPasswds_enabled', - 'loginSec_breachPasswds', + 'loginSec_breachPasswds', 'loginSec_userBlacklist', 'loginSec_strongPasswds_enabled', - 'loginSec_strongPasswds', + 'loginSec_strongPasswds', 'loginSec_maskLoginErrors', 'loginSec_blockAdminReg', 'loginSec_disableAuthorScan', @@ -528,9 +525,9 @@ class MainWP_Child_Wordfence { 'other_WFNet', 'wafStatus', 'learningModeGracePeriodEnabled', - 'learningModeGracePeriod' + 'learningModeGracePeriod' ); - + $scan_opts = array( 'scansEnabled_checkGSB', //paid 'spamvertizeCheck', //paid @@ -573,13 +570,13 @@ class MainWP_Child_Wordfence { 'ssl_verify', 'betaThreatDefenseFeed' ); - + $blocking_opts = array( - 'displayTopLevelBlocking', + 'displayTopLevelBlocking', ); - + $options = array(); - + switch($section) { case self::OPTIONS_TYPE_GLOBAL: $options = $general_opts; @@ -591,7 +588,7 @@ class MainWP_Child_Wordfence { $options = $firewall_opts; break; case self::OPTIONS_TYPE_SCANNER: - $options = $scan_opts; + $options = $scan_opts; break; case self::OPTIONS_TYPE_DIAGNOSTICS: $options = $diagnostics_opts; @@ -602,37 +599,37 @@ class MainWP_Child_Wordfence { case self::OPTIONS_TYPE_ALL: $options = array_merge($general_opts, $traffic_opts, $firewall_opts, $scan_opts, $diagnostics_opts, $blocking_opts); break; - } + } return $options; } - - - private function start_scan() { + + + private function start_scan() { $information = wordfence::ajax_scan_callback(); - if ( is_array($information) && isset($information['ok']) ) + if ( is_array($information) && isset($information['ok']) ) $information['result'] = 'SUCCESS'; - + return $information; } - private function kill_scan() { + private function kill_scan() { wordfence::status(1, 'info', "Scan kill request received."); wordfence::status(10, 'info', "SUM_KILLED:A request was received to kill the previous scan."); wfUtils::clearScanLock(); //Clear the lock now because there may not be a scan running to pick up the kill request and clear the lock wfScanEngine::requestKill(); return array( 'ok' => 1, - ); - } - - private function requestScan() { - return wordfence::ajax_scan_callback(); + ); } - private function killScan() { - return wordfence::ajax_killScan_callback(); + private function requestScan() { + return wordfence::ajax_scan_callback(); } - + + private function killScan() { + return wordfence::ajax_killScan_callback(); + } + function set_showhide() { $hide = isset( $_POST['showhide'] ) && ( $_POST['showhide'] === 'hide' ) ? 'hide' : ''; MainWP_Helper::update_option( 'mainwp_wordfence_hide_plugin', $hide, 'yes' ); @@ -642,7 +639,7 @@ class MainWP_Child_Wordfence { } public function wordfence_init() { - if ( get_option( 'mainwp_wordfence_ext_enabled' ) !== 'Y' ) return; + if ( ! $this->is_wordfence_installed ) return; add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) ); @@ -728,7 +725,7 @@ class MainWP_Child_Wordfence { public function wfc_cron_scan() { if ( ! class_exists( 'wordfence' ) || ! class_exists( 'wfScanEngine' ) ) { return; - } + } $this->start_scan(); } @@ -750,9 +747,9 @@ class MainWP_Child_Wordfence { public function get_log() { $information = array(); $wfLog = wordfence::getLog(); - if ( $wfLog ) { + if ( $wfLog ) { $information['events'] = $wfLog->getStatusEvents( 0 ); - + if (method_exists($wfLog, 'getSummaryEvents')) { $information['summary'] = $wfLog->getSummaryEvents(); } else { @@ -764,22 +761,23 @@ class MainWP_Child_Wordfence { return $information; } - + public function update_log() { return wordfence::ajax_activityLogUpdate_callback(); } + // not used public function load_issues() { $offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0; $limit = isset($_POST['limit']) ? intval($_POST['limit']) : WORDFENCE_SCAN_ISSUES_PER_PAGE; - + $i = new wfIssues(); $iss = $i->getIssues($offset, $limit); $counts = $i->getIssueCounts(); - + return array( 'issuesLists' => $iss, - 'issueCounts' => $counts, + 'issueCounts' => $counts, 'lastScanCompleted' => wfConfig::get( 'lastScanCompleted' ), 'apiKey' => wfConfig::get( 'apiKey' ), 'isPaid' => wfConfig::get('isPaid'), @@ -791,37 +789,38 @@ class MainWP_Child_Wordfence { 'wafData' => $this->_getWAFData() ); } - + public static function ajax_loadIssues_callback(){ $offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0; $limit = isset($_POST['limit']) ? intval($_POST['limit']) : WORDFENCE_SCAN_ISSUES_PER_PAGE; - + $i = new wfIssues(); $iss = $i->getIssues($offset, $limit); $counts = $i->getIssueCounts(); $return = array( 'issuesLists' => $iss, 'issueCounts' => $counts, - 'lastScanCompleted' => wfConfig::get('lastScanCompleted'), + 'lastScanCompleted' => wfConfig::get('lastScanCompleted'), 'apiKey' => wfConfig::get( 'apiKey' ), 'isPaid' => wfConfig::get('isPaid'), - 'lastscan_timestamp' => MainWP_Child_Wordfence::Instance()->get_lastscan(), + 'lastscan_timestamp' => MainWP_Child_Wordfence::Instance()->get_lastscan(), 'todayAttBlocked' => MainWP_Child_Wordfence::Instance()->count_attacks_blocked(1), 'weekAttBlocked' => MainWP_Child_Wordfence::Instance()->count_attacks_blocked(7), - 'monthAttBlocked' => MainWP_Child_Wordfence::Instance()->count_attacks_blocked(30), - ); + 'monthAttBlocked' => MainWP_Child_Wordfence::Instance()->count_attacks_blocked(30), + 'issueCount' => $i->getIssueCount(), + ); return $return; } - + public function load_wafData() { - - $return = array( + + $return = array( 'wafData' => $this->_getWAFData(), - 'ip' => wfUtils::getIP(), + 'ip' => wfUtils::getIP(), 'ajaxWatcherDisabled_front' => (bool)wfConfig::get('ajaxWatcherDisabled_front'), - 'ajaxWatcherDisabled_admin' => (bool)wfConfig::get('ajaxWatcherDisabled_admin') + 'ajaxWatcherDisabled_admin' => (bool)wfConfig::get('ajaxWatcherDisabled_admin') ); - + if (class_exists('wfFirewall')) { $firewall = new wfFirewall(); $return['isSubDirectoryInstallation'] = $firewall->isSubDirectoryInstallation(); @@ -874,15 +873,15 @@ SQL } $wfIssues->updateIssue($issueID, $status); wfScanEngine::refreshScanNotification($wfIssues); - + $counts = $wfIssues->getIssueCounts(); return array( 'ok' => 1, 'issueCounts' => $counts, ); } - - function update_issues_status() { + + function update_issues_status() { $wfIssues = new wfIssues(); $status = $_POST['status']; $issueID = $_POST['id']; @@ -994,8 +993,8 @@ SQL function bulkOperation() { return wordfence::ajax_bulkOperation_callback(); - } - + } + function delete_file() { $issueID = $_POST['issueID']; $wfIssues = new wfIssues(); @@ -1096,25 +1095,25 @@ SQL } return $res; } - - function save_settings_new() - { + + function save_settings_new() + { if (isset($_POST['encrypted'])) - $settings = $this->simple_crypt( 'thisisakey', $_POST['settings'], 'decrypt' ); // to fix pass through sec rules of Dreamhost + $settings = $this->simple_crypt( 'thisisakey', $_POST['settings'], 'decrypt' ); // to fix pass through sec rules of Dreamhost else { $settings = maybe_unserialize( base64_decode( $_POST['settings'] ) ); } - + $section = isset($_POST['savingSection']) ? $_POST['savingSection'] : ''; $saving_opts = self::getSectionSettings($section); - + $result = array(); - + if ( is_array( $settings ) && count( $settings ) > 0 && count($saving_opts) > 0 ) { - + $reload = ''; $opts = $settings; - + // if saving then validate data if (in_array('liveTraf_ignoreUsers', $saving_opts)) { $validUsers = array(); @@ -1142,7 +1141,7 @@ SQL } } - // if saving then validate data + // if saving then validate data if (in_array('other_WFNet', $saving_opts)) { if ( ! $opts['other_WFNet'] ) { $wfdb = new wfDB(); @@ -1153,15 +1152,15 @@ SQL } $regenerateHtaccess = false; - // if saving then validate data + // if saving then validate data if (in_array('bannedURLs', $saving_opts)) { if ( wfConfig::get( 'bannedURLs', false ) !== $opts['bannedURLs'] ) { $regenerateHtaccess = true; } - } - //error_log(print_r($opts, true)); + } + //error_log(print_r($opts, true)); // $to_fix_boolean_values = array( -// 'scansEnabled_checkGSB', +// 'scansEnabled_checkGSB', // 'spamvertizeCheck', // 'checkSpamIP', // 'scansEnabled_checkHowGetIPs', @@ -1186,29 +1185,29 @@ SQL // 'scansEnabled_scanImages', // 'scansEnabled_highSense', // 'scheduledScansEnabled', -// 'lowResourceScansEnabled', +// 'lowResourceScansEnabled', // ); -// +// // save the settings - foreach ( $opts as $key => $val ) { + foreach ( $opts as $key => $val ) { // check saving section fields if ( in_array( $key, $saving_opts ) ) { if ( 'apiKey' == $key ) { //Don't save API key yet continue; - } + } if (in_array( $key, self::$firewall_options_filter ) ) { wfWAF::getInstance()->getStorageEngine()->setConfig($key, $val); - } else { - wfConfig::set( $key, $val ); // save it - } - } + } else { + wfConfig::set( $key, $val ); // save it + } + } } - + if ( $regenerateHtaccess && ( wfConfig::get('cacheType') == 'falcon' ) ) { wfCache::addHtaccessCode('add'); } - - // if saving then validate data + + // if saving then validate data if (in_array('autoUpdate', $saving_opts)) { if ( '1' === $opts['autoUpdate'] ) { wfConfig::enableAutoUpdate(); @@ -1216,8 +1215,8 @@ SQL wfConfig::disableAutoUpdate(); } } - - // if saving then validate data + + // if saving then validate data if (in_array('disableCodeExecutionUploads', $saving_opts)) { if (isset($opts['disableCodeExecutionUploads'])) { try { @@ -1232,8 +1231,8 @@ SQL } } - // if saving then validate data - if (in_array('email_summary_enabled', $saving_opts)) { + // if saving then validate data + if (in_array('email_summary_enabled', $saving_opts)) { if (isset($opts['email_summary_enabled'])) { if ( ! empty( $opts['email_summary_enabled'] ) ) { wfConfig::set( 'email_summary_enabled', 1 ); @@ -1246,9 +1245,9 @@ SQL } } } - - // if saving then validate data - if (in_array('scheduleScan', $saving_opts)) { + + // if saving then validate data + if (in_array('scheduleScan', $saving_opts)) { $sch = isset( $opts['scheduleScan'] ) ? $opts['scheduleScan'] : ''; if ( get_option( 'mainwp_child_wordfence_cron_time' ) !== $sch ) { update_option( 'mainwp_child_wordfence_cron_time', $sch ); @@ -1258,17 +1257,17 @@ SQL } } } - + // Finished saving settings ///////////////////// - - + + $result['cacheType'] = wfConfig::get( 'cacheType' ); $result['paidKeyMsg'] = false; - + // if saving then validate data - if (in_array('apiKey', $saving_opts)) { - $apiKey = trim( $_POST['apiKey'] ); + if (in_array('apiKey', $saving_opts)) { + $apiKey = trim( $_POST['apiKey'] ); if ( ! $apiKey ) { //Empty API key (after trim above), then try to get one. $api = new wfAPI( '', wfUtils::getWPVersion() ); try { @@ -1319,26 +1318,26 @@ SQL } } } - + $result['ok'] = 1; $result['reload'] = $reload; - + return $result; } else { $result['error'] = 'Empty settings'; - } - + } + return $result; - } - - - public static function recentTraffic(){ - return wordfence::ajax_recentTraffic_callback(); + } + + + public static function recentTraffic(){ + return wordfence::ajax_recentTraffic_callback(); } - + function save_setting() { if (isset($_POST['encrypted'])) - $settings = $this->simple_crypt( 'thisisakey', $_POST['settings'], 'decrypt' ); // to fix pass through sec rules of Dreamhost + $settings = $this->simple_crypt( 'thisisakey', $_POST['settings'], 'decrypt' ); // to fix pass through sec rules of Dreamhost else { $settings = maybe_unserialize( base64_decode( $_POST['settings'] ) ); } @@ -1433,7 +1432,7 @@ SQL wp_unschedule_event( $sched, 'mainwp_child_wordfence_cron_scan' ); } } - + $result['cacheType'] = wfConfig::get( 'cacheType' ); $result['paidKeyMsg'] = false; $apiKey = trim( $_POST['apiKey'] ); @@ -1488,7 +1487,7 @@ SQL } $result['ok'] = 1; $result['reload'] = $reload; - + return $result; } } @@ -1558,15 +1557,15 @@ SQL $p = $wpdb->base_prefix; $serverTime = $wfdb->querySingle( 'select unix_timestamp()' ); - + $jsonData = array( 'serverTime' => $serverTime, 'serverMicrotime' => microtime(true), 'msg' => $wfdb->querySingle( "select msg from $p" . 'wfStatus where level < 3 order by ctime desc limit 1' ), ); - + $events = array(); - $alsoGet = $_POST['alsoGet']; + $alsoGet = $_POST['alsoGet']; if ( preg_match( '/^logList_(404|hit|human|ruser|crawler|gCrawler|loginLogout)$/', $alsoGet, $m ) ) { $type = $m[1]; $newestEventTime = $_POST['otherParams']; @@ -1587,7 +1586,7 @@ SQL if (isset($results['sql'])) { $jsonData['sql'] = $results['sql']; } - } + } $jsonData['events'] = $events; $jsonData['alsoGet'] = $alsoGet; //send it back so we don't load data if panel has changed $jsonData['cacheType'] = wfConfig::get( 'cacheType' ); @@ -1597,116 +1596,116 @@ SQL public static function loadLiveTraffic() { $wfdb = new wfDB(); $serverTime = $wfdb->querySingle( 'select unix_timestamp()' ); - $return = wordfence::ajax_loadLiveTraffic_callback(); + $return = wordfence::ajax_loadLiveTraffic_callback(); $return['serverTime'] = $serverTime; $return['serverMicrotime'] = microtime(true); - return $return; + return $return; } - function whitelistWAFParamKey() { + function whitelistWAFParamKey() { $return = wordfence::ajax_whitelistWAFParamKey_callback(); - return $return; + return $return; } - function hideFileHtaccess() { + function hideFileHtaccess() { $return = wordfence::ajax_hideFileHtaccess_callback(); - return $return; - } - + return $return; + } + public static function fixFPD(){ $return = wordfence::ajax_fixFPD_callback(); - return $return; + return $return; } - + public static function disableDirectoryListing() { $return = wordfence::ajax_disableDirectoryListing_callback(); - return $return; - } - + return $return; + } + public static function deleteDatabaseOption() { $return = wordfence::ajax_deleteDatabaseOption_callback(); - return $return; - } + return $return; + } public static function misconfiguredHowGetIPsChoice() { $return = wordfence::ajax_misconfiguredHowGetIPsChoice_callback(); return $return; } - + public static function deleteAdminUser() { $return = wordfence::ajax_deleteAdminUser_callback(); - return $return; - } - + return $return; + } + public static function revokeAdminUser() { $return = wordfence::ajax_revokeAdminUser_callback(); - return $return; + return $return; } public static function clearAllBlocked() { $return = wordfence::ajax_clearAllBlocked_callback(); - return $return; - } - + return $return; + } + public static function permanentlyBlockAllIPs() { $return = wordfence::ajax_permanentlyBlockAllIPs_callback(); - return $return; - } - + return $return; + } + public static function unlockOutIP() { $return = wordfence::ajax_unlockOutIP_callback(); - return $return; - } - + return $return; + } + public static function unblockRange() { $return = wordfence::ajax_unblockRange_callback(); - return $return; - } - + return $return; + } + public static function blockIPUARange() { $return = wordfence::ajax_blockIPUARange_callback(); - return $return; - } - + return $return; + } + public static function loadBlockRanges() { $return = wordfence::ajax_loadBlockRanges_callback(); - return $return; + return $return; } - - public static function saveWAFConfig() { + + public static function saveWAFConfig() { $return = wordfence::ajax_saveWAFConfig_callback(); - if (is_array($return) && isset($return['data'])) { + if (is_array($return) && isset($return['data'])) { $return['learningModeGracePeriod'] = wfWAF::getInstance()->getStorageEngine()->getConfig('learningModeGracePeriod'); } - return $return; - } - + return $return; + } + public static function whitelistBulkDelete() { $return = wordfence::ajax_whitelistBulkDelete_callback(); - return $return; - } - - public static function whitelistBulkEnable() { - $return = wordfence::ajax_whitelistBulkEnable_callback(); - return $return; + return $return; } - + + public static function whitelistBulkEnable() { + $return = wordfence::ajax_whitelistBulkEnable_callback(); + return $return; + } + public static function whitelistBulkDisable() { $return = wordfence::ajax_whitelistBulkDisable_callback(); - return $return; - } + return $return; + } public static function updateConfig() { $return = wordfence::ajax_updateConfig_callback(); - return $return; - } - + return $return; + } + // credit of Wordfence private static function _getWAFData($updated = null) { // custom if(!class_exists('wfWAF')) return false; // end if custom - + $data['learningMode'] = wfWAF::getInstance()->isInLearningMode(); $data['rules'] = wfWAF::getInstance()->getRules(); /** @var wfWAFRule $rule */ @@ -1750,14 +1749,14 @@ SQL $data['rulesLastUpdated'] = $lastUpdated; } $data['isPaid'] = (bool) wfConfig::get('isPaid', 0); - + if ($updated !== null) { $data['updated'] = (bool) $updated; } return $data; } - - + + function reverse_lookup() { $ips = explode( ',', $_POST['ips'] ); $res = array(); @@ -1768,27 +1767,27 @@ SQL return array( 'ok' => 1, 'ips' => $res ); } - - public function saveOptions(){ - if (!empty($_POST['changes']) && ($changes = json_decode(stripslashes($_POST['changes']), true)) !== false) { - try { + + public function saveOptions(){ + if (!empty($_POST['changes']) && ($changes = json_decode(stripslashes($_POST['changes']), true)) !== false) { + try { if (is_array($changes) && isset($changes['whitelistedURLParams']) && isset($changes['whitelistedURLParams']['add'])) { $user = wp_get_current_user(); foreach($changes['whitelistedURLParams']['add'] as $key => &$value) : if (isset($value['data'])) { - + if(isset($value['data']['userID'])) { $value['data']['userID'] = $user->ID; } if(isset($value['data']['username'])) { $value['data']['username'] = $user->user_login; - } + } } endforeach; } - + $errors = wfConfig::validate($changes); - + if ($errors !== true) { if (count($errors) == 1) { return array( @@ -1804,12 +1803,12 @@ SQL 'error' => sprintf(__('Errors occurred while saving the configuration: %s', 'wordfence'), implode(', ', $compoundMessage)), ); } - + return array( 'error' => __('Errors occurred while saving the configuration.', 'wordfence'), ); } - + wfConfig::save($changes); return array('success' => true); } @@ -1824,41 +1823,41 @@ SQL ); } } - + return array( 'error' => __('No configuration changes were provided to save.', 'wordfence'), - ); + ); } - + public function ajax_getBlocks_callback(){ $information = wordfence::ajax_getBlocks_callback(); return $information; } // credit of Wordfence public function ajax_createBlock_callback() - { - return wordfence::ajax_createBlock_callback(); - } - - public static function ajax_deleteBlocks_callback() { + { + return wordfence::ajax_createBlock_callback(); + } + + public static function ajax_deleteBlocks_callback() { $information = wordfence::ajax_deleteBlocks_callback(); return $information; } - - public static function ajax_makePermanentBlocks_callback() { + + public static function ajax_makePermanentBlocks_callback() { $information = wordfence::ajax_makePermanentBlocks_callback(); return $information; } - + public function ajax_blockIP_callback(){ return wordfence::ajax_blockIP_callback(); } - + // credit of Wordfence public function whois(){ return wordfence::ajax_whois_callback(); } - + function unblock_ip() { if ( isset( $_POST['IP'] ) ) { $IP = $_POST['IP']; @@ -1866,7 +1865,7 @@ SQL return array( 'success' => 1 ); } } - + public static function saveCountryBlocking(){ if(! wfConfig::get('isPaid')){ return array('error' => "Sorry but this feature is only available for paid customers."); @@ -2042,7 +2041,7 @@ SQL } return array('ok' => 1); } - + public static function downloadHtaccess() { if ( ! isset( $_GET['_wpnonce'] ) || empty( $_GET['_wpnonce'] ) ) { die( '-1' ); @@ -2201,7 +2200,7 @@ SQL $return['ok'] = 1; return $return; } - + public function getDiagnostics() { $diagnostic = new wfDiagnostic; @@ -2212,15 +2211,15 @@ SQL $themes = wp_get_themes(); $currentTheme = wp_get_theme(); $cols = 3; - + $w = new wfConfig(); - - $inEmail = false; - ob_start(); + + $inEmail = false; + ob_start(); ?>" . esc_attr( print_r( $backup, true ) ); +// if ( ! empty( $non ) ) { +// $jd = $updraftplus->jobdata_getarray( $non ); +// if ( ! empty( $jd ) && is_array( $jd ) ) { +// $rawbackup .= '
' . esc_attr( print_r( $jd, true ) ); +// } +// } +// $rawbackup .= '