mirror of
https://github.com/mainwp/mainwp-child.git
synced 2025-09-06 11:10:43 +08:00
Merge with branch01
This commit is contained in:
parent
5cdbc74c9b
commit
214ac3046a
16 changed files with 1200 additions and 1082 deletions
|
@ -28,7 +28,7 @@ class MainWP_Child_Back_Up_Buddy {
|
||||||
}
|
}
|
||||||
|
|
||||||
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
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( 'wp_ajax_mainwp_backupbuddy_download_archive', array( $this, 'download_archive' ) );
|
||||||
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
|
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ class MainWP_Child_Back_Up_Buddy {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function do_site_stats() {
|
function do_site_stats() {
|
||||||
if (has_action('mainwp_child_reports_log')) {
|
if (has_action('mainwp_child_reports_log')) {
|
||||||
do_action( 'mainwp_child_reports_log', 'backupbuddy');
|
do_action( 'mainwp_child_reports_log', 'backupbuddy');
|
||||||
} else {
|
} else {
|
||||||
|
@ -89,9 +89,9 @@ class MainWP_Child_Back_Up_Buddy {
|
||||||
if (!$this->is_backupbuddy_installed) {
|
if (!$this->is_backupbuddy_installed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
MainWP_Helper::check_methods( 'pb_backupbuddy', array( 'plugin_path' ));
|
MainWP_Helper::check_methods( 'pb_backupbuddy', array( 'plugin_path' ));
|
||||||
|
|
||||||
if ( ! class_exists( 'backupbuddy_core' ) ) {
|
if ( ! class_exists( 'backupbuddy_core' ) ) {
|
||||||
|
@ -102,9 +102,9 @@ class MainWP_Child_Back_Up_Buddy {
|
||||||
if (file_exists(pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'))
|
if (file_exists(pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'))
|
||||||
require_once( 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_classes_exists(array( 'backupbuddy_core', 'pb_backupbuddy_fileoptions' ));
|
||||||
MainWP_Helper::check_methods('backupbuddy_core', 'getLogDirectory');
|
MainWP_Helper::check_methods('backupbuddy_core', 'getLogDirectory');
|
||||||
|
|
||||||
// Backup type.
|
// Backup type.
|
||||||
$pretty_type = array(
|
$pretty_type = array(
|
||||||
'full' => 'Full',
|
'full' => 'Full',
|
||||||
|
@ -112,7 +112,7 @@ class MainWP_Child_Back_Up_Buddy {
|
||||||
'files' => 'Files',
|
'files' => 'Files',
|
||||||
);
|
);
|
||||||
|
|
||||||
$recentBackups_list = glob( backupbuddy_core::getLogDirectory() . 'fileoptions/*.txt' );
|
$recentBackups_list = glob( backupbuddy_core::getLogDirectory() . 'fileoptions/*.txt' );
|
||||||
|
|
||||||
|
|
||||||
foreach( $recentBackups_list as $backup_fileoptions ) {
|
foreach( $recentBackups_list as $backup_fileoptions ) {
|
||||||
|
@ -136,7 +136,7 @@ class MainWP_Child_Back_Up_Buddy {
|
||||||
|
|
||||||
$backupType = '';
|
$backupType = '';
|
||||||
if ( isset( $backup['profile'] ) && isset( $backup['profile']['type'] ) ) {
|
if ( isset( $backup['profile'] ) && isset( $backup['profile']['type'] ) ) {
|
||||||
if (true === MainWP_Helper::check_properties('pb_backupbuddy', 'format', true)) {
|
if (true === MainWP_Helper::check_properties('pb_backupbuddy', 'format', true)) {
|
||||||
if (true === MainWP_Helper::check_methods(pb_backupbuddy::$format, array( 'prettify' ), true)) {
|
if (true === MainWP_Helper::check_methods(pb_backupbuddy::$format, array( 'prettify' ), true)) {
|
||||||
$backupType = pb_backupbuddy::$format->prettify( $backup['profile']['type'], $pretty_type );
|
$backupType = pb_backupbuddy::$format->prettify( $backup['profile']['type'], $pretty_type );
|
||||||
}
|
}
|
||||||
|
@ -152,42 +152,40 @@ class MainWP_Child_Back_Up_Buddy {
|
||||||
}
|
}
|
||||||
|
|
||||||
$finish_time = $backup['finish_time'];
|
$finish_time = $backup['finish_time'];
|
||||||
$message = 'BackupBuddy ' . $backupType . ' finished';
|
$message = 'BackupBuddy ' . $backupType . ' finished';
|
||||||
if (!empty($finish_time)) {
|
if (!empty($finish_time)) {
|
||||||
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time);
|
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time);
|
||||||
MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support backup before update feature
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( file_exists(pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php') ) {
|
if ( file_exists(pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php') ) {
|
||||||
require_once( 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_classes_exists(array( 'backupbuddy_live_periodic' ));
|
||||||
MainWP_Helper::check_methods('backupbuddy_live_periodic', 'get_stats');
|
MainWP_Helper::check_methods('backupbuddy_live_periodic', 'get_stats');
|
||||||
|
|
||||||
$state = backupbuddy_live_periodic::get_stats();
|
$state = backupbuddy_live_periodic::get_stats();
|
||||||
if (is_array($state) && isset($state['stats'])) {
|
if (is_array($state) && isset($state['stats'])) {
|
||||||
|
|
||||||
if ( is_array($state['stats'] ) && isset( $state['stats']['last_remote_snapshot'] )) {
|
if ( is_array($state['stats'] ) && isset( $state['stats']['last_remote_snapshot'] )) {
|
||||||
if (isset( $state['stats']['last_remote_snapshot_response'] )) {
|
if (isset( $state['stats']['last_remote_snapshot_response'] )) {
|
||||||
$resp = $state['stats']['last_remote_snapshot_response'];
|
$resp = $state['stats']['last_remote_snapshot_response'];
|
||||||
if ( isset( $resp['success'] ) && $resp['success']) {
|
if ( isset( $resp['success'] ) && $resp['success']) {
|
||||||
$finish_time = $state['stats']['last_remote_snapshot'];
|
$finish_time = $state['stats']['last_remote_snapshot'];
|
||||||
$backupType = 'Live Backup to cloud';
|
$backupType = 'Live Backup to cloud';
|
||||||
$message = 'BackupBuddy ' . $backupType . ' finished';
|
$message = 'BackupBuddy ' . $backupType . ' finished';
|
||||||
if (!empty($finish_time)) {
|
if (!empty($finish_time)) {
|
||||||
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time);
|
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time);
|
||||||
MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support backup before update feature
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch( Exception $e ) {
|
} catch( Exception $e ) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,47 +721,73 @@ class MainWP_Child_Back_Up_Buddy {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok
|
// ok
|
||||||
public function syncOthersData( $information, $data = array() ) {
|
public function syncOthersData( $information, $data = array() ) {
|
||||||
if ( isset( $data['syncBackupBuddy'] ) && $data['syncBackupBuddy'] ) {
|
if ( isset( $data['syncBackupBuddy'] ) && $data['syncBackupBuddy'] ) {
|
||||||
try {
|
try {
|
||||||
$information['syncBackupBuddy'] = $this->get_sync_data();
|
$information['syncBackupBuddy'] = $this->get_sync_data();
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $information;
|
return $information;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok
|
// ok
|
||||||
public function get_sync_data() {
|
public function get_sync_data() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ( ! class_exists( 'backupbuddy_core' ) ) {
|
if ( ! class_exists( 'backupbuddy_core' ) ) {
|
||||||
MainWP_Helper::check_classes_exists('pb_backupbuddy');
|
MainWP_Helper::check_classes_exists('pb_backupbuddy');
|
||||||
MainWP_Helper::check_methods('pb_backupbuddy', array( 'plugin_path' ) );
|
MainWP_Helper::check_methods('pb_backupbuddy', array( 'plugin_path' ) );
|
||||||
|
|
||||||
$plugin_path = pb_backupbuddy::plugin_path();
|
$plugin_path = pb_backupbuddy::plugin_path();
|
||||||
if (file_exists($plugin_path . '/classes/core.php'))
|
if (file_exists($plugin_path . '/classes/core.php'))
|
||||||
require_once( $plugin_path . '/classes/core.php' );
|
require_once( $plugin_path . '/classes/core.php' );
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWP_Helper::check_classes_exists('backupbuddy_core');
|
MainWP_Helper::check_classes_exists(array( 'backupbuddy_core', 'backupbuddy_api' ));
|
||||||
MainWP_Helper::check_methods('backupbuddy_core', array( 'get_plugins_root', 'get_themes_root', 'get_media_root' ) );
|
MainWP_Helper::check_methods('backupbuddy_core', array( 'get_plugins_root', 'get_themes_root', 'get_media_root' ) );
|
||||||
|
MainWP_Helper::check_methods('backupbuddy_api', array( 'getOverview' ) );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['plugins_root'] = backupbuddy_core::get_plugins_root();
|
$data['plugins_root'] = backupbuddy_core::get_plugins_root();
|
||||||
$data['themes_root'] = backupbuddy_core::get_themes_root();
|
$data['themes_root'] = backupbuddy_core::get_themes_root();
|
||||||
$data['media_root'] = backupbuddy_core::get_media_root();
|
$data['media_root'] = backupbuddy_core::get_media_root();
|
||||||
$data['additional_tables'] = $this->pb_additional_tables();
|
$data['additional_tables'] = $this->pb_additional_tables();
|
||||||
$data['abspath'] = ABSPATH;
|
$data['abspath'] = ABSPATH;
|
||||||
|
|
||||||
|
$getOverview = backupbuddy_api::getOverview();
|
||||||
|
$data['editsSinceLastBackup'] = $getOverview['editsSinceLastBackup'] ;
|
||||||
|
|
||||||
|
if ( isset( $getOverview['lastBackupStats']['finish'] ) ) {
|
||||||
|
$finish_time = $getOverview['lastBackupStats']['finish'] ;
|
||||||
|
$time = $this->localize_time( $finish_time );
|
||||||
|
$data['lastBackupStats'] = date("M j - g:i A", $time);
|
||||||
|
$data['lasttime_backup'] = $finish_time;
|
||||||
|
MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support Require Backup Before Update feature
|
||||||
|
} else {
|
||||||
|
$data['lastBackupStats'] = 'Unknown';
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
// not exit here
|
// not exit here
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function localize_time( $timestamp ) {
|
||||||
|
if ( function_exists( 'get_option' ) ) {
|
||||||
|
$gmt_offset = get_option( 'gmt_offset' );
|
||||||
|
} else {
|
||||||
|
$gmt_offset = 0;
|
||||||
|
}
|
||||||
|
return $timestamp + ( $gmt_offset * 3600 );
|
||||||
|
}
|
||||||
|
|
||||||
function backup_list() {
|
function backup_list() {
|
||||||
require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' );
|
require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' );
|
||||||
$information = array();
|
$information = array();
|
||||||
|
@ -838,7 +862,7 @@ class MainWP_Child_Back_Up_Buddy {
|
||||||
// This will identify the backup zip file we want to list
|
// This will identify the backup zip file we want to list
|
||||||
$serial = $_POST[ 'serial' ];
|
$serial = $_POST[ 'serial' ];
|
||||||
$alerts = array();
|
$alerts = array();
|
||||||
// The fileoptions file that contains the file tree information
|
// The fileoptions file that contains the file tree information
|
||||||
require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' );
|
require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' );
|
||||||
$fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '-filetree.txt';
|
$fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '-filetree.txt';
|
||||||
|
|
||||||
|
@ -852,7 +876,7 @@ class MainWP_Child_Back_Up_Buddy {
|
||||||
pb_backupbuddy::status( 'details', 'Fileoptions instance #28.' );
|
pb_backupbuddy::status( 'details', 'Fileoptions instance #28.' );
|
||||||
$fileoptions = new pb_backupbuddy_fileoptions( $fileoptions_file );
|
$fileoptions = new pb_backupbuddy_fileoptions( $fileoptions_file );
|
||||||
$zip_viewer = $_POST[ 'zip_viewer' ];
|
$zip_viewer = $_POST[ 'zip_viewer' ];
|
||||||
// Either we are getting cached file tree information or we need to create afresh
|
// Either we are getting cached file tree information or we need to create afresh
|
||||||
if ( true !== ( $result = $fileoptions->is_ok() ) ) {
|
if ( true !== ( $result = $fileoptions->is_ok() ) ) {
|
||||||
// Get file listing.
|
// Get file listing.
|
||||||
require_once( pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php' );
|
require_once( pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php' );
|
||||||
|
@ -1018,13 +1042,13 @@ class MainWP_Child_Back_Up_Buddy {
|
||||||
|
|
||||||
// ok
|
// ok
|
||||||
function pb_additional_tables( $display_size = false ) {
|
function pb_additional_tables( $display_size = false ) {
|
||||||
|
|
||||||
MainWP_Helper::check_classes_exists('pb_backupbuddy');
|
MainWP_Helper::check_classes_exists('pb_backupbuddy');
|
||||||
MainWP_Helper::check_methods('pb_backupbuddy', 'plugin_url');
|
MainWP_Helper::check_methods('pb_backupbuddy', 'plugin_url');
|
||||||
MainWP_Helper::check_properties('pb_backupbuddy', 'format');
|
MainWP_Helper::check_properties('pb_backupbuddy', 'format');
|
||||||
MainWP_Helper::check_methods(pb_backupbuddy::$format, 'file_size');
|
MainWP_Helper::check_methods(pb_backupbuddy::$format, 'file_size');
|
||||||
|
|
||||||
|
|
||||||
$return = '';
|
$return = '';
|
||||||
$size_string = '';
|
$size_string = '';
|
||||||
|
|
||||||
|
@ -1890,9 +1914,9 @@ class MainWP_Child_Back_Up_Buddy {
|
||||||
function remote_save() {
|
function remote_save() {
|
||||||
$data = isset($_POST['data']) ? $_POST['data'] : false;
|
$data = isset($_POST['data']) ? $_POST['data'] : false;
|
||||||
$destination_id = isset($_POST['destination_id']) ? $_POST['destination_id'] : 0;
|
$destination_id = isset($_POST['destination_id']) ? $_POST['destination_id'] : 0;
|
||||||
|
|
||||||
if (is_array($data) && isset($data['do_not_override'])) {
|
if (is_array($data) && isset($data['do_not_override'])) {
|
||||||
|
|
||||||
if (true == $data['do_not_override']) {
|
if (true == $data['do_not_override']) {
|
||||||
if (($data['type'] == 's32' || $data['type'] == 's33')) {
|
if (($data['type'] == 's32' || $data['type'] == 's33')) {
|
||||||
$not_override = array(
|
$not_override = array(
|
||||||
|
@ -1903,16 +1927,16 @@ class MainWP_Child_Back_Up_Buddy {
|
||||||
);
|
);
|
||||||
foreach($not_override as $opt) {
|
foreach($not_override as $opt) {
|
||||||
if (isset($data[$opt])) {
|
if (isset($data[$opt])) {
|
||||||
unset($data[$opt]);
|
unset($data[$opt]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($data['do_not_override']);
|
unset($data['do_not_override']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (is_array($data)) {
|
if (is_array($data)) {
|
||||||
if (isset(pb_backupbuddy::$options['remote_destinations'][$destination_id])) { // update
|
if (isset(pb_backupbuddy::$options['remote_destinations'][$destination_id])) { // update
|
||||||
pb_backupbuddy::$options['remote_destinations'][$destination_id] = array_merge( pb_backupbuddy::$options['remote_destinations'][$destination_id], $data );
|
pb_backupbuddy::$options['remote_destinations'][$destination_id] = array_merge( pb_backupbuddy::$options['remote_destinations'][$destination_id], $data );
|
||||||
|
|
|
@ -10,16 +10,16 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
|
|
||||||
return MainWP_Child_Back_Up_Wordpress::$instance;
|
return MainWP_Child_Back_Up_Wordpress::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||||
if ( is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) {
|
if ( is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) {
|
||||||
$this->is_plugin_installed = true;
|
$this->is_plugin_installed = true;
|
||||||
if ( version_compare( phpversion(), '5.3', '>=' ) ) {
|
if ( version_compare( phpversion(), '5.3', '>=' ) ) {
|
||||||
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function init() {
|
public function init() {
|
||||||
|
@ -100,6 +100,9 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
case 'exclude_remove_rule':
|
case 'exclude_remove_rule':
|
||||||
$information = $this->hmbkp_remove_exclude_rule();
|
$information = $this->hmbkp_remove_exclude_rule();
|
||||||
break;
|
break;
|
||||||
|
case 'general_exclude_add_rule':
|
||||||
|
$information = $this->general_exclude_add_rule();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MainWP_Helper::write( $information );
|
MainWP_Helper::write( $information );
|
||||||
|
@ -124,29 +127,29 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
}
|
}
|
||||||
// ok
|
// ok
|
||||||
public function syncOthersData( $information, $data = array() ) {
|
public function syncOthersData( $information, $data = array() ) {
|
||||||
if ( isset( $data['syncBackUpWordPress'] ) && $data['syncBackUpWordPress'] ) {
|
if ( isset( $data['syncBackUpWordPress'] ) && $data['syncBackUpWordPress'] ) {
|
||||||
try {
|
try {
|
||||||
$information['syncBackUpWordPress'] = $this->get_sync_data();
|
$information['syncBackUpWordPress'] = $this->get_sync_data();
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $information;
|
return $information;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok
|
// ok
|
||||||
private function get_sync_data() {
|
private function get_sync_data() {
|
||||||
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
|
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
|
||||||
MainWP_Helper::check_methods('HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ) );
|
MainWP_Helper::check_methods('HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ) );
|
||||||
|
|
||||||
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
||||||
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
|
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
|
||||||
$backups_time = array();
|
$backups_time = array();
|
||||||
|
|
||||||
if (is_array($schedules) && count($schedules)) {
|
if (is_array($schedules) && count($schedules)) {
|
||||||
$check = current($schedules);
|
$check = current($schedules);
|
||||||
MainWP_Helper::check_methods($check, array( 'get_backups' ) );
|
MainWP_Helper::check_methods($check, array( 'get_backups' ) );
|
||||||
|
|
||||||
foreach ( $schedules as $sche ) {
|
foreach ( $schedules as $sche ) {
|
||||||
$existing_backup = $sche->get_backups();
|
$existing_backup = $sche->get_backups();
|
||||||
if ( ! empty( $existing_backup ) ) {
|
if ( ! empty( $existing_backup ) ) {
|
||||||
|
@ -164,7 +167,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_site_stats() {
|
function do_site_stats() {
|
||||||
if (has_action('mainwp_child_reports_log')) {
|
if (has_action('mainwp_child_reports_log')) {
|
||||||
do_action( 'mainwp_child_reports_log', 'backupwordpress');
|
do_action( 'mainwp_child_reports_log', 'backupwordpress');
|
||||||
|
@ -172,23 +175,23 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
$this->do_reports_log('backupwordpress');
|
$this->do_reports_log('backupwordpress');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok
|
// ok
|
||||||
public function do_reports_log($ext = '') {
|
public function do_reports_log($ext = '') {
|
||||||
if ( $ext !== 'backupwordpress' ) return;
|
if ( $ext !== 'backupwordpress' ) return;
|
||||||
if (!$this->is_plugin_installed) return;
|
if (!$this->is_plugin_installed) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
|
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
|
||||||
MainWP_Helper::check_methods('HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_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
|
// Refresh the schedules from the database to make sure we have the latest changes
|
||||||
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
||||||
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
|
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
|
||||||
if (is_array($schedules) && count($schedules) > 0) {
|
if (is_array($schedules) && count($schedules) > 0) {
|
||||||
$check = current($schedules);
|
$check = current($schedules);
|
||||||
MainWP_Helper::check_methods($check, array( 'get_backups', 'get_type' ));
|
MainWP_Helper::check_methods($check, array( 'get_backups', 'get_type' ));
|
||||||
|
|
||||||
foreach($schedules as $schedule) {
|
foreach($schedules as $schedule) {
|
||||||
foreach ( $schedule->get_backups() as $file ) {
|
foreach ( $schedule->get_backups() as $file ) {
|
||||||
$backup_type = $schedule->get_type();
|
$backup_type = $schedule->get_type();
|
||||||
|
@ -206,9 +209,9 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
}
|
}
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_showhide() {
|
function set_showhide() {
|
||||||
$hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
|
$hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
|
||||||
MainWP_Helper::update_option( 'mainwp_backupwordpress_hide_plugin', $hide );
|
MainWP_Helper::update_option( 'mainwp_backupwordpress_hide_plugin', $hide );
|
||||||
|
@ -625,7 +628,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
<p><?php esc_html_e( 'Here\'s a directory listing of all files on your site, you can browse through and exclude files or folders that you don\'t want included in your backup.', 'backupwordpress' ); ?></p>
|
<p><?php esc_html_e( 'Here\'s a directory listing of all files on your site, you can browse through and exclude files or folders that you don\'t want included in your backup.', 'backupwordpress' ); ?></p>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// The directory to display
|
// The directory to display
|
||||||
$directory = $root_dir;
|
$directory = $root_dir;
|
||||||
|
|
||||||
if ( isset( $browse_dir ) ) {
|
if ( isset( $browse_dir ) ) {
|
||||||
|
@ -1047,28 +1050,58 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_exclude_rule() {
|
|
||||||
|
|
||||||
check_admin_referer( 'hmbkp_remove_exclude_rule', 'hmbkp-remove_exclude_rule_nonce' );
|
function general_exclude_add_rule() {
|
||||||
|
|
||||||
if ( ! isset( $_GET['hmbkp_remove_exclude'] ) ) {
|
$sch_id = $this->check_schedule();
|
||||||
die;
|
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $sch_id ) );
|
||||||
}
|
|
||||||
|
|
||||||
$schedule = new Scheduled_Backup( sanitize_text_field( $_GET['hmbkp_schedule_id'] ) );
|
$exclude_paths = urldecode( $_POST['exclude_paths'] );
|
||||||
|
$exclude_paths = explode("\n", $exclude_paths);
|
||||||
|
if (is_array($exclude_paths) && count($exclude_paths) > 0) {
|
||||||
|
foreach ( $exclude_paths as $excl_rule ) {
|
||||||
|
$excl_rule = trim($excl_rule);
|
||||||
|
$excl_rule = trim($excl_rule, '/');
|
||||||
|
|
||||||
$excludes = $schedule->get_excludes();
|
if (empty($excl_rule))
|
||||||
$exclude_rule_to_remove = stripslashes( sanitize_text_field( $_GET['hmbkp_remove_exclude'] ) );
|
continue;
|
||||||
|
|
||||||
$schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) );
|
$exclude_rule = ABSPATH . $excl_rule;
|
||||||
|
$path = realpath($exclude_rule);
|
||||||
|
// If it exist
|
||||||
|
if($path !== false)
|
||||||
|
{
|
||||||
|
$schedule->set_excludes( $exclude_rule, true );
|
||||||
|
$schedule->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$schedule->save();
|
|
||||||
|
|
||||||
wp_safe_redirect( wp_get_referer(), '303' );
|
$un_exclude_paths = urldecode( $_POST['un_exclude_paths'] );
|
||||||
|
$un_exclude_paths = explode("\n", $un_exclude_paths);
|
||||||
|
|
||||||
die;
|
if (is_array($un_exclude_paths) && count(get_user_excludes) > 0) {
|
||||||
|
foreach ( $un_exclude_paths as $exclude_rule_to_remove ) {
|
||||||
|
$exclude_rule_to_remove = trim($exclude_rule_to_remove);
|
||||||
|
$exclude_rule_to_remove = trim($exclude_rule_to_remove, '/');
|
||||||
|
|
||||||
|
if (empty($exclude_rule_to_remove))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$excludes = $schedule->get_excludes();
|
||||||
|
if (method_exists($excludes, 'get_user_excludes')) {
|
||||||
|
$schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) );
|
||||||
|
} else {
|
||||||
|
$schedule->set_excludes( array_diff( $excludes, $exclude_rule_to_remove ) );
|
||||||
|
}
|
||||||
|
$schedule->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array('result' => 'SUCCESS');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function update_schedule() {
|
function update_schedule() {
|
||||||
$sch_id = isset( $_POST['schedule_id'] ) ? $_POST['schedule_id'] : 0;
|
$sch_id = isset( $_POST['schedule_id'] ) ? $_POST['schedule_id'] : 0;
|
||||||
|
@ -1105,7 +1138,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
}
|
}
|
||||||
|
|
||||||
update_option( 'hmbkp_schedule_' . $sch_id, $options );
|
update_option( 'hmbkp_schedule_' . $sch_id, $options );
|
||||||
delete_transient( 'hmbkp_schedules' );
|
delete_transient( 'hmbkp_schedules' );
|
||||||
$out['result'] = 'SUCCESS';
|
$out['result'] = 'SUCCESS';
|
||||||
} else {
|
} else {
|
||||||
$out['result'] = 'NOTCHANGE';
|
$out['result'] = 'NOTCHANGE';
|
||||||
|
|
|
@ -51,20 +51,20 @@ class MainWP_Child_Back_WP_Up {
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if ( is_plugin_active( 'backwpup-pro/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php' ) ) {
|
if ( is_plugin_active( 'backwpup-pro/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php' ) ) {
|
||||||
$file_path1 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php';
|
$file_path1 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php';
|
||||||
$file_path2 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/inc/pro/class-pro.php';
|
$file_path2 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/inc/pro/class-pro.php';
|
||||||
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
|
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
|
||||||
require_once( $file_path1 );
|
require_once( $file_path1 );
|
||||||
require_once( $file_path2 );
|
require_once( $file_path2 );
|
||||||
$this->is_backwpup_installed = true;
|
$this->is_backwpup_installed = true;
|
||||||
$this->is_backwpup_pro = true;
|
$this->is_backwpup_pro = true;
|
||||||
} else if ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) {
|
} else if ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) {
|
||||||
$file_path = plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php';
|
$file_path = plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php';
|
||||||
MainWP_Helper::check_files_exists(array( $file_path ));
|
MainWP_Helper::check_files_exists(array( $file_path ));
|
||||||
require_once( $file_path );
|
require_once( $file_path );
|
||||||
$this->is_backwpup_installed = true;
|
$this->is_backwpup_installed = true;
|
||||||
}
|
}
|
||||||
|
@ -72,17 +72,17 @@ class MainWP_Child_Back_WP_Up {
|
||||||
if ($this->is_backwpup_installed) {
|
if ($this->is_backwpup_installed) {
|
||||||
MainWP_Helper::check_classes_exists('BackWPup');
|
MainWP_Helper::check_classes_exists('BackWPup');
|
||||||
MainWP_Helper::check_methods('get_instance');
|
MainWP_Helper::check_methods('get_instance');
|
||||||
BackWPup::get_instance();
|
BackWPup::get_instance();
|
||||||
|
|
||||||
add_action( 'wp_ajax_mainwp_backwpup_download_backup', array( $this, 'download_backup' ) );
|
add_action( 'wp_ajax_mainwp_backwpup_download_backup', array( $this, 'download_backup' ) );
|
||||||
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
||||||
}
|
}
|
||||||
} catch ( Exception $e) {
|
} catch ( Exception $e) {
|
||||||
// do not exit()
|
// do not exit()
|
||||||
$this->is_backwpup_installed = false;
|
$this->is_backwpup_installed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function action() {
|
public function action() {
|
||||||
if ( ! $this->is_backwpup_installed ) {
|
if ( ! $this->is_backwpup_installed ) {
|
||||||
MainWP_Helper::write( array( 'error' => __( 'Please install BackWPup plugin on child website', $this->plugin_translate ) ) );
|
MainWP_Helper::write( array( 'error' => __( 'Please install BackWPup plugin on child website', $this->plugin_translate ) ) );
|
||||||
|
@ -221,18 +221,42 @@ class MainWP_Child_Back_WP_Up {
|
||||||
if ( $ext !== 'backwpup' ) return;
|
if ( $ext !== 'backwpup' ) return;
|
||||||
if (!$this->is_backwpup_installed)
|
if (!$this->is_backwpup_installed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MainWP_Helper::check_classes_exists(array('BackWPup'));
|
MainWP_Helper::check_classes_exists(array('BackWPup'));
|
||||||
MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' ));
|
MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' ));
|
||||||
|
|
||||||
|
|
||||||
$destinations = BackWPup::get_registered_destinations();
|
$destinations = BackWPup::get_registered_destinations();
|
||||||
$jobdests = $this->get_destinations_list();
|
$jobdests = $this->get_destinations_list();
|
||||||
|
|
||||||
if ( !empty( $jobdests ) ) {
|
if ( !empty( $jobdests ) ) {
|
||||||
|
$job_types = array(
|
||||||
|
'DBDUMP' => __('Database backup', 'mainwp-child'),
|
||||||
|
'FILE' => __('File backup', 'mainwp-child'),
|
||||||
|
'WPEXP' => __('WordPress XML export', 'mainwp-child'),
|
||||||
|
'WPPLUGIN' => __('Installed plugins list', 'mainwp-child'),
|
||||||
|
'DBCHECK' => __('Check database tables', 'mainwp-child')
|
||||||
|
);
|
||||||
|
|
||||||
foreach ($jobdests as $jobdest) {
|
foreach ($jobdests as $jobdest) {
|
||||||
list( $jobid, $dest ) = explode( '_', $jobdest );
|
list( $jobid, $dest ) = explode( '_', $jobdest );
|
||||||
if ( ! empty( $destinations[ $dest ][ 'class' ] ) ) {
|
if ( ! empty( $destinations[ $dest ][ 'class' ] ) ) {
|
||||||
|
|
||||||
|
$job_job_types = BackWPup_Option::get( $jobid, 'type' );
|
||||||
|
|
||||||
|
$backup_type = '';
|
||||||
|
foreach($job_job_types as $typeid) {
|
||||||
|
if (isset( $job_types[$typeid] )) {
|
||||||
|
$backup_type .= ' + ' . $job_types[$typeid];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($backup_type))
|
||||||
|
$backup_type = 'BackWPup';
|
||||||
|
else {
|
||||||
|
$backup_type = ltrim($backup_type, ' + ');
|
||||||
|
}
|
||||||
|
|
||||||
$dest_object = BackWPup::get_destination( $dest );
|
$dest_object = BackWPup::get_destination( $dest );
|
||||||
$items = $dest_object->file_get_list( $jobdest );
|
$items = $dest_object->file_get_list( $jobdest );
|
||||||
//if no items brake
|
//if no items brake
|
||||||
|
@ -240,8 +264,7 @@ class MainWP_Child_Back_WP_Up {
|
||||||
foreach ( $items as $ma ) {
|
foreach ( $items as $ma ) {
|
||||||
if (isset($ma['time'])) {
|
if (isset($ma['time'])) {
|
||||||
$backup_time = $ma[ "time" ];
|
$backup_time = $ma[ "time" ];
|
||||||
$message = 'BackWPup backup finished';
|
$message = 'BackWPup backup finished (' . $backup_type . ')';
|
||||||
$backup_type = 'BackWPup';
|
|
||||||
$destination = "N/A";
|
$destination = "N/A";
|
||||||
if (!empty($backup_time)) {
|
if (!empty($backup_time)) {
|
||||||
do_action( 'mainwp_backwpup_backup', $message, $backup_type, $backup_time );
|
do_action( 'mainwp_backwpup_backup', $message, $backup_type, $backup_time );
|
||||||
|
@ -254,30 +277,30 @@ class MainWP_Child_Back_WP_Up {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok
|
// ok
|
||||||
function syncOthersData( $information, $data = array() ) {
|
function syncOthersData( $information, $data = array() ) {
|
||||||
if ( isset( $data['syncBackwpupData'] ) && $data['syncBackwpupData'] ) {
|
if ( isset( $data['syncBackwpupData'] ) && $data['syncBackwpupData'] ) {
|
||||||
try{
|
try{
|
||||||
$lastbackup = MainWP_Helper::get_lasttime_backup('backwpup');
|
$lastbackup = MainWP_Helper::get_lasttime_backup('backwpup');
|
||||||
$information['syncBackwpupData'] = array(
|
$information['syncBackwpupData'] = array(
|
||||||
'lastbackup' => $lastbackup
|
'lastbackup' => $lastbackup
|
||||||
);
|
);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $information;
|
return $information;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_destinations_list() {
|
function get_destinations_list() {
|
||||||
MainWP_Helper::check_classes_exists(array('BackWPup', 'BackWPup_Option'));
|
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', array( 'get_registered_destinations', 'get_destination' ));
|
||||||
MainWP_Helper::check_methods('BackWPup_Option', array( 'get_job_ids', 'get' ));
|
MainWP_Helper::check_methods('BackWPup_Option', array( 'get_job_ids', 'get' ));
|
||||||
|
|
||||||
$jobdest = array();
|
$jobdest = array();
|
||||||
$jobids = BackWPup_Option::get_job_ids();
|
$jobids = BackWPup_Option::get_job_ids();
|
||||||
$destinations = BackWPup::get_registered_destinations();
|
$destinations = BackWPup::get_registered_destinations();
|
||||||
|
@ -290,7 +313,7 @@ class MainWP_Child_Back_WP_Up {
|
||||||
if ( ! $destinations[ $dest ][ 'class' ] ) {
|
if ( ! $destinations[ $dest ][ 'class' ] ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dest_class = BackWPup::get_destination( $dest );
|
$dest_class = BackWPup::get_destination( $dest );
|
||||||
if ($dest_class && method_exists($dest_class, 'file_get_list')) {
|
if ($dest_class && method_exists($dest_class, 'file_get_list')) {
|
||||||
$can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest );
|
$can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest );
|
||||||
|
@ -396,9 +419,9 @@ class MainWP_Child_Back_WP_Up {
|
||||||
echo '</td></tr>';
|
echo '</td></tr>';
|
||||||
|
|
||||||
echo '<tr><td>' . __( 'Log folder:', 'backwpup' ) . '</td><td>';
|
echo '<tr><td>' . __( 'Log folder:', 'backwpup' ) . '</td><td>';
|
||||||
|
|
||||||
$log_folder = BackWPup_File::get_absolute_path( get_site_option( 'backwpup_cfg_logfolder' ) );
|
$log_folder = BackWPup_File::get_absolute_path( get_site_option( 'backwpup_cfg_logfolder' ) );
|
||||||
|
|
||||||
if ( ! is_dir( $log_folder ) ) {
|
if ( ! is_dir( $log_folder ) ) {
|
||||||
echo sprintf( __( 'Logs folder %s not exist.', 'backwpup' ), esc_html( $log_folder ) );
|
echo sprintf( __( 'Logs folder %s not exist.', 'backwpup' ), esc_html( $log_folder ) );
|
||||||
} elseif ( ! is_writable( $log_folder ) ) {
|
} elseif ( ! is_writable( $log_folder ) ) {
|
||||||
|
@ -474,7 +497,7 @@ class MainWP_Child_Back_WP_Up {
|
||||||
|
|
||||||
$dir = get_site_option( 'backwpup_cfg_logfolder' );
|
$dir = get_site_option( 'backwpup_cfg_logfolder' );
|
||||||
$dir = BackWPup_File::get_absolute_path( $dir );
|
$dir = BackWPup_File::get_absolute_path( $dir );
|
||||||
|
|
||||||
foreach ( $_POST['settings']['logfile'] as $logfile ) {
|
foreach ( $_POST['settings']['logfile'] as $logfile ) {
|
||||||
$logfile = basename( $logfile );
|
$logfile = basename( $logfile );
|
||||||
|
|
||||||
|
@ -591,7 +614,7 @@ class MainWP_Child_Back_WP_Up {
|
||||||
$log_folder = get_site_option( 'backwpup_cfg_logfolder' );
|
$log_folder = get_site_option( 'backwpup_cfg_logfolder' );
|
||||||
$log_folder = BackWPup_File::get_absolute_path( $log_folder );
|
$log_folder = BackWPup_File::get_absolute_path( $log_folder );
|
||||||
$log_folder = untrailingslashit( $log_folder );
|
$log_folder = untrailingslashit( $log_folder );
|
||||||
|
|
||||||
if ( ! is_dir( $log_folder ) ) {
|
if ( ! is_dir( $log_folder ) ) {
|
||||||
return array( 'success' => 1, 'response' => $array );
|
return array( 'success' => 1, 'response' => $array );
|
||||||
}
|
}
|
||||||
|
@ -619,7 +642,7 @@ class MainWP_Child_Back_WP_Up {
|
||||||
if ( is_null($dest_class) ) {
|
if ( is_null($dest_class) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$items = $dest_class->file_get_list( $jobid . '_' . $dest );
|
$items = $dest_class->file_get_list( $jobid . '_' . $dest );
|
||||||
if ( ! empty( $items ) ) {
|
if ( ! empty( $items ) ) {
|
||||||
foreach ( $items as $item ) {
|
foreach ( $items as $item ) {
|
||||||
$temp_single_item = $item;
|
$temp_single_item = $item;
|
||||||
|
|
|
@ -238,13 +238,13 @@ class MainWP_Child_Branding {
|
||||||
}
|
}
|
||||||
|
|
||||||
static function uploadImage( $img_url ) {
|
static function uploadImage( $img_url ) {
|
||||||
include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url
|
include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url
|
||||||
global $mainWPChild;
|
global $mainWPChild;
|
||||||
add_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
add_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
||||||
//Download $img_url
|
//Download $img_url
|
||||||
$temporary_file = download_url( $img_url );
|
$temporary_file = download_url( $img_url );
|
||||||
remove_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
remove_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
||||||
|
|
||||||
if ( is_wp_error( $temporary_file ) ) {
|
if ( is_wp_error( $temporary_file ) ) {
|
||||||
throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
|
throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
|
||||||
} else {
|
} else {
|
||||||
|
@ -286,12 +286,12 @@ class MainWP_Child_Branding {
|
||||||
}
|
}
|
||||||
|
|
||||||
add_filter( 'map_meta_cap', array( $this, 'branding_map_meta_cap' ), 10, 5 );
|
add_filter( 'map_meta_cap', array( $this, 'branding_map_meta_cap' ), 10, 5 );
|
||||||
|
|
||||||
if ( 'T' === get_option( 'mainwp_branding_disable_change' ) ) {
|
if ( 'T' === get_option( 'mainwp_branding_disable_change' ) ) {
|
||||||
|
|
||||||
// Disable the wordpress plugin update notifications
|
// Disable the wordpress plugin update notifications
|
||||||
remove_action('load-update-core.php', 'wp_update_plugins');
|
remove_action('load-update-core.php', 'wp_update_plugins');
|
||||||
add_filter('pre_site_transient_update_plugins', '__return_null');
|
add_filter('pre_site_transient_update_plugins', '__return_null');
|
||||||
|
|
||||||
// Disable the wordpress theme update notifications
|
// Disable the wordpress theme update notifications
|
||||||
remove_action('load-update-core.php', 'wp_update_themes');
|
remove_action('load-update-core.php', 'wp_update_themes');
|
||||||
|
@ -299,40 +299,22 @@ class MainWP_Child_Branding {
|
||||||
|
|
||||||
// Disable the wordpress core update notifications
|
// Disable the wordpress core update notifications
|
||||||
add_action('after_setup_theme', 'remove_core_updates');
|
add_action('after_setup_theme', 'remove_core_updates');
|
||||||
function remove_core_updates() {
|
function remove_core_updates() {
|
||||||
add_action('init', ( $func = function($a){ remove_action( 'wp_version_check', 'wp_version_check' );} ), 2);
|
add_action('init', ( $func = function($a){ remove_action( 'wp_version_check', 'wp_version_check' );} ), 2);
|
||||||
add_filter('pre_option_update_core', '__return_null');
|
add_filter('pre_option_update_core', '__return_null');
|
||||||
add_filter('pre_site_transient_update_core', '__return_null');
|
add_filter('pre_site_transient_update_core', '__return_null');
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action( 'admin_head', array( &$this, 'admin_head_hide_elements' ), 15 );
|
add_action( 'admin_head', array( &$this, 'admin_head_hide_elements' ), 15 );
|
||||||
add_action( 'admin_menu', array($this, 'branding_redirect' ), 9);
|
add_action( 'admin_menu', array($this, 'branding_redirect' ), 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
// to fix
|
// to fix
|
||||||
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );//
|
||||||
// if ( 'T' === get_option( 'mainwp_branding_show_support' ) ) {
|
|
||||||
// $title = $this->settings['contact_support_label'];
|
|
||||||
// if ( isset( $extra_setting['show_button_in'] ) && ( 2 === (int) $extra_setting['show_button_in'] || 3 === (int) $extra_setting['show_button_in'] ) ) {
|
|
||||||
// $title = $this->settings['contact_support_label'];
|
|
||||||
// add_menu_page( $title, $title, 'read', 'ContactSupport2', array(
|
|
||||||
// $this,
|
|
||||||
// 'contact_support',
|
|
||||||
// ), '', '2.0001' );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if ( isset( $extra_setting['show_button_in'] ) && ( 1 === $extra_setting['show_button_in'] || 3 === $extra_setting['show_button_in'] ) ) {
|
|
||||||
// add_submenu_page( null, $title, $this->settings['contact_support_label'], 'read', 'ContactSupport', array(
|
|
||||||
// $this,
|
|
||||||
// 'contact_support',
|
|
||||||
// ) );
|
|
||||||
// add_action( 'admin_bar_menu', array( $this, 'add_support_button_in_top_admin_bar' ), 100 );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
if ( get_option( 'mainwp_branding_disable_wp_branding' ) !== 'Y' ) {
|
if ( get_option( 'mainwp_branding_disable_wp_branding' ) !== 'Y' ) {
|
||||||
add_filter( 'wp_footer', array( &$this, 'branding_global_footer' ), 15 );
|
add_filter( 'wp_footer', array( &$this, 'branding_global_footer' ), 15 );
|
||||||
add_action( 'wp_dashboard_setup', array( &$this, 'custom_dashboard_widgets' ), 999 );
|
add_action( 'wp_dashboard_setup', array( &$this, 'custom_dashboard_widgets' ), 999 );
|
||||||
// branding site generator
|
// branding site generator
|
||||||
$types = array( 'html', 'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export' );
|
$types = array( 'html', 'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export' );
|
||||||
foreach ( $types as $type ) {
|
foreach ( $types as $type ) {
|
||||||
add_filter( 'get_the_generator_' . $type, array( &$this, 'custom_the_generator' ), 999, 2 );
|
add_filter( 'get_the_generator_' . $type, array( &$this, 'custom_the_generator' ), 999, 2 );
|
||||||
|
@ -341,17 +323,17 @@ class MainWP_Child_Branding {
|
||||||
add_action( 'login_enqueue_scripts', array( &$this, 'custom_login_css' ) );
|
add_action( 'login_enqueue_scripts', array( &$this, 'custom_login_css' ) );
|
||||||
add_filter( 'gettext', array( &$this, 'custom_gettext' ), 99, 3 );
|
add_filter( 'gettext', array( &$this, 'custom_gettext' ), 99, 3 );
|
||||||
add_action( 'login_head', array( &$this, 'custom_login_logo' ) );
|
add_action( 'login_head', array( &$this, 'custom_login_logo' ) );
|
||||||
add_filter( 'login_headerurl', array( &$this, 'custom_login_headerurl' ) );
|
add_filter( 'login_headerurl', array( &$this, 'custom_login_headerurl' ) );
|
||||||
add_filter( 'login_headertitle', array( &$this, 'custom_login_headertitle' ) );
|
add_filter( 'login_headertitle', array( &$this, 'custom_login_headertitle' ) );
|
||||||
add_action( 'wp_head', array( &$this, 'custom_favicon_frontend' ) );
|
add_action( 'wp_head', array( &$this, 'custom_favicon_frontend' ) );
|
||||||
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
|
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
|
||||||
//remove_filter( 'update_footer', 'core_update_footer' );
|
//remove_filter( 'update_footer', 'core_update_footer' );
|
||||||
add_filter( 'update_footer', array( &$this, 'core_update_footer' ), 14 );
|
add_filter( 'update_footer', array( &$this, 'core_update_footer' ), 14 );
|
||||||
add_filter( 'admin_footer_text', array( &$this, 'admin_footer_text' ), 14 );
|
add_filter( 'admin_footer_text', array( &$this, 'admin_footer_text' ), 14 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $extra_setting['hide_nag'] ) && ! empty( $extra_setting['hide_nag'] ) ) {
|
if ( isset( $extra_setting['hide_nag'] ) && ! empty( $extra_setting['hide_nag'] ) ) {
|
||||||
add_action( 'admin_init', array($this, 'admin_init'));
|
add_action( 'admin_init', array($this, 'admin_init'));
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action( 'admin_menu', array( &$this, 'remove_default_post_metaboxes' ) );
|
add_action( 'admin_menu', array( &$this, 'remove_default_post_metaboxes' ) );
|
||||||
|
@ -359,14 +341,17 @@ class MainWP_Child_Branding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function admin_init() {
|
public function admin_init() {
|
||||||
remove_action( 'admin_notices', 'update_nag', 3 );
|
remove_action( 'admin_notices', 'update_nag', 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// to fix conflict with other plugin
|
// to fix conflict with other plugin
|
||||||
function admin_menu() {
|
function admin_menu() {
|
||||||
if ( !current_user_can( 'administrator' ) ) {
|
$allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false);
|
||||||
|
if ( $allow_contact ) {
|
||||||
|
; // ok
|
||||||
|
} else if ( !current_user_can( 'administrator' ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$extra_setting = $this->settings['extra_settings'];
|
$extra_setting = $this->settings['extra_settings'];
|
||||||
|
@ -522,27 +507,27 @@ class MainWP_Child_Branding {
|
||||||
if ( false !== $pos1 || false !== $pos2 ) {
|
if ( false !== $pos1 || false !== $pos2 ) {
|
||||||
wp_redirect( get_option( 'siteurl' ) . '/wp-admin/index.php' );
|
wp_redirect( get_option( 'siteurl' ) . '/wp-admin/index.php' );
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function admin_head_hide_elements() {
|
function admin_head_hide_elements() {
|
||||||
?><script type="text/javascript">
|
?><script type="text/javascript">
|
||||||
document.addEventListener("DOMContentLoaded", function(event) {
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
document.getElementById("wp-admin-bar-updates").outerHTML = '';
|
document.getElementById("wp-admin-bar-updates").outerHTML = '';
|
||||||
document.getElementById("menu-plugins").outerHTML = '';
|
document.getElementById("menu-plugins").outerHTML = '';
|
||||||
var els_core = document.querySelectorAll("a[href='update-core.php']");
|
var els_core = document.querySelectorAll("a[href='update-core.php']");
|
||||||
for (var i = 0, l = els_core.length; i < l; i++) {
|
for (var i = 0, l = els_core.length; i < l; i++) {
|
||||||
var el = els_core[i];
|
var el = els_core[i];
|
||||||
el.parentElement.innerHTML = '';
|
el.parentElement.innerHTML = '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script><?php
|
</script><?php
|
||||||
}
|
}
|
||||||
|
|
||||||
function core_update_footer() {
|
function core_update_footer() {
|
||||||
echo ''; // it clear version text
|
echo ''; // it clear version text
|
||||||
}
|
}
|
||||||
|
|
||||||
function admin_footer_text() {
|
function admin_footer_text() {
|
||||||
$extra_setting = $this->settings['extra_settings'];
|
$extra_setting = $this->settings['extra_settings'];
|
||||||
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
|
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
|
||||||
|
@ -569,25 +554,25 @@ class MainWP_Child_Branding {
|
||||||
}
|
}
|
||||||
|
|
||||||
function custom_login_headerurl( $value ) {
|
function custom_login_headerurl( $value ) {
|
||||||
|
|
||||||
$extra_setting = $this->settings['extra_settings'];
|
$extra_setting = $this->settings['extra_settings'];
|
||||||
if ( isset( $extra_setting['login_image_link'] ) && ! empty( $extra_setting['login_image_link'] ) ) {
|
if ( isset( $extra_setting['login_image_link'] ) && ! empty( $extra_setting['login_image_link'] ) ) {
|
||||||
return $extra_setting['login_image_link'];
|
return $extra_setting['login_image_link'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function custom_login_headertitle( $value ) {
|
function custom_login_headertitle( $value ) {
|
||||||
|
|
||||||
$extra_setting = $this->settings['extra_settings'];
|
$extra_setting = $this->settings['extra_settings'];
|
||||||
if ( isset( $extra_setting['login_image_title'] ) && ! empty( $extra_setting['login_image_title'] ) ) {
|
if ( isset( $extra_setting['login_image_title'] ) && ! empty( $extra_setting['login_image_title'] ) ) {
|
||||||
return $extra_setting['login_image_title'];
|
return $extra_setting['login_image_title'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function custom_gettext( $translations, $text, $domain = 'default' ) {
|
function custom_gettext( $translations, $text, $domain = 'default' ) {
|
||||||
$extra_setting = $this->settings['extra_settings'];
|
$extra_setting = $this->settings['extra_settings'];
|
||||||
$texts_replace = $extra_setting['texts_replace'];
|
$texts_replace = $extra_setting['texts_replace'];
|
||||||
|
@ -725,9 +710,6 @@ class MainWP_Child_Branding {
|
||||||
}
|
}
|
||||||
|
|
||||||
function contact_support() {
|
function contact_support() {
|
||||||
if ( !current_user_can('administrator') ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
<style>
|
<style>
|
||||||
.mainwp_info-box-yellow {
|
.mainwp_info-box-yellow {
|
||||||
|
@ -756,10 +738,10 @@ class MainWP_Child_Branding {
|
||||||
if ( ! empty( $send_email_message ) ) {
|
if ( ! empty( $send_email_message ) ) {
|
||||||
$send_email_message = stripslashes( $send_email_message );
|
$send_email_message = stripslashes( $send_email_message );
|
||||||
} else {
|
} else {
|
||||||
$send_email_message = 'Message has been submitted successfully.';
|
$send_email_message = __( 'Message has been submitted successfully.', 'mainwp-child' );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$send_email_message = __( 'Sending email failed!' );
|
$send_email_message = __( 'Sending email failed!', 'mainwp-child' );
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div
|
<div
|
||||||
|
@ -875,7 +857,7 @@ class MainWP_Child_Branding {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function branding_map_meta_cap( $caps, $cap, $user_id, $args ) {
|
public function branding_map_meta_cap( $caps, $cap, $user_id, $args ) {
|
||||||
|
|
||||||
// this is causing of some plugin's menu not added
|
// this is causing of some plugin's menu not added
|
||||||
// if ( 'T' === get_option( 'mainwp_branding_disable_change' ) ) {
|
// if ( 'T' === get_option( 'mainwp_branding_disable_change' ) ) {
|
||||||
// // disable: edit, update, install, active themes and plugins
|
// // disable: edit, update, install, active themes and plugins
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class MainWP_Child_iThemes_Security {
|
class MainWP_Child_iThemes_Security {
|
||||||
public static $instance = null;
|
public static $instance = null;
|
||||||
public $is_plugin_installed = false;
|
public $is_plugin_installed = false;
|
||||||
|
|
||||||
static function Instance() {
|
static function Instance() {
|
||||||
if ( null === MainWP_Child_iThemes_Security::$instance ) {
|
if ( null === MainWP_Child_iThemes_Security::$instance ) {
|
||||||
MainWP_Child_iThemes_Security::$instance = new MainWP_Child_iThemes_Security();
|
MainWP_Child_iThemes_Security::$instance = new MainWP_Child_iThemes_Security();
|
||||||
|
@ -12,15 +12,15 @@ class MainWP_Child_iThemes_Security {
|
||||||
return MainWP_Child_iThemes_Security::$instance;
|
return MainWP_Child_iThemes_Security::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||||
if ( is_plugin_active( 'better-wp-security/better-wp-security.php') || is_plugin_active( 'ithemes-security-pro/ithemes-security-pro.php' ) ) {
|
if ( is_plugin_active( 'better-wp-security/better-wp-security.php') || is_plugin_active( 'ithemes-security-pro/ithemes-security-pro.php' ) ) {
|
||||||
$this->is_plugin_installed = true;
|
$this->is_plugin_installed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->is_plugin_installed)
|
if (!$this->is_plugin_installed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
||||||
}
|
}
|
||||||
// ok
|
// ok
|
||||||
|
@ -29,11 +29,11 @@ class MainWP_Child_iThemes_Security {
|
||||||
try{
|
try{
|
||||||
$information['syncIThemeData'] = array(
|
$information['syncIThemeData'] = array(
|
||||||
'users_and_roles' => $this->get_available_admin_users_and_roles()
|
'users_and_roles' => $this->get_available_admin_users_and_roles()
|
||||||
);
|
);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
error_log($e->getMessage());
|
error_log($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $information;
|
return $information;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,13 +42,13 @@ class MainWP_Child_iThemes_Security {
|
||||||
if ( ! class_exists( 'ITSEC_Core' ) || !class_exists('ITSEC_Modules')) {
|
if ( ! class_exists( 'ITSEC_Core' ) || !class_exists('ITSEC_Modules')) {
|
||||||
$information['error'] = 'NO_ITHEME';
|
$information['error'] = 'NO_ITHEME';
|
||||||
MainWP_Helper::write( $information );
|
MainWP_Helper::write( $information );
|
||||||
}
|
}
|
||||||
|
|
||||||
global $mainwp_itsec_modules_path;
|
global $mainwp_itsec_modules_path;
|
||||||
|
|
||||||
$mainwp_itsec_modules_path = ITSEC_Core::get_core_dir() . '/modules/';
|
$mainwp_itsec_modules_path = ITSEC_Core::get_core_dir() . '/modules/';
|
||||||
MainWP_Helper::update_option( 'mainwp_ithemes_ext_enabled', 'Y', 'yes' );
|
MainWP_Helper::update_option( 'mainwp_ithemes_ext_enabled', 'Y', 'yes' );
|
||||||
|
|
||||||
if ( isset( $_POST['mwp_action'] ) ) {
|
if ( isset( $_POST['mwp_action'] ) ) {
|
||||||
switch ( $_POST['mwp_action'] ) {
|
switch ( $_POST['mwp_action'] ) {
|
||||||
case 'set_showhide':
|
case 'set_showhide':
|
||||||
|
@ -86,7 +86,7 @@ class MainWP_Child_iThemes_Security {
|
||||||
break;
|
break;
|
||||||
case 'module_status':
|
case 'module_status':
|
||||||
$information = $this->update_module_status();
|
$information = $this->update_module_status();
|
||||||
break;
|
break;
|
||||||
case 'wordpress_salts':
|
case 'wordpress_salts':
|
||||||
$information = $this->wordpress_salts();
|
$information = $this->wordpress_salts();
|
||||||
break;
|
break;
|
||||||
|
@ -100,14 +100,14 @@ class MainWP_Child_iThemes_Security {
|
||||||
$information = $this->security_site();
|
$information = $this->security_site();
|
||||||
break;
|
break;
|
||||||
case 'activate_network_brute_force':
|
case 'activate_network_brute_force':
|
||||||
$information = $this->activate_network_brute_force();
|
$information = $this->activate_network_brute_force();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MainWP_Helper::write( $information );
|
MainWP_Helper::write( $information );
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_showhide() {
|
function set_showhide() {
|
||||||
$hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
|
$hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
|
||||||
MainWP_Helper::update_option( 'mainwp_ithemes_hide_plugin', $hide );
|
MainWP_Helper::update_option( 'mainwp_ithemes_hide_plugin', $hide );
|
||||||
$information['result'] = 'success';
|
$information['result'] = 'success';
|
||||||
|
@ -128,7 +128,7 @@ class MainWP_Child_iThemes_Security {
|
||||||
if ( isset($_GET['page']) && ($_GET['page'] == 'itsec' || $_GET['page'] == 'itsec-logs' || $_GET['page'] == 'itsec-security-check') ) {
|
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' );
|
wp_redirect( get_option( 'siteurl' ) . '/wp-admin/index.php' );
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,68 +156,69 @@ class MainWP_Child_iThemes_Security {
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#wp-admin-bar-itsec_admin_bar_menu{
|
#wp-admin-bar-itsec_admin_bar_menu{
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_settings() {
|
function save_settings() {
|
||||||
|
|
||||||
if ( ! class_exists( 'ITSEC_Lib' ) ) {
|
if ( ! class_exists( 'ITSEC_Lib' ) ) {
|
||||||
require( ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php' );
|
require( ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$_itsec_modules = array(
|
$_itsec_modules = array(
|
||||||
'global',
|
'global',
|
||||||
'away-mode',
|
'away-mode',
|
||||||
'backup',
|
'backup',
|
||||||
'hide-backend',
|
'hide-backend',
|
||||||
'ipcheck',
|
'ipcheck',
|
||||||
'ban-users',
|
'ban-users',
|
||||||
'brute-force',
|
'brute-force',
|
||||||
'file-change',
|
'file-change',
|
||||||
'404-detection',
|
'404-detection',
|
||||||
'network-brute-force',
|
'network-brute-force',
|
||||||
'ssl',
|
'ssl',
|
||||||
'strong-passwords',
|
//'strong-passwords',
|
||||||
|
'password-requirements',
|
||||||
'system-tweaks',
|
'system-tweaks',
|
||||||
'wordpress-tweaks',
|
'wordpress-tweaks',
|
||||||
'multisite-tweaks',
|
'multisite-tweaks',
|
||||||
'notification-center'
|
'notification-center',
|
||||||
//'salts',
|
//'salts',
|
||||||
//'content-directory',
|
//'content-directory',
|
||||||
);
|
);
|
||||||
|
|
||||||
$require_permalinks = false;
|
$require_permalinks = false;
|
||||||
$updated = false;
|
$updated = false;
|
||||||
$errors = array();
|
$errors = array();
|
||||||
$nbf_settings = array();
|
$nbf_settings = array();
|
||||||
|
|
||||||
$update_settings = maybe_unserialize( base64_decode( $_POST['settings'] ) );
|
$update_settings = maybe_unserialize( base64_decode( $_POST['settings'] ) );
|
||||||
|
|
||||||
foreach($update_settings as $module => $settings) {
|
foreach($update_settings as $module => $settings) {
|
||||||
$do_not_save = false;
|
$do_not_save = false;
|
||||||
if (in_array($module, $_itsec_modules)) {
|
if (in_array($module, $_itsec_modules)) {
|
||||||
if ($module == 'wordpress-salts') {
|
if ($module == 'wordpress-salts') {
|
||||||
$settings['last_generated'] = ITSEC_Modules::get_setting( $module, 'last_generated' ); // not update
|
$settings['last_generated'] = ITSEC_Modules::get_setting( $module, 'last_generated' ); // not update
|
||||||
} else if ($module == 'global') {
|
} else if ($module == 'global') {
|
||||||
$keep_olds = array( 'did_upgrade', 'log_info', 'show_new_dashboard_notice', 'show_security_check' , 'nginx_file' );
|
$keep_olds = array( 'did_upgrade', 'log_info', 'show_new_dashboard_notice', 'show_security_check' , 'nginx_file' );
|
||||||
foreach($keep_olds as $key) {
|
foreach($keep_olds as $key) {
|
||||||
$settings[$key] = ITSEC_Modules::get_setting( $module, $key ); // not update
|
$settings[$key] = ITSEC_Modules::get_setting( $module, $key ); // not update
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($settings['log_location']) || empty($settings['log_location']) ) {
|
if (!isset($settings['log_location']) || empty($settings['log_location']) ) {
|
||||||
$settings['log_location'] = ITSEC_Modules::get_setting( $module, 'log_location' );
|
$settings['log_location'] = ITSEC_Modules::get_setting( $module, 'log_location' );
|
||||||
} else {
|
} else {
|
||||||
$result = $this->validate_directory('log_location', $settings['log_location']);
|
$result = $this->validate_directory('log_location', $settings['log_location']);
|
||||||
if ($result !== true) {
|
if ($result !== true) {
|
||||||
$errors[] = $result;
|
$errors[] = $result;
|
||||||
$settings['log_location'] = ITSEC_Modules::get_setting( $module, 'log_location' ); // no change
|
$settings['log_location'] = ITSEC_Modules::get_setting( $module, 'log_location' ); // no change
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ($module == 'backup') {
|
} else if ($module == 'backup') {
|
||||||
if (!isset($settings['location']) || empty($settings['location']) ) {
|
if (!isset($settings['location']) || empty($settings['location']) ) {
|
||||||
$settings['location'] = ITSEC_Modules::get_setting( $module, 'location' );
|
$settings['location'] = ITSEC_Modules::get_setting( $module, 'location' );
|
||||||
} else {
|
} else {
|
||||||
$result = $this->validate_directory('location', $settings['location']);
|
$result = $this->validate_directory('location', $settings['location']);
|
||||||
|
@ -226,7 +227,7 @@ class MainWP_Child_iThemes_Security {
|
||||||
$settings['location'] = ITSEC_Modules::get_setting( $module, 'location' ); // no change
|
$settings['location'] = ITSEC_Modules::get_setting( $module, 'location' ); // no change
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isset($settings['exclude']) ) {
|
if (!isset($settings['exclude']) ) {
|
||||||
$settings['exclude'] = ITSEC_Modules::get_setting( $module, 'exclude' );;
|
$settings['exclude'] = ITSEC_Modules::get_setting( $module, 'exclude' );;
|
||||||
}
|
}
|
||||||
} else if ($module == 'hide-backend') {
|
} else if ($module == 'hide-backend') {
|
||||||
|
@ -235,39 +236,39 @@ class MainWP_Child_iThemes_Security {
|
||||||
if ( empty( $permalink_structure ) && ! is_multisite() ) {
|
if ( empty( $permalink_structure ) && ! is_multisite() ) {
|
||||||
$errors[] = __( 'You must change <strong>WordPress permalinks</strong> to a setting other than "Plain" in order to use "Hide Backend" feature.', 'better-wp-security' );
|
$errors[] = __( 'You must change <strong>WordPress permalinks</strong> to a setting other than "Plain" in order to use "Hide Backend" feature.', 'better-wp-security' );
|
||||||
$require_permalinks = true;
|
$require_permalinks = true;
|
||||||
$do_not_save = true;
|
$do_not_save = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ($module == 'network-brute-force') {
|
} else if ($module == 'network-brute-force') {
|
||||||
|
|
||||||
if ( isset( $settings['email'] ) ) {
|
if ( isset( $settings['email'] ) ) {
|
||||||
$result = $this->activate_api_key($settings);
|
$result = $this->activate_api_key($settings);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
$nbf_settings = $settings;
|
$nbf_settings = $settings;
|
||||||
$errors[] = 'Error: Active iThemes Network Brute Force Protection Api Key';
|
$errors[] = 'Error: Active iThemes Network Brute Force Protection Api Key';
|
||||||
} else {
|
} else {
|
||||||
$nbf_settings = $result;
|
$nbf_settings = $result;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$previous_settings = ITSEC_Modules::get_settings( $module );
|
$previous_settings = ITSEC_Modules::get_settings( $module );
|
||||||
// update 'enable_ban' field only
|
// update 'enable_ban' field only
|
||||||
if (isset($settings['enable_ban'])) {
|
if (isset($settings['enable_ban'])) {
|
||||||
$previous_settings['enable_ban'] = $settings['enable_ban'];
|
$previous_settings['enable_ban'] = $settings['enable_ban'];
|
||||||
$nbf_settings = $previous_settings;
|
$nbf_settings = $previous_settings;
|
||||||
} else {
|
} else {
|
||||||
$do_not_save = true;
|
$do_not_save = true;
|
||||||
$nbf_settings = $previous_settings;
|
$nbf_settings = $previous_settings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$settings = $nbf_settings;
|
$settings = $nbf_settings;
|
||||||
} else if ($module == 'notification-center') {
|
} else if ($module == 'notification-center') {
|
||||||
$current_settings = ITSEC_Modules::get_settings( $module );
|
$current_settings = ITSEC_Modules::get_settings( $module );
|
||||||
if (isset($settings['notifications'])) {
|
if (isset($settings['notifications'])) {
|
||||||
$update_fields = array( 'schedule', 'enabled', 'subject');
|
$update_fields = array( 'schedule', 'enabled', 'subject');
|
||||||
if (isset($_POST['is_individual']) && $_POST['is_individual']) {
|
if (isset($_POST['is_individual']) && $_POST['is_individual']) {
|
||||||
$update_fields = array_merge($update_fields, array('user_list', 'email_list'));
|
$update_fields = array_merge($update_fields, array('user_list', 'email_list'));
|
||||||
}
|
}
|
||||||
foreach ($settings['notifications'] as $key => $val) {
|
foreach ($settings['notifications'] as $key => $val) {
|
||||||
foreach ($update_fields as $field) {
|
foreach ($update_fields as $field) {
|
||||||
if(isset($val[$field])) {
|
if(isset($val[$field])) {
|
||||||
$current_settings['notifications'][$key][$field] = $val[$field];
|
$current_settings['notifications'][$key][$field] = $val[$field];
|
||||||
|
@ -278,19 +279,19 @@ class MainWP_Child_iThemes_Security {
|
||||||
ITSEC_Modules::set_settings( $module, $current_settings );
|
ITSEC_Modules::set_settings( $module, $current_settings );
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !$do_not_save ) {
|
if ( !$do_not_save ) {
|
||||||
ITSEC_Modules::set_settings( $module, $settings );
|
ITSEC_Modules::set_settings( $module, $settings );
|
||||||
$updated = true;
|
$updated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $update_settings['itsec_active_modules'] ) ) {
|
if ( isset( $update_settings['itsec_active_modules'] ) ) {
|
||||||
$current_val = get_site_option( 'itsec_active_modules', array() );
|
$current_val = get_site_option( 'itsec_active_modules', array() );
|
||||||
foreach ($update_settings['itsec_active_modules'] as $mod => $val) {
|
foreach ($update_settings['itsec_active_modules'] as $mod => $val) {
|
||||||
$current_val[$mod] = $val;
|
$current_val[$mod] = $val;
|
||||||
}
|
}
|
||||||
update_site_option( 'itsec_active_modules', $current_val );
|
update_site_option( 'itsec_active_modules', $current_val );
|
||||||
}
|
}
|
||||||
|
@ -300,68 +301,68 @@ class MainWP_Child_iThemes_Security {
|
||||||
$values = array(
|
$values = array(
|
||||||
'permalink_structure' => get_option( 'permalink_structure' ),
|
'permalink_structure' => get_option( 'permalink_structure' ),
|
||||||
'is_multisite' => is_multisite() ? 1 : 0,
|
'is_multisite' => is_multisite() ? 1 : 0,
|
||||||
'users_can_register' => get_site_option( 'users_can_register' ) ? 1 : 0,
|
'users_can_register' => get_site_option( 'users_can_register' ) ? 1 : 0,
|
||||||
'server_nginx' => ( ITSEC_Lib::get_server() === 'nginx' ) ? 1 : 0,
|
'server_nginx' => ( ITSEC_Lib::get_server() === 'nginx' ) ? 1 : 0,
|
||||||
'has_ssl' => ITSEC_Lib::get_ssl_support_probability(),
|
'has_ssl' => ITSEC_Lib::get_ssl_support_probability(),
|
||||||
'jquery_version' => ITSEC_Modules::get_setting( 'wordpress-tweaks', 'jquery_version' ),
|
'jquery_version' => ITSEC_Modules::get_setting( 'wordpress-tweaks', 'jquery_version' ),
|
||||||
'server_rules' => ITSEC_Lib_Config_File::get_server_config(),
|
'server_rules' => ITSEC_Lib_Config_File::get_server_config(),
|
||||||
'config_rules' => ITSEC_Lib_Config_File::get_wp_config(),
|
'config_rules' => ITSEC_Lib_Config_File::get_wp_config(),
|
||||||
'lockouts_host' => $this->get_lockouts( 'host', true ),
|
'lockouts_host' => $this->get_lockouts( 'host', true ),
|
||||||
'lockouts_user' => $this->get_lockouts( 'user', true ),
|
'lockouts_user' => $this->get_lockouts( 'user', true ),
|
||||||
'lockouts_username' => $this->get_lockouts( 'username', true ),
|
'lockouts_username' => $this->get_lockouts( 'username', true ),
|
||||||
'default_log_location' => ITSEC_Modules::get_default( 'global', 'log_location' ),
|
'default_log_location' => ITSEC_Modules::get_default( 'global', 'log_location' ),
|
||||||
'default_location' => ITSEC_Modules::get_default( 'backup', 'location' ),
|
'default_location' => ITSEC_Modules::get_default( 'backup', 'location' ),
|
||||||
'excludable_tables' => $this->get_excludable_tables(),
|
'excludable_tables' => $this->get_excludable_tables(),
|
||||||
'users_and_roles' => $this->get_available_admin_users_and_roles()
|
'users_and_roles' => $this->get_available_admin_users_and_roles()
|
||||||
);
|
);
|
||||||
|
|
||||||
$return = array(
|
$return = array(
|
||||||
'site_status' => $values
|
'site_status' => $values
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($require_permalinks) {
|
if ($require_permalinks) {
|
||||||
$return['require_permalinks'] = 1;
|
$return['require_permalinks'] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$return['nbf_settings'] = $nbf_settings;
|
$return['nbf_settings'] = $nbf_settings;
|
||||||
|
|
||||||
if (!empty($errors)) {
|
if (!empty($errors)) {
|
||||||
$return['extra_message'] = $errors;
|
$return['extra_message'] = $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($updated)
|
if ($updated)
|
||||||
$return['result'] = 'success';
|
$return['result'] = 'success';
|
||||||
else
|
else
|
||||||
$return['error'] = __('Not Updated', 'mainwp-child' );
|
$return['error'] = __('Not Updated', 'mainwp-child' );
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function activate_network_brute_force() {
|
public static function activate_network_brute_force() {
|
||||||
$data = maybe_unserialize( base64_decode( $_POST['data'] ) );
|
$data = maybe_unserialize( base64_decode( $_POST['data'] ) );
|
||||||
$information = array();
|
$information = array();
|
||||||
if (is_array($data)) {
|
if (is_array($data)) {
|
||||||
$settings = ITSEC_Modules::get_settings( 'network-brute-force' );
|
$settings = ITSEC_Modules::get_settings( 'network-brute-force' );
|
||||||
$settings['email'] = $data['email'];
|
$settings['email'] = $data['email'];
|
||||||
$settings['updates_optin'] = $data['updates_optin'];
|
$settings['updates_optin'] = $data['updates_optin'];
|
||||||
$settings['api_nag'] = false;
|
$settings['api_nag'] = false;
|
||||||
$results = ITSEC_Modules::set_settings( 'network-brute-force', $settings );
|
$results = ITSEC_Modules::set_settings( 'network-brute-force', $settings );
|
||||||
if ( is_wp_error( $results ) ) {
|
if ( is_wp_error( $results ) ) {
|
||||||
$information['error'] = 'Error: Active iThemes Network Brute Force Protection Api Key';
|
$information['error'] = 'Error: Active iThemes Network Brute Force Protection Api Key';
|
||||||
} else if ( $results['saved'] ) {
|
} else if ( $results['saved'] ) {
|
||||||
ITSEC_Modules::activate( 'network-brute-force' );
|
ITSEC_Modules::activate( 'network-brute-force' );
|
||||||
$nbf_settings = ITSEC_Modules::get_settings( 'network-brute-force' );
|
$nbf_settings = ITSEC_Modules::get_settings( 'network-brute-force' );
|
||||||
// ITSEC_Response::set_response( '<p>' . __( 'Your site is now using Network Brute Force Protection.', 'better-wp-security' ) . '</p>' );
|
// ITSEC_Response::set_response( '<p>' . __( 'Your site is now using Network Brute Force Protection.', 'better-wp-security' ) . '</p>' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($nbf_settings !== null) {
|
if ($nbf_settings !== null) {
|
||||||
$information['nbf_settings'] = $nbf_settings;
|
$information['nbf_settings'] = $nbf_settings;
|
||||||
$information['result'] = 'success';
|
$information['result'] = 'success';
|
||||||
}
|
}
|
||||||
return $information;
|
return $information;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function validate_directory($name, $folder) {
|
private function validate_directory($name, $folder) {
|
||||||
require_once( ITSEC_Core::get_core_dir() . 'lib/class-itsec-lib-directory.php' );
|
require_once( ITSEC_Core::get_core_dir() . 'lib/class-itsec-lib-directory.php' );
|
||||||
$error = null;
|
$error = null;
|
||||||
if ( ! ITSEC_Lib_Directory::is_dir( $folder ) ) {
|
if ( ! ITSEC_Lib_Directory::is_dir( $folder ) ) {
|
||||||
|
@ -383,12 +384,12 @@ class MainWP_Child_iThemes_Security {
|
||||||
return $error;
|
return $error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function activate_api_key($settings) {
|
private function activate_api_key($settings) {
|
||||||
global $mainwp_itsec_modules_path;
|
global $mainwp_itsec_modules_path;
|
||||||
require_once ( $mainwp_itsec_modules_path . 'ipcheck/utilities.php' );
|
require_once ( $mainwp_itsec_modules_path . 'ipcheck/utilities.php' );
|
||||||
|
|
||||||
$key = ITSEC_Network_Brute_Force_Utilities::get_api_key( $settings['email'], $settings['updates_optin'] );
|
$key = ITSEC_Network_Brute_Force_Utilities::get_api_key( $settings['email'], $settings['updates_optin'] );
|
||||||
if ( is_wp_error( $key ) ) {
|
if ( is_wp_error( $key ) ) {
|
||||||
return false;
|
return false;
|
||||||
// $this->set_can_save( false );
|
// $this->set_can_save( false );
|
||||||
|
@ -479,17 +480,17 @@ class MainWP_Child_iThemes_Security {
|
||||||
|
|
||||||
function backup_db() {
|
function backup_db() {
|
||||||
global $itsec_backup, $mainwp_itsec_modules_path;
|
global $itsec_backup, $mainwp_itsec_modules_path;
|
||||||
|
|
||||||
if ( ! isset( $itsec_backup ) ) {
|
if ( ! isset( $itsec_backup ) ) {
|
||||||
require_once ( $mainwp_itsec_modules_path . 'backup/class-itsec-backup.php' );
|
require_once ( $mainwp_itsec_modules_path . 'backup/class-itsec-backup.php' );
|
||||||
$itsec_backup = new ITSEC_Backup();
|
$itsec_backup = new ITSEC_Backup();
|
||||||
$itsec_backup->run();
|
$itsec_backup->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
$return = array();
|
$return = array();
|
||||||
|
|
||||||
$str_error = '';
|
$str_error = '';
|
||||||
$result = $itsec_backup->do_backup( true );
|
$result = $itsec_backup->do_backup( true );
|
||||||
|
|
||||||
if ( is_wp_error( $result ) ) {
|
if ( is_wp_error( $result ) ) {
|
||||||
$errors = ITSEC_Response::get_error_strings( $result );
|
$errors = ITSEC_Response::get_error_strings( $result );
|
||||||
|
@ -497,47 +498,47 @@ class MainWP_Child_iThemes_Security {
|
||||||
foreach ( $errors as $error ) {
|
foreach ( $errors as $error ) {
|
||||||
$str_error .= $error . '<br />';
|
$str_error .= $error . '<br />';
|
||||||
}
|
}
|
||||||
} else if ( is_string( $result ) ) {
|
} else if ( is_string( $result ) ) {
|
||||||
$return['result'] = 'success';
|
$return['result'] = 'success';
|
||||||
$return['message'] = $result;
|
$return['message'] = $result;
|
||||||
} else {
|
} else {
|
||||||
$str_error = sprintf( __( 'The backup request returned an unexpected response. It returned a response of type <code>%1$s</code>.', 'better-wp-security' ), gettype( $result ) ) ;
|
$str_error = sprintf( __( 'The backup request returned an unexpected response. It returned a response of type <code>%1$s</code>.', 'better-wp-security' ), gettype( $result ) ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($str_error)) {
|
if (!empty($str_error)) {
|
||||||
$return['error'] = $str_error;
|
$return['error'] = $str_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function wordpress_salts() {
|
private function wordpress_salts() {
|
||||||
global $mainwp_itsec_modules_path;
|
global $mainwp_itsec_modules_path;
|
||||||
if ( ! class_exists( 'ITSEC_WordPress_Salts_Utilities' ) ) {
|
if ( ! class_exists( 'ITSEC_WordPress_Salts_Utilities' ) ) {
|
||||||
require( $mainwp_itsec_modules_path . 'salts/utilities.php' );
|
require( $mainwp_itsec_modules_path . 'salts/utilities.php' );
|
||||||
}
|
}
|
||||||
$result = ITSEC_WordPress_Salts_Utilities::generate_new_salts();
|
$result = ITSEC_WordPress_Salts_Utilities::generate_new_salts();
|
||||||
$str_error = '';
|
$str_error = '';
|
||||||
if ( is_wp_error( $result ) ) {
|
if ( is_wp_error( $result ) ) {
|
||||||
$errors = ITSEC_Response::get_error_strings( $result );
|
$errors = ITSEC_Response::get_error_strings( $result );
|
||||||
|
|
||||||
foreach ( $errors as $error ) {
|
foreach ( $errors as $error ) {
|
||||||
$str_error .= $error . '<br />';
|
$str_error .= $error . '<br />';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$return['result'] = 'success';
|
$return['result'] = 'success';
|
||||||
$return['message'] = __( 'The WordPress salts were successfully regenerated.', 'better-wp-security' ) ;
|
$return['message'] = __( 'The WordPress salts were successfully regenerated.', 'better-wp-security' ) ;
|
||||||
$last_generated = ITSEC_Core::get_current_time_gmt();
|
$last_generated = ITSEC_Core::get_current_time_gmt();
|
||||||
ITSEC_Modules::set_setting( 'wordpress-salts', 'last_generated', $last_generated );
|
ITSEC_Modules::set_setting( 'wordpress-salts', 'last_generated', $last_generated );
|
||||||
}
|
}
|
||||||
if (!empty($str_error)) {
|
if (!empty($str_error)) {
|
||||||
$return['error'] = $str_error;
|
$return['error'] = $str_error;
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function file_permissions() {
|
private function file_permissions() {
|
||||||
require_once( ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php' );
|
require_once( ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php' );
|
||||||
|
|
||||||
$wp_upload_dir = ITSEC_Core::get_wp_upload_dir();
|
$wp_upload_dir = ITSEC_Core::get_wp_upload_dir();
|
||||||
|
@ -657,31 +658,31 @@ class MainWP_Child_iThemes_Security {
|
||||||
$html = ob_get_clean();
|
$html = ob_get_clean();
|
||||||
return array('html' => $html);
|
return array('html' => $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function file_change() {
|
public function file_change() {
|
||||||
global $mainwp_itsec_modules_path;
|
global $mainwp_itsec_modules_path;
|
||||||
if ( ! class_exists( 'ITSEC_File_Change_Scanner' ) ) {
|
if ( ! class_exists( 'ITSEC_File_Change_Scanner' ) ) {
|
||||||
require_once( $mainwp_itsec_modules_path . 'file-change/scanner.php' );
|
require_once( $mainwp_itsec_modules_path . 'file-change/scanner.php' );
|
||||||
}
|
}
|
||||||
$result = ITSEC_File_Change_Scanner::run_scan( false );
|
$result = ITSEC_File_Change_Scanner::run_scan( false );
|
||||||
if ($result === false || $result === true || $result === -1) {
|
if ($result === false || $result === true || $result === -1) {
|
||||||
$return['result'] = 'success';
|
$return['result'] = 'success';
|
||||||
$return['scan_result'] = $result;
|
$return['scan_result'] = $result;
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function admin_user() {
|
function admin_user() {
|
||||||
|
|
||||||
$settings = $_POST['settings'];
|
$settings = $_POST['settings'];
|
||||||
|
|
||||||
if (!is_array($settings))
|
if (!is_array($settings))
|
||||||
$settings = array();
|
$settings = array();
|
||||||
|
|
||||||
$new_username = isset( $settings['new_username'] ) ? $settings['new_username'] : '';
|
$new_username = isset( $settings['new_username'] ) ? $settings['new_username'] : '';
|
||||||
$change_id = isset( $settings['change_id'] ) && $settings['change_id'] ? true : false;
|
$change_id = isset( $settings['change_id'] ) && $settings['change_id'] ? true : false;
|
||||||
|
|
||||||
|
|
||||||
//load utility functions
|
//load utility functions
|
||||||
if ( ! class_exists( 'ITSEC_Lib' ) ) {
|
if ( ! class_exists( 'ITSEC_Lib' ) ) {
|
||||||
global $itsec_globals;
|
global $itsec_globals;
|
||||||
|
@ -690,7 +691,7 @@ class MainWP_Child_iThemes_Security {
|
||||||
|
|
||||||
$username_exists = username_exists( 'admin' );
|
$username_exists = username_exists( 'admin' );
|
||||||
$user_id_exists = ITSEC_Lib::user_id_exists( 1 );
|
$user_id_exists = ITSEC_Lib::user_id_exists( 1 );
|
||||||
$msg = '';
|
$msg = '';
|
||||||
if ( strlen( $new_username ) >= 1) {
|
if ( strlen( $new_username ) >= 1) {
|
||||||
global $current_user;
|
global $current_user;
|
||||||
if ( ! $username_exists ) {
|
if ( ! $username_exists ) {
|
||||||
|
@ -700,9 +701,9 @@ class MainWP_Child_iThemes_Security {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( true === $change_id && ! $user_id_exists ) {
|
if ( true === $change_id && ! $user_id_exists ) {
|
||||||
if ( ! empty( $msg ) ) {
|
if ( ! empty( $msg ) ) {
|
||||||
$msg .= '<br/>';
|
$msg .= '<br/>';
|
||||||
}
|
}
|
||||||
|
@ -739,8 +740,8 @@ class MainWP_Child_iThemes_Security {
|
||||||
|
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$itsec_files = ITSEC_Core::get_itsec_files();
|
$itsec_files = ITSEC_Core::get_itsec_files();
|
||||||
|
|
||||||
// do not need to check this
|
// do not need to check this
|
||||||
//if ( $itsec_files->get_file_lock( 'admin_user' ) ) { //make sure it isn't already running
|
//if ( $itsec_files->get_file_lock( 'admin_user' ) ) { //make sure it isn't already running
|
||||||
|
|
||||||
//sanitize the username
|
//sanitize the username
|
||||||
|
@ -757,9 +758,9 @@ class MainWP_Child_iThemes_Security {
|
||||||
|
|
||||||
} else { // we're only changing the username
|
} else { // we're only changing the username
|
||||||
|
|
||||||
//query main user table
|
//query main user table
|
||||||
$wpdb->query( "UPDATE `" . $wpdb->users . "` SET user_login = '" . esc_sql( $new_user ) . "' WHERE user_login='admin';" );
|
$wpdb->query( "UPDATE `" . $wpdb->users . "` SET user_login = '" . esc_sql( $new_user ) . "' WHERE user_login='admin';" );
|
||||||
|
|
||||||
if ( is_multisite() ) { //process sitemeta if we're in a multi-site situation
|
if ( is_multisite() ) { //process sitemeta if we're in a multi-site situation
|
||||||
|
|
||||||
$oldAdmins = $wpdb->get_var( 'SELECT meta_value FROM `' . $wpdb->sitemeta . "` WHERE meta_key = 'site_admins'" );
|
$oldAdmins = $wpdb->get_var( 'SELECT meta_value FROM `' . $wpdb->sitemeta . "` WHERE meta_key = 'site_admins'" );
|
||||||
|
@ -788,7 +789,7 @@ class MainWP_Child_iThemes_Security {
|
||||||
if ( true === $id ) { //change the user id
|
if ( true === $id ) { //change the user id
|
||||||
|
|
||||||
$wpdb->query( 'DELETE FROM `' . $wpdb->users . '` WHERE ID = 1;' );
|
$wpdb->query( 'DELETE FROM `' . $wpdb->users . '` WHERE ID = 1;' );
|
||||||
|
|
||||||
$wpdb->insert( $wpdb->users, array(
|
$wpdb->insert( $wpdb->users, array(
|
||||||
'user_login' => $user_login,
|
'user_login' => $user_login,
|
||||||
'user_pass' => $user_object->user_pass,
|
'user_pass' => $user_object->user_pass,
|
||||||
|
@ -859,14 +860,14 @@ class MainWP_Child_iThemes_Security {
|
||||||
return $rules_array;
|
return $rules_array;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function change_database_prefix() {
|
public function change_database_prefix() {
|
||||||
global $mainwp_itsec_modules_path;
|
global $mainwp_itsec_modules_path;
|
||||||
require_once( $mainwp_itsec_modules_path . 'database-prefix/utility.php' );
|
require_once( $mainwp_itsec_modules_path . 'database-prefix/utility.php' );
|
||||||
$str_error = '';
|
$str_error = '';
|
||||||
$return = array();
|
$return = array();
|
||||||
|
|
||||||
if ( isset( $_POST['change_prefix'] ) && 'yes' === $_POST['change_prefix'] ) {
|
if ( isset( $_POST['change_prefix'] ) && 'yes' === $_POST['change_prefix'] ) {
|
||||||
$result = ITSEC_Database_Prefix_Utility::change_database_prefix();
|
$result = ITSEC_Database_Prefix_Utility::change_database_prefix();
|
||||||
$return = $result['errors'];
|
$return = $result['errors'];
|
||||||
|
@ -878,18 +879,18 @@ class MainWP_Child_iThemes_Security {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ITSEC_Response::reload_module( 'database-prefix' );
|
ITSEC_Response::reload_module( 'database-prefix' );
|
||||||
|
|
||||||
if ( false === $result['new_prefix'] ) {
|
if ( false === $result['new_prefix'] ) {
|
||||||
$return['error'] = $str_error;
|
$return['error'] = $str_error;
|
||||||
} else {
|
} else {
|
||||||
$return['result'] = 'success';
|
$return['result'] = 'success';
|
||||||
$return['message'] = sprintf( __( 'The database table prefix was successfully changed to <code>%1$s</code>.', 'better-wp-security' ), $result['new_prefix'] );
|
$return['message'] = sprintf( __( 'The database table prefix was successfully changed to <code>%1$s</code>.', 'better-wp-security' ), $result['new_prefix'] );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function api_key() {
|
public function api_key() {
|
||||||
|
@ -909,53 +910,53 @@ class MainWP_Child_iThemes_Security {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reset_api_key() {
|
public function reset_api_key() {
|
||||||
|
|
||||||
$defaults = ITSEC_Modules::get_defaults( 'network-brute-force' );
|
$defaults = ITSEC_Modules::get_defaults( 'network-brute-force' );
|
||||||
$results = ITSEC_Modules::set_settings( 'network-brute-force', $defaults );
|
$results = ITSEC_Modules::set_settings( 'network-brute-force', $defaults );
|
||||||
|
|
||||||
ITSEC_Response::set_response( $results['saved'] );
|
ITSEC_Response::set_response( $results['saved'] );
|
||||||
ITSEC_Response::add_errors( $results['errors'] );
|
ITSEC_Response::add_errors( $results['errors'] );
|
||||||
ITSEC_Response::add_messages( $results['messages'] );
|
ITSEC_Response::add_messages( $results['messages'] );
|
||||||
|
|
||||||
$information = array();
|
$information = array();
|
||||||
if ( $results['saved'] ) {
|
if ( $results['saved'] ) {
|
||||||
$information['result'] = 'success';
|
$information['result'] = 'success';
|
||||||
$information['nbf_settings'] = ITSEC_Modules::get_settings( 'network-brute-force');
|
$information['nbf_settings'] = ITSEC_Modules::get_settings( 'network-brute-force');
|
||||||
} else if ( empty( $results['errors'] ) ) {
|
} else if ( empty( $results['errors'] ) ) {
|
||||||
$information['error_reset_api'] = 1;
|
$information['error_reset_api'] = 1;
|
||||||
}
|
}
|
||||||
return $information;
|
return $information;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function malware_scan() {
|
public function malware_scan() {
|
||||||
global $mainwp_itsec_modules_path;
|
global $mainwp_itsec_modules_path;
|
||||||
|
|
||||||
if ( ! class_exists( 'ITSEC_Malware_Scanner' ) ) {
|
if ( ! class_exists( 'ITSEC_Malware_Scanner' ) ) {
|
||||||
require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php' );
|
require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php' );
|
||||||
require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php' );
|
require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = array();
|
$response = array();
|
||||||
if ( ! ITSEC_Core::current_user_can_manage() ) {
|
if ( ! ITSEC_Core::current_user_can_manage() ) {
|
||||||
$response['error'] = 'The currently logged in user does not have sufficient permissions to run this scan.';
|
$response['error'] = 'The currently logged in user does not have sufficient permissions to run this scan.';
|
||||||
} else {
|
} else {
|
||||||
$results = ITSEC_Malware_Scanner::scan();
|
$results = ITSEC_Malware_Scanner::scan();
|
||||||
$response['html'] = ITSEC_Malware_Scan_Results_Template::get_html( $results, true );
|
$response['html'] = ITSEC_Malware_Scan_Results_Template::get_html( $results, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function malware_get_scan_results() {
|
public function malware_get_scan_results() {
|
||||||
|
|
||||||
global $mainwp_itsec_modules_path;
|
global $mainwp_itsec_modules_path;
|
||||||
if ( ! class_exists( 'ITSEC_Malware_Scanner' ) ) {
|
if ( ! class_exists( 'ITSEC_Malware_Scanner' ) ) {
|
||||||
require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php' );
|
require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php' );
|
||||||
require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php' );
|
require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php' );
|
||||||
}
|
}
|
||||||
$response = array();
|
$response = array();
|
||||||
$results= ITSEC_Malware_Scanner::scan();
|
$results= ITSEC_Malware_Scanner::scan();
|
||||||
$response['html'] = ITSEC_Malware_Scan_Results_Template::get_html( $results, true );
|
$response['html'] = ITSEC_Malware_Scan_Results_Template::get_html( $results, true );
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1090,32 +1091,32 @@ class MainWP_Child_iThemes_Security {
|
||||||
'result' => 'success',
|
'result' => 'success',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update_module_status() {
|
public function update_module_status() {
|
||||||
|
|
||||||
$active_modules = $_POST['active_modules'];
|
$active_modules = $_POST['active_modules'];
|
||||||
|
|
||||||
if (!is_array($active_modules))
|
if (!is_array($active_modules))
|
||||||
$active_modules = array();
|
$active_modules = array();
|
||||||
|
|
||||||
$current_val = get_site_option( 'itsec_active_modules', array() );
|
$current_val = get_site_option( 'itsec_active_modules', array() );
|
||||||
foreach ($active_modules as $mod => $val) {
|
foreach ($active_modules as $mod => $val) {
|
||||||
$current_val[$mod] = $val;
|
$current_val[$mod] = $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
update_site_option( 'itsec_active_modules', $current_val );
|
update_site_option( 'itsec_active_modules', $current_val );
|
||||||
return array('result' => 'success');
|
return array('result' => 'success');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function reload_backup_exclude( ) {
|
private function reload_backup_exclude( ) {
|
||||||
return array(
|
return array(
|
||||||
'exclude' => ITSEC_Modules::get_setting( 'backup', 'exclude' ),
|
'exclude' => ITSEC_Modules::get_setting( 'backup', 'exclude' ),
|
||||||
'excludable_tables' => $this->get_excludable_tables(),
|
'excludable_tables' => $this->get_excludable_tables(),
|
||||||
'result' => 'success'
|
'result' => 'success'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function get_excludable_tables( ) {
|
private function get_excludable_tables( ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$all_sites = ITSEC_Modules::get_setting( 'backup', 'all_sites' );
|
$all_sites = ITSEC_Modules::get_setting( 'backup', 'all_sites' );
|
||||||
|
@ -1154,18 +1155,18 @@ class MainWP_Child_iThemes_Security {
|
||||||
|
|
||||||
return $excludes ;
|
return $excludes ;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function security_site() {
|
private function security_site() {
|
||||||
global $mainwp_itsec_modules_path;
|
global $mainwp_itsec_modules_path;
|
||||||
require_once( $mainwp_itsec_modules_path . 'security-check/scanner.php' );
|
require_once( $mainwp_itsec_modules_path . 'security-check/scanner.php' );
|
||||||
require_once( $mainwp_itsec_modules_path . 'security-check/feedback-renderer.php' );
|
require_once( $mainwp_itsec_modules_path . 'security-check/feedback-renderer.php' );
|
||||||
$results = ITSEC_Security_Check_Scanner::get_results();
|
$results = ITSEC_Security_Check_Scanner::get_results();
|
||||||
ob_start();
|
ob_start();
|
||||||
ITSEC_Security_Check_Feedback_Renderer::render( $results );
|
ITSEC_Security_Check_Feedback_Renderer::render( $results );
|
||||||
$response = ob_get_clean();
|
$response = ob_get_clean();
|
||||||
return array('result' => 'success' , 'response' => $response);
|
return array('result' => 'success' , 'response' => $response);
|
||||||
}
|
}
|
||||||
|
|
||||||
// source from itheme plugin
|
// source from itheme plugin
|
||||||
// ok
|
// ok
|
||||||
public function get_available_admin_users_and_roles() {
|
public function get_available_admin_users_and_roles() {
|
||||||
|
@ -1198,6 +1199,6 @@ class MainWP_Child_iThemes_Security {
|
||||||
'roles' => $available_roles,
|
'roles' => $available_roles,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -257,16 +257,8 @@ class MainWP_Child_Plugins_Check {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! defined( 'MINUTE_IN_SECONDS' ) ) {
|
|
||||||
define( 'MINUTE_IN_SECONDS', 60 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! defined( 'HOUR_IN_SECONDS' ) ) {
|
|
||||||
define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! defined( 'DAY_IN_SECONDS' ) ) {
|
if ( ! defined( 'DAY_IN_SECONDS' ) ) {
|
||||||
define( 'DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS );
|
define( 'DAY_IN_SECONDS', 24 * 60 * 60 );
|
||||||
}
|
}
|
||||||
|
|
||||||
//Store the master response for usage in the plugin table
|
//Store the master response for usage in the plugin table
|
||||||
|
@ -274,7 +266,6 @@ class MainWP_Child_Plugins_Check {
|
||||||
|
|
||||||
if ( 0 === count( $all_plugins ) ) {
|
if ( 0 === count( $all_plugins ) ) {
|
||||||
delete_transient( $this->tran_name_plugins_to_batch );
|
delete_transient( $this->tran_name_plugins_to_batch );
|
||||||
//wp_schedule_single_event( time() + DAY_IN_SECONDS, $this->cron_name_daily );
|
|
||||||
} else {
|
} else {
|
||||||
set_transient( $this->tran_name_plugins_to_batch, $all_plugins, DAY_IN_SECONDS );
|
set_transient( $this->tran_name_plugins_to_batch, $all_plugins, DAY_IN_SECONDS );
|
||||||
wp_schedule_single_event( time(), $this->cron_name_batching );
|
wp_schedule_single_event( time(), $this->cron_name_batching );
|
||||||
|
@ -287,18 +278,11 @@ class MainWP_Child_Plugins_Check {
|
||||||
//Get the WordPress current version to be polite in the API call
|
//Get the WordPress current version to be polite in the API call
|
||||||
include( ABSPATH . WPINC . '/version.php' );
|
include( ABSPATH . WPINC . '/version.php' );
|
||||||
|
|
||||||
if ( ! defined( 'MINUTE_IN_SECONDS' ) ) {
|
|
||||||
define( 'MINUTE_IN_SECONDS', 60 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! defined( 'HOUR_IN_SECONDS' ) ) {
|
|
||||||
define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
|
|
||||||
}
|
|
||||||
global $wp_version;
|
global $wp_version;
|
||||||
|
|
||||||
//General options to be passed to wp_remote_get
|
//General options to be passed to wp_remote_get
|
||||||
$options = array(
|
$options = array(
|
||||||
'timeout' => HOUR_IN_SECONDS,
|
'timeout' => 60 * 60, //HOUR_IN_SECONDS
|
||||||
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
|
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -202,16 +202,8 @@ class MainWP_Child_Themes_Check {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! defined( 'MINUTE_IN_SECONDS' ) ) {
|
|
||||||
define( 'MINUTE_IN_SECONDS', 60 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! defined( 'HOUR_IN_SECONDS' ) ) {
|
|
||||||
define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! defined( 'DAY_IN_SECONDS' ) ) {
|
if ( ! defined( 'DAY_IN_SECONDS' ) ) {
|
||||||
define( 'DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS );
|
define( 'DAY_IN_SECONDS', 24 * 60 * 60 );
|
||||||
}
|
}
|
||||||
|
|
||||||
//Store the master response for usage in the plugin table
|
//Store the master response for usage in the plugin table
|
||||||
|
@ -219,7 +211,6 @@ class MainWP_Child_Themes_Check {
|
||||||
|
|
||||||
if ( 0 === count( $all_themes ) ) {
|
if ( 0 === count( $all_themes ) ) {
|
||||||
delete_transient( $this->tran_name_themes_to_batch );
|
delete_transient( $this->tran_name_themes_to_batch );
|
||||||
//wp_schedule_single_event( time() + DAY_IN_SECONDS, $this->cron_name_daily );
|
|
||||||
} else {
|
} else {
|
||||||
set_transient( $this->tran_name_themes_to_batch, $all_themes, DAY_IN_SECONDS );
|
set_transient( $this->tran_name_themes_to_batch, $all_themes, DAY_IN_SECONDS );
|
||||||
wp_schedule_single_event( time(), $this->cron_name_batching );
|
wp_schedule_single_event( time(), $this->cron_name_batching );
|
||||||
|
@ -229,19 +220,9 @@ class MainWP_Child_Themes_Check {
|
||||||
|
|
||||||
|
|
||||||
private function try_get_response_body( $theme ) {
|
private function try_get_response_body( $theme ) {
|
||||||
//Some of this code is lifted from class-wp-upgrader
|
|
||||||
|
|
||||||
//Get the WordPress current version to be polite in the API call
|
//Get the WordPress current version to be polite in the API call
|
||||||
include( ABSPATH . WPINC . '/version.php' );
|
include( ABSPATH . WPINC . '/version.php' );
|
||||||
|
|
||||||
if ( ! defined( 'MINUTE_IN_SECONDS' ) ) {
|
|
||||||
define( 'MINUTE_IN_SECONDS', 60 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! defined( 'HOUR_IN_SECONDS' ) ) {
|
|
||||||
define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
|
|
||||||
}
|
|
||||||
|
|
||||||
$url = $http_url = 'http://api.wordpress.org/themes/info/1.0/';
|
$url = $http_url = 'http://api.wordpress.org/themes/info/1.0/';
|
||||||
if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
|
if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
|
||||||
$url = set_url_scheme( $url, 'https' );
|
$url = set_url_scheme( $url, 'https' );
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -11,15 +11,15 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
return MainWP_Child_Updraft_Plus_Backups::$instance;
|
return MainWP_Child_Updraft_Plus_Backups::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||||
if ( is_plugin_active( 'updraftplus/updraftplus.php' ) && defined('UPDRAFTPLUS_DIR')) {
|
if ( is_plugin_active( 'updraftplus/updraftplus.php' ) && defined('UPDRAFTPLUS_DIR')) {
|
||||||
$this->is_plugin_installed = true;
|
$this->is_plugin_installed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->is_plugin_installed)
|
if (!$this->is_plugin_installed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
||||||
add_filter('updraftplus_save_last_backup', array( __CLASS__, 'hookUpdraftplusSaveLastBackup' ));
|
add_filter('updraftplus_save_last_backup', array( __CLASS__, 'hookUpdraftplusSaveLastBackup' ));
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,9 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
|
|
||||||
if (isset($last_backup['backup_time'])) {
|
if (isset($last_backup['backup_time'])) {
|
||||||
$backup_time = $last_backup['backup_time'];
|
$backup_time = $last_backup['backup_time'];
|
||||||
MainWP_Helper::update_lasttime_backup('updraftplus', $backup_time);
|
if ($last_backup['success']) {
|
||||||
|
MainWP_Helper::update_lasttime_backup('updraftplus', $backup_time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $last_backup;
|
return $last_backup;
|
||||||
}
|
}
|
||||||
|
@ -48,9 +50,9 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $information;
|
return $information;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +64,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->required_files();
|
$this->required_files();
|
||||||
|
|
||||||
global $updraftplus;
|
global $updraftplus;
|
||||||
if ( empty( $updraftplus ) && class_exists( 'UpdraftPlus' ) ) {
|
if ( empty( $updraftplus ) && class_exists( 'UpdraftPlus' ) ) {
|
||||||
$updraftplus = new UpdraftPlus();
|
$updraftplus = new UpdraftPlus();
|
||||||
|
@ -71,13 +73,13 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
$information['error'] = 'Error empty updraftplus';
|
$information['error'] = 'Error empty updraftplus';
|
||||||
MainWP_Helper::write( $information );
|
MainWP_Helper::write( $information );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $_POST['mwp_action'] ) ) {
|
if ( isset( $_POST['mwp_action'] ) ) {
|
||||||
|
|
||||||
if ( get_option( 'mainwp_updraftplus_ext_enabled' ) !== 'Y' ) {
|
if ( get_option( 'mainwp_updraftplus_ext_enabled' ) !== 'Y' ) {
|
||||||
MainWP_Helper::update_option( 'mainwp_updraftplus_ext_enabled', 'Y', 'yes' );
|
MainWP_Helper::update_option( 'mainwp_updraftplus_ext_enabled', 'Y', 'yes' );
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
switch ( $_POST['mwp_action'] ) {
|
switch ( $_POST['mwp_action'] ) {
|
||||||
case 'set_showhide':
|
case 'set_showhide':
|
||||||
|
@ -249,7 +251,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
private function connected_html() {
|
private function connected_html() {
|
||||||
MainWP_Helper::check_classes_exists('UpdraftPlus_Options');
|
MainWP_Helper::check_classes_exists('UpdraftPlus_Options');
|
||||||
MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option');
|
MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option');
|
||||||
|
|
||||||
$vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' );
|
$vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' );
|
||||||
if ( !is_array( $vault_settings ) || empty( $vault_settings['token'] ) || empty( $vault_settings['email'] ) ) {
|
if ( !is_array( $vault_settings ) || empty( $vault_settings['token'] ) || empty( $vault_settings['email'] ) ) {
|
||||||
return '';
|
return '';
|
||||||
|
@ -382,13 +384,13 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
if ( ! class_exists( 'UpdraftPlus' ) && file_exists( UPDRAFTPLUS_DIR . '/class-updraftplus.php') ) {
|
if ( ! class_exists( 'UpdraftPlus' ) && file_exists( UPDRAFTPLUS_DIR . '/class-updraftplus.php') ) {
|
||||||
require_once( UPDRAFTPLUS_DIR . '/class-updraftplus.php' );
|
require_once( UPDRAFTPLUS_DIR . '/class-updraftplus.php' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'UpdraftPlus_Options' ) && file_exists( UPDRAFTPLUS_DIR . '/options.php' ) ) {
|
if ( ! class_exists( 'UpdraftPlus_Options' ) && file_exists( UPDRAFTPLUS_DIR . '/options.php' ) ) {
|
||||||
require_once( UPDRAFTPLUS_DIR . '/options.php' );
|
require_once( UPDRAFTPLUS_DIR . '/options.php' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_settings() {
|
function save_settings() {
|
||||||
$settings = maybe_unserialize( base64_decode( $_POST['settings'] ) );
|
$settings = maybe_unserialize( base64_decode( $_POST['settings'] ) );
|
||||||
|
|
||||||
|
@ -539,8 +541,10 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
if(is_array($opts) && isset($opts['settings'])) {
|
if(is_array($opts) && isset($opts['settings'])) {
|
||||||
$settings_key = key($opts['settings']);
|
$settings_key = key($opts['settings']);
|
||||||
$opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']);
|
$opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']);
|
||||||
|
$opts['settings'][$settings_key]['endpoint'] = $settings[ $key ]['endpoint'];
|
||||||
} else {
|
} else {
|
||||||
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
|
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
|
||||||
|
$opts['endpoint'] = $settings[ $key ]['endpoint'];
|
||||||
}
|
}
|
||||||
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
||||||
} else if ( 'updraft_ftp' === $key ) {
|
} else if ( 'updraft_ftp' === $key ) {
|
||||||
|
@ -595,15 +599,15 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
}
|
}
|
||||||
UpdraftPlus_Options::update_updraft_option( 'updraft_sftp', $opts );
|
UpdraftPlus_Options::update_updraft_option( 'updraft_sftp', $opts );
|
||||||
} else if ( 'updraft_backblaze' === $key ) {
|
} else if ( 'updraft_backblaze' === $key ) {
|
||||||
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_backblaze' );
|
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_backblaze' );
|
||||||
if (!is_array($opts))
|
if (!is_array($opts))
|
||||||
$opts = array();
|
$opts = array();
|
||||||
if (is_array($opts) && isset($opts['settings'])) {
|
if (is_array($opts) && isset($opts['settings'])) {
|
||||||
$settings_key = key($opts['settings']);
|
$settings_key = key($opts['settings']);
|
||||||
$opts['settings'][$settings_key]['account_id'] = $settings[ $key ]['account_id'];
|
$opts['settings'][$settings_key]['account_id'] = $settings[ $key ]['account_id'];
|
||||||
$opts['settings'][$settings_key]['key'] = $settings[ $key ]['key'];
|
$opts['settings'][$settings_key]['key'] = $settings[ $key ]['key'];
|
||||||
$opts['settings'][$settings_key]['bucket_name'] = $this->replace_tokens( $settings[ $key ]['bucket_name'] );
|
$opts['settings'][$settings_key]['bucket_name'] = $this->replace_tokens( $settings[ $key ]['bucket_name'] );
|
||||||
$opts['settings'][$settings_key]['backup_path'] = $this->replace_tokens( $settings[ $key ]['backup_path'] );
|
$opts['settings'][$settings_key]['backup_path'] = $this->replace_tokens( $settings[ $key ]['backup_path'] );
|
||||||
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -612,13 +616,13 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
$updated = true;
|
$updated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!isset($settings['do_not_save_remote_settings']) || empty($settings['do_not_save_remote_settings'])) {
|
if (!isset($settings['do_not_save_remote_settings']) || empty($settings['do_not_save_remote_settings'])) {
|
||||||
UpdraftPlus_Options::update_updraft_option( 'updraft_service', $settings['updraft_service'] );
|
UpdraftPlus_Options::update_updraft_option( 'updraft_service', $settings['updraft_service'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
global $updraftplus;
|
global $updraftplus;
|
||||||
if ( isset( $settings['updraft_interval'] ) ) {
|
if ( isset( $settings['updraft_interval'] ) ) {
|
||||||
// fix for premium version
|
// fix for premium version
|
||||||
|
@ -666,7 +670,10 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
|
|
||||||
function addons_connect() {
|
function addons_connect() {
|
||||||
if ( ! defined( 'UDADDONS2_SLUG' ) ) {
|
if ( ! defined( 'UDADDONS2_SLUG' ) ) {
|
||||||
return array( 'error' => 'NO_PREMIUM' );
|
if (is_file(UPDRAFTPLUS_DIR.'/udaddons/updraftplus-addons.php')) require_once(UPDRAFTPLUS_DIR.'/udaddons/updraftplus-addons.php');
|
||||||
|
if ( ! defined( 'UDADDONS2_SLUG' ) ) {
|
||||||
|
return array( 'error' => 'NO_PREMIUM' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$addons_options = maybe_unserialize( base64_decode( $_POST['addons_options'] ) );
|
$addons_options = maybe_unserialize( base64_decode( $_POST['addons_options'] ) );
|
||||||
|
@ -742,8 +749,6 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
$ehash = substr( md5( $input['email'] ), 0, 23 );
|
$ehash = substr( md5( $input['email'] ), 0, 23 );
|
||||||
delete_site_transient( 'udaddons_connect_' . $ehash );
|
delete_site_transient( 'udaddons_connect_' . $ehash );
|
||||||
|
|
||||||
// add_settings_error( UDADDONS2_SLUG."_options", UDADDONS2_SLUG."_options_nodb", "Whinge, whinge", "error" );
|
|
||||||
|
|
||||||
return $input;
|
return $input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -829,7 +834,9 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
$ret_info = '';
|
$ret_info = '';
|
||||||
if ( ! $failed ) {
|
if ( ! $failed ) {
|
||||||
$all_tables = $wpdb_obj->get_results( 'SHOW TABLES', ARRAY_N );
|
$all_tables = $wpdb_obj->get_results( 'SHOW TABLES', ARRAY_N );
|
||||||
$all_tables = array_map( create_function( '$a', 'return $a[0];' ), $all_tables );
|
//$all_tables = array_map( create_function( '$a', 'return $a[0];' ), $all_tables );
|
||||||
|
$all_tables = array_map(array($this, 'cb_get_name_base_type'), $all_tables);
|
||||||
|
|
||||||
if ( empty( $_POST['prefix'] ) ) {
|
if ( empty( $_POST['prefix'] ) ) {
|
||||||
$ret_info .= sprintf( __( '%s table(s) found.', 'updraftplus' ), count( $all_tables ) );
|
$ret_info .= sprintf( __( '%s table(s) found.', 'updraftplus' ), count( $all_tables ) );
|
||||||
} else {
|
} else {
|
||||||
|
@ -869,6 +876,9 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
return array( 'r' => $_POST['row'], 'm' => $ret . $ret_after );
|
return array( 'r' => $_POST['row'], 'm' => $ret . $ret_after );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function cb_get_name_base_type($a) {
|
||||||
|
return $a[0];
|
||||||
|
}
|
||||||
|
|
||||||
function backup_now() {
|
function backup_now() {
|
||||||
global $updraftplus;
|
global $updraftplus;
|
||||||
|
@ -1024,7 +1034,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
if ( empty( $updraftplus ) ) {
|
if ( empty( $updraftplus ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// UNIX timestamp
|
// UNIX timestamp
|
||||||
$next_scheduled_backup = wp_next_scheduled( 'updraft_backup' );
|
$next_scheduled_backup = wp_next_scheduled( 'updraft_backup' );
|
||||||
$next_scheduled_backup_gmt = $next_scheduled_backup_database_gmt = 0;
|
$next_scheduled_backup_gmt = $next_scheduled_backup_database_gmt = 0;
|
||||||
|
@ -1037,11 +1047,12 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
$next_scheduled_backup = 'Nothing currently scheduled';
|
$next_scheduled_backup = 'Nothing currently scheduled';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MainWP_Helper::check_classes_exists('UpdraftPlus_Options');
|
MainWP_Helper::check_classes_exists( array( 'UpdraftPlus_Options', 'UpdraftPlus_Filesystem_Functions' )) ;
|
||||||
MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option');
|
MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option');
|
||||||
MainWP_Helper::check_methods($updraftplus, array( 'backups_dir_location', 'really_is_writable' ));
|
MainWP_Helper::check_methods('UpdraftPlus_Filesystem_Functions', 'really_is_writable');
|
||||||
|
MainWP_Helper::check_methods($updraftplus, array( 'backups_dir_location' ));
|
||||||
|
|
||||||
$next_scheduled_backup_database = wp_next_scheduled( 'updraft_backup_database' );
|
$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' ) ) {
|
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' );
|
$next_scheduled_backup_database = ( 'Nothing currently scheduled' === $next_scheduled_backup ) ? $next_scheduled_backup : __( 'At the same time as the files backup', 'updraftplus' );
|
||||||
|
@ -1057,7 +1068,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
}
|
}
|
||||||
|
|
||||||
$updraft_dir = $updraftplus->backups_dir_location();
|
$updraft_dir = $updraftplus->backups_dir_location();
|
||||||
$backup_disabled = ( $updraftplus->really_is_writable( $updraft_dir ) ) ? 0 : 1;
|
$backup_disabled = (UpdraftPlus_Filesystem_Functions::really_is_writable($updraft_dir)) ? 0 : 1;
|
||||||
|
|
||||||
$current_timegmt = time();
|
$current_timegmt = time();
|
||||||
$current_time = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $current_timegmt ), 'D, F j, Y H:i' );
|
$current_time = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $current_timegmt ), 'D, F j, Y H:i' );
|
||||||
|
@ -1092,7 +1103,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
|
|
||||||
private function next_scheduled_backups() {
|
private function next_scheduled_backups() {
|
||||||
global $updraftplus;
|
global $updraftplus;
|
||||||
|
|
||||||
$next_scheduled_backup_gmt = $next_scheduled_backup_database_gmt = 0;
|
$next_scheduled_backup_gmt = $next_scheduled_backup_database_gmt = 0;
|
||||||
|
|
||||||
// UNIX timestamp
|
// UNIX timestamp
|
||||||
|
@ -1107,7 +1118,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
$next_scheduled_backup = __('Nothing currently scheduled', 'updraftplus');
|
$next_scheduled_backup = __('Nothing currently scheduled', 'updraftplus');
|
||||||
$files_not_scheduled = true;
|
$files_not_scheduled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$next_scheduled_backup_database = wp_next_scheduled('updraft_backup_database');
|
$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')) {
|
if (UpdraftPlus_Options::get_updraft_option('updraft_interval_database',UpdraftPlus_Options::get_updraft_option('updraft_interval')) == UpdraftPlus_Options::get_updraft_option('updraft_interval')) {
|
||||||
if (isset($files_not_scheduled)) {
|
if (isset($files_not_scheduled)) {
|
||||||
|
@ -1129,7 +1140,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
$database_not_scheduled = true;
|
$database_not_scheduled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$current_timegmt = time();
|
$current_timegmt = time();
|
||||||
$current_time = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $current_timegmt ), 'D, F j, Y H:i' );
|
$current_time = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $current_timegmt ), 'D, F j, Y H:i' );
|
||||||
|
|
||||||
|
@ -1142,8 +1153,11 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
<td style="width: 124px; vertical-align:top; margin: 0px; padding: 0px;">' . __( 'Time now', 'updraftplus' ) . ': </td><td style="color:blue; margin: 0px; padding: 0px;">' . $current_time . '</td>
|
<td style="width: 124px; vertical-align:top; margin: 0px; padding: 0px;">' . __( 'Time now', 'updraftplus' ) . ': </td><td style="color:blue; margin: 0px; padding: 0px;">' . $current_time . '</td>
|
||||||
</table>';
|
</table>';
|
||||||
|
|
||||||
|
MainWP_Helper::check_classes_exists( array( 'UpdraftPlus_Filesystem_Functions' ) ) ;
|
||||||
|
MainWP_Helper::check_methods('UpdraftPlus_Filesystem_Functions', 'really_is_writable');
|
||||||
|
|
||||||
$updraft_dir = $updraftplus->backups_dir_location();
|
$updraft_dir = $updraftplus->backups_dir_location();
|
||||||
$backup_disabled = ( $updraftplus->really_is_writable( $updraft_dir ) ) ? 0 : 1;
|
$backup_disabled = (UpdraftPlus_Filesystem_Functions::really_is_writable($updraft_dir)) ? 0 : 1;
|
||||||
|
|
||||||
$out = array(
|
$out = array(
|
||||||
'n' => $html,
|
'n' => $html,
|
||||||
|
@ -1167,7 +1181,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
|
|
||||||
private function deleteset() {
|
private function deleteset() {
|
||||||
global $updraftplus;
|
global $updraftplus;
|
||||||
|
|
||||||
if (method_exists($updraftplus, 'get_backup_history')) {
|
if (method_exists($updraftplus, 'get_backup_history')) {
|
||||||
$backups = $updraftplus->get_backup_history();
|
$backups = $updraftplus->get_backup_history();
|
||||||
} else if (class_exists('UpdraftPlus_Backup_History')) {
|
} else if (class_exists('UpdraftPlus_Backup_History')) {
|
||||||
|
@ -1301,12 +1315,12 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function build_historystatus() {
|
public function build_historystatus() {
|
||||||
|
|
||||||
MainWP_Helper::check_classes_exists('UpdraftPlus_Backup_History');
|
MainWP_Helper::check_classes_exists('UpdraftPlus_Backup_History');
|
||||||
MainWP_Helper::check_methods('UpdraftPlus_Backup_History', 'get_history');
|
MainWP_Helper::check_methods('UpdraftPlus_Backup_History', 'get_history');
|
||||||
|
|
||||||
$backup_history = UpdraftPlus_Backup_History::get_history();
|
$backup_history = UpdraftPlus_Backup_History::get_history();
|
||||||
|
|
||||||
$output = $this->existing_backup_table( $backup_history );
|
$output = $this->existing_backup_table( $backup_history );
|
||||||
|
|
||||||
if ( ! empty( $messages ) && is_array( $messages ) ) {
|
if ( ! empty( $messages ) && is_array( $messages ) ) {
|
||||||
|
@ -1392,13 +1406,13 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
$updraftplus->jobdata_set( 'job_type', 'download' );
|
$updraftplus->jobdata_set( 'job_type', 'download' );
|
||||||
$updraftplus->jobdata_set( 'job_time_ms', $updraftplus->job_time_ms );
|
$updraftplus->jobdata_set( 'job_time_ms', $updraftplus->job_time_ms );
|
||||||
|
|
||||||
// Retrieve the information from our backup history
|
// Retrieve the information from our backup history
|
||||||
if (method_exists($updraftplus, 'get_backup_history')) {
|
if (method_exists($updraftplus, 'get_backup_history')) {
|
||||||
$backup_history = $updraftplus->get_backup_history();
|
$backup_history = $updraftplus->get_backup_history();
|
||||||
} else if (class_exists('UpdraftPlus_Backup_History')) {
|
} else if (class_exists('UpdraftPlus_Backup_History')) {
|
||||||
$backup_history = UpdraftPlus_Backup_History::get_history();
|
$backup_history = UpdraftPlus_Backup_History::get_history();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Base name
|
// Base name
|
||||||
$file = $backup_history[ $timestamp ][ $type ];
|
$file = $backup_history[ $timestamp ][ $type ];
|
||||||
|
|
||||||
|
@ -1554,13 +1568,13 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
|
|
||||||
public function restore_alldownloaded() {
|
public function restore_alldownloaded() {
|
||||||
global $updraftplus;
|
global $updraftplus;
|
||||||
|
|
||||||
if (method_exists($updraftplus, 'get_backup_history')) {
|
if (method_exists($updraftplus, 'get_backup_history')) {
|
||||||
$backups = $updraftplus->get_backup_history();
|
$backups = $updraftplus->get_backup_history();
|
||||||
} else if (class_exists('UpdraftPlus_Backup_History')) {
|
} else if (class_exists('UpdraftPlus_Backup_History')) {
|
||||||
$backups = UpdraftPlus_Backup_History::get_history();
|
$backups = UpdraftPlus_Backup_History::get_history();
|
||||||
}
|
}
|
||||||
|
|
||||||
$updraft_dir = $updraftplus->backups_dir_location();
|
$updraft_dir = $updraftplus->backups_dir_location();
|
||||||
|
|
||||||
$timestamp = (int) $_POST['timestamp'];
|
$timestamp = (int) $_POST['timestamp'];
|
||||||
|
@ -1701,7 +1715,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// not used
|
// not used
|
||||||
public function restoreBackup() {
|
public function restoreBackup() {
|
||||||
|
|
||||||
|
@ -2116,7 +2130,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function option_filter_template( $val ) {
|
public function option_filter_template( $val ) {
|
||||||
global $updraftplus;
|
global $updraftplus;
|
||||||
|
|
||||||
|
@ -2487,10 +2501,10 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function analyse_db_file($timestamp, $res, $db_file = false, $header_only = false) {
|
public function analyse_db_file($timestamp, $res, $db_file = false, $header_only = false) {
|
||||||
global $updraftplus;
|
global $updraftplus;
|
||||||
|
|
||||||
$mess = array();
|
$mess = array();
|
||||||
$warn = array();
|
$warn = array();
|
||||||
$err = array();
|
$err = array();
|
||||||
|
@ -2853,9 +2867,9 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
$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 .= '<option value="'.esc_attr($collate).'" '.selected($collate, $similar_type_collate, $echo = false).' '.implode(' ', $option_other_attr).'>'.esc_html($collate).'</option>';
|
||||||
}
|
}
|
||||||
$collate_select_html .= '</select>';
|
$collate_select_html .= '</select>';
|
||||||
|
|
||||||
$info['addui'] = empty($info['addui']) ? $collate_select_html : $info['addui'].'<br>'.$collate_select_html;
|
$info['addui'] = empty($info['addui']) ? $collate_select_html : $info['addui'].'<br>'.$collate_select_html;
|
||||||
|
|
||||||
if ($db_charset_forbidden) {
|
if ($db_charset_forbidden) {
|
||||||
$collate_change_on_charset_selection_data = array(
|
$collate_change_on_charset_selection_data = array(
|
||||||
'db_supported_collations' => $db_supported_collations,
|
'db_supported_collations' => $db_supported_collations,
|
||||||
|
@ -2921,7 +2935,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
return array($mess, $warn, $err, $info);
|
return array($mess, $warn, $err, $info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function gzopen_for_read( $file, &$warn, &$err ) {
|
private function gzopen_for_read( $file, &$warn, &$err ) {
|
||||||
if ( ! function_exists( 'gzopen' ) || ! function_exists( 'gzread' ) ) {
|
if ( ! function_exists( 'gzopen' ) || ! function_exists( 'gzread' ) ) {
|
||||||
$missing = '';
|
$missing = '';
|
||||||
|
@ -3014,13 +3028,13 @@ class MainWP_Child_Updraft_Plus_Backups {
|
||||||
if ( false === $backup_history ) {
|
if ( false === $backup_history ) {
|
||||||
$backup_history = UpdraftPlus_Backup_History::get_history();
|
$backup_history = UpdraftPlus_Backup_History::get_history();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( $backup_history ) ) {
|
if ( empty( $backup_history ) ) {
|
||||||
return '<p><em>' . __( 'You have not yet made any backups.', 'updraftplus' ) . '</em></p>';
|
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' ));
|
MainWP_Helper::check_methods($updraftplus, array( 'backups_dir_location', 'get_backupable_file_entities' ));
|
||||||
|
|
||||||
$updraft_dir = $updraftplus->backups_dir_location();
|
$updraft_dir = $updraftplus->backups_dir_location();
|
||||||
$backupable_entities = $updraftplus->get_backupable_file_entities( true, true );
|
$backupable_entities = $updraftplus->get_backupable_file_entities( true, true );
|
||||||
|
|
||||||
|
@ -3094,7 +3108,7 @@ ENDHERE;
|
||||||
} else if ( method_exists($updraftplus, 'is_db_encrypted') && $updraftplus->is_db_encrypted( $db ) ) {
|
} else if ( method_exists($updraftplus, 'is_db_encrypted') && $updraftplus->is_db_encrypted( $db ) ) {
|
||||||
$entities .= '/dbcrypted=1/';
|
$entities .= '/dbcrypted=1/';
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret .= $this->download_db_button( 'db', $key, $esc_pretty_date, $nonce_field, $backup, $accept );
|
$ret .= $this->download_db_button( 'db', $key, $esc_pretty_date, $nonce_field, $backup, $accept );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3959,7 +3973,7 @@ ENDHERE;
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_sync_data() {
|
public function get_sync_data() {
|
||||||
$this->required_files();
|
$this->required_files();
|
||||||
return $this->get_updraft_data();
|
return $this->get_updraft_data();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class MainWP_Child_Vulnerability_Checker {
|
class MainWP_Child_Vulnerability_Checker {
|
||||||
|
|
||||||
public static $instance = null;
|
public static $instance = null;
|
||||||
|
|
||||||
static function Instance() {
|
static function Instance() {
|
||||||
if ( null === MainWP_Child_Vulnerability_Checker::$instance ) {
|
if ( null === MainWP_Child_Vulnerability_Checker::$instance ) {
|
||||||
MainWP_Child_Vulnerability_Checker::$instance = new MainWP_Child_Vulnerability_Checker();
|
MainWP_Child_Vulnerability_Checker::$instance = new MainWP_Child_Vulnerability_Checker();
|
||||||
|
@ -11,8 +11,8 @@ class MainWP_Child_Vulnerability_Checker {
|
||||||
return MainWP_Child_Vulnerability_Checker::$instance;
|
return MainWP_Child_Vulnerability_Checker::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function action() {
|
public function action() {
|
||||||
|
@ -21,44 +21,44 @@ class MainWP_Child_Vulnerability_Checker {
|
||||||
switch ( $_POST['mwp_action'] ) {
|
switch ( $_POST['mwp_action'] ) {
|
||||||
case 'vulner_recheck':
|
case 'vulner_recheck':
|
||||||
$information = $this->vulner_recheck();
|
$information = $this->vulner_recheck();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MainWP_Helper::write( $information );
|
MainWP_Helper::write( $information );
|
||||||
}
|
}
|
||||||
|
|
||||||
function vulner_recheck(){
|
function vulner_recheck(){
|
||||||
$result = array();
|
$result = array();
|
||||||
$force = (isset($_POST['force']) && !empty($_POST['force'])) ? true : false;
|
$force = (isset($_POST['force']) && !empty($_POST['force'])) ? true : false;
|
||||||
$result['plugin'] = $this->check_plugins($force);
|
$result['plugin'] = $this->check_plugins($force);
|
||||||
$result['wp'] = $this->check_wp($force);
|
$result['wp'] = $this->check_wp($force);
|
||||||
$result['theme'] = $this->check_themes($force);
|
$result['theme'] = $this->check_themes($force);
|
||||||
$information = array( 'result' => $result, 'ok' => 1);
|
$information = array( 'result' => $result, 'ok' => 1);
|
||||||
return $information;
|
return $information;
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_plugins($force = false){
|
function check_plugins($force = false){
|
||||||
$result = array();
|
$result = array();
|
||||||
$active_plugins = get_option('active_plugins');
|
$active_plugins = get_option('active_plugins');
|
||||||
|
|
||||||
if( !empty($active_plugins) ){
|
if( !empty($active_plugins) ){
|
||||||
foreach($active_plugins as $plug){
|
foreach($active_plugins as $plug){
|
||||||
|
|
||||||
$plugin_file = WP_CONTENT_DIR . '/plugins/' . $plug;
|
$plugin_file = WP_CONTENT_DIR . '/plugins/' . $plug;
|
||||||
$plugin_info = get_plugin_data($plugin_file);
|
$plugin_info = get_plugin_data($plugin_file);
|
||||||
$plugin_version = isset($plugin_info['Version']) ? $plugin_info['Version'] : '';
|
$plugin_version = isset($plugin_info['Version']) ? $plugin_info['Version'] : '';
|
||||||
$string = explode('/',$plug);
|
$string = explode('/',$plug);
|
||||||
$plug_vuln = get_transient('mainwp_vulnche_trans_plug_'.$string[0]);
|
$plug_vuln = get_transient('mainwp_vulnche_trans_plug_'.$string[0]);
|
||||||
if(false === $plug_vuln || $force) {
|
if(false === $plug_vuln || $force) {
|
||||||
$plug_vuln = $this->vulnche_get_content('https://wpvulndb.com/api/v2/plugins/' . $string[0]);
|
$plug_vuln = $this->vulnche_get_content('https://wpvulndb.com/api/v2/plugins/' . $string[0]);
|
||||||
set_transient('mainwp_vulnche_trans_plug_'.$string[0],$plug_vuln, 1 * DAY_IN_SECONDS);
|
set_transient('mainwp_vulnche_trans_plug_'.$string[0],$plug_vuln, 1 * DAY_IN_SECONDS);
|
||||||
}
|
}
|
||||||
if ($plug_vuln) {
|
if ($plug_vuln) {
|
||||||
$plug_vuln = json_decode($plug_vuln, true);
|
$plug_vuln = json_decode($plug_vuln, true);
|
||||||
$plug_vuln_filter = $plug_vuln;
|
$plug_vuln_filter = $plug_vuln;
|
||||||
|
|
||||||
foreach ($plug_vuln as $slug => $pl_data) {
|
foreach ($plug_vuln as $slug => $pl_data) {
|
||||||
if (isset($pl_data['vulnerabilities']) && count($pl_data['vulnerabilities']) > 0) {
|
if (isset($pl_data['vulnerabilities']) && count($pl_data['vulnerabilities']) > 0) {
|
||||||
$plug_vulner_data = array();
|
$plug_vulner_data = array();
|
||||||
foreach($pl_data['vulnerabilities'] as $vuln_data) {
|
foreach($pl_data['vulnerabilities'] as $vuln_data) {
|
||||||
if ( isset($vuln_data['fixed_in']) && version_compare( $plugin_version, $vuln_data['fixed_in'] ) >= 0 ) {
|
if ( isset($vuln_data['fixed_in']) && version_compare( $plugin_version, $vuln_data['fixed_in'] ) >= 0 ) {
|
||||||
|
@ -83,41 +83,41 @@ class MainWP_Child_Vulnerability_Checker {
|
||||||
|
|
||||||
if (count($plug_vuln_filter) == 0) {
|
if (count($plug_vuln_filter) == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$plug_vuln = json_encode($plug_vuln_filter);
|
$plug_vuln = json_encode($plug_vuln_filter);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$result[$plug] = $plug_vuln;
|
$result[$plug] = $plug_vuln;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_wp($force = false){
|
function check_wp($force = false){
|
||||||
$wp_vuln = get_transient('mainwp_vulnche_trans_wp_json');
|
$wp_vuln = get_transient('mainwp_vulnche_trans_wp_json');
|
||||||
$wp_version = str_replace('.', '', get_bloginfo('version'));
|
$wp_version = str_replace('.', '', get_bloginfo('version'));
|
||||||
if(false === $wp_vuln || $force) {
|
if(false === $wp_vuln || $force) {
|
||||||
$wp_vuln = $this->vulnche_get_content('https://wpvulndb.com/api/v2/wordpresses/' . $wp_version);
|
$wp_vuln = $this->vulnche_get_content('https://wpvulndb.com/api/v2/wordpresses/' . $wp_version);
|
||||||
set_transient('mainwp_vulnche_trans_wp_json', $wp_vuln, 1 * DAY_IN_SECONDS);
|
set_transient('mainwp_vulnche_trans_wp_json', $wp_vuln, 1 * DAY_IN_SECONDS);
|
||||||
}
|
}
|
||||||
return $wp_vuln;
|
return $wp_vuln;
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_themes($force = false){
|
function check_themes($force = false){
|
||||||
|
|
||||||
require_once( ABSPATH . 'wp-admin/includes/misc.php' );
|
require_once( ABSPATH . 'wp-admin/includes/misc.php' );
|
||||||
require_once( ABSPATH . 'wp-admin/includes/theme.php' );
|
require_once( ABSPATH . 'wp-admin/includes/theme.php' );
|
||||||
|
|
||||||
if ( current_user_can( 'switch_themes' ) ) {
|
if ( current_user_can( 'switch_themes' ) ) {
|
||||||
$themes = wp_prepare_themes_for_js();
|
$themes = wp_prepare_themes_for_js();
|
||||||
} else {
|
} else {
|
||||||
$themes = wp_prepare_themes_for_js( array( wp_get_theme() ) );
|
$themes = wp_prepare_themes_for_js( array( wp_get_theme() ) );
|
||||||
}
|
}
|
||||||
wp_reset_vars( array( 'theme', 'search' ) );
|
wp_reset_vars( array( 'theme', 'search' ) );
|
||||||
$result = array();
|
$result = array();
|
||||||
if(!empty($themes)){
|
if(!empty($themes)){
|
||||||
foreach($themes as $th){
|
foreach($themes as $th){
|
||||||
if(empty($th['parent'])) {
|
if(empty($th['parent'])) {
|
||||||
$th_vuln = get_transient('mainwp_vulnche_trans_theme_' . $th['id']);
|
$th_vuln = get_transient('mainwp_vulnche_trans_theme_' . $th['id']);
|
||||||
|
@ -125,47 +125,47 @@ class MainWP_Child_Vulnerability_Checker {
|
||||||
$th_vuln = $this->vulnche_get_content('https://wpvulndb.com/api/v2/themes/' . $th['id']);
|
$th_vuln = $this->vulnche_get_content('https://wpvulndb.com/api/v2/themes/' . $th['id']);
|
||||||
set_transient('mainwp_vulnche_trans_theme_' . $th['id'], $th_vuln, 1 * DAY_IN_SECONDS);
|
set_transient('mainwp_vulnche_trans_theme_' . $th['id'], $th_vuln, 1 * DAY_IN_SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($th_vuln) {
|
if ($th_vuln) {
|
||||||
$th_vuln = json_decode($th_vuln, true);
|
$th_vuln = json_decode($th_vuln, true);
|
||||||
$th_vuln_filter = $th_vuln;
|
$th_vuln_filter = $th_vuln;
|
||||||
foreach ($th_vuln as $slug => $th_data) {
|
foreach ($th_vuln as $slug => $th_data) {
|
||||||
if (isset($th_data['vulnerabilities']) && count($th_data['vulnerabilities']) > 0) {
|
if (isset($th_data['vulnerabilities']) && count($th_data['vulnerabilities']) > 0) {
|
||||||
|
|
||||||
$th_vulner_data = array();
|
$th_vulner_data = array();
|
||||||
foreach($th_data['vulnerabilities'] as $vuln_data) {
|
foreach($th_data['vulnerabilities'] as $vuln_data) {
|
||||||
if (empty($vuln_data))
|
if (empty($vuln_data))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( isset($vuln_data['fixed_in']) && version_compare( $th['version'], $vuln_data['fixed_in'] ) >= 0 ) {
|
if ( isset($vuln_data['fixed_in']) && version_compare( $th['version'], $vuln_data['fixed_in'] ) >= 0 ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$th_vulner_data[] = $vuln_data;
|
$th_vulner_data[] = $vuln_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($th_vulner_data) == 0) {
|
if(count($th_vulner_data) == 0) {
|
||||||
unset($th_vuln_filter[$slug]);
|
unset($th_vuln_filter[$slug]);
|
||||||
} else {
|
} else {
|
||||||
$th_vuln_filter[$slug]['vulnerabilities'] = $th_vulner_data;
|
$th_vuln_filter[$slug]['vulnerabilities'] = $th_vulner_data;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unset($th_vuln_filter[$slug]);
|
unset($th_vuln_filter[$slug]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($th_vuln_filter) == 0) {
|
if (count($th_vuln_filter) == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$th_vuln = json_encode($th_vuln_filter);
|
$th_vuln = json_encode($th_vuln_filter);
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result[$th['id']]['vulner_data'] = $th_vuln;
|
$result[$th['id']]['vulner_data'] = $th_vuln;
|
||||||
$result[$th['id']]['name'] = $th['name'];
|
$result[$th['id']]['name'] = $th['name'];
|
||||||
$result[$th['id']]['author'] = $th['author'];
|
$result[$th['id']]['author'] = $th['author'];
|
||||||
$result[$th['id']]['detected_version'] = $th['version'];
|
$result[$th['id']]['detected_version'] = $th['version'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,29 +173,29 @@ class MainWP_Child_Vulnerability_Checker {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function vulnche_get_content ($url) {
|
function vulnche_get_content ($url) {
|
||||||
|
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT, $this->get_random_user_agent());
|
curl_setopt($ch, CURLOPT_USERAGENT, $this->get_random_user_agent());
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
|
||||||
|
|
||||||
$output = curl_exec($ch);
|
$output = curl_exec($ch);
|
||||||
$info = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$info = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
if ($output === false || $info != 200) {
|
if ($output === false || $info != 200) {
|
||||||
$output = null;
|
$output = null;
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_random_user_agent ( ) {
|
function get_random_user_agent ( ) {
|
||||||
|
|
||||||
$someUA = array (
|
$someUA = array (
|
||||||
"Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.1b1) Gecko/20081007 Firefox/3.1b1",
|
"Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.1b1) Gecko/20081007 Firefox/3.1b1",
|
||||||
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.0",
|
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.0",
|
||||||
|
@ -209,9 +209,9 @@ class MainWP_Child_Vulnerability_Checker {
|
||||||
"Mozilla/4.08 (compatible; MSIE 6.0; Windows NT 5.1)",
|
"Mozilla/4.08 (compatible; MSIE 6.0; Windows NT 5.1)",
|
||||||
"Mozilla/4.01 (compatible; MSIE 6.0; Windows NT 5.1)"
|
"Mozilla/4.01 (compatible; MSIE 6.0; Windows NT 5.1)"
|
||||||
);
|
);
|
||||||
|
|
||||||
srand((double)microtime()*1000000);
|
srand((double)microtime()*1000000);
|
||||||
|
|
||||||
return $someUA[rand(0,count($someUA)-1)];
|
return $someUA[rand(0,count($someUA)-1)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class MainWP_Child_WooCommerce_Status {
|
||||||
$information['error'] = 'NO_WOOCOMMERCE';
|
$information['error'] = 'NO_WOOCOMMERCE';
|
||||||
MainWP_Helper::write( $information );
|
MainWP_Helper::write( $information );
|
||||||
}
|
}
|
||||||
|
|
||||||
$is_ver220 = $this->is_version_220();
|
$is_ver220 = $this->is_version_220();
|
||||||
if ( isset( $_POST['mwp_action'] ) ) {
|
if ( isset( $_POST['mwp_action'] ) ) {
|
||||||
switch ( $_POST['mwp_action'] ) {
|
switch ( $_POST['mwp_action'] ) {
|
||||||
|
@ -35,7 +35,7 @@ class MainWP_Child_WooCommerce_Status {
|
||||||
break;
|
break;
|
||||||
case 'report_data':
|
case 'report_data':
|
||||||
$information = ! $is_ver220 ? $this->report_data() : $this->report_data_two();
|
$information = ! $is_ver220 ? $this->report_data() : $this->report_data_two();
|
||||||
break;
|
break;
|
||||||
case 'update_wc_db':
|
case 'update_wc_db':
|
||||||
$information = $this->update_wc_db();
|
$information = $this->update_wc_db();
|
||||||
break;
|
break;
|
||||||
|
@ -178,6 +178,10 @@ class MainWP_Child_WooCommerce_Status {
|
||||||
$reports = new WC_Admin_Report();
|
$reports = new WC_Admin_Report();
|
||||||
$start_date = $_POST['start_date'];
|
$start_date = $_POST['start_date'];
|
||||||
$end_date = $_POST['end_date'];
|
$end_date = $_POST['end_date'];
|
||||||
|
|
||||||
|
$start_date = date( 'Y-m-d H:i:s', $start_date );
|
||||||
|
$end_date = date( 'Y-m-d H:i:s', $end_date );
|
||||||
|
|
||||||
// Get sales
|
// Get sales
|
||||||
$sales = $wpdb->get_var( "SELECT SUM( postmeta.meta_value ) FROM {$wpdb->posts} as posts
|
$sales = $wpdb->get_var( "SELECT SUM( postmeta.meta_value ) FROM {$wpdb->posts} as posts
|
||||||
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID
|
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID
|
||||||
|
@ -193,10 +197,13 @@ class MainWP_Child_WooCommerce_Status {
|
||||||
'on-hold',
|
'on-hold',
|
||||||
) ) ) . "' )
|
) ) ) . "' )
|
||||||
AND postmeta.meta_key = '_order_total'
|
AND postmeta.meta_key = '_order_total'
|
||||||
AND posts.post_date >= '" . date( 'Y-m-01', $start_date ) . "'
|
AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s')
|
||||||
AND posts.post_date <= '" . date( 'Y-m-d H:i:s', $end_date ) . "'
|
AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s')
|
||||||
" );
|
" );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Get top seller
|
// Get top seller
|
||||||
$top_seller = $wpdb->get_row( "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id
|
$top_seller = $wpdb->get_row( "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id
|
||||||
FROM {$wpdb->posts} as posts
|
FROM {$wpdb->posts} as posts
|
||||||
|
@ -216,8 +223,8 @@ class MainWP_Child_WooCommerce_Status {
|
||||||
) ) ) . "' )
|
) ) ) . "' )
|
||||||
AND order_item_meta.meta_key = '_qty'
|
AND order_item_meta.meta_key = '_qty'
|
||||||
AND order_item_meta_2.meta_key = '_product_id'
|
AND order_item_meta_2.meta_key = '_product_id'
|
||||||
AND posts.post_date >= '" . date( 'Y-m-01', $start_date ) . "'
|
AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s')
|
||||||
AND posts.post_date <= '" . date( 'Y-m-d H:i:s', $end_date ) . "'
|
AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s')
|
||||||
GROUP BY product_id
|
GROUP BY product_id
|
||||||
ORDER BY qty DESC
|
ORDER BY qty DESC
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
|
@ -284,9 +291,12 @@ class MainWP_Child_WooCommerce_Status {
|
||||||
}
|
}
|
||||||
|
|
||||||
function sync_data_two() {
|
function sync_data_two() {
|
||||||
// sync data at current time
|
// sync data for current month
|
||||||
$start_date = current_time( 'timestamp' );
|
$start_date = date( 'Y-m-01 00:00:00', time() );
|
||||||
$end_date = current_time( 'timestamp' );
|
$end_date = date( 'Y-m-d H:i:s', time() );
|
||||||
|
|
||||||
|
$start_date = strtotime( $start_date );
|
||||||
|
$end_date = strtotime( $end_date );
|
||||||
|
|
||||||
return $this->get_woocom_data( $start_date, $end_date );
|
return $this->get_woocom_data( $start_date, $end_date );
|
||||||
}
|
}
|
||||||
|
@ -297,14 +307,14 @@ class MainWP_Child_WooCommerce_Status {
|
||||||
|
|
||||||
return $this->get_woocom_data( $start_date, $end_date );
|
return $this->get_woocom_data( $start_date, $end_date );
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_db_update() {
|
function check_db_update() {
|
||||||
if ( version_compare( get_option( 'woocommerce_db_version' ), WC_VERSION, '<' ) ) {
|
if ( version_compare( get_option( 'woocommerce_db_version' ), WC_VERSION, '<' ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_woocom_data( $start_date, $end_date ) {
|
function get_woocom_data( $start_date, $end_date ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$file = WP_PLUGIN_DIR . '/woocommerce/includes/admin/reports/class-wc-admin-report.php';
|
$file = WP_PLUGIN_DIR . '/woocommerce/includes/admin/reports/class-wc-admin-report.php';
|
||||||
|
@ -313,6 +323,10 @@ class MainWP_Child_WooCommerce_Status {
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$start_date = date( 'Y-m-d H:i:s', $start_date );
|
||||||
|
$end_date = date( 'Y-m-d H:i:s', $end_date );
|
||||||
|
|
||||||
$reports = new WC_Admin_Report();
|
$reports = new WC_Admin_Report();
|
||||||
// Sales
|
// Sales
|
||||||
$query = array();
|
$query = array();
|
||||||
|
@ -325,8 +339,8 @@ class MainWP_Child_WooCommerce_Status {
|
||||||
'on-hold',
|
'on-hold',
|
||||||
) ) ) . "' ) ";
|
) ) ) . "' ) ";
|
||||||
$query['where'] .= "AND postmeta.meta_key = '_order_total' ";
|
$query['where'] .= "AND postmeta.meta_key = '_order_total' ";
|
||||||
$query['where'] .= "AND posts.post_date >= '" . date( 'Y-m-01', $start_date ) . "' ";
|
$query['where'] .= "AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') ";
|
||||||
$query['where'] .= "AND posts.post_date <= '" . date( 'Y-m-d H:i:s', $end_date ) . "' ";
|
$query['where'] .= "AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') ";
|
||||||
|
|
||||||
$sales = $wpdb->get_var( implode( ' ', apply_filters( 'woocommerce_dashboard_status_widget_sales_query', $query ) ) );
|
$sales = $wpdb->get_var( implode( ' ', apply_filters( 'woocommerce_dashboard_status_widget_sales_query', $query ) ) );
|
||||||
|
|
||||||
|
@ -345,13 +359,13 @@ class MainWP_Child_WooCommerce_Status {
|
||||||
) ) ) . "' ) ";
|
) ) ) . "' ) ";
|
||||||
$query['where'] .= "AND order_item_meta.meta_key = '_qty' ";
|
$query['where'] .= "AND order_item_meta.meta_key = '_qty' ";
|
||||||
$query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' ";
|
$query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' ";
|
||||||
$query['where'] .= "AND posts.post_date >= %s ";
|
$query['where'] .= "AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') ";
|
||||||
$query['where'] .= "AND posts.post_date <= %s ";
|
$query['where'] .= "AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') ";
|
||||||
$query['groupby'] = 'GROUP BY product_id';
|
$query['groupby'] = 'GROUP BY product_id';
|
||||||
$query['orderby'] = 'ORDER BY qty DESC';
|
$query['orderby'] = 'ORDER BY qty DESC';
|
||||||
$query['limits'] = 'LIMIT 1';
|
$query['limits'] = 'LIMIT 1';
|
||||||
|
|
||||||
$top_seller = $wpdb->get_row( $wpdb->prepare( implode( ' ', $query ), date( 'Y-m-01', $start_date ), date( 'Y-m-d H:i:s', $end_date ) ) );
|
$top_seller = $wpdb->get_row( implode( ' ', $query ) );
|
||||||
|
|
||||||
|
|
||||||
if ( ! empty( $top_seller ) ) {
|
if ( ! empty( $top_seller ) ) {
|
||||||
|
@ -413,17 +427,17 @@ class MainWP_Child_WooCommerce_Status {
|
||||||
'stock' => $stock,
|
'stock' => $stock,
|
||||||
'nostock' => $nostock,
|
'nostock' => $nostock,
|
||||||
'lowstock' => $lowinstock_count,
|
'lowstock' => $lowinstock_count,
|
||||||
'outstock' => $outofstock_count
|
'outstock' => $outofstock_count
|
||||||
);
|
);
|
||||||
$information['data'] = $data;
|
$information['data'] = $data;
|
||||||
$information['need_db_update'] = $this->check_db_update();
|
$information['need_db_update'] = $this->check_db_update();
|
||||||
return $information;
|
return $information;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function update_wc_db() {
|
private static function update_wc_db() {
|
||||||
include_once( WC()->plugin_path() . '/includes/class-wc-background-updater.php' );
|
include_once( WC()->plugin_path() . '/includes/class-wc-background-updater.php' );
|
||||||
$background_updater = new WC_Background_Updater();
|
$background_updater = new WC_Background_Updater();
|
||||||
|
|
||||||
$current_db_version = get_option( 'woocommerce_db_version' );
|
$current_db_version = get_option( 'woocommerce_db_version' );
|
||||||
$logger = wc_get_logger();
|
$logger = wc_get_logger();
|
||||||
$update_queued = false;
|
$update_queued = false;
|
||||||
|
@ -444,9 +458,9 @@ class MainWP_Child_WooCommerce_Status {
|
||||||
if ( $update_queued ) {
|
if ( $update_queued ) {
|
||||||
$background_updater->save()->dispatch();
|
$background_updater->save()->dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
return array('result' => 'success');
|
return array('result' => 'success');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,14 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
|
||||||
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'You dont send nonce: ' . $action ) ) ) . '</mainwp>' );
|
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'You dont send nonce: ' . $action ) ) ) . '</mainwp>' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To fix verify nonce conflict #1
|
||||||
|
// this is fake nonce to fix some conflict of wp_verify_nonce
|
||||||
|
// just return false to unverify nonce, does not exit
|
||||||
|
if ($nonce == 'mainwp-bsm-unverify-nonce') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$token = wp_get_session_token();
|
$token = wp_get_session_token();
|
||||||
$i = wp_nonce_tick();
|
$i = wp_nonce_tick();
|
||||||
|
|
||||||
|
@ -75,8 +83,19 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To fix verify nonce conflict #2
|
||||||
|
// this is fake post field to fix some conflict of wp_verify_nonce
|
||||||
|
// just return false to unverify nonce, does not exit
|
||||||
|
if ( isset($_POST[$action]) && ($_POST[$action] == 'mainwp-bsm-unverify-nonce')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ob_start();
|
||||||
|
@debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||||
|
$stackTrace = "\n" . @ob_get_clean();
|
||||||
|
|
||||||
// Invalid nonce
|
// Invalid nonce
|
||||||
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'Invalid nonce! Try to use: ' . $action ) ) ) . '</mainwp>' );
|
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'Invalid nonce! Try to use: ' . $action . '<br/>Trace: ' .$stackTrace) ) ) . '</mainwp>' );
|
||||||
}
|
}
|
||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +103,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
|
||||||
}
|
}
|
||||||
|
|
||||||
class MainWP_Child {
|
class MainWP_Child {
|
||||||
public static $version = '3.4.8';
|
public static $version = '3.5';
|
||||||
private $update_version = '1.3';
|
private $update_version = '1.3';
|
||||||
|
|
||||||
private $callableFunctions = array(
|
private $callableFunctions = array(
|
||||||
|
@ -149,10 +168,11 @@ class MainWP_Child {
|
||||||
'custom_post_type' => 'custom_post_type',
|
'custom_post_type' => 'custom_post_type',
|
||||||
'backup_buddy' => 'backup_buddy',
|
'backup_buddy' => 'backup_buddy',
|
||||||
'get_site_icon' => 'get_site_icon',
|
'get_site_icon' => 'get_site_icon',
|
||||||
'vulner_checker' => 'vulner_checker',
|
'vulner_checker' => 'vulner_checker',
|
||||||
'wp_staging' => 'wp_staging',
|
'wp_staging' => 'wp_staging',
|
||||||
'disconnect' => 'disconnect',
|
'disconnect' => 'disconnect',
|
||||||
'time_capsule' => 'time_capsule',
|
'time_capsule' => 'time_capsule',
|
||||||
|
'extra_excution' => 'extra_execution',
|
||||||
);
|
);
|
||||||
|
|
||||||
private $FTP_ERROR = 'Failed! Please, add FTP details for automatic updates.';
|
private $FTP_ERROR = 'Failed! Please, add FTP details for automatic updates.';
|
||||||
|
@ -179,11 +199,11 @@ class MainWP_Child {
|
||||||
$this->update();
|
$this->update();
|
||||||
$this->load_all_options();
|
$this->load_all_options();
|
||||||
$this->filterFunction = function($a) {
|
$this->filterFunction = function($a) {
|
||||||
if ($a == null) { return false; }
|
if ($a == null) { return false; }
|
||||||
if (is_object($a) && property_exists($a, "last_checked") && !property_exists($a, "checked"))
|
if (is_object($a) && property_exists($a, "last_checked") && !property_exists($a, "checked"))
|
||||||
return false;
|
return false;
|
||||||
return $a;
|
return $a;
|
||||||
};
|
};
|
||||||
$this->plugin_dir = dirname( $plugin_file );
|
$this->plugin_dir = dirname( $plugin_file );
|
||||||
$this->plugin_slug = plugin_basename( $plugin_file );
|
$this->plugin_slug = plugin_basename( $plugin_file );
|
||||||
list ( $t1, $t2 ) = explode( '/', $this->plugin_slug );
|
list ( $t1, $t2 ) = explode( '/', $this->plugin_slug );
|
||||||
|
@ -193,7 +213,7 @@ class MainWP_Child {
|
||||||
$this->comments_and_clauses = '';
|
$this->comments_and_clauses = '';
|
||||||
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
||||||
add_action( 'init', array( &$this, 'check_login' ), 1 );
|
add_action( 'init', array( &$this, 'check_login' ), 1 );
|
||||||
add_action( 'init', array( &$this, 'parse_init' ), 9999 );
|
add_action( 'init', array( &$this, 'parse_init' ), 9999 );
|
||||||
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
||||||
add_action( 'admin_init', array( &$this, 'admin_init' ) );
|
add_action( 'admin_init', array( &$this, 'admin_init' ) );
|
||||||
add_action( 'admin_head', array( &$this, 'admin_head' ) );
|
add_action( 'admin_head', array( &$this, 'admin_head' ) );
|
||||||
|
@ -503,17 +523,15 @@ class MainWP_Child {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function pre_current_active_plugins() {
|
public function pre_current_active_plugins() {
|
||||||
$plugin_updates = get_plugin_updates();
|
if (isset($_GET['_detect_plugins_updates']) && $_GET['_detect_plugins_updates'] = 'yes') {
|
||||||
$fix_update_plugins = array();
|
// to fix some premium plugins update notification
|
||||||
if ( is_array( $plugin_updates ) ) {
|
$current = get_site_transient( 'update_plugins' );
|
||||||
foreach ( $plugin_updates as $slug => $plugin_update ) {
|
set_site_transient( 'update_plugins', $current );
|
||||||
if ( in_array( $slug, array( 'ithemes-security-pro/ithemes-security-pro.php', 'monarch/monarch.php', 'cornerstone/cornerstone.php', 'updraftplus/updraftplus.php', 'wp-all-import-pro/wp-all-import-pro.php') ) ) {
|
|
||||||
$fix_update_plugins[ $slug ] = $plugin_update;
|
$plugin_updates = get_plugin_updates();
|
||||||
}
|
set_site_transient( 'mainwp_update_plugins_cached', $plugin_updates, DAY_IN_SECONDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_site_transient( 'tofix_update_plugins', $fix_update_plugins);
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkOtherAuth() {
|
function checkOtherAuth() {
|
||||||
$auths = get_option( 'mainwp_child_auth' );
|
$auths = get_option( 'mainwp_child_auth' );
|
||||||
|
@ -734,7 +752,7 @@ class MainWP_Child {
|
||||||
|
|
||||||
<?php if ( !$hide_connection_detail ) { ?>
|
<?php if ( !$hide_connection_detail ) { ?>
|
||||||
<div class="mainwp-child-setting-tab connection-detail" <?php echo ('connection-detail' !== $shownPage) ? $hide_style : '' ; ?>>
|
<div class="mainwp-child-setting-tab connection-detail" <?php echo ('connection-detail' !== $shownPage) ? $hide_style : '' ; ?>>
|
||||||
<?php MainWP_Child_Server_Information::renderConnectionDetails(); ?>
|
<?php MainWP_Child_Server_Information::renderConnectionDetails(); ?>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
@ -873,12 +891,12 @@ class MainWP_Child {
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
function admin_init() {
|
function admin_init() {
|
||||||
if ( MainWP_Helper::isAdmin() && is_admin() ) {
|
if ( MainWP_Helper::isAdmin() && is_admin() ) {
|
||||||
MainWP_Clone::get()->init_ajax();
|
MainWP_Clone::get()->init_ajax();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function admin_head() {
|
function admin_head() {
|
||||||
if (isset($_GET['page']) && $_GET['page'] == 'mainwp_child_tab') {
|
if (isset($_GET['page']) && $_GET['page'] == 'mainwp_child_tab') {
|
||||||
?>
|
?>
|
||||||
|
@ -914,7 +932,7 @@ class MainWP_Child {
|
||||||
MainWP_Helper::update_option( 'mainwp_child_uniqueId', '' );
|
MainWP_Helper::update_option( 'mainwp_child_uniqueId', '' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="postbox">
|
<div class="postbox">
|
||||||
<h2 class="hndle"><span><?php esc_html_e( 'Connection settings', 'mainwp-child' ); ?></span></h2>
|
<h2 class="hndle"><span><?php esc_html_e( 'Connection settings', 'mainwp-child' ); ?></span></h2>
|
||||||
|
@ -1323,7 +1341,7 @@ class MainWP_Child {
|
||||||
|
|
||||||
remove_action( 'admin_init', 'send_frame_options_header' );
|
remove_action( 'admin_init', 'send_frame_options_header' );
|
||||||
remove_action( 'login_init', 'send_frame_options_header' );
|
remove_action( 'login_init', 'send_frame_options_header' );
|
||||||
|
|
||||||
// Call Heatmap
|
// Call Heatmap
|
||||||
if ( 'yes' === get_option( 'heatMapExtensionLoaded' ) ) {
|
if ( 'yes' === get_option( 'heatMapExtensionLoaded' ) ) {
|
||||||
if ( ( '1' !== get_option( 'heatMapsIndividualOverrideSetting' ) && '0' !== get_option( 'heatMapEnabled' ) ) ||
|
if ( ( '1' !== get_option( 'heatMapsIndividualOverrideSetting' ) && '0' !== get_option( 'heatMapEnabled' ) ) ||
|
||||||
|
@ -1385,7 +1403,7 @@ class MainWP_Child {
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init extensions
|
// Init extensions
|
||||||
// Handle fatal errors for those init if needed
|
// Handle fatal errors for those init if needed
|
||||||
// OK
|
// OK
|
||||||
|
@ -1393,28 +1411,28 @@ class MainWP_Child {
|
||||||
MainWP_Child_Updraft_Plus_Backups::Instance()->updraftplus_init();
|
MainWP_Child_Updraft_Plus_Backups::Instance()->updraftplus_init();
|
||||||
MainWP_Child_Back_Up_Wordpress::Instance()->init();
|
MainWP_Child_Back_Up_Wordpress::Instance()->init();
|
||||||
MainWP_Child_WP_Rocket::Instance()->init();
|
MainWP_Child_WP_Rocket::Instance()->init();
|
||||||
MainWP_Child_Back_WP_Up::Instance()->init();
|
MainWP_Child_Back_WP_Up::Instance()->init();
|
||||||
MainWP_Child_Back_Up_Buddy::Instance();
|
MainWP_Child_Back_Up_Buddy::Instance();
|
||||||
MainWP_Child_Wordfence::Instance()->wordfence_init();
|
MainWP_Child_Wordfence::Instance()->wordfence_init();
|
||||||
MainWP_Child_Timecapsule::Instance()->init();
|
MainWP_Child_Timecapsule::Instance()->init();
|
||||||
MainWP_Child_Staging::Instance()->init();
|
MainWP_Child_Staging::Instance()->init();
|
||||||
MainWP_Child_Branding::Instance()->branding_init();
|
MainWP_Child_Branding::Instance()->branding_init();
|
||||||
MainWP_Client_Report::Instance()->creport_init();
|
MainWP_Client_Report::Instance()->creport_init();
|
||||||
MainWP_Child_Pagespeed::Instance()->init();
|
MainWP_Child_Pagespeed::Instance()->init();
|
||||||
MainWP_Child_Links_Checker::Instance()->init();
|
MainWP_Child_Links_Checker::Instance()->init();
|
||||||
|
|
||||||
global $_wp_submenu_nopriv;
|
global $_wp_submenu_nopriv;
|
||||||
if ($_wp_submenu_nopriv === null)
|
if ($_wp_submenu_nopriv === null)
|
||||||
$_wp_submenu_nopriv = array(); // fix warning
|
$_wp_submenu_nopriv = array(); // fix warning
|
||||||
|
|
||||||
//Call the function required
|
//Call the function required
|
||||||
if ( $auth && isset( $_POST['function'] ) && isset( $this->callableFunctions[ $_POST['function'] ] ) ) {
|
if ( $auth && isset( $_POST['function'] ) && isset( $this->callableFunctions[ $_POST['function'] ] ) ) {
|
||||||
define( 'DOING_CRON', true );
|
define( 'DOING_CRON', true );
|
||||||
// ob_start();
|
// ob_start();
|
||||||
// require_once( ABSPATH . 'wp-admin/admin.php' );
|
// require_once( ABSPATH . 'wp-admin/admin.php' );
|
||||||
// ob_end_clean();
|
// ob_end_clean();
|
||||||
|
|
||||||
MainWP_Helper::handle_fatal_error();
|
MainWP_Helper::handle_fatal_error();
|
||||||
MainWP_Child::fix_for_custom_themes();
|
MainWP_Child::fix_for_custom_themes();
|
||||||
call_user_func( array( $this, $this->callableFunctions[ $_POST['function'] ] ) );
|
call_user_func( array( $this, $this->callableFunctions[ $_POST['function'] ] ) );
|
||||||
} else if ( isset( $_POST['function'] ) && isset( $this->callableFunctionsNoAuth[ $_POST['function'] ] ) ) {
|
} else if ( isset( $_POST['function'] ) && isset( $this->callableFunctionsNoAuth[ $_POST['function'] ] ) ) {
|
||||||
|
@ -1424,8 +1442,8 @@ class MainWP_Child {
|
||||||
} else if (isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) && !isset($this->callableFunctions[ $_POST['function'] ]) && !isset( $this->callableFunctionsNoAuth[ $_POST['function'] ]) ) {
|
} else if (isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) && !isset($this->callableFunctions[ $_POST['function'] ]) && !isset( $this->callableFunctionsNoAuth[ $_POST['function'] ]) ) {
|
||||||
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' ) );
|
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
|
// going to retire soon
|
||||||
if ( 1 === (int) get_option( 'mainwpKeywordLinks' ) ) {
|
if ( 1 === (int) get_option( 'mainwpKeywordLinks' ) ) {
|
||||||
new MainWP_Keyword_Links();
|
new MainWP_Keyword_Links();
|
||||||
if ( ! is_admin() ) {
|
if ( ! is_admin() ) {
|
||||||
|
@ -1457,7 +1475,7 @@ class MainWP_Child {
|
||||||
$nossl = get_option( 'mainwp_child_nossl' );
|
$nossl = get_option( 'mainwp_child_nossl' );
|
||||||
$serverNoSsl = ( isset( $pNossl ) && 1 === (int) $pNossl );
|
$serverNoSsl = ( isset( $pNossl ) && 1 === (int) $pNossl );
|
||||||
|
|
||||||
if ( ( 1 === (int) $nossl ) || $serverNoSsl ) {
|
if ( ( 1 === (int) $nossl ) || $serverNoSsl ) {
|
||||||
$auth = hash_equals( md5( $func . $nonce . get_option( 'mainwp_child_nossl_key' ) ), base64_decode( $signature ) );
|
$auth = hash_equals( md5( $func . $nonce . get_option( 'mainwp_child_nossl_key' ) ), base64_decode( $signature ) );
|
||||||
} else {
|
} else {
|
||||||
$auth = openssl_verify( $func . $nonce, base64_decode( $signature ), base64_decode( get_option( 'mainwp_child_pubkey' ) ) );
|
$auth = openssl_verify( $func . $nonce, base64_decode( $signature ), base64_decode( get_option( 'mainwp_child_pubkey' ) ) );
|
||||||
|
@ -1508,14 +1526,14 @@ class MainWP_Child {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function http_request_reject_unsafe_urls( $r, $url ) {
|
public function http_request_reject_unsafe_urls( $r, $url ) {
|
||||||
$r['reject_unsafe_urls'] = false;
|
$r['reject_unsafe_urls'] = false;
|
||||||
if ( isset($_POST['wpadmin_user']) && !empty($_POST['wpadmin_user']) && isset($_POST['wpadmin_passwd']) && !empty($_POST['wpadmin_passwd']) ) {
|
if ( isset($_POST['wpadmin_user']) && !empty($_POST['wpadmin_user']) && isset($_POST['wpadmin_passwd']) && !empty($_POST['wpadmin_passwd']) ) {
|
||||||
$auth = base64_encode( $_POST['wpadmin_user'] . ':' . $_POST['wpadmin_passwd'] );
|
$auth = base64_encode( $_POST['wpadmin_user'] . ':' . $_POST['wpadmin_passwd'] );
|
||||||
$r['headers']['Authorization'] = "Basic $auth";
|
$r['headers']['Authorization'] = "Basic $auth";
|
||||||
}
|
}
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Functions to support core functionality
|
* Functions to support core functionality
|
||||||
*/
|
*/
|
||||||
|
@ -1623,7 +1641,7 @@ class MainWP_Child {
|
||||||
// to fix activate issue
|
// to fix activate issue
|
||||||
if ('quotes-collection/quotes-collection.php' == $args['slug']) {
|
if ('quotes-collection/quotes-collection.php' == $args['slug']) {
|
||||||
activate_plugin( $path . $fileName, '', false, true );
|
activate_plugin( $path . $fileName, '', false, true );
|
||||||
} else {
|
} else {
|
||||||
activate_plugin( $path . $fileName, '' /* false, true */ );
|
activate_plugin( $path . $fileName, '' /* false, true */ );
|
||||||
}
|
}
|
||||||
do_action( 'activate_plugin', $args['slug'], null );
|
do_action( 'activate_plugin', $args['slug'], null );
|
||||||
|
@ -1766,6 +1784,11 @@ class MainWP_Child {
|
||||||
|
|
||||||
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
|
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
|
||||||
|
|
||||||
|
// to fix
|
||||||
|
@wp_version_check();
|
||||||
|
@wp_update_themes();
|
||||||
|
@wp_update_plugins();
|
||||||
|
|
||||||
$upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
|
$upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
|
||||||
$translations = explode( ',', urldecode( $_POST['list'] ) );
|
$translations = explode( ',', urldecode( $_POST['list'] ) );
|
||||||
$all_language_updates = wp_get_translation_updates();
|
$all_language_updates = wp_get_translation_updates();
|
||||||
|
@ -1818,6 +1841,8 @@ class MainWP_Child {
|
||||||
}
|
}
|
||||||
include_once( ABSPATH . '/wp-admin/includes/file.php' );
|
include_once( ABSPATH . '/wp-admin/includes/file.php' );
|
||||||
include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
||||||
|
include_once( ABSPATH . '/wp-admin/includes/plugin-install.php' );
|
||||||
|
|
||||||
$information = array();
|
$information = array();
|
||||||
$information['upgrades'] = array();
|
$information['upgrades'] = array();
|
||||||
$mwp_premium_updates_todo = array();
|
$mwp_premium_updates_todo = array();
|
||||||
|
@ -1857,11 +1882,10 @@ class MainWP_Child {
|
||||||
global $wp_current_filter;
|
global $wp_current_filter;
|
||||||
$wp_current_filter[] = 'load-plugins.php';
|
$wp_current_filter[] = 'load-plugins.php';
|
||||||
@wp_update_plugins();
|
@wp_update_plugins();
|
||||||
|
|
||||||
// trick to prevent some premium plugins re-create update info
|
// trick to prevent some premium plugins re-create update info
|
||||||
remove_all_filters('pre_set_site_transient_update_plugins');
|
remove_all_filters('pre_set_site_transient_update_plugins');
|
||||||
|
|
||||||
|
|
||||||
$information['plugin_updates'] = get_plugin_updates();
|
$information['plugin_updates'] = get_plugin_updates();
|
||||||
|
|
||||||
$plugins = explode( ',', urldecode( $_POST['list'] ) );
|
$plugins = explode( ',', urldecode( $_POST['list'] ) );
|
||||||
|
@ -1882,13 +1906,30 @@ class MainWP_Child {
|
||||||
if ( count( $plugins ) > 0 ) {
|
if ( count( $plugins ) > 0 ) {
|
||||||
//@see wp-admin/update.php
|
//@see wp-admin/update.php
|
||||||
$failed = true;
|
$failed = true;
|
||||||
|
// to fix update of Yithemes premiums plugins that hooked to upgrader_pre_download
|
||||||
|
$url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins));
|
||||||
|
$nonce = 'bulk-update-plugins';
|
||||||
|
|
||||||
$upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
|
$upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
|
||||||
$result = $upgrader->bulk_upgrade( $plugins );
|
$result = $upgrader->bulk_upgrade( $plugins );
|
||||||
|
|
||||||
if ( ! empty( $result ) ) {
|
if ( ! empty( $result ) ) {
|
||||||
foreach ( $result as $plugin => $info ) {
|
foreach ( $result as $plugin => $info ) {
|
||||||
if ( empty( $info ) ) {
|
if ( empty( $info ) ) {
|
||||||
|
|
||||||
$information['upgrades'][ $plugin ] = false;
|
$information['upgrades'][ $plugin ] = false;
|
||||||
|
// try to fix if that is premiums update
|
||||||
|
$api = apply_filters( 'plugins_api', false, 'plugin_information', array( 'slug' => $plugin ) );
|
||||||
|
|
||||||
|
if ( !is_wp_error( $api ) && !empty($api)) {
|
||||||
|
if ( isset($api->download_link) ) {
|
||||||
|
$res = $upgrader->install($api->download_link);
|
||||||
|
if ( !is_wp_error( $res ) && !(is_null( $res )) ) {
|
||||||
|
$information['upgrades'][ $plugin ] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$information['upgrades'][ $plugin ] = true;
|
$information['upgrades'][ $plugin ] = true;
|
||||||
// to fix logging update
|
// to fix logging update
|
||||||
|
@ -1896,6 +1937,7 @@ class MainWP_Child {
|
||||||
$plugin_info = $information['plugin_updates'][$plugin];
|
$plugin_info = $information['plugin_updates'][$plugin];
|
||||||
$args = array();
|
$args = array();
|
||||||
$args['type'] = 'plugin';
|
$args['type'] = 'plugin';
|
||||||
|
$args['slug'] = $plugin;
|
||||||
$args['name'] = $plugin_info->Name;
|
$args['name'] = $plugin_info->Name;
|
||||||
$args['version'] = $plugin_info->update->new_version;
|
$args['version'] = $plugin_info->update->new_version;
|
||||||
$args['old_version'] = $plugin_info->Version;
|
$args['old_version'] = $plugin_info->Version;
|
||||||
|
@ -2230,12 +2272,12 @@ class MainWP_Child {
|
||||||
if ( isset( $_POST['_ezin_post_category'] ) ) {
|
if ( isset( $_POST['_ezin_post_category'] ) ) {
|
||||||
$new_post['_ezin_post_category'] = maybe_unserialize( base64_decode( $_POST['_ezin_post_category'] ) );
|
$new_post['_ezin_post_category'] = maybe_unserialize( base64_decode( $_POST['_ezin_post_category'] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$others = array();
|
$others = array();
|
||||||
if ( isset( $_POST['featured_image_data'] ) && !empty($_POST['featured_image_data'])) {
|
if ( isset( $_POST['featured_image_data'] ) && !empty($_POST['featured_image_data'])) {
|
||||||
$others['featured_image_data'] = unserialize(base64_decode( $_POST['featured_image_data'] ));
|
$others['featured_image_data'] = unserialize(base64_decode( $_POST['featured_image_data'] ));
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = MainWP_Helper::createPost( $new_post, $post_custom, $post_category, $post_featured_image, $upload_dir, $post_tags, $others );
|
$res = MainWP_Helper::createPost( $new_post, $post_custom, $post_category, $post_featured_image, $upload_dir, $post_tags, $others );
|
||||||
|
|
||||||
if (is_array($res) && isset($res['error'])) {
|
if (is_array($res) && isset($res['error'])) {
|
||||||
|
@ -2472,10 +2514,10 @@ class MainWP_Child {
|
||||||
$extra = $_POST['extra'];
|
$extra = $_POST['extra'];
|
||||||
$userId = $_POST['id'];
|
$userId = $_POST['id'];
|
||||||
$user_pass = $_POST['user_pass'];
|
$user_pass = $_POST['user_pass'];
|
||||||
$failed = false;
|
$failed = false;
|
||||||
|
|
||||||
global $current_user;
|
global $current_user;
|
||||||
$reassign = ( isset( $current_user ) && isset( $current_user->ID ) ) ? $current_user->ID : 0;
|
$reassign = ( isset( $current_user ) && isset( $current_user->ID ) ) ? $current_user->ID : 0;
|
||||||
include_once( ABSPATH . '/wp-admin/includes/user.php' );
|
include_once( ABSPATH . '/wp-admin/includes/user.php' );
|
||||||
|
|
||||||
if ( 'delete' === $action ) {
|
if ( 'delete' === $action ) {
|
||||||
|
@ -2497,25 +2539,25 @@ class MainWP_Child {
|
||||||
} else {
|
} else {
|
||||||
$failed = true;
|
$failed = true;
|
||||||
}
|
}
|
||||||
} else if ( 'update_user' === $action ) {
|
} else if ( 'update_user' === $action ) {
|
||||||
$my_user = $_POST['extra'];
|
$my_user = $_POST['extra'];
|
||||||
if (is_array($my_user)) {
|
if (is_array($my_user)) {
|
||||||
foreach($my_user as $idx => $val) {
|
foreach($my_user as $idx => $val) {
|
||||||
if ($val === 'donotupdate' || (empty($val) && $idx !== 'role')) {
|
if ($val === 'donotupdate' || (empty($val) && $idx !== 'role')) {
|
||||||
unset($my_user[$idx]);
|
unset($my_user[$idx]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result = $this->edit_user( $userId, $my_user );
|
$result = $this->edit_user( $userId, $my_user );
|
||||||
if (is_array($result) && isset($result['error'])) {
|
if (is_array($result) && isset($result['error'])) {
|
||||||
$information['error'] = $result['error'];
|
$information['error'] = $result['error'];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$failed = true;
|
$failed = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$failed = true;
|
$failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($failed)
|
if ($failed)
|
||||||
$information['status'] = 'FAIL';
|
$information['status'] = 'FAIL';
|
||||||
|
|
||||||
|
@ -2524,7 +2566,7 @@ class MainWP_Child {
|
||||||
if ('update_user' === $action && isset($_POST['optimize']) && !empty($_POST['optimize'])) {
|
if ('update_user' === $action && isset($_POST['optimize']) && !empty($_POST['optimize'])) {
|
||||||
$information['users'] = $this->get_all_users_int(500); // to fix
|
$information['users'] = $this->get_all_users_int(500); // to fix
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
MainWP_Helper::write( $information );
|
MainWP_Helper::write( $information );
|
||||||
}
|
}
|
||||||
|
@ -2532,12 +2574,12 @@ class MainWP_Child {
|
||||||
function edit_user( $user_id, $data) {
|
function edit_user( $user_id, $data) {
|
||||||
$wp_roles = wp_roles();
|
$wp_roles = wp_roles();
|
||||||
$user = new stdClass;
|
$user = new stdClass;
|
||||||
|
|
||||||
$update = true;
|
$update = true;
|
||||||
|
|
||||||
if ( $user_id ) {
|
if ( $user_id ) {
|
||||||
$user->ID = (int) $user_id;
|
$user->ID = (int) $user_id;
|
||||||
$userdata = get_userdata( $user_id );
|
$userdata = get_userdata( $user_id );
|
||||||
$user->user_login = wp_slash( $userdata->user_login );
|
$user->user_login = wp_slash( $userdata->user_login );
|
||||||
} else {
|
} else {
|
||||||
return array('error' => 'ERROR: Empty user id.');
|
return array('error' => 'ERROR: Empty user id.');
|
||||||
|
@ -2560,8 +2602,8 @@ class MainWP_Child {
|
||||||
// If the new role isn't editable by the logged-in user die with error
|
// If the new role isn't editable by the logged-in user die with error
|
||||||
$editable_roles = get_editable_roles();
|
$editable_roles = get_editable_roles();
|
||||||
if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) )
|
if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) )
|
||||||
return array('error' => 'You can’t give users that role.');
|
return array('error' => 'You can’t give users that role.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$email = '';
|
$email = '';
|
||||||
if ( isset( $data['email'] ) )
|
if ( isset( $data['email'] ) )
|
||||||
|
@ -2570,8 +2612,8 @@ class MainWP_Child {
|
||||||
if ( !empty( $email ) )
|
if ( !empty( $email ) )
|
||||||
$user->user_email = sanitize_text_field( wp_unslash( $email ) );
|
$user->user_email = sanitize_text_field( wp_unslash( $email ) );
|
||||||
else
|
else
|
||||||
$user->user_email = $userdata->user_email;
|
$user->user_email = $userdata->user_email;
|
||||||
|
|
||||||
if ( isset( $data['url'] ) ) {
|
if ( isset( $data['url'] ) ) {
|
||||||
if ( empty ( $data['url'] ) || $data['url'] == 'http://' ) {
|
if ( empty ( $data['url'] ) || $data['url'] == 'http://' ) {
|
||||||
$user->user_url = '';
|
$user->user_url = '';
|
||||||
|
@ -2581,18 +2623,18 @@ class MainWP_Child {
|
||||||
$user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url;
|
$user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $data['first_name'] ) )
|
if ( isset( $data['first_name'] ) )
|
||||||
$user->first_name = sanitize_text_field( $data['first_name'] );
|
$user->first_name = sanitize_text_field( $data['first_name'] );
|
||||||
if ( isset( $data['last_name'] ) )
|
if ( isset( $data['last_name'] ) )
|
||||||
$user->last_name = sanitize_text_field( $data['last_name'] );
|
$user->last_name = sanitize_text_field( $data['last_name'] );
|
||||||
if ( isset( $data['nickname'] ) && !empty($data['nickname']))
|
if ( isset( $data['nickname'] ) && !empty($data['nickname']))
|
||||||
$user->nickname = sanitize_text_field( $data['nickname'] );
|
$user->nickname = sanitize_text_field( $data['nickname'] );
|
||||||
if ( isset( $data['display_name'] ) )
|
if ( isset( $data['display_name'] ) )
|
||||||
$user->display_name = sanitize_text_field( $data['display_name'] );
|
$user->display_name = sanitize_text_field( $data['display_name'] );
|
||||||
if ( isset( $data['description'] ) )
|
if ( isset( $data['description'] ) )
|
||||||
$user->description = trim( $data['description'] );
|
$user->description = trim( $data['description'] );
|
||||||
|
|
||||||
$errors = new WP_Error();
|
$errors = new WP_Error();
|
||||||
|
|
||||||
/* checking that username has been typed */
|
/* checking that username has been typed */
|
||||||
|
@ -2600,7 +2642,7 @@ class MainWP_Child {
|
||||||
$errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ) );
|
$errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ) );
|
||||||
|
|
||||||
do_action_ref_array( 'check_passwords', array( $user->user_login, &$pass1, &$pass2 ) );
|
do_action_ref_array( 'check_passwords', array( $user->user_login, &$pass1, &$pass2 ) );
|
||||||
|
|
||||||
if (!empty($pass1) || !empty($pass2)) {
|
if (!empty($pass1) || !empty($pass2)) {
|
||||||
// Check for blank password when adding a user.
|
// Check for blank password when adding a user.
|
||||||
if ( ! $update && empty( $pass1 ) ) {
|
if ( ! $update && empty( $pass1 ) ) {
|
||||||
|
@ -2622,7 +2664,7 @@ class MainWP_Child {
|
||||||
} else {
|
} else {
|
||||||
$user->user_pass = $userdata->user_pass;
|
$user->user_pass = $userdata->user_pass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This filter is documented in wp-includes/user.php */
|
/** This filter is documented in wp-includes/user.php */
|
||||||
$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
|
$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
|
||||||
|
|
||||||
|
@ -2646,20 +2688,20 @@ class MainWP_Child {
|
||||||
foreach ( $errors->get_error_messages() as $message ) {
|
foreach ( $errors->get_error_messages() as $message ) {
|
||||||
if ( is_string( $message ) )
|
if ( is_string( $message ) )
|
||||||
$error_str .= ' ' . esc_html( strip_tags( $message ) );
|
$error_str .= ' ' . esc_html( strip_tags( $message ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
return array( 'error' => $error_str );
|
return array( 'error' => $error_str );
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_id = wp_update_user( $user );
|
$user_id = wp_update_user( $user );
|
||||||
|
|
||||||
return $user_id;
|
return $user_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_user_to_edit( $user_id ) {
|
function get_user_to_edit( $user_id ) {
|
||||||
require_once(ABSPATH . 'wp-admin/includes/user.php');
|
require_once(ABSPATH . 'wp-admin/includes/user.php');
|
||||||
$profileuser = get_user_to_edit($user_id);
|
$profileuser = get_user_to_edit($user_id);
|
||||||
|
|
||||||
$edit_data = array();
|
$edit_data = array();
|
||||||
if (is_object($profileuser)) {
|
if (is_object($profileuser)) {
|
||||||
$user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) );
|
$user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) );
|
||||||
|
@ -2668,7 +2710,7 @@ class MainWP_Child {
|
||||||
$edit_data['first_name'] = $profileuser->first_name;
|
$edit_data['first_name'] = $profileuser->first_name;
|
||||||
$edit_data['last_name'] = $profileuser->last_name;
|
$edit_data['last_name'] = $profileuser->last_name;
|
||||||
$edit_data['nickname'] = $profileuser->nickname;
|
$edit_data['nickname'] = $profileuser->nickname;
|
||||||
|
|
||||||
$public_display = array();
|
$public_display = array();
|
||||||
$public_display['display_nickname'] = $profileuser->nickname;
|
$public_display['display_nickname'] = $profileuser->nickname;
|
||||||
$public_display['display_username'] = $profileuser->user_login;
|
$public_display['display_username'] = $profileuser->user_login;
|
||||||
|
@ -2693,15 +2735,15 @@ class MainWP_Child {
|
||||||
$edit_data['public_display'] = $public_display;
|
$edit_data['public_display'] = $public_display;
|
||||||
$edit_data['display_name'] = $profileuser->display_name;
|
$edit_data['display_name'] = $profileuser->display_name;
|
||||||
$edit_data['user_email'] = $profileuser->user_email;
|
$edit_data['user_email'] = $profileuser->user_email;
|
||||||
$edit_data['user_url'] = $profileuser->user_url;
|
$edit_data['user_url'] = $profileuser->user_url;
|
||||||
foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) {
|
foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) {
|
||||||
$edit_data['contact_methods'][$name] = $profileuser->$name;
|
$edit_data['contact_methods'][$name] = $profileuser->$name;
|
||||||
}
|
}
|
||||||
$edit_data['description'] = $profileuser->description;
|
$edit_data['description'] = $profileuser->description;
|
||||||
}
|
}
|
||||||
return $edit_data;
|
return $edit_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo: backwards compatible: wp_set_comment_status ?
|
//todo: backwards compatible: wp_set_comment_status ?
|
||||||
function comment_action() {
|
function comment_action() {
|
||||||
//Read form data
|
//Read form data
|
||||||
|
@ -3221,12 +3263,15 @@ class MainWP_Child {
|
||||||
$security['scripts_version'] = true;
|
$security['scripts_version'] = true;
|
||||||
$security['styles_version'] = true;
|
$security['styles_version'] = true;
|
||||||
$security['generator_version'] = true;
|
$security['generator_version'] = true;
|
||||||
MainWP_Security::remove_scripts_version( true );
|
|
||||||
MainWP_Security::remove_styles_version( true );
|
|
||||||
MainWP_Security::remove_generator_version( true );
|
MainWP_Security::remove_generator_version( true );
|
||||||
$information['versions'] = 'Y';
|
$information['versions'] = 'Y';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( 'all' === $_POST['feature'] || 'registered_versions' === $_POST['feature'] ) {
|
||||||
|
$security['registered_versions'] = true;
|
||||||
|
$information['registered_versions'] = 'Y';
|
||||||
|
}
|
||||||
|
|
||||||
if ( 'all' === $_POST['feature'] || 'admin' === $_POST['feature'] ) {
|
if ( 'all' === $_POST['feature'] || 'admin' === $_POST['feature'] ) {
|
||||||
$information['admin'] = ( ! MainWP_Security::admin_user_ok() ? 'N' : 'Y' );
|
$information['admin'] = ( ! MainWP_Security::admin_user_ok() ? 'N' : 'Y' );
|
||||||
}
|
}
|
||||||
|
@ -3282,6 +3327,10 @@ class MainWP_Child {
|
||||||
$information['versions'] = 'N';
|
$information['versions'] = 'N';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( 'all' === $_POST['feature'] || 'registered_versions' === $_POST['feature'] ) {
|
||||||
|
$security['registered_versions'] = false;
|
||||||
|
$information['registered_versions'] = 'N';
|
||||||
|
}
|
||||||
if ( 'all' === $_POST['feature'] || 'readme' === $_POST['feature'] ) {
|
if ( 'all' === $_POST['feature'] || 'readme' === $_POST['feature'] ) {
|
||||||
$security['readme'] = false;
|
$security['readme'] = false;
|
||||||
$information['readme'] = MainWP_Security::remove_readme_ok();
|
$information['readme'] = MainWP_Security::remove_readme_ok();
|
||||||
|
@ -3311,6 +3360,7 @@ class MainWP_Child {
|
||||||
$information['php_reporting'] = ( ! MainWP_Security::remove_php_reporting_ok() ? 'N' : 'Y' );
|
$information['php_reporting'] = ( ! MainWP_Security::remove_php_reporting_ok() ? 'N' : 'Y' );
|
||||||
$information['versions'] = ( ! MainWP_Security::remove_scripts_version_ok() || ! MainWP_Security::remove_styles_version_ok() || ! MainWP_Security::remove_generator_version_ok()
|
$information['versions'] = ( ! MainWP_Security::remove_scripts_version_ok() || ! MainWP_Security::remove_styles_version_ok() || ! MainWP_Security::remove_generator_version_ok()
|
||||||
? 'N' : 'Y' );
|
? 'N' : 'Y' );
|
||||||
|
$information['registered_versions'] = ( MainWP_Security::remove_registered_versions_ok() ? 'Y' : 'N' );
|
||||||
$information['admin'] = ( MainWP_Security::admin_user_ok() ? 'Y' : 'N' );
|
$information['admin'] = ( MainWP_Security::admin_user_ok() ? 'Y' : 'N' );
|
||||||
$information['readme'] = ( MainWP_Security::remove_readme_ok() ? 'Y' : 'N' );
|
$information['readme'] = ( MainWP_Security::remove_readme_ok() ? 'Y' : 'N' );
|
||||||
|
|
||||||
|
@ -3507,6 +3557,7 @@ class MainWP_Child {
|
||||||
|
|
||||||
@wp_update_plugins();
|
@wp_update_plugins();
|
||||||
include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
||||||
|
|
||||||
$plugin_updates = get_plugin_updates();
|
$plugin_updates = get_plugin_updates();
|
||||||
if ( is_array( $plugin_updates ) ) {
|
if ( is_array( $plugin_updates ) ) {
|
||||||
$information['plugin_updates'] = array();
|
$information['plugin_updates'] = array();
|
||||||
|
@ -3518,19 +3569,22 @@ class MainWP_Child {
|
||||||
|
|
||||||
$information['plugin_updates'][ $slug ] = $plugin_update;
|
$information['plugin_updates'][ $slug ] = $plugin_update;
|
||||||
}
|
}
|
||||||
|
|
||||||
// to fix bug
|
|
||||||
$fix_update_plugins = get_site_transient( 'tofix_update_plugins' );
|
|
||||||
if ( is_array( $fix_update_plugins ) && ( count( $fix_update_plugins ) > 0 ) ) {
|
|
||||||
foreach( $fix_update_plugins as $slug => $plugin_update ) {
|
|
||||||
if ( !isset( $information['plugin_updates'][ $slug ] ) ) {
|
|
||||||
$information['plugin_updates'][ $slug ] = $plugin_update;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// end fix
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// to fix bug
|
||||||
|
$info_update_plugins_cached = get_site_transient( 'mainwp_update_plugins_cached' );
|
||||||
|
if ( is_array( $info_update_plugins_cached ) && ( count( $info_update_plugins_cached ) > 0 ) ) {
|
||||||
|
if (!isset($information['plugin_updates'])) {
|
||||||
|
$information['plugin_updates'] = array();
|
||||||
|
}
|
||||||
|
foreach( $info_update_plugins_cached as $slug => $plugin_update ) {
|
||||||
|
if ( !isset( $information['plugin_updates'][ $slug ] ) ) {
|
||||||
|
$information['plugin_updates'][ $slug ] = $plugin_update;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// end fix
|
||||||
|
|
||||||
if ( null !== $this->filterFunction ) {
|
if ( null !== $this->filterFunction ) {
|
||||||
remove_filter( 'pre_site_transient_update_plugins', $this->filterFunction, 99 );
|
remove_filter( 'pre_site_transient_update_plugins', $this->filterFunction, 99 );
|
||||||
}
|
}
|
||||||
|
@ -3619,6 +3673,9 @@ class MainWP_Child {
|
||||||
if ( ! MainWP_Security::remove_scripts_version_ok() || ! MainWP_Security::remove_styles_version_ok() || ! MainWP_Security::remove_generator_version_ok() ) {
|
if ( ! MainWP_Security::remove_scripts_version_ok() || ! MainWP_Security::remove_styles_version_ok() || ! MainWP_Security::remove_generator_version_ok() ) {
|
||||||
$securityIssuess ++;
|
$securityIssuess ++;
|
||||||
}
|
}
|
||||||
|
if ( ! MainWP_Security::remove_registered_versions_ok() ) {
|
||||||
|
$securityIssuess ++;
|
||||||
|
}
|
||||||
if ( ! MainWP_Security::admin_user_ok() ) {
|
if ( ! MainWP_Security::admin_user_ok() ) {
|
||||||
$securityIssuess ++;
|
$securityIssuess ++;
|
||||||
}
|
}
|
||||||
|
@ -3638,7 +3695,10 @@ class MainWP_Child {
|
||||||
$information['categories'] = $categories;
|
$information['categories'] = $categories;
|
||||||
$get_file_size = apply_filters('mainwp-child-get-total-size', true);
|
$get_file_size = apply_filters('mainwp-child-get-total-size', true);
|
||||||
if ($get_file_size) {
|
if ($get_file_size) {
|
||||||
$information['totalsize'] = $this->getTotalFileSize();
|
$max_exe = ini_get( 'max_execution_time' ); // to fix issue of some hosts have limit of execution time
|
||||||
|
if ($max_exe > 20) {
|
||||||
|
$information['totalsize'] = $this->getTotalFileSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$information['dbsize'] = MainWP_Child_DB::get_size();
|
$information['dbsize'] = MainWP_Child_DB::get_size();
|
||||||
|
|
||||||
|
@ -3670,21 +3730,21 @@ class MainWP_Child {
|
||||||
$information['uniqueId'] = get_option( 'mainwp_child_uniqueId', '' );
|
$information['uniqueId'] = get_option( 'mainwp_child_uniqueId', '' );
|
||||||
$information['plugins_outdate_info'] = MainWP_Child_Plugins_Check::Instance()->get_plugins_outdate_info();
|
$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();
|
$information['themes_outdate_info'] = MainWP_Child_Themes_Check::Instance()->get_themes_outdate_info();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
do_action('mainwp_child_site_stats');
|
do_action('mainwp_child_site_stats');
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $_POST['othersData'] ) ) {
|
if ( isset( $_POST['othersData'] ) ) {
|
||||||
$othersData = json_decode( stripslashes( $_POST['othersData'] ), true );
|
$othersData = json_decode( stripslashes( $_POST['othersData'] ), true );
|
||||||
if ( ! is_array( $othersData ) ) {
|
if ( ! is_array( $othersData ) ) {
|
||||||
$othersData = array();
|
$othersData = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$information = apply_filters( 'mainwp-site-sync-others-data', $information, $othersData );
|
$information = apply_filters( 'mainwp-site-sync-others-data', $information, $othersData );
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
// do not exit
|
// do not exit
|
||||||
}
|
}
|
||||||
|
@ -3719,7 +3779,7 @@ class MainWP_Child {
|
||||||
$favi = $favi_url = get_site_icon_url();
|
$favi = $favi_url = get_site_icon_url();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( $favi ) ) {
|
if ( empty( $favi ) ) {
|
||||||
if ( file_exists( ABSPATH . 'favicon.ico' ) ) {
|
if ( file_exists( ABSPATH . 'favicon.ico' ) ) {
|
||||||
$favi = 'favicon.ico';
|
$favi = 'favicon.ico';
|
||||||
} else if ( file_exists( ABSPATH . 'favicon.png' ) ) {
|
} else if ( file_exists( ABSPATH . 'favicon.png' ) ) {
|
||||||
|
@ -3889,7 +3949,7 @@ class MainWP_Child {
|
||||||
$link_count = new WPSEO_Link_Column_Count();
|
$link_count = new WPSEO_Link_Column_Count();
|
||||||
$link_count->set( $post_ids );
|
$link_count->set( $post_ids );
|
||||||
}
|
}
|
||||||
foreach ( $posts as $post ) {
|
foreach ( $posts as $post ) {
|
||||||
$outPost = array();
|
$outPost = array();
|
||||||
$outPost['id'] = $post->ID;
|
$outPost['id'] = $post->ID;
|
||||||
$outPost['post_type'] = $post->post_type;
|
$outPost['post_type'] = $post->post_type;
|
||||||
|
@ -3903,11 +3963,11 @@ class MainWP_Child {
|
||||||
} else {
|
} else {
|
||||||
$outPost['dts'] = strtotime( $post->post_modified_gmt );
|
$outPost['dts'] = strtotime( $post->post_modified_gmt );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($post->post_status == 'future') {
|
if ($post->post_status == 'future') {
|
||||||
$outPost['dts'] = strtotime( $post->post_date_gmt );
|
$outPost['dts'] = strtotime( $post->post_date_gmt );
|
||||||
}
|
}
|
||||||
|
|
||||||
$usr = get_user_by( 'id', $post->post_author );
|
$usr = get_user_by( 'id', $post->post_author );
|
||||||
$outPost['author'] = ! empty( $usr ) ? $usr->user_nicename : 'removed';
|
$outPost['author'] = ! empty( $usr ) ? $usr->user_nicename : 'removed';
|
||||||
$categoryObjects = get_the_category( $post->ID );
|
$categoryObjects = get_the_category( $post->ID );
|
||||||
|
@ -4147,7 +4207,7 @@ class MainWP_Child {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
add_filter( 'posts_where', array( &$this, 'posts_where' ) );
|
add_filter( 'posts_where', array( &$this, 'posts_where' ) );
|
||||||
$where_post_date = isset($_POST['where_post_date']) && !empty($_POST['where_post_date']) ? true : false;
|
$where_post_date = isset($_POST['where_post_date']) && !empty($_POST['where_post_date']) ? true : false;
|
||||||
if ( isset( $_POST['postId'] ) ) {
|
if ( isset( $_POST['postId'] ) ) {
|
||||||
$this->posts_where_suffix .= " AND $wpdb->posts.ID = " . $_POST['postId'];
|
$this->posts_where_suffix .= " AND $wpdb->posts.ID = " . $_POST['postId'];
|
||||||
} else if ( isset( $_POST['userId'] ) ) {
|
} else if ( isset( $_POST['userId'] ) ) {
|
||||||
|
@ -4325,7 +4385,7 @@ class MainWP_Child {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( $themes as $idx => $themeToDelete ) {
|
foreach ( $themes as $idx => $themeToDelete ) {
|
||||||
if ( $themeToDelete !== $theme_name ) {
|
if ( $themeToDelete !== $theme_name ) {
|
||||||
$theTheme = wp_get_theme( $themeToDelete );
|
$theTheme = wp_get_theme( $themeToDelete );
|
||||||
|
@ -4405,7 +4465,7 @@ class MainWP_Child {
|
||||||
if ('quotes-collection/quotes-collection.php' == $plugin) {
|
if ('quotes-collection/quotes-collection.php' == $plugin) {
|
||||||
activate_plugin( $plugin, '', false, true );
|
activate_plugin( $plugin, '', false, true );
|
||||||
do_action( 'activate_plugin', $plugin, null );
|
do_action( 'activate_plugin', $plugin, null );
|
||||||
} else {
|
} else {
|
||||||
activate_plugin( $plugin );
|
activate_plugin( $plugin );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4444,7 +4504,7 @@ class MainWP_Child {
|
||||||
$all_plugins = get_plugins();
|
$all_plugins = get_plugins();
|
||||||
foreach ( $plugins as $idx => $plugin ) {
|
foreach ( $plugins as $idx => $plugin ) {
|
||||||
if ( $plugin !== $this->plugin_slug ) {
|
if ( $plugin !== $this->plugin_slug ) {
|
||||||
if ( isset( $all_plugins[ $plugin ] ) ) {
|
if ( isset( $all_plugins[ $plugin ] ) ) {
|
||||||
if (is_plugin_active($plugin)) {
|
if (is_plugin_active($plugin)) {
|
||||||
$thePlugin = get_plugin_data( $plugin );
|
$thePlugin = get_plugin_data( $plugin );
|
||||||
if ( null !== $thePlugin && '' !== $thePlugin ) {
|
if ( null !== $thePlugin && '' !== $thePlugin ) {
|
||||||
|
@ -4564,11 +4624,11 @@ class MainWP_Child {
|
||||||
|
|
||||||
function get_all_users_int($number = false) {
|
function get_all_users_int($number = false) {
|
||||||
$allusers = array();
|
$allusers = array();
|
||||||
|
|
||||||
$params = array();
|
$params = array();
|
||||||
if ($number)
|
if ($number)
|
||||||
$params['number'] = $number;
|
$params['number'] = $number;
|
||||||
|
|
||||||
$new_users = get_users($params);
|
$new_users = get_users($params);
|
||||||
if ( is_array( $new_users ) ) {
|
if ( is_array( $new_users ) ) {
|
||||||
foreach ( $new_users as $new_user ) {
|
foreach ( $new_users as $new_user ) {
|
||||||
|
@ -4592,24 +4652,24 @@ class MainWP_Child {
|
||||||
return $allusers;
|
return $allusers;
|
||||||
}
|
}
|
||||||
|
|
||||||
function search_users() {
|
function search_users() {
|
||||||
|
|
||||||
$search_user_role = array();
|
$search_user_role = array();
|
||||||
$check_users_role = false;
|
$check_users_role = false;
|
||||||
|
|
||||||
if (isset($_POST['role']) && !empty($_POST['role'])) {
|
if (isset($_POST['role']) && !empty($_POST['role'])) {
|
||||||
$check_users_role = true;
|
$check_users_role = true;
|
||||||
$all_users_role = $this->get_all_users(true);
|
$all_users_role = $this->get_all_users(true);
|
||||||
foreach($all_users_role as $user) {
|
foreach($all_users_role as $user) {
|
||||||
$search_user_role[] = $user['id'];
|
$search_user_role[] = $user['id'];
|
||||||
}
|
}
|
||||||
unset($all_users_role);
|
unset($all_users_role);
|
||||||
}
|
}
|
||||||
|
|
||||||
$columns = explode( ',', $_POST['search_columns'] );
|
$columns = explode( ',', $_POST['search_columns'] );
|
||||||
$allusers = array();
|
$allusers = array();
|
||||||
$exclude = array();
|
$exclude = array();
|
||||||
|
|
||||||
foreach ( $columns as $col ) {
|
foreach ( $columns as $col ) {
|
||||||
if ( empty( $col ) ) {
|
if ( empty( $col ) ) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -4621,7 +4681,7 @@ class MainWP_Child {
|
||||||
'search_columns' => array( $col ),
|
'search_columns' => array( $col ),
|
||||||
'query_orderby' => array( $col ),
|
'query_orderby' => array( $col ),
|
||||||
'exclude' => $exclude,
|
'exclude' => $exclude,
|
||||||
) );
|
) );
|
||||||
if ( ! empty( $user_query->results ) ) {
|
if ( ! empty( $user_query->results ) ) {
|
||||||
foreach ( $user_query->results as $new_user ) {
|
foreach ( $user_query->results as $new_user ) {
|
||||||
if ($check_users_role) {
|
if ($check_users_role) {
|
||||||
|
@ -4648,7 +4708,7 @@ class MainWP_Child {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWP_Helper::write( $allusers );
|
MainWP_Helper::write( $allusers );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4679,6 +4739,10 @@ class MainWP_Child {
|
||||||
}
|
}
|
||||||
|
|
||||||
function activation() {
|
function activation() {
|
||||||
|
$mu_plugin_enabled = apply_filters('mainwp_child_mu_plugin_enabled', false);
|
||||||
|
if ($mu_plugin_enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
$to_delete = array(
|
$to_delete = array(
|
||||||
'mainwp_child_pubkey',
|
'mainwp_child_pubkey',
|
||||||
'mainwp_child_nonce',
|
'mainwp_child_nonce',
|
||||||
|
@ -4701,6 +4765,11 @@ class MainWP_Child {
|
||||||
}
|
}
|
||||||
|
|
||||||
function deactivation( $deact = true) {
|
function deactivation( $deact = true) {
|
||||||
|
|
||||||
|
$mu_plugin_enabled = apply_filters('mainwp_child_mu_plugin_enabled', false);
|
||||||
|
if ($mu_plugin_enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
$to_delete = array(
|
$to_delete = array(
|
||||||
'mainwp_child_pubkey',
|
'mainwp_child_pubkey',
|
||||||
'mainwp_child_nonce',
|
'mainwp_child_nonce',
|
||||||
|
@ -4718,7 +4787,7 @@ class MainWP_Child {
|
||||||
wp_cache_delete( $delete, 'options' );
|
wp_cache_delete( $delete, 'options' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($deact)
|
if ($deact)
|
||||||
do_action( 'mainwp_child_deactivation' );
|
do_action( 'mainwp_child_deactivation' );
|
||||||
}
|
}
|
||||||
|
@ -4825,12 +4894,12 @@ class MainWP_Child {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// to fix for window host, performance not good?
|
// to fix for window host, performance not good?
|
||||||
if ( class_exists( 'RecursiveIteratorIterator' ) ) {
|
if ( class_exists( 'RecursiveIteratorIterator' ) ) {
|
||||||
$size = 0;
|
$size = 0;
|
||||||
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file){
|
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file){
|
||||||
$size+=$file->getSize();
|
$size+=$file->getSize();
|
||||||
}
|
}
|
||||||
if ( $size && MainWP_Helper::ctype_digit( $size ) ) {
|
if ( $size && MainWP_Helper::ctype_digit( $size ) ) {
|
||||||
return $size / 1024 / 1024;
|
return $size / 1024 / 1024;
|
||||||
}
|
}
|
||||||
|
@ -5428,20 +5497,27 @@ class MainWP_Child {
|
||||||
function vulner_checker() {
|
function vulner_checker() {
|
||||||
MainWP_Child_Vulnerability_Checker::Instance()->action();
|
MainWP_Child_Vulnerability_Checker::Instance()->action();
|
||||||
}
|
}
|
||||||
|
|
||||||
function time_capsule() {
|
function time_capsule() {
|
||||||
MainWP_Child_Timecapsule::Instance()->action();
|
MainWP_Child_Timecapsule::Instance()->action();
|
||||||
}
|
}
|
||||||
|
|
||||||
function wp_staging() {
|
function wp_staging() {
|
||||||
MainWP_Child_Staging::Instance()->action();
|
MainWP_Child_Staging::Instance()->action();
|
||||||
}
|
}
|
||||||
|
|
||||||
function disconnect() {
|
function extra_execution() {
|
||||||
$this->deactivation(false);
|
$post = $_POST;
|
||||||
MainWP_Helper::write( array( 'result' => 'success' ) );
|
$information = array();
|
||||||
|
$information = apply_filters('mainwp_child_extra_execution', $information, $post);
|
||||||
|
MainWP_Helper::write( $information );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function disconnect() {
|
||||||
|
$this->deactivation(false);
|
||||||
|
MainWP_Helper::write( array( 'result' => 'success' ) );
|
||||||
|
}
|
||||||
|
|
||||||
static function fix_for_custom_themes() {
|
static function fix_for_custom_themes() {
|
||||||
if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) {
|
if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) {
|
||||||
include_once( ABSPATH . '/wp-admin/includes/screen.php' );
|
include_once( ABSPATH . '/wp-admin/includes/screen.php' );
|
||||||
|
|
|
@ -12,27 +12,27 @@ class MainWP_Client_Report {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function init() {
|
public function init() {
|
||||||
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
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( '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_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' ) );
|
add_action( 'mainwp_child_log', array( 'MainWP_Client_Report', 'do_reports_log' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok
|
// ok
|
||||||
public function syncOthersData( $information, $data = array() ) {
|
public function syncOthersData( $information, $data = array() ) {
|
||||||
if ( isset( $data['syncClientReportData'] ) && $data['syncClientReportData'] ) {
|
if ( isset( $data['syncClientReportData'] ) && $data['syncClientReportData'] ) {
|
||||||
$creport_sync_data = array();
|
$creport_sync_data = array();
|
||||||
if ( ( $firsttime = get_option( 'mainwp_creport_first_time_activated' ) ) !== false ) {
|
if ( ( $firsttime = get_option( 'mainwp_creport_first_time_activated' ) ) !== false ) {
|
||||||
$creport_sync_data['firsttime_activated'] = $firsttime;
|
$creport_sync_data['firsttime_activated'] = $firsttime;
|
||||||
}
|
}
|
||||||
if ( !empty( $creport_sync_data ) ) {
|
if ( !empty( $creport_sync_data ) ) {
|
||||||
$information['syncClientReportData'] = $creport_sync_data;
|
$information['syncClientReportData'] = $creport_sync_data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $information;
|
return $information;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function init_stream_connectors( $classes ) {
|
public static function init_stream_connectors( $classes ) {
|
||||||
$connectors = array(
|
$connectors = array(
|
||||||
'Backups',
|
'Backups',
|
||||||
|
@ -87,6 +87,9 @@ class MainWP_Client_Report {
|
||||||
case 'wordfence':
|
case 'wordfence':
|
||||||
MainWP_Child_Wordfence::Instance()->do_reports_log( $ext );
|
MainWP_Child_Wordfence::Instance()->do_reports_log( $ext );
|
||||||
break;
|
break;
|
||||||
|
case 'wptimecapsule':
|
||||||
|
MainWP_Child_Timecapsule::Instance()->do_reports_log( $ext );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +380,7 @@ class MainWP_Client_Report {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if ( 'mainwp_backups' === $context ) {
|
} else if ( 'mainwp_backups' === $context ) {
|
||||||
if ( $record->context !== 'mainwp_backups' && $record->context !== 'backwpup_backups' && $record->context !== 'updraftplus_backups' && $record->context !== 'backupwordpress_backups' && $record->context !== 'backupbuddy_backups' ) {
|
if ( $record->context !== 'mainwp_backups' && $record->context !== 'backwpup_backups' && $record->context !== 'updraftplus_backups' && $record->context !== 'backupwordpress_backups' && $record->context !== 'backupbuddy_backups' && $record->context !== 'wptimecapsule_backups') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if ( 'mainwp_sucuri' === $context ) {
|
} else if ( 'mainwp_sucuri' === $context ) {
|
||||||
|
@ -669,28 +672,28 @@ class MainWP_Client_Report {
|
||||||
case 'status': // sucuri cases
|
case 'status': // sucuri cases
|
||||||
case 'webtrust':
|
case 'webtrust':
|
||||||
if ( 'mainwp_sucuri' === $context ) {
|
if ( 'mainwp_sucuri' === $context ) {
|
||||||
|
|
||||||
$scan_data = $this->get_stream_meta_data( $record, 'scan_data' );
|
$scan_data = $this->get_stream_meta_data( $record, 'scan_data' );
|
||||||
if (!empty($scan_data)) {
|
if (!empty($scan_data)) {
|
||||||
$scan_data = maybe_unserialize( base64_decode( $scan_data ) );
|
$scan_data = maybe_unserialize( base64_decode( $scan_data ) );
|
||||||
if ( is_array( $scan_data ) ) {
|
if ( is_array( $scan_data ) ) {
|
||||||
|
|
||||||
$blacklisted = $scan_data['blacklisted'];
|
$blacklisted = $scan_data['blacklisted'];
|
||||||
$malware_exists = $scan_data['malware_exists'];
|
$malware_exists = $scan_data['malware_exists'];
|
||||||
|
|
||||||
$status = array();
|
$status = array();
|
||||||
if ( $blacklisted ) {
|
if ( $blacklisted ) {
|
||||||
$status[] = __( 'Site Blacklisted', 'mainwp-child' ); }
|
$status[] = __( 'Site Blacklisted', 'mainwp-child' ); }
|
||||||
if ( $malware_exists ) {
|
if ( $malware_exists ) {
|
||||||
$status[] = __( 'Site With Warnings', 'mainwp-child' ); }
|
$status[] = __( 'Site With Warnings', 'mainwp-child' ); }
|
||||||
|
|
||||||
if ($data == 'status') {
|
if ($data == 'status') {
|
||||||
$token_values[$token] = count( $status ) > 0 ? implode( ', ', $status ) : __( 'Verified Clear', 'mainwp-child' );
|
$token_values[$token] = count( $status ) > 0 ? implode( ', ', $status ) : __( 'Verified Clear', 'mainwp-child' );
|
||||||
} else if ($data == 'webtrust') {
|
} else if ($data == 'webtrust') {
|
||||||
$token_values[$token] = $blacklisted ? __( 'Site Blacklisted', 'mainwp-child' ) : __( 'Trusted', 'mainwp-child' );
|
$token_values[$token] = $blacklisted ? __( 'Site Blacklisted', 'mainwp-child' ) : __( 'Trusted', 'mainwp-child' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$token_values[ $token ] = $this->get_stream_meta_data( $record, $data );
|
$token_values[ $token ] = $this->get_stream_meta_data( $record, $data );
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,7 +343,8 @@ class MainWP_Keyword_Links {
|
||||||
$this->link_exact_match = $link->exact_match;
|
$this->link_exact_match = $link->exact_match;
|
||||||
$this->link_case_sensitive = $link->case_sensitive;
|
$this->link_case_sensitive = $link->case_sensitive;
|
||||||
$keywords = $this->explode_multi( $link->keyword );
|
$keywords = $this->explode_multi( $link->keyword );
|
||||||
usort( $keywords, create_function( '$a,$b', 'return strlen($a)<strlen($b);' ) );
|
//usort( $keywords, create_function( '$a,$b', 'return strlen($a)<strlen($b);' ) );
|
||||||
|
usort( $keywords, array($this, 'usort_callback_func') );
|
||||||
$replace_cs = $link->case_sensitive ? 's' : 'is';
|
$replace_cs = $link->case_sensitive ? 's' : 'is';
|
||||||
//print_r($keywords);
|
//print_r($keywords);
|
||||||
foreach ( $keywords as $keyword ) {
|
foreach ( $keywords as $keyword ) {
|
||||||
|
@ -386,6 +387,10 @@ class MainWP_Keyword_Links {
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function usort_callback_func($a, $b) {
|
||||||
|
return strlen($a)<strlen($b);
|
||||||
|
}
|
||||||
|
|
||||||
public function keyword_mark( $matches ) {
|
public function keyword_mark( $matches ) {
|
||||||
|
|
||||||
if ( preg_match( '/^[<{].*?[>}]$/is', $matches[1] ) ) {
|
if ( preg_match( '/^[<{].*?[>}]$/is', $matches[1] ) ) {
|
||||||
|
|
|
@ -9,8 +9,7 @@ class MainWP_Security {
|
||||||
// MainWP_Security::remove_plugin_update();
|
// MainWP_Security::remove_plugin_update();
|
||||||
// MainWP_Security::remove_theme_update();
|
// MainWP_Security::remove_theme_update();
|
||||||
MainWP_Security::remove_php_reporting();
|
MainWP_Security::remove_php_reporting();
|
||||||
MainWP_Security::remove_scripts_version();
|
MainWP_Security::remove_registered_versions();
|
||||||
MainWP_Security::remove_styles_version();
|
|
||||||
MainWP_Security::remove_generator_version();
|
MainWP_Security::remove_generator_version();
|
||||||
MainWP_Security::remove_readme();
|
MainWP_Security::remove_readme();
|
||||||
|
|
||||||
|
@ -256,20 +255,6 @@ class MainWP_Security {
|
||||||
//Removed version information for scripts/stylesheets
|
//Removed version information for scripts/stylesheets
|
||||||
public static function remove_scripts_version_ok() {
|
public static function remove_scripts_version_ok() {
|
||||||
return self::get_security_option( 'scripts_version' );
|
return self::get_security_option( 'scripts_version' );
|
||||||
|
|
||||||
// global $wp_scripts;
|
|
||||||
// if (!is_a($wp_scripts, 'WP_Scripts'))
|
|
||||||
// {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// foreach ($wp_scripts->registered as $handle => $script)
|
|
||||||
// {
|
|
||||||
// if ($wp_scripts->registered[$handle]->ver != null)
|
|
||||||
// {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function remove_script_versions( $src ) {
|
public static function remove_script_versions( $src ) {
|
||||||
|
@ -280,13 +265,29 @@ class MainWP_Security {
|
||||||
|
|
||||||
return $src;
|
return $src;
|
||||||
}
|
}
|
||||||
// else if ( false === strpos( $src, '?ver=' ) ) {
|
|
||||||
// self::update_security_option('scripts_version', true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return $src;
|
return $src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function remove_registered_versions_ok() {
|
||||||
|
return self::get_security_option( 'registered_versions' );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function remove_registered_versions() {
|
||||||
|
if ( self::get_security_option( 'registered_versions' ) ) {
|
||||||
|
global $wp_styles;
|
||||||
|
if ( $wp_styles instanceof WP_Styles ) {
|
||||||
|
foreach ( $wp_styles->registered as $handle => $style ) {
|
||||||
|
$wp_styles->registered[ $handle ]->ver = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
global $wp_scripts;
|
||||||
|
if ( $wp_scripts instanceof WP_Scripts ) {
|
||||||
|
foreach ( $wp_scripts->registered as $handle => $script ) {
|
||||||
|
$wp_scripts->registered[ $handle ]->ver = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function remove_generator_version_ok() {
|
public static function remove_generator_version_ok() {
|
||||||
return self::get_security_option( 'generator_version' );
|
return self::get_security_option( 'generator_version' );
|
||||||
|
@ -313,27 +314,10 @@ class MainWP_Security {
|
||||||
|
|
||||||
return $src;
|
return $src;
|
||||||
}
|
}
|
||||||
// else if ( false === strpos( $src, '?ver=' ) ) {
|
|
||||||
// self::update_security_option('styles_version', true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return $src;
|
return $src;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function remove_scripts_version( $force = false ) {
|
public static function remove_readme( $force = false ) {
|
||||||
if ( $force || self::get_security_option( 'scripts_version' ) ) {
|
|
||||||
global $wp_scripts;
|
|
||||||
if ( !( $wp_scripts instanceof WP_Scripts ) ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ( $wp_scripts->registered as $handle => $script ) {
|
|
||||||
$wp_scripts->registered[ $handle ]->ver = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function remove_readme( $force = false ) {
|
|
||||||
if ( $force || self::get_security_option( 'readme' ) ) {
|
if ( $force || self::get_security_option( 'readme' ) ) {
|
||||||
if ( @file_exists( ABSPATH . 'readme.html' ) ) {
|
if ( @file_exists( ABSPATH . 'readme.html' ) ) {
|
||||||
if ( ! @unlink( ABSPATH . 'readme.html' ) ) {
|
if ( ! @unlink( ABSPATH . 'readme.html' ) ) {
|
||||||
|
@ -357,34 +341,6 @@ class MainWP_Security {
|
||||||
|
|
||||||
public static function remove_styles_version_ok() {
|
public static function remove_styles_version_ok() {
|
||||||
return self::get_security_option( 'styles_version' );
|
return self::get_security_option( 'styles_version' );
|
||||||
|
|
||||||
// global $wp_styles;
|
|
||||||
// if (!is_a($wp_styles, 'WP_Styles'))
|
|
||||||
// {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// foreach ($wp_styles->registered as $handle => $style)
|
|
||||||
// {
|
|
||||||
// if ($wp_styles->registered[$handle]->ver != null)
|
|
||||||
// {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function remove_styles_version( $force = true ) {
|
|
||||||
if ( $force || self::get_security_option( 'styles_version' ) ) {
|
|
||||||
global $wp_styles;
|
|
||||||
if ( !( $wp_styles instanceof WP_Styles ) ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ( $wp_styles->registered as $handle => $style ) {
|
|
||||||
$wp_styles->registered[ $handle ]->ver = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Admin user name is not admin
|
//Admin user name is not admin
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
Author: MainWP
|
Author: MainWP
|
||||||
Author URI: https://mainwp.com
|
Author URI: https://mainwp.com
|
||||||
Text Domain: mainwp-child
|
Text Domain: mainwp-child
|
||||||
Version: 3.4.8
|
Version: 3.5
|
||||||
*/
|
*/
|
||||||
if ( ( isset( $_REQUEST['heatmap'] ) && '1' === $_REQUEST['heatmap'] ) || ( isset( $_REQUEST['mainwpsignature'] ) && ( ! empty( $_REQUEST['mainwpsignature'] ) ) ) ) {
|
if ( ( isset( $_REQUEST['heatmap'] ) && '1' === $_REQUEST['heatmap'] ) || ( isset( $_REQUEST['mainwpsignature'] ) && ( ! empty( $_REQUEST['mainwpsignature'] ) ) ) ) {
|
||||||
header( 'X-Frame-Options: ALLOWALL' );
|
header( 'X-Frame-Options: ALLOWALL' );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue