merge + new version

This commit is contained in:
ruben- 2017-08-24 20:41:12 +02:00
parent 31c9c0823b
commit d8c850ea6d
13 changed files with 878 additions and 380 deletions

View file

@ -14,7 +14,7 @@ class MainWP_Child_Back_Up_Buddy {
public function __construct() {
// To fix bug run dashboard on local machine
//if ( is_plugin_active( 'backupbuddy/backupbuddy.php' )) {
//if ( is_plugin_active( 'backupbuddy/backupbuddy.php' )) {
if ( class_exists('pb_backupbuddy')) {
$this->is_backupbuddy_installed = true;
}
@ -27,8 +27,8 @@ class MainWP_Child_Back_Up_Buddy {
return;
}
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( 'wp_ajax_mainwp_backupbuddy_download_archive', array( $this, 'download_archive' ) );
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
if ( get_option( 'mainwp_backupbuddy_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
@ -72,27 +72,27 @@ class MainWP_Child_Back_Up_Buddy {
}
function do_site_stats() {
if (has_action('mainwp_child_reports_log')) {
do_action( 'mainwp_child_reports_log', 'backupbuddy');
} else {
$this->do_reports_log('backupbuddy');
}
}
function do_site_stats() {
if (has_action('mainwp_child_reports_log')) {
do_action( 'mainwp_child_reports_log', 'backupbuddy');
} else {
$this->do_reports_log('backupbuddy');
}
}
function do_reports_log($ext = '') {
if ($ext !== 'backupbuddy')
return;
function do_reports_log($ext = '') {
if ($ext !== 'backupbuddy')
return;
if (!$this->is_backupbuddy_installed) {
return;
}
if (!$this->is_backupbuddy_installed) {
return;
}
if ( ! class_exists( 'backupbuddy_core' ) ) {
require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' );
}
if ( ! class_exists( 'backupbuddy_core' ) ) {
require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' );
}
$backups = array();
$backups = array();
$backup_sort_dates = array();
$files = glob( backupbuddy_core::getBackupDirectory() . 'backup*.zip' );
@ -151,8 +151,8 @@ class MainWP_Child_Back_Up_Buddy {
$backup_type = $detected_type;
if (!empty($modified_time)) {
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backup_type, $modified_time);
MainWP_Helper::update_lasttime_backup('backupbuddy', $modified_time); // to support backup before update feature
}
MainWP_Helper::update_lasttime_backup('backupbuddy', $modified_time); // to support backup before update feature
}
}
}
}
@ -160,7 +160,7 @@ class MainWP_Child_Back_Up_Buddy {
}
public function action() {
$information = array();
$information = array();
if ( ! $this->is_backupbuddy_installed ) {
MainWP_Helper::write( array( 'error' => __( 'Please install the BackupBuddy plugin on the child site.', $this->plugin_translate ) ) );
}
@ -223,6 +223,9 @@ class MainWP_Child_Back_Up_Buddy {
case 'zip_viewer':
$information = $this->zip_viewer();
break;
case 'exclude_tree':
$information = $this->exclude_tree();
break;
case 'restore_file_view':
$information = $this->restore_file_view();
break;
@ -344,8 +347,10 @@ class MainWP_Child_Back_Up_Buddy {
'disable_localization',
'limit_single_cron_per_pass',
'use_internal_cron',
'cron_request_timeout_override',
'remote_send_timeout_retries',
'hide_live',
'hide_dashboard_widget',
'set_greedy_execution_time',
'archive_limit_size_big',
'max_execution_time',
@ -364,6 +369,8 @@ class MainWP_Child_Back_Up_Buddy {
'backup_cron_rescheduling',
'skip_spawn_cron_call',
'backup_cron_passed_force_time',
'php_runtime_test_minimum_interval',
'php_memory_test_minimum_interval',
'database_method_strategy',
'skip_database_dump', // profiles#0
'breakout_tables',
@ -410,7 +417,7 @@ class MainWP_Child_Back_Up_Buddy {
'email_notify_send_finish',
'email_notify_send_finish_subject',
'email_notify_send_finish_body',
'no_new_backups_error_days',
'no_new_backups_error_days',
'email_notify_error',
'email_notify_error_subject',
'email_notify_error_body',
@ -683,6 +690,17 @@ class MainWP_Child_Back_Up_Buddy {
return $information;
}
public function get_sync_data() {
$information = array();
$information['plugins_root'] = backupbuddy_core::get_plugins_root();
$information['themes_root'] = backupbuddy_core::get_themes_root();
$information['media_root'] = backupbuddy_core::get_media_root();
$information['additional_tables'] = $this->pb_additional_tables();
$information['abspath'] = ABSPATH;
return $information;
}
function backup_list() {
require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' );
$information = array();
@ -870,6 +888,113 @@ class MainWP_Child_Back_Up_Buddy {
}
function exclude_tree() {
$root = substr( ABSPATH, 0, strlen( ABSPATH ) - 1 ) . '/' . ltrim( urldecode( $_POST['dir'] ), '/\\' );
if( file_exists( $root ) ) {
$files = scandir( $root );
natcasesort( $files );
// Sort with directories first.
$sorted_files = array(); // Temporary holder for sorting files.
$sorted_directories = array(); // Temporary holder for sorting directories.
foreach( $files as $file ) {
if ( ( $file == '.' ) || ( $file == '..' ) ) {
continue;
}
if( is_file( str_replace( '//', '/', $root . $file ) ) ) {
array_push( $sorted_files, $file );
} else {
array_unshift( $sorted_directories, $file );
}
}
$files = array_merge( array_reverse( $sorted_directories ), $sorted_files );
unset( $sorted_files );
unset( $sorted_directories );
unset( $file );
ob_start();
if( count( $files ) > 0 ) { // Files found.
echo '<ul class="jqueryFileTree" style="display: none;">';
foreach( $files as $file ) {
if( file_exists( str_replace( '//', '/', $root . $file ) ) ) {
if ( is_dir( str_replace( '//', '/', $root . $file ) ) ) { // Directory.
echo '<li class="directory collapsed">';
$return = '';
$return .= '<div class="pb_backupbuddy_treeselect_control">';
$return .= '<img src="' . pb_backupbuddy::plugin_url() . '/images/redminus.png" style="vertical-align: -3px;" title="Add to exclusions..." class="pb_backupbuddy_filetree_exclude">';
$return .= '</div>';
echo '<a href="#" rel="' . htmlentities( str_replace( ABSPATH, '', $root ) . $file) . '/" title="Toggle expand...">' . htmlentities($file) . $return . '</a>';
echo '</li>';
} else { // File.
echo '<li class="file collapsed">';
$return = '';
$return .= '<div class="pb_backupbuddy_treeselect_control">';
$return .= '<img src="' . pb_backupbuddy::plugin_url() . '/images/redminus.png" style="vertical-align: -3px;" title="Add to exclusions..." class="pb_backupbuddy_filetree_exclude">';
$return .= '</div>';
echo '<a href="#" rel="' . htmlentities( str_replace( ABSPATH, '', $root ) . $file) . '">' . htmlentities($file) . $return . '</a>';
echo '</li>';
}
}
}
echo '</ul>';
} else {
echo '<ul class="jqueryFileTree" style="display: none;">';
echo '<li><a href="#" rel="' . htmlentities( pb_backupbuddy::_POST( 'dir' ) . 'NONE' ) . '"><i>Empty Directory ...</i></a></li>';
echo '</ul>';
}
$html = ob_get_clean();
return array('result' => $html) ;
} else {
return array('error' => 'Error #1127555. Unable to read child site root.') ;
}
}
function pb_additional_tables( $display_size = false ) {
$return = '';
$size_string = '';
global $wpdb;
if ( true === $display_size ) {
$results = $wpdb->get_results( "SHOW TABLE STATUS", ARRAY_A );
} else {
$results = $wpdb->get_results( "SELECT table_name FROM information_schema.tables WHERE table_schema = DATABASE()", ARRAY_A );
}
foreach( $results as $result ) {
if ( true === $display_size ) {
// Fix up row count and average row length for InnoDB engine which returns inaccurate (and changing) values for these.
if ( 'InnoDB' === $result[ 'Engine' ] ) {
if ( false !== ( $rowCount = $wpdb->get_var( "SELECT COUNT(1) as rowCount FROM `{$rs[ 'Name' ]}`", ARRAY_A ) ) ) {
if ( 0 < ( $result[ 'Rows' ] = $rowCount ) ) {
$result[ 'Avg_row_length' ] = ( $result[ 'Data_length' ] / $result[ 'Rows' ] );
}
}
unset( $rowCount );
}
// Table size.
$size_string = ' (' . pb_backupbuddy::$format->file_size( ( $result['Data_length'] + $result['Index_length'] ) ) . ') ';
} // end if display size enabled.
$return .= '<li class="file ext_sql collapsed">';
$return .= '<a rel="/" alt="' . $result['table_name'] . '">' . $result['table_name'] . $size_string;
$return .= '<div class="pb_backupbuddy_treeselect_control">';
$return .= '<img src="' . pb_backupbuddy::plugin_url() . '/images/redminus.png" style="vertical-align: -3px;" title="Add to exclusions..." class="pb_backupbuddy_table_addexclude"> <img src="' . pb_backupbuddy::plugin_url() . '/images/greenplus.png" style="vertical-align: -3px;" title="Add to inclusions..." class="pb_backupbuddy_table_addinclude">';
$return .= '</div>';
$return .= '</a>';
$return .= '</li>';
}
return '<div class="jQueryOuterTree" style="position: absolute; height: 160px;"><ul class="jqueryFileTree">' . $return . '</ul></div>';
}
function restore_file_view() {
$archive_file = $_POST[ 'archive' ]; // archive to extract from.

View file

@ -2,7 +2,7 @@
class MainWP_Child_Back_Up_Wordpress {
public static $instance = null;
public $is_plugin_installed = false;
public $is_plugin_installed = false;
static function Instance() {
if ( null === MainWP_Child_Back_Up_Wordpress::$instance ) {
MainWP_Child_Back_Up_Wordpress::$instance = new MainWP_Child_Back_Up_Wordpress();

View file

@ -247,7 +247,11 @@ class MainWP_Child_iThemes_Security {
}
}
}
if ( isset( $update_settings['itsec_active_modules'] ) ) {
update_site_option( 'itsec_active_modules', $update_settings['itsec_active_modules'] );
}
require_once( ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php' );
$values = array(

View file

@ -32,12 +32,15 @@ class MainWP_Child_Skeleton_Key {
case 'skeleton_key_visit_site_as_browser':
$information = $this->visit_site_as_browser();
break;
case 'save_settings':
$information = $this->save_settings();
break;
default:
$information = array( 'error' => 'Unknown action' );
}
MainWP_Child_Skeleton_Key::$information = $information;
MainWP_Helper::write( $information );
//MainWP_Child_Skeleton_Key::$information = $information;
exit();
}
@ -62,19 +65,26 @@ class MainWP_Child_Skeleton_Key {
$manager = WP_Session_Tokens::get_instance( $current_user->ID );
$token = $manager->create( $expiration );
$auth_cookie = wp_generate_auth_cookie( $current_user->ID, $expiration, 'auth', $token );
$logged_cookie = wp_generate_auth_cookie( $current_user->ID, $expiration, 'logged_in', $token );
$_COOKIE[ AUTH_COOKIE ] = $auth_cookie;
$_COOKIE[ LOGGED_IN_COOKIE ] = $logged_cookie;
$secure = is_ssl();
if ( $secure ) {
$auth_cookie_name = SECURE_AUTH_COOKIE;
$scheme = 'secure_auth';
} else {
$auth_cookie_name = AUTH_COOKIE;
$scheme = 'auth';
}
$auth_cookie = wp_generate_auth_cookie( $current_user->ID, $expiration, $scheme, $token );
$logged_in_cookie = wp_generate_auth_cookie( $current_user->ID, $expiration, 'logged_in', $token );
$_COOKIE[ $auth_cookie_name ] = $auth_cookie;
$_COOKIE[ LOGGED_IN_COOKIE ] = $logged_in_cookie;
$post_args = array();
$post_args['body'] = array();
$post_args['redirection'] = 5;
$post_args['decompress'] = false; // For gzinflate() data error bug
$post_args['cookies'] = array(
new WP_Http_Cookie( array( 'name' => AUTH_COOKIE, 'value' => $auth_cookie ) ),
new WP_Http_Cookie( array( 'name' => LOGGED_IN_COOKIE, 'value' => $logged_cookie ) ),
new WP_Http_Cookie( array( 'name' => $auth_cookie_name, 'value' => $auth_cookie ) ),
new WP_Http_Cookie( array( 'name' => LOGGED_IN_COOKIE, 'value' => $logged_in_cookie ) ),
);
if ( isset( $args['get'] ) ) {
@ -109,6 +119,8 @@ class MainWP_Child_Skeleton_Key {
$post_args['body'] = $temp_post;
}
$post_args['timeout'] = 25;
$full_url = add_query_arg( $get_args, get_site_url() . $url );
$response = wp_remote_post( $full_url, $post_args );
@ -169,4 +181,57 @@ class MainWP_Child_Skeleton_Key {
return $array;
}
public function save_settings() {
$settings = isset($_POST['settings']) ? $_POST['settings'] : array();
if (!is_array($settings) || empty($settings))
return array('error' => 'Invalid data');
$whitelist_options = array(
'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string', 'WPLANG' ),
);
if ( !is_multisite() ) {
if ( !defined( 'WP_SITEURL' ) )
$whitelist_options['general'][] = 'siteurl';
if ( !defined( 'WP_HOME' ) )
$whitelist_options['general'][] = 'home';
$whitelist_options['general'][] = 'admin_email';
$whitelist_options['general'][] = 'users_can_register';
$whitelist_options['general'][] = 'default_role';
}
//$whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
$whitelist_general = $whitelist_options[ 'general' ];
// Handle translation install.
if ( ! empty( $settings['WPLANG'] ) ) {
require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
if ( wp_can_install_language_pack() ) {
$language = wp_download_language_pack( $settings['WPLANG'] );
if ( $language ) {
$settings['WPLANG'] = $language;
}
}
}
$updated = false;
foreach($settings as $option => $value) {
if (in_array($option, $whitelist_general)) {
if ( ! is_array( $value ) )
$value = trim( $value );
$value = wp_unslash( $value );
update_option($option, $value);
$updated = true;
}
}
if (!$updated)
return false;
return array('result' => 'ok');
}
}

View file

@ -13,19 +13,19 @@ class MainWP_Child_Updraft_Plus_Backups {
public function __construct() {
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' ));
}
public static function hookUpdraftplusSaveLastBackup($last_backup) {
if (!is_array($last_backup))
return $last_backup;
public static function hookUpdraftplusSaveLastBackup($last_backup) {
if (!is_array($last_backup))
return $last_backup;
if (isset($last_backup['backup_time'])) {
$backup_time = $last_backup['backup_time'];
MainWP_Helper::update_lasttime_backup('updraftplus', $backup_time);
}
return $last_backup;
}
if (isset($last_backup['backup_time'])) {
$backup_time = $last_backup['backup_time'];
MainWP_Helper::update_lasttime_backup('updraftplus', $backup_time);
}
return $last_backup;
}
function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncUpdraftData'] ) && $data['syncUpdraftData'] ) {
@ -195,7 +195,7 @@ class MainWP_Child_Updraft_Plus_Backups {
'updraft_disable_ping',
'updraft_openstack',
'updraft_bitcasa',
'updraft_cloudfiles',
//'updraft_cloudfiles',
'updraft_ssl_useservercerts',
'updraft_ssl_disableverify',
'updraft_report_warningsonly',
@ -213,8 +213,8 @@ class MainWP_Child_Updraft_Plus_Backups {
'updraft_sftp_settings',
'updraft_webdav_settings',
'updraft_dreamobjects',
'updraft_onedrive',
'updraft_azure',
//'updraft_onedrive', // disalbed
//'updraft_azure', // disabled
'updraft_googlecloud',
//'updraft_updraftvault',
'updraft_retain_extrarules'
@ -381,36 +381,73 @@ class MainWP_Child_Updraft_Plus_Backups {
if ( class_exists( 'UpdraftPlus_Options' ) ) {
foreach ( $keys_filter as $key ) {
if ( isset( $settings[ $key ] ) ) {
$settings_key = null;
if ( 'updraft_dropbox' === $key && is_array($settings[ $key ])) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dropbox' );
if (isset($settings['is_general']) && !empty($settings['is_general'])){
$opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
} else {
$opts['appkey'] = $settings[ $key ]['appkey'];
$opts['secret'] = $settings[ $key ]['secret'];
$opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
}
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dropbox' );
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
if (isset($settings['is_general']) && !empty($settings['is_general'])){
$opts['settings'][$settings_key]['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
} else {
// $opts['settings'][$settings_key]['appkey'] = $settings[ $key ]['appkey'];
// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret'];
$opts['settings'][$settings_key]['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
}
} else {
if (isset($settings['is_general']) && !empty($settings['is_general'])){
$opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
} else {
// $opts['appkey'] = $settings[ $key ]['appkey'];
// $opts['secret'] = $settings[ $key ]['secret'];
$opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
}
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else if ( 'updraft_googledrive' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_googledrive' );
$opts['clientid'] = $settings[ $key ]['clientid'];
$opts['secret'] = $settings[ $key ]['secret'];
$opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret'];
$opts['settings'][$settings_key]['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
} else {
// $opts['clientid'] = $settings[ $key ]['clientid'];
// $opts['secret'] = $settings[ $key ]['secret'];
$opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else if ( 'updraft_googlecloud' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( $key );
$opts['clientid'] = $settings[ $key ]['clientid'];
$opts['secret'] = $settings[ $key ]['secret'];
$opts['project_id'] = $settings[ $key ]['project_id'];
$opts['bucket_path'] = $settings[ $key ]['bucket_path'];
$opts['storage_class'] = $settings[ $key ]['storage_class'];
$opts['bucket_location'] = $settings[ $key ]['bucket_location'];
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret'];
// $opts['settings'][$settings_key]['project_id'] = $settings[ $key ]['project_id'];
// $opts['settings'][$settings_key]['bucket_path'] = $settings[ $key ]['bucket_path'];
$opts['settings'][$settings_key]['storage_class'] = $settings[ $key ]['storage_class'];
$opts['settings'][$settings_key]['bucket_location'] = $settings[ $key ]['bucket_location'];
} else {
// $opts['clientid'] = $settings[ $key ]['clientid'];
// $opts['secret'] = $settings[ $key ]['secret'];
// $opts['project_id'] = $settings[ $key ]['project_id'];
// $opts['bucket_path'] = $settings[ $key ]['bucket_path'];
$opts['storage_class'] = $settings[ $key ]['storage_class'];
$opts['bucket_location'] = $settings[ $key ]['bucket_location'];
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else if ( 'updraft_onedrive' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_onedrive' );
$opts['clientid'] = $settings[ $key ]['clientid'];
$opts['secret'] = $settings[ $key ]['secret'];
$opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret'];
$opts['settings'][$settings_key]['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
} else {
// $opts['clientid'] = $settings[ $key ]['clientid'];
// $opts['secret'] = $settings[ $key ]['secret'];
$opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else if ( 'updraft_email' === $key ) {
$value = $settings[ $key ];
@ -422,33 +459,106 @@ class MainWP_Child_Updraft_Plus_Backups {
}
UpdraftPlus_Options::update_updraft_option( $key, $value );
} else if ( 'updraft_s3' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3' );
$opts['accesskey'] = $settings[ $key ]['accesskey'];
$opts['secretkey'] = $settings[ $key ]['secretkey'];
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
$opts['rrs'] = $settings[ $key ]['rrs'];
$opts['server_side_encryption'] = $settings[ $key ]['server_side_encryption'];
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3' );
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
// $opts['settings'][$settings_key]['accesskey'] = $settings[ $key ]['accesskey'];
// $opts['settings'][$settings_key]['secretkey'] = $settings[ $key ]['secretkey'];
$opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']);
if (!empty($opts['settings'][$settings_key]['path']) && '/' == substr($opts['settings'][$settings_key]['path'], 0, 1)) {
$opts['settings'][$settings_key]['path'] = substr($opts['settings'][$settings_key]['path'], 1);
}
if (isset($settings[ $key ]['rrs'])) { // premium settings
$opts['settings'][$settings_key]['rrs'] = $settings[ $key ]['rrs'];
$opts['settings'][$settings_key]['server_side_encryption'] = $settings[ $key ]['server_side_encryption'];
}
} else {
// $opts['accesskey'] = $settings[ $key ]['accesskey'];
// $opts['secretkey'] = $settings[ $key ]['secretkey'];
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
if (!empty($opts['path']) && '/' == substr($opts['path'], 0, 1)) {
$opts['path'] = substr($opts['path'], 1);
}
if (isset($settings[ $key ]['rrs'])) { // premium settings
$opts['rrs'] = $settings[ $key ]['rrs'];
$opts['server_side_encryption'] = $settings[ $key ]['server_side_encryption'];
}
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else if ( 'updraft_s3generic' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3generic' );
$opts['endpoint'] = $settings[ $key ]['endpoint'];
$opts['accesskey'] = $settings[ $key ]['accesskey'];
$opts['secretkey'] = $settings[ $key ]['secretkey'];
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
// $opts['settings'][$settings_key]['endpoint'] = $settings[ $key ]['endpoint'];
// $opts['settings'][$settings_key]['accesskey'] = $settings[ $key ]['accesskey'];
// $opts['settings'][$settings_key]['secretkey'] = $settings[ $key ]['secretkey'];
$opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']);
} else {
// $opts['endpoint'] = $settings[ $key ]['endpoint'];
// $opts['accesskey'] = $settings[ $key ]['accesskey'];
// $opts['secretkey'] = $settings[ $key ]['secretkey'];
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else if ( 'updraft_ftp' === $key ) {
$opts = $settings[ $key ];
if ( isset( $opts['path'] ) ) {
$opts['path'] = $this->replace_tokens( $opts['path'] );
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else if ( 'updraft_sftp_settings' === $key ) {
$opts = $settings[ $key ];
if ( isset( $opts['path'] ) ) {
$opts['path'] = $this->replace_tokens( $opts['path'] );
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else {
} else if ( 'updraft_dreamobjects' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dreamobjects' );
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
$opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']);
} else {
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else if ( 'updraft_ftp' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_ftp' );
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
if ( isset( $settings[ $key ]['path'] ) ) {
$opts['settings'][$settings_key]['host'] = $settings[ $key ]['host'];
$opts['settings'][$settings_key]['user'] = $settings[ $key ]['user'];
$opts['settings'][$settings_key]['pass'] = $settings[ $key ]['pass'];
$opts['settings'][$settings_key]['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
$opts['settings'][$settings_key]['passive'] = isset($settings[ $key ]['passive']) ? $settings[ $key ]['passive'] : 0;
}
} else {
if ( isset( $settings[ $key ]['path'] ) ) {
$opts['host'] = $settings[ $key ]['host'];
$opts['user'] = $settings[ $key ]['user'];
$opts['pass'] = $settings[ $key ]['pass'];
$opts['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
$opts['passive'] = isset($settings[ $key ]['passive']) ? $settings[ $key ]['passive'] : 0;
}
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} else if ( 'updraft_sftp_settings' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_sftp' );
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
if ( isset( $settings[ $key ]['path'] ) ) {
$opts['settings'][$settings_key]['host'] = $settings[ $key ]['host'];
$opts['settings'][$settings_key]['port'] = $settings[ $key ]['port'];
$opts['settings'][$settings_key]['user'] = $settings[ $key ]['user'];
$opts['settings'][$settings_key]['pass'] = $settings[ $key ]['pass'];
$opts['settings'][$settings_key]['key'] = $settings[ $key ]['key'];
$opts['settings'][$settings_key]['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
$opts['settings'][$settings_key]['scp'] = isset($settings[ $key ]['scp']) ? $settings[ $key ]['scp'] : 0;
}
} else {
if ( isset( $settings[ $key ]['path'] ) ) {
$opts['host'] = $settings[ $key ]['host'];
$opts['port'] = $settings[ $key ]['port'];
$opts['user'] = $settings[ $key ]['user'];
$opts['pass'] = $settings[ $key ]['pass'];
$opts['key'] = $settings[ $key ]['key'];
$opts['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
$opts['scp'] = isset($settings[ $key ]['scp']) ? $settings[ $key ]['scp'] : 0;
}
}
UpdraftPlus_Options::update_updraft_option( 'updraft_sftp', $opts );
} else {
UpdraftPlus_Options::update_updraft_option( $key, $settings[ $key ] );
}
$updated = true;
@ -479,37 +589,27 @@ class MainWP_Child_Updraft_Plus_Backups {
$out['result'] = 'noupdate';
}
// $sync_updraft_status = array();
// if ($updraftplus)
// $sync_updraft_status['updraft_backup_history'] = $updraftplus->get_backup_history();
//
// if (class_exists('UpdraftPlus_Options')) {
// $sync_updraft_status['updraft_last_backup'] = UpdraftPlus_Options::get_updraft_option('updraft_last_backup');
// }
//
// $out['sync_updraft_status'] = $sync_updraft_status;
return $out;
}
function replace_tokens($str = '') {
if (stripos($str, '%sitename%') !== false) {
$replace_token = get_bloginfo( 'name' );
$replace_token = sanitize_file_name($replace_token);
$replace_token = strtolower($replace_token);
$str = str_ireplace("%sitename%", $replace_token, $str);
}
function replace_tokens($str = '') {
if (stripos($str, '%sitename%') !== false) {
$replace_token = get_bloginfo( 'name' );
$replace_token = sanitize_file_name($replace_token);
$replace_token = strtolower($replace_token);
$str = str_ireplace("%sitename%", $replace_token, $str);
}
if (stripos($str, '%siteurl%') !== false) {
$replace_token = get_bloginfo( 'url' );
$replace_token = preg_replace('/^https?:\/\//i', '', $replace_token);
$replace_token = sanitize_file_name($replace_token);
$str = str_ireplace("%siteurl%", $replace_token, $str);
}
return $str;
}
if (stripos($str, '%siteurl%') !== false) {
$replace_token = get_bloginfo( 'url' );
$replace_token = preg_replace('/^https?:\/\//i', '', $replace_token);
$replace_token = sanitize_file_name($replace_token);
$str = str_ireplace("%siteurl%", $replace_token, $str);
}
return $str;
}
function addons_connect() {
function addons_connect() {
if ( ! defined( 'UDADDONS2_SLUG' ) ) {
return array( 'error' => 'NO_PREMIUM' );
}
@ -1383,7 +1483,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$mess = array();
parse_str( $_POST['restoreopts'], $res );
if ( isset( $res['updraft_restore'] ) ) {
if ( isset( $res['updraft_restore'] ) ) {
set_error_handler( array( $this, 'get_php_errors' ), E_ALL & ~E_STRICT );
$elements = array_flip( $res['updraft_restore'] );

View file

@ -25,6 +25,12 @@ class MainWP_Child_Wordfence {
'loginSec_blockAdminReg',
'loginSec_countFailMins',
'loginSec_disableAuthorScan',
'notification_updatesNeeded',
"notification_securityAlerts",
"notification_promotions",
"notification_blogHighlights",
"notification_productUpdates",
"notification_scanStatus",
'loginSec_lockInvalidUsers',
'loginSec_lockoutMins',
'loginSec_maskLoginErrors',
@ -44,8 +50,9 @@ class MainWP_Child_Wordfence {
'scansEnabled_diskSpace',
'scansEnabled_dns',
'scansEnabled_fileContents',
'scansEnabled_fileContentsGSB',
'scan_include_extra',
'scansEnabled_heartbleed',
//'scansEnabled_heartbleed',
'scansEnabled_checkHowGetIPs',
'scansEnabled_highSense',
'lowResourceScansEnabled',
@ -100,9 +107,10 @@ class MainWP_Child_Wordfence {
'disableCodeExecutionUploads',
//'isPaid',
"advancedCommentScanning",
"scansEnabled_checkGSB",
"checkSpamIP",
"spamvertizeCheck",
'scansEnabled_public',
//'scansEnabled_public',
'email_summary_enabled',
'email_summary_dashboard_widget_enabled',
'ssl_verify',
@ -110,9 +118,10 @@ class MainWP_Child_Wordfence {
'email_summary_excluded_directories',
'allowed404s',
'wafAlertWhitelist',
'wafAlertOnAttacks'
//'ajaxWatcherDisabled_front', // do not update those values when save settings
//'ajaxWatcherDisabled_admin'
'wafAlertOnAttacks',
//'ajaxWatcherDisabled_front', // do not update those values when save settings
//'ajaxWatcherDisabled_admin'
'howGetIPs_trusted_proxies',
);
public static $diagnosticParams = array(
@ -264,69 +273,72 @@ class MainWP_Child_Wordfence {
case 'update_waf_rules':
$information = $this->updateWAFRules();
break;
case 'save_debugging_config':
case 'save_debugging_config':
$information = $this->save_debugging_config();
break;
case 'load_live_traffic':
$information = $this->loadLiveTraffic();
break;
case 'white_list_waf':
$information = $this->whitelistWAFParamKey();
break;
case 'hide_file_htaccess':
$information = $this->hideFileHtaccess();
break;
case 'fix_fpd':
$information = $this->fixFPD();
break;
case 'disable_directory_listing':
$information = $this->disableDirectoryListing();
break;
case 'delete_database_option':
$information = $this->deleteDatabaseOption();
break;
case 'delete_admin_user':
$information = $this->deleteAdminUser();
break;
case 'revoke_admin_user':
$information = $this->revokeAdminUser();
break;
case 'clear_all_blocked':
$information = $this->clearAllBlocked();
break;
case 'permanently_block_all_ips':
$information = $this->permanentlyBlockAllIPs();
break;
case 'unlockout_ip':
$information = $this->unlockOutIP();
break;
case 'unblock_range':
$information = $this->unblockRange();
break;
case 'block_ip_ua_range':
$information = $this->blockIPUARange();
break;
case 'load_block_ranges':
$information = $this->loadBlockRanges();
break;
case 'save_waf_config':
$information = $this->saveWAFConfig();
break;
case 'whitelist_bulk_delete':
$information = $this->whitelistBulkDelete();
break;
case 'whitelist_bulk_enable':
$information = $this->whitelistBulkEnable();
break;
case 'whitelist_bulk_disable':
$information = $this->whitelistBulkDisable();
break;
case 'update_config':
$information = $this->updateConfig();
break;
case 'save_country_blocking':
$information = $this->saveCountryBlocking();
break;
case 'load_live_traffic':
$information = $this->loadLiveTraffic();
break;
case 'white_list_waf':
$information = $this->whitelistWAFParamKey();
break;
case 'hide_file_htaccess':
$information = $this->hideFileHtaccess();
break;
case 'fix_fpd':
$information = $this->fixFPD();
break;
case 'disable_directory_listing':
$information = $this->disableDirectoryListing();
break;
case 'delete_database_option':
$information = $this->deleteDatabaseOption();
break;
case 'misconfigured_howget_ips_choice':
$information = $this->misconfiguredHowGetIPsChoice();
break;
case 'delete_admin_user':
$information = $this->deleteAdminUser();
break;
case 'revoke_admin_user':
$information = $this->revokeAdminUser();
break;
case 'clear_all_blocked':
$information = $this->clearAllBlocked();
break;
case 'permanently_block_all_ips':
$information = $this->permanentlyBlockAllIPs();
break;
case 'unlockout_ip':
$information = $this->unlockOutIP();
break;
case 'unblock_range':
$information = $this->unblockRange();
break;
case 'block_ip_ua_range':
$information = $this->blockIPUARange();
break;
case 'load_block_ranges':
$information = $this->loadBlockRanges();
break;
case 'save_waf_config':
$information = $this->saveWAFConfig();
break;
case 'whitelist_bulk_delete':
$information = $this->whitelistBulkDelete();
break;
case 'whitelist_bulk_enable':
$information = $this->whitelistBulkEnable();
break;
case 'whitelist_bulk_disable':
$information = $this->whitelistBulkDisable();
break;
case 'update_config':
$information = $this->updateConfig();
break;
case 'save_country_blocking':
$information = $this->saveCountryBlocking();
break;
}
}
MainWP_Helper::write( $information );
@ -356,7 +368,7 @@ class MainWP_Child_Wordfence {
function set_showhide() {
$hide = isset( $_POST['showhide'] ) && ( $_POST['showhide'] === 'hide' ) ? 'hide' : '';
MainWP_Helper::update_option( 'mainwp_wordfence_hide_plugin', $hide );
MainWP_Helper::update_option( 'mainwp_wordfence_hide_plugin', $hide, 'yes' );
$information['result'] = 'SUCCESS';
return $information;
@ -1039,12 +1051,17 @@ SQL
return $return;
}
public static function deleteDatabaseOption() {
public static function deleteDatabaseOption() {
$return = wordfence::ajax_deleteDatabaseOption_callback();
return $return;
}
}
public static function misconfiguredHowGetIPsChoice() {
$return = wordfence::ajax_misconfiguredHowGetIPsChoice_callback();
return $return;
}
public static function deleteAdminUser() {
public static function deleteAdminUser() {
$return = wordfence::ajax_deleteAdminUser_callback();
return $return;
}
@ -1884,7 +1901,7 @@ SQL
return array('ok' => 1, 'isPaid' => $isPaid );
}
public static function save_debugging_config() {
public static function save_debugging_config() {
$settings = $_POST['settings'];
foreach (self::$diagnosticParams as $param) {
if (isset($settings[$param])) {

View file

@ -20,7 +20,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
$skeleton_keyuse_nonce_hmac = $_GET['skeleton_keyuse_nonce_hmac'];
$skeleton_keycurrent_time = intval( time() );
if ( $skeleton_keyuse_nonce_key >= $skeleton_keycurrent_time && $skeleton_keyuse_nonce_key <= ( $skeleton_keycurrent_time + 30 ) ) {
if ( $skeleton_keycurrent_time >= $skeleton_keyuse_nonce_key && $skeleton_keycurrent_time <= ( $skeleton_keyuse_nonce_key + 30 ) ) {
if ( strcmp( $skeleton_keyuse_nonce_hmac, hash_hmac( 'sha256', $skeleton_keyuse_nonce_key, NONCE_KEY ) ) === 0 ) {
@ -84,7 +84,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
}
class MainWP_Child {
public static $version = '3.4.2';
public static $version = '3.4.3';
private $update_version = '1.3';
private $callableFunctions = array(
@ -174,8 +174,8 @@ class MainWP_Child {
public function __construct( $plugin_file ) {
$this->update();
$this->filterFunction = create_function( '$a', 'if ($a == null) { return false; } return $a;' );
$this->load_all_options();
$this->filterFunction = create_function( '$a', 'if ($a == null) { return false; } if (is_object($a) && property_exists($a, "last_checked") && !property_exists($a, "checked")) return false; return $a;' );
$this->plugin_dir = dirname( $plugin_file );
$this->plugin_slug = plugin_basename( $plugin_file );
list ( $t1, $t2 ) = explode( '/', $this->plugin_slug );
@ -229,6 +229,85 @@ class MainWP_Child {
}
function load_all_options() {
global $wpdb;
if ( !defined( 'WP_INSTALLING' ) || !is_multisite() )
$alloptions = wp_cache_get( 'alloptions', 'options' );
else
$alloptions = false;
if ( !defined( 'WP_INSTALLING' ) || !is_multisite() )
$notoptions = wp_cache_get( 'notoptions', 'options' );
else
$notoptions = false;
if ( !isset($alloptions['mainwp_db_version']) ) {
$suppress = $wpdb->suppress_errors();
$options = array(
'mainwp_child_auth',
'mainwp_branding_plugin_header',
'mainwp_child_reports_db',
'mainwp_child_fix_htaccess',
'mainwp_child_pluginDir',
'mainwp_updraftplus_hide_plugin',
'mainwp_backwpup_ext_enabled',
'mainwpKeywordLinks',
'mainwp_child_server',
'mainwp_kwl_options',
'mainwp_kwl_keyword_links',
'mainwp_keyword_links_htaccess_set',
'mainwp_pagespeed_hide_plugin',
'mainwp_kwl_enable_statistic',
'mainwp_child_clone_permalink',
'mainwp_child_restore_permalink',
'mainwp_ext_snippets_enabled',
'mainwp_child_pubkey',
'mainwp_child_nossl',
'mainwp_security',
'mainwp_backupwordpress_ext_enabled',
'mainwp_wprocket_ext_enabled',
'mainwp_wordfence_ext_enabled',
'mainwp_branding_button_contact_label',
'mainwp_branding_extra_settings',
'mainwp_branding_child_hide',
'mainwp_branding_ext_enabled',
'mainwp_creport_ext_branding_enabled',
'mainwp_pagespeed_ext_enabled',
'mainwp_linkschecker_ext_enabled',
'mainwp_ithemes_ext_enabled',
);
$query = "SELECT option_name, option_value FROM $wpdb->options WHERE option_name in (";
foreach ($options as $option) {
$query .= "'" . $option . "', ";
}
$query = substr($query, 0, strlen($query) - 2);
$query .= ")";
$alloptions_db = $wpdb->get_results( $query );
$wpdb->suppress_errors($suppress);
if ( !is_array( $alloptions ) ) $alloptions = array();
if ( is_array( $alloptions_db ) ) {
foreach ( (array) $alloptions_db as $o ) {
$alloptions[ $o->option_name ] = $o->option_value;
unset($options[array_search($o->option_name, $options)]);
}
foreach ($options as $option ) {
$notoptions[ $option ] = true;
}
if ( ! defined( 'WP_INSTALLING' ) || ! is_multisite() ) {
wp_cache_set( 'alloptions', $alloptions, 'options' );
wp_cache_set( 'notoptions', $notoptions, 'options' );
}
}
}
return $alloptions;
}
function update() {
$update_version = get_option( 'mainwp_child_update_version' );
@ -2132,15 +2211,22 @@ class MainWP_Child {
}
$res = MainWP_Helper::createPost( $new_post, $post_custom, $post_category, $post_featured_image, $upload_dir, $post_tags );
if (is_array($res) && isset($res['error'])) {
MainWP_Helper::error( $res['error'] );
}
$created = $res['success'];
if ( true !== $created ) {
MainWP_Helper::error( $created );
MainWP_Helper::error( 'Undefined error' );
}
$information['added'] = true;
$information['added_id'] = $res['added_id'];
$information['link'] = $res['link'];
do_action('mainwp_child_after_newpost', $res);
MainWP_Helper::write( $information );
}
@ -2257,7 +2343,7 @@ class MainWP_Child {
'is_sticky' => is_sticky( $id ) ? 1 : 0,
'post_title' => $post->post_title,
'post_content' => $post->post_content,
'post_status' => $post->post_status, //was 'publish'
'post_status' => $post->post_status,
'post_date' => $post->post_date,
'post_date_gmt' => $post->post_date_gmt,
'post_tags' => $post_tags,
@ -2272,6 +2358,9 @@ class MainWP_Child {
$post_featured_image = $img[0];
}
require_once ABSPATH . 'wp-admin/includes/post.php';
wp_set_post_lock($id);
$post_data = array(
'new_post' => base64_encode( serialize( $new_post ) ),
'post_custom' => base64_encode( serialize( $post_custom ) ),
@ -2335,6 +2424,9 @@ class MainWP_Child {
}
}
require_once ABSPATH . 'wp-admin/includes/post.php';
wp_set_post_lock($id);
$post_data = array(
'new_post' => base64_encode( serialize( $new_post ) ),
'post_custom' => base64_encode( serialize( $post_custom ) ),
@ -3268,6 +3360,7 @@ class MainWP_Child {
$information['version'] = self::$version;
$information['wpversion'] = $wp_version;
$information['siteurl'] = get_option( 'siteurl' );
$information['wpe'] = function_exists( 'is_wpe' ) ? 1 : 0;
$information['site_info'] = array(
'wpversion' => $wp_version,
@ -3548,6 +3641,12 @@ class MainWP_Child {
}
}
if ( isset( $othersData['syncBackupBuddy'] ) && !empty( $othersData['syncBackupBuddy'] ) ) {
if ( MainWP_Child_Back_Up_Buddy::Instance()->is_backupbuddy_installed ) {
$information['syncBackupBuddy'] = MainWP_Child_Back_Up_Buddy::Instance()->get_sync_data();
}
}
if ( isset( $othersData['syncWPRocketData'] ) && ( 'yes' === $othersData['syncWPRocketData'] ) ) {
$data = array();
if ( MainWP_Child_WP_Rocket::isActivated() ) {
@ -3782,8 +3881,23 @@ class MainWP_Child {
$args['numberposts'] = $pCount;
}
$wp_seo_enabled = false;
if ( isset( $_POST['WPSEOEnabled'] ) && $_POST['WPSEOEnabled']) {
if (is_plugin_active('wordpress-seo/wp-seo.php') && class_exists('WPSEO_Link_Column_Count')) {
$wp_seo_enabled = true;
}
}
$posts = get_posts( $args );
if ( is_array( $posts ) ) {
if ($wp_seo_enabled) {
$post_ids = array();
foreach ( $posts as $post ) {
$post_ids[] = $post->ID;
}
$link_count = new WPSEO_Link_Column_Count();
$link_count->set( $post_ids );
}
foreach ( $posts as $post ) {
$outPost = array();
$outPost['id'] = $post->ID;
@ -3832,6 +3946,17 @@ class MainWP_Child {
$outPost['[post.website.name]'] = get_bloginfo( 'name' );
}
}
if ($wp_seo_enabled) {
$post_id = $post->ID;
$outPost['seo_data'] = array(
'count_seo_links' => $link_count->get( $post_id, 'internal_link_count' ),
'count_seo_linked' => $link_count->get( $post_id, 'incoming_link_count' ),
'seo_score' => MainWP_Wordpress_SEO::Instance()->parse_column_score($post_id),
'readability_score' => MainWP_Wordpress_SEO::Instance()->parse_column_score_readability($post_id),
);
}
$allPosts[] = $outPost;
}
}
@ -4049,6 +4174,10 @@ class MainWP_Child {
$this->posts_where_suffix .= " AND $wpdb->posts.post_modified < '" . $_POST['dtsstop'] . "'";
}
}
if ( isset( $_POST['exclude_page_type'] ) && $_POST['exclude_page_type'] ) {
$this->posts_where_suffix .= " AND $wpdb->posts.post_type NOT IN ('page')";
}
}
$maxPages = MAINWP_CHILD_NR_OF_PAGES;
@ -4520,6 +4649,7 @@ class MainWP_Child {
global $wp_version;
$information['version'] = self::$version;
$information['wpversion'] = $wp_version;
$information['wpe'] = function_exists( 'is_wpe' ) ? 1 : 0;
MainWP_Helper::write( $information );
}

View file

@ -14,7 +14,7 @@ class MainWP_Client_Report {
public static function init() {
add_filter( 'wp_stream_connectors', array( 'MainWP_Client_Report', 'init_stream_connectors' ), 10, 1 );
add_filter( 'mainwp_client_reports_connectors', array( 'MainWP_Client_Report', 'init_report_connectors' ), 10, 1 );
add_action( 'mainwp_child_log', array( 'MainWP_Client_Report', 'do_reports_log' ) );
add_action( 'mainwp_child_log', array( 'MainWP_Client_Report', 'do_reports_log' ) );
}
public static function init_stream_connectors( $classes ) {
@ -57,28 +57,31 @@ class MainWP_Client_Report {
return $classes;
}
public static function do_reports_log( $ext = '' ) {
switch( $ext ) {
case 'backupbuddy':
MainWP_Child_Back_Up_Buddy::Instance()->do_reports_log( $ext );
break;
case 'backupwordpress':
MainWP_Child_Back_Up_Wordpress::Instance()->do_reports_log( $ext );
break;
case 'backwpup':
MainWP_Child_Back_WP_Up::Instance()->do_reports_log( $ext );
break;
case 'wordfence':
MainWP_Child_Wordfence::Instance()->do_reports_log( $ext );
break;
}
}
public static function do_reports_log( $ext = '' ) {
switch( $ext ) {
case 'backupbuddy':
MainWP_Child_Back_Up_Buddy::Instance()->do_reports_log( $ext );
break;
case 'backupwordpress':
MainWP_Child_Back_Up_Wordpress::Instance()->do_reports_log( $ext );
break;
case 'backwpup':
MainWP_Child_Back_WP_Up::Instance()->do_reports_log( $ext );
break;
case 'wordfence':
MainWP_Child_Wordfence::Instance()->do_reports_log( $ext );
break;
// case 'wptimecapsule':
// MainWP_Child_WP_Time_Capsule::Instance()->do_reports_log( $ext );
// break;
}
}
public function action() {
$information = array();
if ( !function_exists( 'mainwp_wp_stream_query' ) || !class_exists( 'MainWP_WP_Stream' ) ) {
if ( !function_exists( 'mainwp_wp_stream_query' ) || !class_exists( 'MainWP_WP_Stream' ) ) {
$information['error'] = 'NO_CREPORT';
MainWP_Helper::write( $information );
}
@ -149,7 +152,7 @@ class MainWP_Client_Report {
$args = array();
foreach ( $allowed_params as $param ) {
$paramval = mainwp_wp_stream_filter_input( INPUT_POST, $param );
$paramval = mainwp_wp_stream_filter_input( INPUT_POST, $param );
if ( $paramval || '0' === $paramval ) {
$args[ $param ] = $paramval;
}
@ -227,22 +230,22 @@ class MainWP_Client_Report {
$args['action__not_in'] = array( 'login' );
$args['fields'] = 'with-meta';
if ( isset( $args['date_from'] ) ) {
$args['date_from'] = date( 'Y-m-d H:i:s', $args['date_from'] );
}
$args['fields'] = 'with-meta';
if ( isset( $args['date_from'] ) ) {
$args['date_from'] = date( 'Y-m-d H:i:s', $args['date_from'] );
}
if ( isset( $args['date_to'] ) ) {
$args['date_to'] = date( 'Y-m-d H:i:s', $args['date_to'] );
}
if ( isset( $args['date_to'] ) ) {
$args['date_to'] = date( 'Y-m-d H:i:s', $args['date_to'] );
}
if ( MainWP_Child_Branding::is_branding() ) {
$args['hide_child_reports'] = 1;
}
if ( MainWP_Child_Branding::is_branding() ) {
$args['hide_child_reports'] = 1;
}
$args['records_per_page'] = 9999;
$records = mainwp_wp_stream_query( $args );
$records = mainwp_wp_stream_query( $args );
if ( ! is_array( $records ) ) {
$records = array();
@ -251,8 +254,8 @@ class MainWP_Client_Report {
//return $records;
//$other_tokens_data = $this->get_other_tokens_data($records, $other_tokens);
// to fix invalid data
$skip_records = array();
// to fix invalid data
$skip_records = array();
if ( isset( $other_tokens['header'] ) && is_array( $other_tokens['header'] ) ) {
$other_tokens_data['header'] = $this->get_other_tokens_data( $records, $other_tokens['header'], $skip_records);
}
@ -403,21 +406,21 @@ class MainWP_Client_Report {
continue;
}
} else if ( 'updated' === $action && ('themes' === $context || 'plugins' === $context)) {
$name = $this->get_stream_meta_data( $record, 'name' );
if ( empty($name) ) { // to fix empty value
if (!in_array($record->ID, $skip_records))
$skip_records[] = $record->ID;
continue;
} else {
$old_version = $this->get_stream_meta_data( $record, 'old_version' );
$version = $this->get_stream_meta_data( $record, 'version' );
if (version_compare($version, $old_version, '<=')) { // to fix
if (!in_array($record->ID, $skip_records))
$skip_records[] = $record->ID;
continue;
}
}
}
$name = $this->get_stream_meta_data( $record, 'name' );
if ( empty($name) ) { // to fix empty value
if (!in_array($record->ID, $skip_records))
$skip_records[] = $record->ID;
continue;
} else {
$old_version = $this->get_stream_meta_data( $record, 'old_version' );
$version = $this->get_stream_meta_data( $record, 'version' );
if (version_compare($version, $old_version, '<=')) { // to fix
if (!in_array($record->ID, $skip_records))
$skip_records[] = $record->ID;
continue;
}
}
}
}
@ -457,13 +460,13 @@ class MainWP_Client_Report {
);
$some_allowed_data = array(
'ID',
'ID',
'name',
'title',
'oldversion',
'currentversion',
'date',
'time',
'time',
'count',
'author',
'old.version',
@ -488,9 +491,9 @@ class MainWP_Client_Report {
$loop_count = 0;
foreach ( $records as $record ) {
if (in_array($record->ID, $skip_records)) {
continue;
}
if (in_array($record->ID, $skip_records)) {
continue;
}
$theme_edited = $users_updated = $plugin_edited = false;
@ -509,7 +512,7 @@ class MainWP_Client_Report {
$users_updated = true;
}
} 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;
}
} else if ( 'mainwp_sucuri' === $context ) {
@ -517,14 +520,14 @@ class MainWP_Client_Report {
continue;
}
} else if ( 'wordfence' === $context ) {
if ( $record->context !== 'wordfence_scans' ) {
continue;
}
} else if ( 'maintenance' === $context ) {
if ( $record->context !== 'mainwp_maintenances' ) {
continue;
}
} else {
if ( $record->context !== 'wordfence_scans' ) {
continue;
}
} else if ( 'maintenance' === $context ) {
if ( $record->context !== 'mainwp_maintenances' ) {
continue;
}
} else {
if ( $action !== $record->action ) {
continue;
}
@ -538,8 +541,8 @@ class MainWP_Client_Report {
} else if ( 'menus' === $context && 'menus' !== $record->connector ) {
continue;
}
// else if ($context === "themes" && $record->connector !== "themes")
// continue;
// else if ($context === "themes" && $record->connector !== "themes")
// continue;
if ( 'comments' !== $context && 'media' !== $context &&
'widgets' !== $context && 'menus' !== $context &&
@ -588,15 +591,15 @@ class MainWP_Client_Report {
}
switch ( $data ) {
case 'ID':
case 'ID':
$token_values[ $token ] = $record->ID;
break;
case 'date':
$token_values[ $token ] = MainWP_Helper::formatDate( MainWP_Helper::getTimestamp( strtotime( $record->created ) ) );
break;
case 'time':
$token_values[ $token ] = MainWP_Helper::formatTime( MainWP_Helper::getTimestamp( strtotime( $record->created ) ) );
break;
case 'time':
$token_values[ $token ] = MainWP_Helper::formatTime( MainWP_Helper::getTimestamp( strtotime( $record->created ) ) );
break;
case 'area':
$data = 'sidebar_name';
$token_values[ $token ] = $this->get_stream_meta_data( $record, $data );
@ -626,7 +629,7 @@ class MainWP_Client_Report {
}
$token_values[ $token ] = $roles;
} else {
$token_values[ $token ] = $this->get_stream_meta_data( $record, $data );
$token_values[ $token ] = $this->get_stream_meta_data( $record, $data );
}
break;
case 'title':
@ -657,10 +660,10 @@ class MainWP_Client_Report {
$token_values[ $token ] = $value;
}
break;
case 'details':
case 'result':
case 'details':
case 'result':
if ( 'wordfence' === $context || 'maintenance' === $context ) {
$token_values[ $token ] = $this->get_stream_meta_data( $record, $data );
$token_values[ $token ] = $this->get_stream_meta_data( $record, $data );
}
break;
case 'destination': // backup cases
@ -691,7 +694,7 @@ class MainWP_Client_Report {
return '';
}
$meta_key = $data;
$meta_key = $data;
$value = '';
@ -699,7 +702,7 @@ class MainWP_Client_Report {
$meta = $record->meta;
if ( isset( $meta[ $meta_key ] ) ) {
$value = $meta[ $meta_key ];
$value = current( $value );
$value = current( $value );
if ( 'author_meta' === $meta_key || 'user_meta' === $meta_key ) {
$value = maybe_unserialize( $value );
$value = $value['display_name'];
@ -713,7 +716,7 @@ class MainWP_Client_Report {
function set_showhide() {
MainWP_Helper::update_option( 'mainwp_creport_ext_branding_enabled', 'Y', 'yes' );
$hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
MainWP_Helper::update_option( 'mainwp_creport_branding_stream_hide', $hide );
MainWP_Helper::update_option( 'mainwp_creport_branding_stream_hide', $hide, 'yes' );
$information['result'] = 'SUCCESS';
return $information;

View file

@ -125,15 +125,15 @@ class MainWP_Helper {
if (!is_array($img_data))
$img_data = array();
include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url
$upload_dir = wp_upload_dir();
$upload_dir = wp_upload_dir();
if ($check_file_existed) {
$local_img_url = $upload_dir['url'] . '/' . basename( $img_url );
$attach_id = MainWP_Helper::get_image_id($local_img_url);
if ($attach_id) {
return array( 'id' => $attach_id, 'url' => $local_img_url );
}
}
if ($check_file_existed) {
$local_img_url = $upload_dir['url'] . '/' . basename( $img_url );
$attach_id = MainWP_Helper::get_image_id($local_img_url);
if ($attach_id) {
return array( 'id' => $attach_id, 'url' => $local_img_url );
}
}
//Download $img_url
$temporary_file = download_url( $img_url );
@ -169,11 +169,11 @@ class MainWP_Helper {
return null;
}
static function get_image_id($image_url) {
global $wpdb;
$attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url ));
return $attachment[0];
}
static function get_image_id($image_url) {
global $wpdb;
$attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url ));
return $attachment[0];
}
static function uploadFile( $file_url, $path, $file_name ) {
$file_name = sanitize_file_name( $file_name );
@ -279,18 +279,25 @@ class MainWP_Helper {
if ( isset( $new_post['post_date_gmt'] ) && ! empty( $new_post['post_date_gmt'] ) && $new_post['post_date_gmt'] != '0000-00-00 00:00:00' ) {
$post_date_timestamp = strtotime( $new_post['post_date_gmt'] ) + get_option( 'gmt_offset' ) * 60 * 60;
$new_post['post_date'] = date( 'Y-m-d H:i:s', $post_date_timestamp );
$new_post['post_status'] = ( $post_date_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future';
} else {
$new_post['post_status'] = 'publish';
//$new_post['post_status'] = ( $post_date_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future';
}
// else {
// $new_post['post_status'] = 'publish';
// }
}
$wpr_options = isset( $_POST['wpr_options'] ) ? $_POST['wpr_options'] : array();
$edit_post_id = 0;
if ( isset( $post_custom['_mainwp_edit_post_id'] ) && $post_custom['_mainwp_edit_post_id'] ) {
$edit_post_id = current($post_custom['_mainwp_edit_post_id']);
}
$edit_post_id = 0;
if ( isset( $post_custom['_mainwp_edit_post_id'] ) && $post_custom['_mainwp_edit_post_id'] ) {
$edit_post_id = current($post_custom['_mainwp_edit_post_id']);
require_once ABSPATH . 'wp-admin/includes/post.php';
if ( $user_id = wp_check_post_lock( $edit_post_id ) ) {
$user = get_userdata( $user_id );
$error = sprintf( __( 'This content is currently locked. %s is currently editing.' ), $user->display_name );
return array( 'error' => $error);
}
}
//Search for all the images added to the new post
//some images have a href tag to click to navigate to the image.. we need to replace this too
@ -314,12 +321,12 @@ class MainWP_Helper {
}
try {
// in the case edit post will check if file existed
if ( $edit_post_id ) {
$downloadfile = MainWP_Helper::uploadImage( $originalImgUrl , array(), true );
} else {
$downloadfile = MainWP_Helper::uploadImage( $originalImgUrl );
}
// in the case edit post will check if file existed
if ( $edit_post_id ) {
$downloadfile = MainWP_Helper::uploadImage( $originalImgUrl , array(), true );
} else {
$downloadfile = MainWP_Helper::uploadImage( $originalImgUrl );
}
$localUrl = $downloadfile['url'];
$linkToReplaceWith = dirname( $localUrl );
@ -419,8 +426,8 @@ class MainWP_Helper {
}
$random_timestamp = rand( $random_date_from, $random_date_to );
$post_status = ( $random_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future';
$new_post['post_status'] = $post_status;
// $post_status = ( $random_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future';
// $new_post['post_status'] = $post_status;
$new_post['post_date'] = date( 'Y-m-d H:i:s', $random_timestamp );
}
}
@ -434,14 +441,14 @@ class MainWP_Helper {
$post_status = $new_post['post_status'];
$new_post['post_status'] = 'auto-draft';
// update post
if ( $edit_post_id ) {
// check if post existed
$current_post = get_post($edit_post_id);
if ( $current_post && ( ( !isset( $new_post['post_type'] ) && $current_post->post_type == 'post' ) || ( isset( $new_post['post_type'] ) && $new_post['post_type'] == $current_post->post_type ) ) ) {
$new_post['ID'] = $edit_post_id;
}
}
// update post
if ( $edit_post_id ) {
// check if post existed
$current_post = get_post($edit_post_id);
if ( $current_post && ( ( !isset( $new_post['post_type'] ) && $current_post->post_type == 'post' ) || ( isset( $new_post['post_type'] ) && $new_post['post_type'] == $current_post->post_type ) ) ) {
$new_post['ID'] = $edit_post_id;
}
}
$new_post_id = wp_insert_post( $new_post, $wp_error );
@ -450,7 +457,7 @@ class MainWP_Helper {
return $wp_error->get_error_message();
}
if ( empty( $new_post_id ) ) {
return 'Undefined error';
return array( 'error' => 'Empty post id');
}
wp_update_post( array( 'ID' => $new_post_id, 'post_status' => $post_status ) );
@ -497,9 +504,9 @@ class MainWP_Helper {
$not_allowed[] = '_saved_draft_publish_date_to';
$not_allowed[] = '_post_to_only_existing_categories';
$not_allowed[] = '_mainwp_robot_post_comments';
$not_allowed[] = '_mainwp_edit_post_site_id';
$not_allowed[] = '_mainwp_edit_post_id';
$not_allowed[] = '_edit_post_status';
$not_allowed[] = '_mainwp_edit_post_site_id';
$not_allowed[] = '_mainwp_edit_post_id';
$not_allowed[] = '_edit_post_status';
$post_to_only_existing_categories = false;
foreach ( $post_custom as $meta_key => $meta_values ) {
@ -511,7 +518,7 @@ class MainWP_Helper {
if ( ! $seo_ext_activated ) {
// if Wordpress SEO plugin is not activated do not save yoast post meta
if ( strpos( $meta_key, '_yoast_wpseo_' ) === false ) {
update_post_meta( $new_post_id, $meta_key, $meta_value );
update_post_meta( $new_post_id, $meta_key, $meta_value );
}
} else {
update_post_meta( $new_post_id, $meta_key, $meta_value );
@ -575,7 +582,7 @@ class MainWP_Helper {
}
}
$featured_image_exist = false;
$featured_image_exist = false;
//If featured image exists - set it
if ( null !== $post_featured_image ) {
try {
@ -583,16 +590,16 @@ class MainWP_Helper {
if ( null !== $upload ) {
update_post_meta( $new_post_id, '_thumbnail_id', $upload['id'] ); //Add the thumbnail to the post!
$featured_image_exist = true;
$featured_image_exist = true;
}
} catch ( Exception $e ) {
}
}
if ( !$featured_image_exist ) {
delete_post_meta( $new_post_id, '_thumbnail_id' );
}
if ( !$featured_image_exist ) {
delete_post_meta( $new_post_id, '_thumbnail_id' );
}
// post plus extension process
if ( $is_post_plus ) {
@ -635,11 +642,11 @@ class MainWP_Helper {
}
// end of post plus
// to support custom post author
$custom_post_author = apply_filters('mainwp_create_post_custom_author', false, $new_post_id);
if ( !empty( $custom_post_author ) ) {
wp_update_post( array( 'ID' => $new_post_id, 'post_author' => $custom_post_author ) );
}
// to support custom post author
$custom_post_author = apply_filters('mainwp_create_post_custom_author', false, $new_post_id);
if ( !empty( $custom_post_author ) ) {
wp_update_post( array( 'ID' => $new_post_id, 'post_author' => $custom_post_author ) );
}
// MainWP Robot
if ( $is_robot_post ) {
@ -647,6 +654,11 @@ class MainWP_Helper {
MainWP_Child_Robot::Instance()->wpr_insertcomments( $new_post_id, $all_comments );
}
// unlock if edit post
if ($edit_post_id) {
update_post_meta( $edit_post_id, '_edit_lock', '' );
}
$ret['success'] = true;
$ret['link'] = $permalink;
$ret['added_id'] = $new_post_id;
@ -980,11 +992,11 @@ class MainWP_Helper {
return ( $gmtOffset ? ( $gmtOffset * HOUR_IN_SECONDS ) + $timestamp : $timestamp );
}
public static function formatDate( $timestamp ) {
public static function formatDate( $timestamp ) {
return date_i18n( get_option( 'date_format' ), $timestamp );
}
public static function formatTime( $timestamp ) {
public static function formatTime( $timestamp ) {
return date_i18n( get_option( 'time_format' ), $timestamp );
}
@ -998,14 +1010,14 @@ class MainWP_Helper {
<br>
<div style="background:#ffffff;padding:0 1.618em;font:13px/20px Helvetica,Arial,Sans-serif;padding-bottom:50px!important">
<div style="width:600px;background:#fff;margin-left:auto;margin-right:auto;margin-top:10px;margin-bottom:25px;padding:0!important;border:10px Solid #fff;border-radius:10px;overflow:hidden">
<div style="display: block; width: 100% ; background-image: url(http://mainwp.com/wp-content/uploads/2013/02/debut_light.png) ; background-repeat: repeat; border-bottom: 2px Solid #7fb100 ; overflow: hidden;">
<div style="display: block; width: 100% ; background-image: url(https://mainwp.com/wp-content/uploads/2013/02/debut_light.png) ; background-repeat: repeat; border-bottom: 2px Solid #7fb100 ; overflow: hidden;">
<div style="display: block; width: 95% ; margin-left: auto ; margin-right: auto ; padding: .5em 0 ;">
<div style="float: left;"><a href="http://mainwp.com"><img src="//mainwp.com/wp-content/uploads/2013/07/MainWP-Logo-1000-300x62.png" alt="MainWP" height="30"/></a></div>
<div style="float: left;"><a href="https://mainwp.com"><img src="https://mainwp.com/wp-content/uploads/2013/07/MainWP-Logo-1000-300x62.png" alt="MainWP" height="30"/></a></div>
<div style="float: right; margin-top: .6em ;">
<span style="display: inline-block; margin-right: .8em;"><a href="https://mainwp.com/mainwp-extensions/" style="font-family: Helvetica, Sans; color: #7fb100; text-transform: uppercase; font-size: 14px;">Extensions</a></span>
<span style="display: inline-block; margin-right: .8em;"><a style="font-family: Helvetica, Sans; color: #7fb100; text-transform: uppercase; font-size: 14px;" href="http://mainwp.com/forum">Support</a></span>
<span style="display: inline-block; margin-right: .8em;"><a style="font-family: Helvetica, Sans; color: #7fb100; text-transform: uppercase; font-size: 14px;" href="http://docs.mainwp.com">Documentation</a></span>
<span style="display: inline-block; margin-right: .5em;" class="mainwp-memebers-area"><a href="http://mainwp.com/member/login/index" style="padding: .6em .5em ; border-radius: 50px ; -moz-border-radius: 50px ; -webkit-border-radius: 50px ; background: #1c1d1b; border: 1px Solid #000; color: #fff !important; font-size: .9em !important; font-weight: normal ; -webkit-box-shadow: 0px 0px 0px 5px rgba(0, 0, 0, .1); box-shadow: 0px 0px 0px 5px rgba(0, 0, 0, .1);">Members Area</a></span>
<span style="display: inline-block; margin-right: .8em;"><a style="font-family: Helvetica, Sans; color: #7fb100; text-transform: uppercase; font-size: 14px;" href="https://mainwp.com/forum">Support</a></span>
<span style="display: inline-block; margin-right: .8em;"><a style="font-family: Helvetica, Sans; color: #7fb100; text-transform: uppercase; font-size: 14px;" href="https://docs.mainwp.com">Documentation</a></span>
<span style="display: inline-block; margin-right: .5em;" class="mainwp-memebers-area"><a href="https://mainwp.com/member/login/index" style="padding: .6em .5em ; border-radius: 50px ; -moz-border-radius: 50px ; -webkit-border-radius: 50px ; background: #1c1d1b; border: 1px Solid #000; color: #fff !important; font-size: .9em !important; font-weight: normal ; -webkit-box-shadow: 0px 0px 0px 5px rgba(0, 0, 0, .1); box-shadow: 0px 0px 0px 5px rgba(0, 0, 0, .1);">Members Area</a></span>
</div><div style="clear: both;"></div>
</div>
</div>
@ -1015,14 +1027,14 @@ class MainWP_Helper {
<div></div>
<br />
<div>MainWP</div>
<div><a href="http://www.MainWP.com" target="_blank">www.MainWP.com</a></div>
<div><a href="https://www.MainWP.com" target="_blank">www.MainWP.com</a></div>
<p></p>
</div>
<div style="display: block; width: 100% ; background: #1c1d1b;">
<div style="display: block; width: 95% ; margin-left: auto ; margin-right: auto ; padding: .5em 0 ;">
<div style="padding: .5em 0 ; float: left;"><p style="color: #fff; font-family: Helvetica, Sans; font-size: 12px ;">© 2013 MainWP. All Rights Reserved.</p></div>
<div style="float: right;"><a href="http://mainwp.com"><img src="//mainwp.com/wp-content/uploads/2013/07/MainWP-Icon-300.png" height="45"/></a></div><div style="clear: both;"></div>
<div style="float: right;"><a href="https://mainwp.com"><img src="https://mainwp.com/wp-content/uploads/2013/07/MainWP-Icon-300.png" height="45"/></a></div><div style="clear: both;"></div>
</div>
</div>
</div>
@ -1072,52 +1084,54 @@ class MainWP_Helper {
}
}
static function update_lasttime_backup( $by, $time ) {
$backup_by = array('backupbuddy', 'backupwordpress', 'backwpup', 'updraftplus');
static function update_lasttime_backup( $by, $time ) {
$backup_by = array('backupbuddy', 'backupwordpress', 'backwpup', 'updraftplus', 'wptimecapsule');
if (!in_array($by, $backup_by))
return false;
if (!in_array($by, $backup_by))
return false;
$lasttime = get_option('mainwp_lasttime_backup_' . $by);
if ( $time > $lasttime ) {
update_option('mainwp_lasttime_backup_' . $by, $time);
}
$lasttime = get_option('mainwp_lasttime_backup_' . $by);
if ( $time > $lasttime ) {
update_option('mainwp_lasttime_backup_' . $by, $time);
}
return true;
return true;
}
static function get_lasttime_backup( $by ) {
if ($by == 'backupwp') // to compatible
$by = 'backupwordpress';
$backup_by = array('backupbuddy', 'backupwordpress', 'backwpup', 'updraftplus');
switch($by) {
case 'backupbuddy':
if ( !is_plugin_active( 'backupbuddy/backupbuddy.php' )) {
return -1;
}
break;
case 'backupwordpress':
if ( !is_plugin_active( 'backupwordpress/backupwordpress.php' )) {
return -1;
}
break;
case 'backwpup':
if ( !is_plugin_active( 'backwpup/backwpup.php' ) && !is_plugin_active( 'backwpup-pro/backwpup.php' ) ) {
return -1;
}
break;
case 'updraftplus':
if ( !is_plugin_active( 'updraftplus/updraftplus.php' )) {
return -1;
}
break;
default:
return 0;
break;
}
return get_option('mainwp_lasttime_backup_' . $by, 0);
static function get_lasttime_backup( $by ) {
if ($by == 'backupwp') // to compatible
$by = 'backupwordpress';
switch($by) {
case 'backupbuddy':
if ( !is_plugin_active( 'backupbuddy/backupbuddy.php' ) && !is_plugin_active( 'Backupbuddy/backupbuddy.php' )) {
return -1;
}
break;
case 'backupwordpress':
if ( !is_plugin_active( 'backupwordpress/backupwordpress.php' )) {
return -1;
}
break;
case 'backwpup':
if ( !is_plugin_active( 'backwpup/backwpup.php' ) && !is_plugin_active( 'backwpup-pro/backwpup.php' ) ) {
return -1;
}
break;
case 'updraftplus':
if ( !is_plugin_active( 'updraftplus/updraftplus.php' )) {
return -1;
}
break;
case 'wptimecapsule':
if ( !is_plugin_active( 'wp-time-capsule/wp-time-capsule.php' )) {
return -1;
}
break;
default:
return 0;
break;
}
return get_option('mainwp_lasttime_backup_' . $by, 0);
}

View file

@ -53,7 +53,9 @@ class MainWP_Security {
$file = $directory . DIRECTORY_SEPARATOR . 'index.php';
if ( ! file_exists( $file ) ) {
$h = fopen( $file, 'w' );
fwrite( $h, '<?php die(); ?>' );
fwrite( $h, '<?php ' . "\n" );
fwrite( $h, "header(\$_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden' );" . "\n" );
fwrite( $h, "die( '403 Fordibben' );" . "\n" );
fclose( $h );
}
}

View file

@ -119,4 +119,42 @@ class MainWP_Wordpress_SEO {
return false;
}
// from wordpress-seo plugin
public function parse_column_score( $post_id ) {
if ( '1' === WPSEO_Meta::get_value( 'meta-robots-noindex', $post_id ) ) {
$rank = new WPSEO_Rank( WPSEO_Rank::NO_INDEX );
$title = __( 'Post is set to noindex.', 'wordpress-seo' );
WPSEO_Meta::set_value( 'linkdex', 0, $post_id );
}
elseif ( '' === WPSEO_Meta::get_value( 'focuskw', $post_id ) ) {
$rank = new WPSEO_Rank( WPSEO_Rank::NO_FOCUS );
$title = __( 'Focus keyword not set.', 'wordpress-seo' );
}
else {
$score = (int) WPSEO_Meta::get_value( 'linkdex', $post_id );
$rank = WPSEO_Rank::from_numeric_score( $score );
$title = $rank->get_label();
}
return $this->render_score_indicator( $rank, $title );
}
// from wordpress-seo plugin
public function parse_column_score_readability( $post_id ) {
$score = (int) WPSEO_Meta::get_value( 'content_score', $post_id );
$rank = WPSEO_Rank::from_numeric_score( $score );
return $this->render_score_indicator( $rank );
}
// from wordpress-seo plugin
private function render_score_indicator( $rank, $title = '' ) {
if ( empty( $title ) ) {
$title = $rank->get_label();
}
return '<div aria-hidden="true" title="' . esc_attr( $title ) . '" class="wpseo-score-icon ' . esc_attr( $rank->get_css_class() ) . '"></div><span class="screen-reader-text">' . $title . '</span>';
}
}

View file

@ -250,7 +250,7 @@ class Tar_Archiver {
'home' => get_option( 'home' ),
'abspath' => ABSPATH,
'prefix' => $wpdb->prefix,
'lang' => WPLANG,
'lang' => get_bloginfo("language"),
'plugins' => $plugins,
'themes' => $themes,
) ) );
@ -288,7 +288,7 @@ class Tar_Archiver {
}
$iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $path ), RecursiveIteratorIterator::SELF_FIRST,
RecursiveIteratorIterator::CATCH_GET_CHILD );
RecursiveIteratorIterator::CATCH_GET_CHILD );
if ( class_exists( 'ExampleSortedIterator' ) ) {
$iterator = new ExampleSortedIterator( $iterator );
@ -417,7 +417,7 @@ class Tar_Archiver {
'',
'',
'',
'' );
'' );
$checksum = 0;
for ( $i = 0; $i < 512; $i ++ ) {
@ -449,7 +449,7 @@ class Tar_Archiver {
'',
'',
$prefix,
'' );
'' );
$checksum = 0;
for ( $i = 0; $i < 512; $i ++ ) {
@ -548,7 +548,7 @@ class Tar_Archiver {
'',
'',
'',
'' );
'' );
$checksum = 0;
for ( $i = 0; $i < 512; $i ++ ) {
@ -584,7 +584,7 @@ class Tar_Archiver {
'',
'',
$prefix,
'' );
'' );
$checksum = 0;
for ( $i = 0; $i < 512; $i ++ ) {
@ -672,7 +672,7 @@ class Tar_Archiver {
'',
'',
'',
'' );
'' );
$checksum = 0;
for ( $i = 0; $i < 512; $i ++ ) {
@ -704,7 +704,7 @@ class Tar_Archiver {
'',
'',
$prefix,
'' );
'' );
$checksum = 0;
for ( $i = 0; $i < 512; $i ++ ) {

View file

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