diff --git a/class/class-mainwp-child-back-up-wordpress.php b/class/class-mainwp-child-back-up-wordpress.php index 15c9bf5..ddffa30 100644 --- a/class/class-mainwp-child-back-up-wordpress.php +++ b/class/class-mainwp-child-back-up-wordpress.php @@ -63,6 +63,9 @@ class MainWP_Child_Back_Up_Wordpress { case 'run_schedule': $information = $this->run_schedule(); break; + case 'save_all_schedules': + $information = $this->save_all_schedules(); + break; case 'update_schedule': $information = $this->update_schedule(); break; @@ -157,17 +160,35 @@ class MainWP_Child_Back_Up_Wordpress { $schedule_id = $this->check_schedule(); $schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) ); + // Delete the running backup - if ( $schedule->get_running_backup_filename() && file_exists( trailingslashit( hmbkp_path() ) . $schedule->get_running_backup_filename() ) ) { - unlink( trailingslashit( hmbkp_path() ) . $schedule->get_running_backup_filename() ); + if (method_exists($schedule, 'get_running_backup_filename' )) { + if ( $schedule->get_running_backup_filename() && file_exists( trailingslashit( hmbkp_path() ) . $schedule->get_running_backup_filename() ) ) { + unlink( trailingslashit( hmbkp_path() ) . $schedule->get_running_backup_filename() ); + } + if ( $schedule->get_schedule_running_path() && file_exists( $schedule->get_schedule_running_path() ) ) { + unlink( $schedule->get_schedule_running_path() ); + } + } else { + $status = $schedule->get_status(); + // Delete the running backup + if ( $status->get_backup_filename() && file_exists( trailingslashit( HM\BackUpWordPress\Path::get_path() ) . $status->get_backup_filename() ) ) { + unlink( trailingslashit( HM\BackUpWordPress\Path::get_path() ) . $status->get_backup_filename() ); + } + if ( file_exists( $status->get_status_filepath() ) ) { + unlink( $status->get_status_filepath() ); + } + } - if ( $schedule->get_schedule_running_path() && file_exists( $schedule->get_schedule_running_path() ) ) { - unlink( $schedule->get_schedule_running_path() ); - } HM\BackUpWordPress\Path::get_instance()->cleanup(); - $information['scheduleStatus'] = $schedule->get_status(); + if ($status === null) { + $information['scheduleStatus'] = $schedule->get_status(); + } else { + $information['scheduleStatus'] = $status->get_status(); + } + $information['result'] = 'SUCCESS'; return $information; @@ -179,7 +200,13 @@ class MainWP_Child_Back_Up_Wordpress { HM\BackUpWordPress\Path::get_instance()->cleanup(); - $information['scheduleStatus'] = $schedule->get_status(); + if (method_exists($schedule, 'get_running_backup_filename' )) { + $information['scheduleStatus'] = $schedule->get_status(); + } else { + $status = $schedule->get_status(); + $information['scheduleStatus'] = $status->get_status(); + } + $information['result'] = 'SUCCESS'; return $information; @@ -187,19 +214,13 @@ class MainWP_Child_Back_Up_Wordpress { function run_schedule() { $schedule_id = $this->check_schedule(); - HM\BackUpWordPress\Path::get_instance()->cleanup(); - // Fixes an issue on servers which only allow a single session per client - session_write_close(); - - $task = new \HM\Backdrop\Task( 'hmbkp_run_schedule_async', $schedule_id ); - - $task->schedule(); - $schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) ); - - $information['scheduleStatus'] = $schedule->get_status(); - $information['file_size_text'] = $this->hmbkp_get_site_size_text( $schedule ); - $information['started_ago'] = human_time_diff( $schedule->get_schedule_running_start_time() ); - + if (function_exists('hmbkp_run_schedule_async')) { + hmbkp_run_schedule_async($schedule_id); + } else if (function_exists('\HM\BackUpWordPress\run_schedule_async')) { + $task = new \HM\Backdrop\Task( '\HM\BackUpWordPress\run_schedule_async', $schedule_id ); + $task->schedule(); + } else + return array( 'error' => __('Error run schedule', 'mainwp-child') ); return array( 'result' => 'SUCCESS' ); } @@ -224,15 +245,21 @@ class MainWP_Child_Back_Up_Wordpress { } $schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) ); - + $started_ago = method_exists($schedule, 'get_schedule_running_start_time') ? $schedule->get_schedule_running_start_time() : $schedule->get_schedule_start_time(); $out = array( 'b' => $this->get_backupslist_html( $schedule ), 'count' => count( $schedule->get_backups() ), 'file_size_text' => $this->hmbkp_get_site_size_text( $schedule ), - 'scheduleStatus' => $schedule->get_status(), - 'started_ago' => human_time_diff( $schedule->get_schedule_running_start_time() ), + 'started_ago' => human_time_diff( $started_ago ), ); + if (method_exists($schedule, 'get_running_backup_filename' )) { + $out['scheduleStatus'] = $schedule->get_status(); + } else { + $status = $schedule->get_status(); + $out['scheduleStatus'] = $status->get_status(); + } + $information['backups'][ $schedule_id ] = $out; } @@ -245,19 +272,31 @@ class MainWP_Child_Back_Up_Wordpress { $current_option = get_option( 'hmbkp_schedule_' . $sch_id ); if ( is_array( $current_option ) ) { unset( $current_option['excludes'] ); // not send this value + $started_ago = method_exists($schedule, 'get_schedule_running_start_time') ? $schedule->get_schedule_running_start_time() : $schedule->get_schedule_start_time(); $send_back_schedules[ $sch_id ] = array( 'options' => $current_option, 'b' => $this->get_backupslist_html( $schedule ), 'count' => count( $schedule->get_backups() ), 'file_size_text' => $this->hmbkp_get_site_size_text( $schedule ), 'scheduleStatus' => $schedule->get_status(), - 'started_ago' => human_time_diff( $schedule->get_schedule_running_start_time() ), + 'started_ago' => human_time_diff( $started_ago ), ); + if (method_exists($schedule, 'get_running_backup_filename' )) { + $send_back_schedules['scheduleStatus'] = $schedule->get_status(); + } else { + $status = $schedule->get_status(); + $send_back_schedules['scheduleStatus'] = $status->get_status(); + } } } } - $information['backups_path'] = str_replace( HM\BackUpWordPress\Backup::get_home_path(), '', hmbkp_path() ); + if (function_exists('HM\BackUpWordPress\Backup::get_home_path')) + $backups_path = str_replace( HM\BackUpWordPress\Backup::get_home_path(), '', hmbkp_path() ); + else + $backups_path = str_replace( HM\BackUpWordPress\Path::get_home_path(), '', HM\BackUpWordPress\Path::get_path() ); + + $information['backups_path'] = $backups_path; $information['send_back_schedules'] = $send_back_schedules; $information['result'] = 'SUCCESS'; @@ -273,19 +312,25 @@ class MainWP_Child_Back_Up_Wordpress { $schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) ); - $deleted = $schedule->delete_backup( sanitize_text_field( base64_decode( $_POST['hmbkp_backuparchive'] ) ) ); + $deleted = $schedule->delete_backup(base64_decode( urldecode($_POST['hmbkp_backuparchive'] ))); if ( is_wp_error( $deleted ) ) { return array( 'error' => $deleted->get_error_message() ); } - return array( + $ret = array( 'result' => 'SUCCESS', 'b' => $this->get_backupslist_html( $schedule ), 'count' => count( $schedule->get_backups() ), 'file_size_text' => $this->hmbkp_get_site_size_text( $schedule ), - 'scheduleStatus' => $schedule->get_status(), ); + if (method_exists($schedule, 'get_running_backup_filename' )) { + $ret['scheduleStatus'] = $schedule->get_status(); + } else { + $status = $schedule->get_status(); + $ret['scheduleStatus'] = $status->get_status(); + } + return $ret; } function get_backupslist_html( $schedule ) { @@ -297,7 +342,7 @@ class MainWP_Child_Back_Up_Wordpress { - + @@ -341,17 +386,19 @@ class MainWP_Child_Back_Up_Wordpress { function hmbkp_get_site_size_text( HM\BackUpWordPress\Scheduled_Backup $schedule ) { - - if ( ( 'database' === $schedule->get_type() ) || $schedule->is_site_size_cached() ) { - - return sprintf( '(%s)', esc_attr( $schedule->get_formatted_site_size() ) ); - + if (method_exists($schedule, 'is_site_size_cached')) { + if ( ( 'database' === $schedule->get_type() ) || $schedule->is_site_size_cached() ) { + return sprintf( '(%s)', esc_attr( $schedule->get_formatted_site_size() ) ); + } } else { - - return sprintf( '(' . __( 'calculating the size of your backup…', 'mainwp-backupwordpress-extension' ) . ')' ); - + $site_size = new HM\BackUpWordPress\Site_Size( $schedule->get_type(), $schedule->get_excludes() ); + if ( ( 'database' === $schedule->get_type() ) || $site_size->is_site_size_cached() ) { + return sprintf( '(%s)', esc_attr( $site_size->get_formatted_site_size() ) ); + } } + return sprintf( '(' . __( 'calculating the size of your backup…', 'mainwp-backupwordpress-extension' ) . ')' ); + } function hmbkp_get_backup_row( $file, HM\BackUpWordPress\Scheduled_Backup $schedule ) { @@ -371,19 +418,29 @@ class MainWP_Child_Back_Up_Wordpress { - + - - | - + + | + + | + @@ -664,7 +721,7 @@ class MainWP_Child_Back_Up_Wordpress { - filesize( $file ); @@ -737,7 +794,7 @@ class MainWP_Child_Back_Up_Wordpress { - getPathname(); @@ -857,11 +914,11 @@ class MainWP_Child_Back_Up_Wordpress { return array( 'error' => 'Error: Schedule data' ); } - $current_value = get_option( 'hmbkp_schedule_' . $sch_id ); - if ( is_array( $current_value ) && isset( $current_value['excludes'] ) ) { - // do not update 'excludes' value - $options['excludes'] = $current_value['excludes']; - } +// $current_value = get_option( 'hmbkp_schedule_' . $sch_id ); +// if ( is_array( $current_value ) && isset( $current_value['excludes'] ) ) { +// // do not update 'excludes' value +// $options['excludes'] = $current_value['excludes']; +// } $filter_opts = array( 'type', @@ -888,7 +945,7 @@ class MainWP_Child_Back_Up_Wordpress { $out['result'] = 'NOTCHANGE'; } - $schedule = new HM\BackUpWordPress\Scheduled_Backup( $sch_id ); + $schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $sch_id ) ); if ( ! empty( $options['reoccurrence'] ) && ! empty( $options['schedule_start_time'] ) ) { // Calculate the start time depending on the recurrence @@ -906,6 +963,55 @@ class MainWP_Child_Back_Up_Wordpress { return $out; } + public function save_all_schedules() { + $schedules = isset( $_POST['all_schedules'] ) ? maybe_unserialize( base64_decode( $_POST['all_schedules'] ) ) : false; + + if ( ! is_array( $schedules ) || empty( $schedules ) ) { + return array( 'error' => 'Error: Schedule data' ); + } + + $out = array(); + foreach($schedules as $sch_id => $sch) { + if ( empty($sch_id) || !isset( $sch['options'] ) || ! is_array( $sch['options'] ) ) + continue; + $options = $sch['options']; + $filter_opts = array( + 'type', + 'email', + 'reoccurrence', + 'max_backups', + 'schedule_start_time', + ); + if ( is_array( $options ) ) { + $old_options = get_option( 'hmbkp_schedule_' . $sch_id ); + if ( is_array( $old_options ) ) { + foreach ( $old_options as $key => $val ) { + if ( ! in_array( $key, $filter_opts ) ) { + $options[ $key ] = $old_options[ $key ]; + } + } + } + update_option( 'hmbkp_schedule_' . $sch_id, $options ); + } + + $schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $sch_id ) ); + + if ( ! empty( $options['reoccurrence'] ) && ! empty( $options['schedule_start_time'] ) ) { + // Calculate the start time depending on the recurrence + $start_time = $options['schedule_start_time']; + if ( $start_time ) { + $schedule->set_schedule_start_time( $start_time ); + } + } + + if ( ! empty( $options['reoccurrence'] ) ) { + $schedule->set_reoccurrence( $options['reoccurrence'] ); + } + $out['result'] = 'SUCCESS'; + } + return $out; + } + public static function isActivated() { if ( ! defined( 'HMBKP_PLUGIN_PATH' ) || ! class_exists( 'HM\BackUpWordPress\Plugin' ) ) { return false; diff --git a/class/class-mainwp-child-branding.php b/class/class-mainwp-child-branding.php index 5d1655c..b7a910e 100644 --- a/class/class-mainwp-child-branding.php +++ b/class/class-mainwp-child-branding.php @@ -57,6 +57,7 @@ class MainWP_Child_Branding { public function child_deactivation() { $dell_all = array( 'mainwp_branding_disable_change', + 'mainwp_branding_disable_switching_theme', 'mainwp_branding_child_hide', 'mainwp_branding_show_support', 'mainwp_branding_support_email', @@ -224,6 +225,13 @@ class MainWP_Child_Branding { } else { MainWP_Helper::update_option( 'mainwp_branding_disable_change', '' ); } + + if ( $settings['child_disable_switching_theme'] ) { + MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', 'T' ); + } else { + MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', '' ); + } + $information['result'] = 'SUCCESS'; return $information; @@ -294,10 +302,10 @@ class MainWP_Child_Branding { if ( get_option( 'mainwp_branding_disable_wp_branding' ) !== 'Y' ) { add_filter( 'wp_footer', array( &$this, 'branding_global_footer' ), 15 ); add_action( 'wp_dashboard_setup', array( &$this, 'custom_dashboard_widgets' ), 999 ); - // branding site generator + // branding site generator $types = array( 'html', 'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export' ); foreach ( $types as $type ) { - add_filter( 'get_the_generator_' . $type, array( &$this, 'custom_the_generator' ) ); + add_filter( 'get_the_generator_' . $type, array( &$this, 'custom_the_generator' ), 999, 2 ); } add_action( 'admin_head', array( &$this, 'custom_admin_css' ) ); add_action( 'login_enqueue_scripts', array( &$this, 'custom_login_css' ) ); @@ -511,6 +519,7 @@ class MainWP_Child_Branding { function custom_the_generator( $generator, $type = '' ) { $extra_setting = $this->settings['extra_settings']; + error_log($type . "======" . print_r($extra_setting, true)); if ( isset( $extra_setting['site_generator'] ) ) { if ( ! empty( $extra_setting['site_generator'] ) ) { switch ( $type ) : @@ -639,7 +648,7 @@ class MainWP_Child_Branding { } ?>
"; $caps[0] = 'do_not_allow'; } } - + if ( 'T' === get_option( 'mainwp_branding_disable_switching_theme' ) ) { + // disable: theme switching + if ( 'switch_themes' === $cap ) { + $caps[0] = 'do_not_allow'; + } + } return $caps; } diff --git a/class/class-mainwp-child-server-information.php b/class/class-mainwp-child-server-information.php index c5f24b0..74d2b35 100644 --- a/class/class-mainwp-child-server-information.php +++ b/class/class-mainwp-child-server-information.php @@ -273,7 +273,7 @@ class MainWP_Child_Server_Information { is installed on this site. This plugin is known to - have a potential conflict with functions. functions. Please click this link for possible solutions @@ -356,11 +356,11 @@ class MainWP_Child_Server_Information { - + - Version + Version @@ -763,7 +763,7 @@ class MainWP_Child_Server_Information { ?> -
+
diff --git a/class/class-mainwp-child.php b/class/class-mainwp-child.php index 1737719..85e9653 100644 --- a/class/class-mainwp-child.php +++ b/class/class-mainwp-child.php @@ -9,6 +9,7 @@ define( 'MAINWP_CHILD_NR_OF_PAGES', 50 ); include_once( ABSPATH . '/wp-admin/includes/file.php' ); include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); + if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyuse_nonce_hmac'] ) ) { $skeleton_keyuse_nonce_key = intval( $_GET['skeleton_keyuse_nonce_key'] ); $skeleton_keyuse_nonce_hmac = $_GET['skeleton_keyuse_nonce_hmac']; @@ -78,7 +79,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus } class MainWP_Child { - public static $version = '3.0.1'; + public static $version = '3.0.2'; private $update_version = '1.3'; private $callableFunctions = array( @@ -90,6 +91,7 @@ class MainWP_Child { 'newadminpassword' => 'newAdminPassword', 'installplugintheme' => 'installPluginTheme', 'upgradeplugintheme' => 'upgradePluginTheme', + 'upgradetranslation' => 'upgradeTranslation', 'backup' => 'backup', 'backup_checkpid' => 'backup_checkpid', 'cloneinfo' => 'cloneinfo', @@ -174,6 +176,7 @@ class MainWP_Child { add_action( 'admin_menu', array( &$this, 'admin_menu' ) ); add_action( 'admin_init', array( &$this, 'admin_init' ) ); add_action( 'init', array( &$this, 'localization' ) ); + add_action( 'pre_current_active_plugins', array( &$this, 'pre_current_active_plugins' ) ); if ( is_admin() ) { MainWP_Helper::update_option( 'mainwp_child_plugin_version', self::$version, 'yes' ); @@ -369,6 +372,19 @@ class MainWP_Child { load_plugin_textdomain( 'mainwp-child', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' ); } + public function pre_current_active_plugins() { + $plugin_updates = get_plugin_updates(); + $fix_update_plugins = array(); + if ( is_array( $plugin_updates ) ) { + foreach ( $plugin_updates as $slug => $plugin_update ) { + if ( in_array( $slug, array( 'ithemes-security-pro/ithemes-security-pro.php', 'monarch/monarch.php', 'cornerstone/cornerstone.php') ) ) { + $fix_update_plugins[ $slug ] = $plugin_update; + } + } + } + set_site_transient( 'tofix_update_plugins', $fix_update_plugins); + } + function checkOtherAuth() { $auths = get_option( 'mainwp_child_auth' ); @@ -918,26 +934,26 @@ class MainWP_Child { new MainWP_Heatmap_Tracker(); } } + /** * Security */ MainWP_Security::fixAll(); if ( isset( $_GET['mainwptest'] ) ) { - // error_reporting(E_ALL); - // ini_set('display_errors', TRUE); - // ini_set('display_startup_errors', TRUE); - // echo '
';
-			//            $start = microtime(true);
+//			            error_reporting(E_ALL);
+//			            ini_set('display_errors', TRUE);
+//			            ini_set('display_startup_errors', TRUE);
+//			            echo '
';
+//			            $start = microtime(true);
+//
+//			print_r(wp_get_translation_updates());
+//
+//			print_r($this->getSiteStats(array(), false));
+//
 
-			//            phpinfo();
-			//            $_POST['type'] = 'full';
-			//            $_POST['ext'] = 'tar.gz';
-			//            $_POST['pid'] = time();
-			//            print_r($this->backup(false));
-
-			//            $stop = microtime(true);
-			//            die(($stop - $start) . 's
'); +// $stop = microtime(true); +// die(($stop - $start) . 's
'); } //Register does not require auth, so we register here.. @@ -1162,12 +1178,12 @@ class MainWP_Child { } if ( is_wp_error( $result ) ) { + $err_code = $result->get_error_code(); if ( $result->get_error_data() && is_string( $result->get_error_data() ) ) { $error = $result->get_error_data(); - MainWP_Helper::error( $error ); + MainWP_Helper::error( $error, $err_code ); } else { - $error = $result->get_error_code(); - MainWP_Helper::error( implode( ', ', $error ) ); + MainWP_Helper::error( implode( ', ', $error ), $err_code ); } } } @@ -1323,6 +1339,53 @@ class MainWP_Child { MainWP_Helper::write( $information ); } + function upgradeTranslation() { + //Prevent disable/re-enable at upgrade + define( 'DOING_CRON', true ); + + MainWP_Helper::getWPFilesystem(); + include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' ); + if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { + include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + } + if ( file_exists( ABSPATH . '/wp-admin/includes/template.php' ) ) { + include_once( ABSPATH . '/wp-admin/includes/template.php' ); + } + if ( file_exists( ABSPATH . '/wp-admin/includes/misc.php' ) ) { + include_once( ABSPATH . '/wp-admin/includes/misc.php' ); + } + include_once( ABSPATH . '/wp-admin/includes/file.php' ); + + include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); + + $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) ); + $translations = explode( ',', urldecode( $_POST['list'] ) ); + $all_language_updates = wp_get_translation_updates(); + + $language_updates = array(); + foreach ( $all_language_updates as $current_language_update ) { + if ( in_array( $current_language_update->slug, $translations ) ) { + $language_updates[] = $current_language_update; + } + } + + $result = count( $language_updates ) == 0 ? false : $upgrader->bulk_upgrade( $language_updates ); + if ( ! empty( $result ) ) { + for ( $i = 0; $i < count( $result ); $i++ ) { + if ( empty( $result[$i] ) || is_wp_error( $result[$i] ) ) { + $information['upgrades'][ $language_updates[$i]->slug ] = false; + } else { + $information['upgrades'][ $language_updates[$i]->slug ] = true; + } + } + } else { + MainWP_Helper::error( __( 'Bad request', 'mainwp-child' ) ); + } + + $information['sync'] = $this->getSiteStats( array(), false ); + MainWP_Helper::write( $information ); + } + /** * Expects $_POST['type'] == plugin/theme * $_POST['list'] == 'theme1,theme2' or 'plugin1,plugin2' @@ -1433,10 +1496,17 @@ class MainWP_Child { remove_filter( 'pre_site_transient_update_plugins', $this->filterFunction, 99 ); } } else if ( isset( $_POST['type'] ) && 'theme' === $_POST['type'] ) { + + $last_update = get_site_transient( 'update_themes' ); + include_once( ABSPATH . '/wp-admin/includes/update.php' ); if ( null !== $this->filterFunction ) { add_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 ); } + +// $last_update = get_site_transient( 'update_themes' ); +// $originalLastChecked = !empty( $last_update ) && property_exists( $last_update, 'last_checked' ) ? $last_update->last_checked : 0; + @wp_update_themes(); include_once( ABSPATH . '/wp-admin/includes/theme.php' ); $information['theme_updates'] = $this->upgrade_get_theme_updates(); @@ -1464,8 +1534,26 @@ class MainWP_Child { } //@see wp-admin/update.php + if ( null !== $this->filterFunction ) { + remove_filter( 'pre_site_transient_update_plugins', $this->filterFunction, 99 ); + } + + $last_update2 = get_site_transient( 'update_themes' ); + set_site_transient( 'update_themes', $last_update ); +// if ( !empty( $last_update ) && property_exists( $last_update, 'last_checked' ) ) { +// $last_update->last_checked = $originalLastChecked; +// set_site_transient( 'update_themes', $last_update ); +// } + +// @wp_update_themes(); + $upgrader = new Theme_Upgrader( new Bulk_Theme_Upgrader_Skin( compact( 'nonce', 'url' ) ) ); $result = $upgrader->bulk_upgrade( $themes ); + if ( null !== $this->filterFunction ) { + add_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 ); + } + + set_site_transient( 'update_themes', $last_update2 ); if ( $addFilterToFixUpdate_optimizePressTheme ) { remove_filter( 'site_transient_update_themes', array( @@ -1486,6 +1574,15 @@ class MainWP_Child { MainWP_Helper::error( __( 'Bad request', 'mainwp-child' ) ); } } + +// $last_update = get_site_transient( 'update_themes' ); +// if ( !empty( $last_update ) && property_exists( $last_update, 'last_checked' ) ) { +// $last_update->last_checked = $originalLastChecked; +// set_site_transient( 'update_themes', $last_update ); +// } + +// @wp_update_themes(); + if ( count( $premiumThemes ) > 0 ) { $mwp_premium_updates = apply_filters( 'mwp_premium_perform_update', array() ); $mwp_premium_updates_todo = array(); @@ -1618,7 +1715,7 @@ class MainWP_Child { //Already added - can't readd. Deactivate plugin.. if ( get_option( 'mainwp_child_pubkey' ) ) { - MainWP_Helper::error( __( 'Public key already set, reset the MainWP plugin on your site and try again.', 'mainwp-child' ) ); + MainWP_Helper::error( __( 'Public key already set, reset the MainWP Child plugin on your Child site and try again.', 'mainwp-child' ) ); } if ( '' != get_option( 'mainwp_child_uniqueId' ) ) { @@ -2283,9 +2380,11 @@ class MainWP_Child { if ( 'all' === $_POST['feature'] || 'versions' === $_POST['feature'] ) { $security['scripts_version'] = true; $security['styles_version'] = true; + $security['generator_version'] = true; MainWP_Security::remove_scripts_version( true ); MainWP_Security::remove_styles_version( true ); - $information['versions'] = ( ! MainWP_Security::remove_scripts_version_ok() || ! MainWP_Security::remove_styles_version_ok() ? 'N' : 'Y' ); + MainWP_Security::remove_generator_version( true ); + $information['versions'] = 'Y'; } if ( 'all' === $_POST['feature'] || 'admin' === $_POST['feature'] ) { @@ -2339,6 +2438,7 @@ class MainWP_Child { if ( 'all' === $_POST['feature'] || 'versions' === $_POST['feature'] ) { $security['scripts_version'] = false; $security['styles_version'] = false; + $security['generator_version'] = false; $information['versions'] = 'N'; } @@ -2369,7 +2469,7 @@ class MainWP_Child { // $information['file_perms'] = (!MainWP_Security::fix_file_permissions_ok() ? 'N' : 'Y'); $information['db_reporting'] = ( ! MainWP_Security::remove_database_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() + $information['versions'] = ( ! MainWP_Security::remove_scripts_version_ok() || ! MainWP_Security::remove_styles_version_ok() || ! MainWP_Security::remove_generator_version_ok() ? 'N' : 'Y' ); $information['admin'] = ( ! MainWP_Security::admin_user_ok() ? 'N' : 'Y' ); $information['readme'] = ( MainWP_Security::remove_readme_ok() ? 'Y' : 'N' ); @@ -2396,6 +2496,7 @@ class MainWP_Child { $update_htaccess = true; } MainWP_Helper::update_option( 'heatMapEnabled', '0', 'yes' ); + MainWP_Helper::update_option( 'heatMapExtensionLoaded', '', 'yes' ); } } @@ -2561,7 +2662,19 @@ class MainWP_Child { $information['plugin_updates'][ $slug ] = $plugin_update; } + + // to fix bug + $fix_update_plugins = get_site_transient( 'tofix_update_plugins' ); + if ( 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 } + if ( null !== $this->filterFunction ) { remove_filter( 'pre_site_transient_update_plugins', $this->filterFunction, 99 ); } @@ -2586,6 +2699,34 @@ class MainWP_Child { if ( null !== $this->filterFunction ) { remove_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 ); } + + $translation_updates = wp_get_translation_updates(); + if ( !empty( $translation_updates ) ) { + $information['translation_updates'] = array(); + foreach ($translation_updates as $translation_update) + { + $new_translation_update = array('type' => $translation_update->type, + 'slug' => $translation_update->slug, + 'language' => $translation_update->language, + 'version' => $translation_update->version); + if ( 'plugin' === $translation_update->type ) { + $all_plugins = get_plugins(); + foreach ( $all_plugins as $file => $plugin ) { + if ( stristr( $file, $translation_update->slug ) ) { + $new_translation_update['name'] = $plugin['Name']; + break; + } + } + } else if ( 'theme' === $translation_update->type ) { + $theme = wp_get_theme($translation_update->slug); + $new_translation_update['name'] = $theme->name; + } else if ( ( 'core' === $translation_update->type ) && ( 'default' === $translation_update->slug ) ) { + $new_translation_update['name'] = 'Wordpress core'; + } + $information['translation_updates'][] = $new_translation_update; + } + } + $information['recent_comments'] = $this->get_recent_comments( array( 'approve', 'hold' ), 5 ); $information['recent_posts'] = $this->get_recent_posts( array( 'publish', 'draft', 'pending', 'trash' ), 5 ); $information['recent_pages'] = $this->get_recent_posts( array( @@ -2618,7 +2759,7 @@ class MainWP_Child { if ( ! MainWP_Security::remove_php_reporting_ok() ) { $securityIssuess ++; } - if ( ! MainWP_Security::remove_scripts_version_ok() || ! MainWP_Security::remove_styles_version_ok() ) { + if ( ! MainWP_Security::remove_scripts_version_ok() || ! MainWP_Security::remove_styles_version_ok() || ! MainWP_Security::remove_generator_version_ok() ) { $securityIssuess ++; } if ( ! MainWP_Security::admin_user_ok() ) { @@ -3640,6 +3781,35 @@ class MainWP_Child { function getTotalFileSize( $directory = WP_CONTENT_DIR ) { try { + function continueFileSize( $dir, $limit ) { + $dirs = array( $dir ); + $cnt = 0; + while ( isset( $dirs[0] ) ) { + $path = array_shift( $dirs ); + if ( stristr( $path, WP_CONTENT_DIR . '/uploads/mainwp' ) ) { + continue; + } + $uploadDir = MainWP_Helper::getMainWPDir(); + $uploadDir = $uploadDir[0]; + if ( stristr( $path, $uploadDir ) ) { + continue; + } + $res = @glob( $path . '/*' ); + if ( is_array( $res ) ) { + foreach ( $res as $next ) { + if ( is_dir( $next ) ) { + $dirs[] = $next; + } else { + if ($cnt++ > $limit) return false;; + } + } + } + } + return true; + } + + if ( !continueFilesize( $directory, 20000 ) ) return 0; + if ( MainWP_Helper::function_exists( 'popen' ) ) { $uploadDir = MainWP_Helper::getMainWPDir(); $uploadDir = $uploadDir[0]; @@ -3648,18 +3818,19 @@ class MainWP_Child { $size = @fread( $popenHandle, 1024 ); @pclose( $popenHandle ); $size = substr( $size, 0, strpos( $size, "\t" ) ); - if ( ctype_digit( $size ) ) { + if ( MainWP_Helper::ctype_digit( $size ) ) { return $size / 1024; } } } + if ( MainWP_Helper::function_exists( 'shell_exec' ) ) { $uploadDir = MainWP_Helper::getMainWPDir(); $uploadDir = $uploadDir[0]; - $size = @shell_exec( 'du -s ' . $directory . ' --exclude "' . str_replace( ABSPATH, '', $uploadDir ) . '"', 'r' ); + $size = @shell_exec( 'du -s ' . $directory . ' --exclude "' . str_replace( ABSPATH, '', $uploadDir ) . '"' ); if ( null !== $size ) { $size = substr( $size, 0, strpos( $size, "\t" ) ); - if ( ctype_digit( $size ) ) { + if ( MainWP_Helper::ctype_digit( $size ) ) { return $size / 1024; } } @@ -3673,7 +3844,7 @@ class MainWP_Child { $size = $ref->size; $obj = null; - if ( ctype_digit( $size ) ) { + if ( MainWP_Helper::ctype_digit( $size ) ) { return $size / 1024; } } @@ -3949,11 +4120,7 @@ class MainWP_Child { } $code = stripslashes( $_POST['code'] ); if ( 'run_snippet' === $action ) { - $return = $this->execute_snippet( $code ); - if ( is_array( $return ) && isset( $return['result'] ) && 'SUCCESS' === $return['result'] ) { - $information['status'] = 'SUCCESS'; - } - $information['result'] = isset( $return['output'] ) ? $return['output'] : ''; + $information = $this->execute_snippet( $code ); } else if ( 'save_snippet' === $action ) { $type = $_POST['type']; $slug = $_POST['slug']; @@ -4035,11 +4202,14 @@ class MainWP_Child { $result = eval( $code ); $output = ob_get_contents(); ob_end_clean(); - $return = array( 'output' => $output ); - if ( $result ) { - $return['result'] = 'SUCCESS'; + $return = array(); + if ( false === $result && ( $error = error_get_last() ) ) { + $return['status'] = 'FAIL'; + $return['result'] = $error['message']; + } else { + $return['status'] = 'SUCCESS'; + $return['result'] = $output; } - return $return; } diff --git a/class/class-mainwp-heatmap-tracker.php b/class/class-mainwp-heatmap-tracker.php index 554f184..1bc24c4 100644 --- a/class/class-mainwp-heatmap-tracker.php +++ b/class/class-mainwp-heatmap-tracker.php @@ -289,7 +289,7 @@ class MainWP_Heatmap_Tracker { */ public function trackerJsInline() { echo '