Merge pull request #42 from mainwp/bogdan01-cf-autofix

Apply fixes from CodeFactor
This commit is contained in:
Bogdan Rapaić 2020-03-26 20:46:22 +01:00 committed by GitHub
commit 5cc164ad82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 882 additions and 882 deletions

View file

@ -380,7 +380,7 @@ class MainWP_Backup {
} }
$db_files = $this->createBackupDB( dirname( $filepath ) . DIRECTORY_SEPARATOR . 'dbBackup' ); $db_files = $this->createBackupDB( dirname( $filepath ) . DIRECTORY_SEPARATOR . 'dbBackup' );
$error = false; $error = false;
foreach ( $db_files as $db_file ) { foreach ( $db_files as $db_file ) {
if ( 0 === ( $rslt = $this->zip->add( $db_file, PCLZIP_OPT_REMOVE_PATH, dirname( $db_file ), PCLZIP_OPT_ADD_PATH, basename( WP_CONTENT_DIR ) ) ) ) { if ( 0 === ( $rslt = $this->zip->add( $db_file, PCLZIP_OPT_REMOVE_PATH, dirname( $db_file ), PCLZIP_OPT_ADD_PATH, basename( WP_CONTENT_DIR ) ) ) ) {
$error = true; $error = true;
@ -735,7 +735,7 @@ class MainWP_Backup {
$table = $curr_table[0]; $table = $curr_table[0];
$currentfile = $filepath_prefix . '-' . MainWP_Helper::sanitize_filename( $table ) . '.sql'; $currentfile = $filepath_prefix . '-' . MainWP_Helper::sanitize_filename( $table ) . '.sql';
$db_files[] = $currentfile; $db_files[] = $currentfile;
if ( file_exists( $currentfile ) ) { if ( file_exists( $currentfile ) ) {
continue; continue;
} }

View file

@ -16,8 +16,8 @@
*/ */
class MainWP_Child_Back_Up_Buddy { class MainWP_Child_Back_Up_Buddy {
public static $instance = null; public static $instance = null;
public $plugin_translate = 'mainwp-child'; public $plugin_translate = 'mainwp-child';
public $is_backupbuddy_installed = false; public $is_backupbuddy_installed = false;
static function Instance() { static function Instance() {
@ -176,7 +176,7 @@ class MainWP_Child_Back_Up_Buddy {
} }
$finish_time = $backup['finish_time']; $finish_time = $backup['finish_time'];
$message = 'BackupBuddy ' . $backupType . ' finished'; $message = 'BackupBuddy ' . $backupType . ' finished';
if ( ! empty($finish_time)) { if ( ! empty($finish_time)) {
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time); do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time);
} }
@ -196,8 +196,8 @@ class MainWP_Child_Back_Up_Buddy {
$resp = $state['stats']['last_remote_snapshot_response']; $resp = $state['stats']['last_remote_snapshot_response'];
if ( isset( $resp['success'] ) && $resp['success']) { if ( isset( $resp['success'] ) && $resp['success']) {
$finish_time = $state['stats']['last_remote_snapshot']; $finish_time = $state['stats']['last_remote_snapshot'];
$backupType = 'Live Backup to cloud'; $backupType = 'Live Backup to cloud';
$message = 'BackupBuddy ' . $backupType . ' finished'; $message = 'BackupBuddy ' . $backupType . ' finished';
if ( ! empty($finish_time)) { if ( ! empty($finish_time)) {
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time); do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time);
} }
@ -527,7 +527,7 @@ class MainWP_Child_Back_Up_Buddy {
} }
global $wpdb; global $wpdb;
$option = 'pb_' . pb_backupbuddy::settings( 'slug' ); $option = 'pb_' . pb_backupbuddy::settings( 'slug' );
$newOptions = sanitize_option( $option, $newOptions ); $newOptions = sanitize_option( $option, $newOptions );
$newOptions = maybe_serialize( $newOptions ); $newOptions = maybe_serialize( $newOptions );
@ -535,7 +535,7 @@ class MainWP_Child_Back_Up_Buddy {
$wpdb->update( $wpdb->options, array( 'option_value' => $newOptions ), array( 'option_name' => $option ) ); $wpdb->update( $wpdb->options, array( 'option_value' => $newOptions ), array( 'option_name' => $option ) );
$information['backupDirectoryDefault'] = backupbuddy_core::_getBackupDirectoryDefault(); $information['backupDirectoryDefault'] = backupbuddy_core::_getBackupDirectoryDefault();
$information['result'] = 'SUCCESS'; $information['result'] = 'SUCCESS';
} }
return $information; return $information;
@ -545,12 +545,12 @@ class MainWP_Child_Back_Up_Buddy {
// Keep log serial. // Keep log serial.
$old_log_serial = pb_backupbuddy::$options['log_serial']; $old_log_serial = pb_backupbuddy::$options['log_serial'];
$keepDestNote = ''; $keepDestNote = '';
$remote_destinations = pb_backupbuddy::$options['remote_destinations']; $remote_destinations = pb_backupbuddy::$options['remote_destinations'];
pb_backupbuddy::$options = pb_backupbuddy::settings( 'default_options' ); pb_backupbuddy::$options = pb_backupbuddy::settings( 'default_options' );
if ( '1' == $_POST['keep_destinations'] ) { if ( '1' == $_POST['keep_destinations'] ) {
pb_backupbuddy::$options['remote_destinations'] = $remote_destinations; pb_backupbuddy::$options['remote_destinations'] = $remote_destinations;
$keepDestNote = ' ' . __( 'Remote destination settings were not reset.', 'mainwp-child' ); $keepDestNote = ' ' . __( 'Remote destination settings were not reset.', 'mainwp-child' );
} }
// Replace log serial. // Replace log serial.
@ -563,7 +563,7 @@ class MainWP_Child_Back_Up_Buddy {
backupbuddy_core::addNotification( 'settings_reset', 'Plugin settings reset', $resetNote . $keepDestNote ); backupbuddy_core::addNotification( 'settings_reset', 'Plugin settings reset', $resetNote . $keepDestNote );
$information['message'] = $resetNote . $keepDestNote; $information['message'] = $resetNote . $keepDestNote;
$information['result'] = 'SUCCESS'; $information['result'] = 'SUCCESS';
return $information; return $information;
} }
@ -610,10 +610,10 @@ class MainWP_Child_Back_Up_Buddy {
} }
function schedules_list() { function schedules_list() {
$information = array(); $information = array();
$information['schedules'] = pb_backupbuddy::$options['schedules']; $information['schedules'] = pb_backupbuddy::$options['schedules'];
$information['next_schedule_index'] = pb_backupbuddy::$options['next_schedule_index']; $information['next_schedule_index'] = pb_backupbuddy::$options['next_schedule_index'];
$information['schedules_run_time'] = $this->get_schedules_run_time(); $information['schedules_run_time'] = $this->get_schedules_run_time();
// to fix missing destination notice // to fix missing destination notice
if (isset(pb_backupbuddy::$options['remote_destinations'])) { // update if (isset(pb_backupbuddy::$options['remote_destinations'])) { // update
@ -648,7 +648,7 @@ class MainWP_Child_Back_Up_Buddy {
function save_scheduled_backup() { function save_scheduled_backup() {
$schedule_id = intval($_POST['schedule_id']); $schedule_id = intval($_POST['schedule_id']);
$schedule = unserialize(base64_decode($_POST['data'])); $schedule = unserialize(base64_decode($_POST['data']));
if ( ! is_array($schedule)) { if ( ! is_array($schedule)) {
return array( 'error' => __( 'Invalid schedule data', 'mainwp-child' ) ); return array( 'error' => __( 'Invalid schedule data', 'mainwp-child' ) );
@ -664,24 +664,24 @@ class MainWP_Child_Back_Up_Buddy {
return array( 'error' => 'Error scheduling event with WordPress. Your schedule may not work properly. Please try again. Error #3488439b. Check your BackupBuddy error log for details.' ); return array( 'error' => 'Error scheduling event with WordPress. Your schedule may not work properly. Please try again. Error #3488439b. Check your BackupBuddy error log for details.' );
} }
} else { } else {
$first_run = $schedule['first_run']; $first_run = $schedule['first_run'];
$next_scheduled_time = wp_next_scheduled( 'backupbuddy_cron', array( 'run_scheduled_backup', array( (int) $schedule_id ) ) ); $next_scheduled_time = wp_next_scheduled( 'backupbuddy_cron', array( 'run_scheduled_backup', array( (int) $schedule_id ) ) );
backupbuddy_core::unschedule_event( $next_scheduled_time, 'backupbuddy_cron', array( 'run_scheduled_backup', array( (int) $schedule_id ) ) ); backupbuddy_core::unschedule_event( $next_scheduled_time, 'backupbuddy_cron', array( 'run_scheduled_backup', array( (int) $schedule_id ) ) );
backupbuddy_core::schedule_event( $first_run, $schedule['interval'], 'run_scheduled_backup', array( (int) $schedule_id ) ); // Add new schedule. backupbuddy_core::schedule_event( $first_run, $schedule['interval'], 'run_scheduled_backup', array( (int) $schedule_id ) ); // Add new schedule.
pb_backupbuddy::$options['schedules'][ $schedule_id ] = $schedule; pb_backupbuddy::$options['schedules'][ $schedule_id ] = $schedule;
} }
pb_backupbuddy::save(); pb_backupbuddy::save();
$information['result'] = 'SUCCESS'; $information['result'] = 'SUCCESS';
$information['schedules'] = pb_backupbuddy::$options['schedules']; $information['schedules'] = pb_backupbuddy::$options['schedules'];
$information['next_schedule_index'] = pb_backupbuddy::$options['next_schedule_index']; $information['next_schedule_index'] = pb_backupbuddy::$options['next_schedule_index'];
$information['schedules_run_time'] = $this->get_schedules_run_time(); $information['schedules_run_time'] = $this->get_schedules_run_time();
return $information; return $information;
} }
function save_profile() { function save_profile() {
$profile_id = $_POST['profile_id']; $profile_id = $_POST['profile_id'];
$profile = unserialize(base64_decode($_POST['data'])); $profile = unserialize(base64_decode($_POST['data']));
if ( ! is_array($profile)) { if ( ! is_array($profile)) {
return array( 'error' => __( 'Invalid profile data', 'mainwp-child' ) ); return array( 'error' => __( 'Invalid profile data', 'mainwp-child' ) );
@ -708,11 +708,11 @@ class MainWP_Child_Back_Up_Buddy {
} }
function delete_backup( $type = 'default', $subsite_mode = false ) { function delete_backup( $type = 'default', $subsite_mode = false ) {
$item_ids = $_POST['item_ids']; $item_ids = $_POST['item_ids'];
$item_ids = explode(',', $item_ids); $item_ids = explode(',', $item_ids);
$information = array(); $information = array();
if ( is_array( $item_ids ) && count( $item_ids ) > 0 ) { if ( is_array( $item_ids ) && count( $item_ids ) > 0 ) {
$needs_save = false; $needs_save = false;
$deleted_files = array(); $deleted_files = array();
foreach ( $item_ids as $item ) { foreach ( $item_ids as $item ) {
if ( file_exists( backupbuddy_core::getBackupDirectory() . $item ) ) { if ( file_exists( backupbuddy_core::getBackupDirectory() . $item ) ) {
@ -727,7 +727,7 @@ class MainWP_Child_Back_Up_Buddy {
$backup_files = array(); $backup_files = array();
} }
if ( count( $backup_files ) > 5 ) { // Keep a minimum number of backups in array for stats. if ( count( $backup_files ) > 5 ) { // Keep a minimum number of backups in array for stats.
$this_serial = backupbuddy_core::get_serial_from_file( $item ); $this_serial = backupbuddy_core::get_serial_from_file( $item );
$fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $this_serial . '.txt'; $fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $this_serial . '.txt';
if ( file_exists( $fileoptions_file ) ) { if ( file_exists( $fileoptions_file ) ) {
@unlink( $fileoptions_file ); @unlink( $fileoptions_file );
@ -780,19 +780,19 @@ class MainWP_Child_Back_Up_Buddy {
MainWP_Helper::check_methods('backupbuddy_core', array( 'get_plugins_root', 'get_themes_root', 'get_media_root' ) ); MainWP_Helper::check_methods('backupbuddy_core', array( 'get_plugins_root', 'get_themes_root', 'get_media_root' ) );
MainWP_Helper::check_methods('backupbuddy_api', array( 'getOverview' ) ); MainWP_Helper::check_methods('backupbuddy_api', array( 'getOverview' ) );
$data = array(); $data = array();
$data['plugins_root'] = backupbuddy_core::get_plugins_root(); $data['plugins_root'] = backupbuddy_core::get_plugins_root();
$data['themes_root'] = backupbuddy_core::get_themes_root(); $data['themes_root'] = backupbuddy_core::get_themes_root();
$data['media_root'] = backupbuddy_core::get_media_root(); $data['media_root'] = backupbuddy_core::get_media_root();
$data['additional_tables'] = $this->pb_additional_tables(); $data['additional_tables'] = $this->pb_additional_tables();
$data['abspath'] = ABSPATH; $data['abspath'] = ABSPATH;
$getOverview = backupbuddy_api::getOverview(); $getOverview = backupbuddy_api::getOverview();
$data['editsSinceLastBackup'] = $getOverview['editsSinceLastBackup']; $data['editsSinceLastBackup'] = $getOverview['editsSinceLastBackup'];
if ( isset( $getOverview['lastBackupStats']['finish'] ) ) { if ( isset( $getOverview['lastBackupStats']['finish'] ) ) {
$finish_time = $getOverview['lastBackupStats']['finish']; $finish_time = $getOverview['lastBackupStats']['finish'];
$time = $this->localize_time( $finish_time ); $time = $this->localize_time( $finish_time );
$data['lastBackupStats'] = date('M j - g:i A', $time); $data['lastBackupStats'] = date('M j - g:i A', $time);
$data['lasttime_backup'] = $finish_time; $data['lasttime_backup'] = $finish_time;
MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support Require Backup Before Update feature MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support Require Backup Before Update feature
@ -819,15 +819,15 @@ class MainWP_Child_Back_Up_Buddy {
function backup_list() { function backup_list() {
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
$information = array(); $information = array();
$information['backup_list'] = $this->get_backup_list(); $information['backup_list'] = $this->get_backup_list();
$information['recent_backup_list'] = $this->get_recent_backup_list(); $information['recent_backup_list'] = $this->get_recent_backup_list();
//$information['destinations_list'] = pb_backupbuddy_destinations::get_destinations_list(); //$information['destinations_list'] = pb_backupbuddy_destinations::get_destinations_list();
$backup_directory = backupbuddy_core::getBackupDirectory(); $backup_directory = backupbuddy_core::getBackupDirectory();
$backup_directory = str_replace( '\\', '/', $backup_directory ); $backup_directory = str_replace( '\\', '/', $backup_directory );
$backup_directory = rtrim( $backup_directory, '/\\' ) . '/'; $backup_directory = rtrim( $backup_directory, '/\\' ) . '/';
$information['backupDirectoryWithinSiteRoot'] = ( false !== stristr( $backup_directory, ABSPATH ) ) ? 'yes' : 'no'; $information['backupDirectoryWithinSiteRoot'] = ( false !== stristr( $backup_directory, ABSPATH ) ) ? 'yes' : 'no';
$information['result'] = 'SUCCESS'; $information['result'] = 'SUCCESS';
return $information; return $information;
} }
@ -837,14 +837,14 @@ class MainWP_Child_Back_Up_Buddy {
pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy( backupbuddy_core::getBackupDirectory() ); pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy( backupbuddy_core::getBackupDirectory() );
} }
$backup_file = $_POST['backup_file']; $backup_file = $_POST['backup_file'];
$note = $_POST['note']; $note = $_POST['note'];
$note = preg_replace( '/[[:space:]]+/', ' ', $note ); $note = preg_replace( '/[[:space:]]+/', ' ', $note );
$note = preg_replace( '/[^[:print:]]/', '', $note ); $note = preg_replace( '/[^[:print:]]/', '', $note );
$note = substr( $note, 0, 200 ); $note = substr( $note, 0, 200 );
// Returns true on success, else the error message. // Returns true on success, else the error message.
$old_comment = pb_backupbuddy::$classes['zipbuddy']->get_comment( $backup_file ); $old_comment = pb_backupbuddy::$classes['zipbuddy']->get_comment( $backup_file );
$comment = backupbuddy_core::normalize_comment_data( $old_comment ); $comment = backupbuddy_core::normalize_comment_data( $old_comment );
$comment['note'] = $note; $comment['note'] = $note;
//$new_comment = base64_encode( serialize( $comment ) ); //$new_comment = base64_encode( serialize( $comment ) );
@ -871,7 +871,7 @@ class MainWP_Child_Back_Up_Buddy {
function get_hash() { function get_hash() {
$callback_data = $_POST['callback_data']; $callback_data = $_POST['callback_data'];
$file = backupbuddy_core::getBackupDirectory() . $callback_data; $file = backupbuddy_core::getBackupDirectory() . $callback_data;
if (file_exists($file)) { if (file_exists($file)) {
return array( return array(
'result' => 'SUCCESS', 'result' => 'SUCCESS',
@ -888,7 +888,7 @@ class MainWP_Child_Back_Up_Buddy {
$max_cache_time = 86400; $max_cache_time = 86400;
// This is the root directory we want the listing for // This is the root directory we want the listing for
$root = $_POST['dir']; $root = $_POST['dir'];
$root_len = strlen( $root ); $root_len = strlen( $root );
// This will identify the backup zip file we want to list // This will identify the backup zip file we want to list
@ -907,14 +907,14 @@ class MainWP_Child_Back_Up_Buddy {
pb_backupbuddy::status( 'details', 'Fileoptions instance #28.' ); pb_backupbuddy::status( 'details', 'Fileoptions instance #28.' );
$fileoptions = new pb_backupbuddy_fileoptions( $fileoptions_file ); $fileoptions = new pb_backupbuddy_fileoptions( $fileoptions_file );
$zip_viewer = $_POST['zip_viewer']; $zip_viewer = $_POST['zip_viewer'];
// Either we are getting cached file tree information or we need to create afresh // Either we are getting cached file tree information or we need to create afresh
if ( true !== ( $result = $fileoptions->is_ok() ) ) { if ( true !== ( $result = $fileoptions->is_ok() ) ) {
// Get file listing. // Get file listing.
require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php'; require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy( ABSPATH, array(), 'unzip' ); pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy( ABSPATH, array(), 'unzip' );
$files = pb_backupbuddy::$classes['zipbuddy']->get_file_list( backupbuddy_core::getBackupDirectory() . str_replace( '\\/', '', $zip_viewer ) ); $files = pb_backupbuddy::$classes['zipbuddy']->get_file_list( backupbuddy_core::getBackupDirectory() . str_replace( '\\/', '', $zip_viewer ) );
$fileoptions->options = $files; $fileoptions->options = $files;
$fileoptions->save(); $fileoptions->save();
} else { } else {
$files = &$fileoptions->options; $files = &$fileoptions->options;
@ -1018,7 +1018,7 @@ class MainWP_Child_Back_Up_Buddy {
natcasesort( $files ); natcasesort( $files );
// Sort with directories first. // Sort with directories first.
$sorted_files = array(); // Temporary holder for sorting files. $sorted_files = array(); // Temporary holder for sorting files.
$sorted_directories = array(); // Temporary holder for sorting directories. $sorted_directories = array(); // Temporary holder for sorting directories.
foreach ( $files as $file ) { foreach ( $files as $file ) {
if ( ( $file == '.' ) || ( $file == '..' ) ) { if ( ( $file == '.' ) || ( $file == '..' ) ) {
@ -1043,7 +1043,7 @@ class MainWP_Child_Back_Up_Buddy {
if ( file_exists( str_replace( '//', '/', $root . $file ) ) ) { if ( file_exists( str_replace( '//', '/', $root . $file ) ) ) {
if ( is_dir( str_replace( '//', '/', $root . $file ) ) ) { // Directory. if ( is_dir( str_replace( '//', '/', $root . $file ) ) ) { // Directory.
echo '<li class="directory collapsed">'; echo '<li class="directory collapsed">';
$return = ''; $return = '';
$return .= '<div class="pb_backupbuddy_treeselect_control">'; $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 .= '<img src="' . pb_backupbuddy::plugin_url() . '/images/redminus.png" style="vertical-align: -3px;" title="Add to exclusions..." class="pb_backupbuddy_filetree_exclude">';
$return .= '</div>'; $return .= '</div>';
@ -1051,7 +1051,7 @@ class MainWP_Child_Back_Up_Buddy {
echo '</li>'; echo '</li>';
} else { // File. } else { // File.
echo '<li class="file collapsed">'; echo '<li class="file collapsed">';
$return = ''; $return = '';
$return .= '<div class="pb_backupbuddy_treeselect_control">'; $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 .= '<img src="' . pb_backupbuddy::plugin_url() . '/images/redminus.png" style="vertical-align: -3px;" title="Add to exclusions..." class="pb_backupbuddy_filetree_exclude">';
$return .= '</div>'; $return .= '</div>';
@ -1082,7 +1082,7 @@ class MainWP_Child_Back_Up_Buddy {
MainWP_Helper::check_properties('pb_backupbuddy', 'format'); MainWP_Helper::check_properties('pb_backupbuddy', 'format');
MainWP_Helper::check_methods(pb_backupbuddy::$format, 'file_size'); MainWP_Helper::check_methods(pb_backupbuddy::$format, 'file_size');
$return = ''; $return = '';
$size_string = ''; $size_string = '';
global $wpdb; global $wpdb;
@ -1124,15 +1124,15 @@ class MainWP_Child_Back_Up_Buddy {
function restore_file_view() { function restore_file_view() {
$archive_file = $_POST['archive']; // archive to extract from. $archive_file = $_POST['archive']; // archive to extract from.
$file = $_POST['file']; // file to extract. $file = $_POST['file']; // file to extract.
$serial = backupbuddy_core::get_serial_from_file( $archive_file ); // serial of archive. $serial = backupbuddy_core::get_serial_from_file( $archive_file ); // serial of archive.
$temp_file = uniqid(); // temp filename to extract into. $temp_file = uniqid(); // temp filename to extract into.
require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php'; require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
$zipbuddy = new pluginbuddy_zipbuddy( backupbuddy_core::getBackupDirectory() ); $zipbuddy = new pluginbuddy_zipbuddy( backupbuddy_core::getBackupDirectory() );
// Calculate temp directory & lock it down. // Calculate temp directory & lock it down.
$temp_dir = get_temp_dir(); $temp_dir = get_temp_dir();
$destination = $temp_dir . 'backupbuddy-' . $serial; $destination = $temp_dir . 'backupbuddy-' . $serial;
if ( ( ( ! file_exists( $destination ) ) && ( false === mkdir( $destination ) ) ) ) { if ( ( ( ! file_exists( $destination ) ) && ( false === mkdir( $destination ) ) ) ) {
$error = 'Error #458485945b: Unable to create temporary location.'; $error = 'Error #458485945b: Unable to create temporary location.';
@ -1155,7 +1155,7 @@ class MainWP_Child_Back_Up_Buddy {
$file_content = ''; $file_content = '';
$extractions = array( $file => $temp_file ); $extractions = array( $file => $temp_file );
$extract_result = $zipbuddy->extract( backupbuddy_core::getBackupDirectory() . $archive_file, $destination, $extractions ); $extract_result = $zipbuddy->extract( backupbuddy_core::getBackupDirectory() . $archive_file, $destination, $extractions );
if ( false === $extract_result ) { // failed. if ( false === $extract_result ) { // failed.
//echo ' -->'; //echo ' -->';
@ -1184,11 +1184,11 @@ class MainWP_Child_Back_Up_Buddy {
function restore_file_restore() { function restore_file_restore() {
$files = $_POST['files']; // file to extract. $files = $_POST['files']; // file to extract.
$archive_file = $_POST['archive']; // archive to extract from. $archive_file = $_POST['archive']; // archive to extract from.
$files_array = explode( ',', $files ); $files_array = explode( ',', $files );
$files = array(); $files = array();
foreach ( $files_array as $file ) { foreach ( $files_array as $file ) {
if ( substr( $file, -1 ) == '/' ) { // If directory then add wildcard. if ( substr( $file, -1 ) == '/' ) { // If directory then add wildcard.
$file = $file . '*'; $file = $file . '*';
@ -1208,14 +1208,14 @@ class MainWP_Child_Back_Up_Buddy {
require pb_backupbuddy::plugin_path() . '/classes/_restoreFiles.php'; require pb_backupbuddy::plugin_path() . '/classes/_restoreFiles.php';
ob_start(); ob_start();
$result = backupbuddy_restore_files::restore( backupbuddy_core::getBackupDirectory() . $archive_file, $files, $finalPath = ABSPATH ); $result = backupbuddy_restore_files::restore( backupbuddy_core::getBackupDirectory() . $archive_file, $files, $finalPath = ABSPATH );
$restore_result = ob_get_clean(); $restore_result = ob_get_clean();
pb_backupbuddy::flush(); pb_backupbuddy::flush();
return array( 'restore_result' => $restore_result ); return array( 'restore_result' => $restore_result );
} }
function get_backup_list( $type = 'default', $subsite_mode = false ) { function get_backup_list( $type = 'default', $subsite_mode = false ) {
$backups = array(); $backups = array();
$backup_sort_dates = array(); $backup_sort_dates = array();
$files = glob( backupbuddy_core::getBackupDirectory() . 'backup*.zip' ); $files = glob( backupbuddy_core::getBackupDirectory() . 'backup*.zip' );
@ -1275,10 +1275,10 @@ class MainWP_Child_Back_Up_Buddy {
// Defaults... // Defaults...
$detected_type = ''; $detected_type = '';
$file_size = ''; $file_size = '';
$modified = ''; $modified = '';
$modified_time = 0; $modified_time = 0;
$integrity = ''; $integrity = '';
$main_string = 'Warn#284.'; $main_string = 'Warn#284.';
if ( is_array( $backup_integrity ) ) { // Data intact... put it all together. if ( is_array( $backup_integrity ) ) { // Data intact... put it all together.
@ -1306,8 +1306,8 @@ class MainWP_Child_Back_Up_Buddy {
} }
} }
$file_size = pb_backupbuddy::$format->file_size( $backup_integrity['size'] ); $file_size = pb_backupbuddy::$format->file_size( $backup_integrity['size'] );
$modified = pb_backupbuddy::$format->date( pb_backupbuddy::$format->localize_time( $backup_integrity['modified'] ), 'l, F j, Y - g:i:s a' ); $modified = pb_backupbuddy::$format->date( pb_backupbuddy::$format->localize_time( $backup_integrity['modified'] ), 'l, F j, Y - g:i:s a' );
$modified_time = $backup_integrity['modified']; $modified_time = $backup_integrity['modified'];
if ( isset( $backup_integrity['status'] ) ) { // Pre-v4.0. if ( isset( $backup_integrity['status'] ) ) { // Pre-v4.0.
$status = $backup_integrity['status']; $status = $backup_integrity['status'];
@ -1318,7 +1318,7 @@ class MainWP_Child_Back_Up_Buddy {
// Calculate main row string. // Calculate main row string.
if ( $type == 'default' ) { // Default backup listing. if ( $type == 'default' ) { // Default backup listing.
$download_url = '/wp-admin/admin-ajax.php?action=mainwp_backupbuddy_download_archive&backupbuddy_backup=' . basename( $file ) . '&_wpnonce=' . MainWP_Helper::create_nonce_without_session( 'mainwp_download_backup' ); $download_url = '/wp-admin/admin-ajax.php?action=mainwp_backupbuddy_download_archive&backupbuddy_backup=' . basename( $file ) . '&_wpnonce=' . MainWP_Helper::create_nonce_without_session( 'mainwp_download_backup' );
$main_string = '<a href="#" download-url="' . $download_url . '"class="backupbuddyFileTitle mwp_bb_download_backup_lnk" title="' . basename( $file ) . '">' . $modified . ' (' . $time_ago . ')</a>'; $main_string = '<a href="#" download-url="' . $download_url . '"class="backupbuddyFileTitle mwp_bb_download_backup_lnk" title="' . basename( $file ) . '">' . $modified . ' (' . $time_ago . ')</a>';
} elseif ( $type == 'migrate' ) { // Migration backup listing. } elseif ( $type == 'migrate' ) { // Migration backup listing.
$main_string = '<a class="pb_backupbuddy_hoveraction_migrate backupbuddyFileTitle" rel="' . basename( $file ) . '" href="' . pb_backupbuddy::page_url() . '&migrate=' . basename( $file ) . '&value=' . basename( $file ) . '" title="' . basename( $file ) . '">' . $modified . ' (' . $time_ago . ')</a>'; $main_string = '<a class="pb_backupbuddy_hoveraction_migrate backupbuddyFileTitle" rel="' . basename( $file ) . '" href="' . pb_backupbuddy::page_url() . '&migrate=' . basename( $file ) . '&value=' . basename( $file ) . '" title="' . basename( $file ) . '">' . $modified . ' (' . $time_ago . ')</a>';
} else { } else {
@ -1486,7 +1486,7 @@ class MainWP_Child_Back_Up_Buddy {
function pb_backupbuddy_aasort ( &$array, $key) { function pb_backupbuddy_aasort ( &$array, $key) {
$sorter = array(); $sorter = array();
$ret = array(); $ret = array();
reset($array); reset($array);
foreach ($array as $ii => $va) { foreach ($array as $ii => $va) {
$sorter[ $ii ] = $va[ $key ]; $sorter[ $ii ] = $va[ $key ];
@ -1523,7 +1523,7 @@ class MainWP_Child_Back_Up_Buddy {
} }
function view_log() { function view_log() {
$serial = $_POST['serial']; $serial = $_POST['serial'];
$logFile = backupbuddy_core::getLogDirectory() . 'status-' . $serial . '_sum_' . pb_backupbuddy::$options['log_serial'] . '.txt'; $logFile = backupbuddy_core::getLogDirectory() . 'status-' . $serial . '_sum_' . pb_backupbuddy::$options['log_serial'] . '.txt';
if ( ! file_exists( $logFile ) ) { if ( ! file_exists( $logFile ) ) {
@ -1579,7 +1579,7 @@ class MainWP_Child_Back_Up_Buddy {
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
pb_backupbuddy::status( 'details', 'Fileoptions instance #27.' ); pb_backupbuddy::status( 'details', 'Fileoptions instance #27.' );
$optionsFile = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt'; $optionsFile = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt';
$backup_options = new pb_backupbuddy_fileoptions( $optionsFile, $read_only = true ); $backup_options = new pb_backupbuddy_fileoptions( $optionsFile, $read_only = true );
if ( true !== ( $result = $backup_options->is_ok() ) ) { if ( true !== ( $result = $backup_options->is_ok() ) ) {
return array( 'error' => __('Unable to access fileoptions data file.', 'mainwp-child' ) . ' Error: ' . $result ); return array( 'error' => __('Unable to access fileoptions data file.', 'mainwp-child' ) . ' Error: ' . $result );
@ -1587,7 +1587,7 @@ class MainWP_Child_Back_Up_Buddy {
ob_start(); ob_start();
$integrity = $backup_options->options['integrity']; $integrity = $backup_options->options['integrity'];
$start_time = 'Unknown'; $start_time = 'Unknown';
$finish_time = 'Unknown'; $finish_time = 'Unknown';
if ( isset( $backup_options->options['start_time'] ) ) { if ( isset( $backup_options->options['start_time'] ) ) {
$start_time = pb_backupbuddy::$format->date( pb_backupbuddy::$format->localize_time( $backup_options->options['start_time'] ) ) . ' <span class="description">(' . pb_backupbuddy::$format->time_ago( $backup_options->options['start_time'] ) . ' ago)</span>'; $start_time = pb_backupbuddy::$format->date( pb_backupbuddy::$format->localize_time( $backup_options->options['start_time'] ) ) . ' <span class="description">(' . pb_backupbuddy::$format->time_ago( $backup_options->options['start_time'] ) . ' ago)</span>';
@ -1623,7 +1623,7 @@ class MainWP_Child_Back_Up_Buddy {
} }
// The tests & their status.. // The tests & their status..
$tests = array(); $tests = array();
$tests[] = array( 'BackupBackup data file exists', pb_pretty_results( $integrity['status_details']['found_dat'] ) ); $tests[] = array( 'BackupBackup data file exists', pb_pretty_results( $integrity['status_details']['found_dat'] ) );
$tests[] = array( 'Database SQL file exists', pb_pretty_results( $integrity['status_details']['found_sql'] ) ); $tests[] = array( 'Database SQL file exists', pb_pretty_results( $integrity['status_details']['found_sql'] ) );
if ( $integrity['detected_type'] == 'full' ) { // Full backup. if ( $integrity['detected_type'] == 'full' ) { // Full backup.
@ -1680,7 +1680,7 @@ class MainWP_Child_Back_Up_Buddy {
echo '<br><br>'; echo '<br><br>';
//***** BEGIN STEPS. //***** BEGIN STEPS.
$steps = array(); $steps = array();
$steps[] = array( 'Start Time', $start_time, '' ); $steps[] = array( 'Start Time', $start_time, '' );
if ( isset( $backup_options->options['steps'] ) ) { if ( isset( $backup_options->options['steps'] ) ) {
foreach ( $backup_options->options['steps'] as $step ) { foreach ( $backup_options->options['steps'] as $step ) {
@ -1805,9 +1805,9 @@ class MainWP_Child_Back_Up_Buddy {
} }
function reset_integrity() { function reset_integrity() {
$_GET['reset_integrity'] = $_POST['reset_integrity']; $_GET['reset_integrity'] = $_POST['reset_integrity'];
$information['backup_list'] = $this->get_backup_list(); $information['backup_list'] = $this->get_backup_list();
$information['result'] = 'SUCCESS'; $information['result'] = 'SUCCESS';
return $information; return $information;
} }
@ -1834,14 +1834,14 @@ class MainWP_Child_Back_Up_Buddy {
die( 'Error #548957857584784332. The requested backup file does not exist. It may have already been deleted.' ); die( 'Error #548957857584784332. The requested backup file does not exist. It may have already been deleted.' );
} }
$abspath = str_replace( '\\', '/', ABSPATH ); $abspath = str_replace( '\\', '/', ABSPATH );
$backup_dir = str_replace( '\\', '/', backupbuddy_core::getBackupDirectory() ); $backup_dir = str_replace( '\\', '/', backupbuddy_core::getBackupDirectory() );
if ( false === stristr( $backup_dir, $abspath ) ) { if ( false === stristr( $backup_dir, $abspath ) ) {
die( 'Error #5432532. You cannot download backups stored outside of the WordPress web root. Please use FTP or other means.' ); die( 'Error #5432532. You cannot download backups stored outside of the WordPress web root. Please use FTP or other means.' );
} }
$sitepath = str_replace( $abspath, '', $backup_dir ); $sitepath = str_replace( $abspath, '', $backup_dir );
$download_url = rtrim( site_url(), '/\\' ) . '/' . trim( $sitepath, '/\\' ) . '/' . pb_backupbuddy::_GET( 'backupbuddy_backup' ); $download_url = rtrim( site_url(), '/\\' ) . '/' . trim( $sitepath, '/\\' ) . '/' . pb_backupbuddy::_GET( 'backupbuddy_backup' );
if ( pb_backupbuddy::$options['lock_archives_directory'] == '1' ) { if ( pb_backupbuddy::$options['lock_archives_directory'] == '1' ) {
@ -1879,7 +1879,7 @@ class MainWP_Child_Back_Up_Buddy {
require_once pb_backupbuddy::plugin_path() . '/classes/backup.php'; require_once pb_backupbuddy::plugin_path() . '/classes/backup.php';
$newBackup = new pb_backupbuddy_backup(); $newBackup = new pb_backupbuddy_backup();
$profile_array = pb_backupbuddy::$options['profiles'][ $requested_profile ]; $profile_array = pb_backupbuddy::$options['profiles'][ $requested_profile ];
$serial_override = pb_backupbuddy::random_string( 10 ); $serial_override = pb_backupbuddy::random_string( 10 );
if ( $newBackup->start_backup_process( if ( $newBackup->start_backup_process(
@ -1901,7 +1901,7 @@ class MainWP_Child_Back_Up_Buddy {
function start_backup() { function start_backup() {
require_once pb_backupbuddy::plugin_path() . '/classes/backup.php'; require_once pb_backupbuddy::plugin_path() . '/classes/backup.php';
$newBackup = new pb_backupbuddy_backup(); $newBackup = new pb_backupbuddy_backup();
$data = $_POST['data']; $data = $_POST['data'];
if (is_array($data) && isset($data['serial_override'])) { if (is_array($data) && isset($data['serial_override'])) {
if ( $newBackup->start_backup_process( if ( $newBackup->start_backup_process(
$data['profile_array'], $data['profile_array'],
@ -1924,7 +1924,7 @@ class MainWP_Child_Back_Up_Buddy {
} }
function backup_status() { function backup_status() {
$data = $_POST['data']; $data = $_POST['data'];
$result = ''; $result = '';
if (is_array($data) && isset($data['serial'])) { if (is_array($data) && isset($data['serial'])) {
ob_start(); ob_start();
@ -1946,7 +1946,7 @@ class MainWP_Child_Back_Up_Buddy {
} }
function remote_save() { function remote_save() {
$data = isset($_POST['data']) ? $_POST['data'] : false; $data = isset($_POST['data']) ? $_POST['data'] : false;
$destination_id = isset($_POST['destination_id']) ? $_POST['destination_id'] : 0; $destination_id = isset($_POST['destination_id']) ? $_POST['destination_id'] : 0;
if (is_array($data) && isset($data['do_not_override'])) { if (is_array($data) && isset($data['do_not_override'])) {
@ -2012,8 +2012,8 @@ class MainWP_Child_Back_Up_Buddy {
function remote_send() { function remote_send() {
$destination_id = isset($_POST['destination_id']) ? $_POST['destination_id'] : null; $destination_id = isset($_POST['destination_id']) ? $_POST['destination_id'] : null;
$file = isset($_POST['file']) ? $_POST['file'] : null; $file = isset($_POST['file']) ? $_POST['file'] : null;
$trigger = isset($_POST['trigger']) ? $_POST['trigger'] : 'manual'; $trigger = isset($_POST['trigger']) ? $_POST['trigger'] : 'manual';
if ( $file != 'importbuddy.php' ) { if ( $file != 'importbuddy.php' ) {
$backup_file = backupbuddy_core::getBackupDirectory() . $file; $backup_file = backupbuddy_core::getBackupDirectory() . $file;
@ -2076,7 +2076,7 @@ class MainWP_Child_Back_Up_Buddy {
return array( 'error' => $error ); return array( 'error' => $error );
} else { } else {
if ( isset( $stash_quota['quota_warning'] ) && ( $stash_quota['quota_warning'] != '' ) ) { if ( isset( $stash_quota['quota_warning'] ) && ( $stash_quota['quota_warning'] != '' ) ) {
$warning = 'Warning: ' . $stash_quota['quota_warning'] . "\n\n"; $warning = 'Warning: ' . $stash_quota['quota_warning'] . "\n\n";
$success_output = true; $success_output = true;
} }
} }
@ -2117,7 +2117,7 @@ class MainWP_Child_Back_Up_Buddy {
$other_action = $_POST['other_action']; $other_action = $_POST['other_action'];
$message = ''; $message = '';
$error = ''; $error = '';
if ( 'cleanup_now' == $other_action ) { if ( 'cleanup_now' == $other_action ) {
$message = 'Performing cleanup procedures now trimming old files and data.'; $message = 'Performing cleanup procedures now trimming old files and data.';
@ -2126,7 +2126,7 @@ class MainWP_Child_Back_Up_Buddy {
} elseif ( 'delete_tempfiles_now' == $other_action) { } elseif ( 'delete_tempfiles_now' == $other_action) {
$tempDir = backupbuddy_core::getTempDirectory(); $tempDir = backupbuddy_core::getTempDirectory();
$logDir = backupbuddy_core::getLogDirectory(); $logDir = backupbuddy_core::getLogDirectory();
$message = 'Deleting all files contained within `' . $tempDir . '` and `' . $logDir . '`.'; $message = 'Deleting all files contained within `' . $tempDir . '` and `' . $logDir . '`.';
pb_backupbuddy::$filesystem->unlink_recursive( $tempDir ); pb_backupbuddy::$filesystem->unlink_recursive( $tempDir );
pb_backupbuddy::$filesystem->unlink_recursive( $logDir ); pb_backupbuddy::$filesystem->unlink_recursive( $logDir );
@ -2150,7 +2150,7 @@ class MainWP_Child_Back_Up_Buddy {
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
$fileoptions_directory = backupbuddy_core::getLogDirectory() . 'fileoptions/'; $fileoptions_directory = backupbuddy_core::getLogDirectory() . 'fileoptions/';
$files = glob( $fileoptions_directory . '*.txt' ); $files = glob( $fileoptions_directory . '*.txt' );
if ( ! is_array( $files ) ) { if ( ! is_array( $files ) ) {
$files = array(); $files = array();
} }
@ -2268,7 +2268,7 @@ class MainWP_Child_Back_Up_Buddy {
echo __('An error was encountered attempting to scan this site.', 'it-l10n-backupbuddy' ), '<br />'; echo __('An error was encountered attempting to scan this site.', 'it-l10n-backupbuddy' ), '<br />';
echo __('An internet connection is required and this site must be accessible on the public internet.', 'it-l10n-backupbuddy' ); echo __('An internet connection is required and this site must be accessible on the public internet.', 'it-l10n-backupbuddy' );
echo '<br>'; echo '<br>';
$scan = array(); $scan = array();
$continue_2 = false; $continue_2 = false;
} else { } else {
$scan = maybe_unserialize( $scan ); $scan = maybe_unserialize( $scan );
@ -2537,8 +2537,8 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
global $wp_version; global $wp_version;
$itxapi_username = strtolower( $_POST['live_username'] ); $itxapi_username = strtolower( $_POST['live_username'] );
$password_hash = iThemes_Credentials::get_password_hash( $itxapi_username, $_POST['live_password'] ); $password_hash = iThemes_Credentials::get_password_hash( $itxapi_username, $_POST['live_password'] );
$access_token = ITXAPI_Helper2::get_access_token( $itxapi_username, $password_hash, site_url(), $wp_version ); $access_token = ITXAPI_Helper2::get_access_token( $itxapi_username, $password_hash, site_url(), $wp_version );
$settings = array( $settings = array(
'itxapi_username' => $itxapi_username, 'itxapi_username' => $itxapi_username,
@ -2568,10 +2568,10 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
$nextDestKey = 0; $nextDestKey = 0;
} }
pb_backupbuddy::$options['remote_destinations'][ $nextDestKey ] = pb_backupbuddy_destination_live::$default_settings; pb_backupbuddy::$options['remote_destinations'][ $nextDestKey ] = pb_backupbuddy_destination_live::$default_settings;
pb_backupbuddy::$options['remote_destinations'][ $nextDestKey ]['itxapi_username'] = $_POST['live_username']; pb_backupbuddy::$options['remote_destinations'][ $nextDestKey ]['itxapi_username'] = $_POST['live_username'];
pb_backupbuddy::$options['remote_destinations'][ $nextDestKey ]['itxapi_token'] = $itxapi_token; pb_backupbuddy::$options['remote_destinations'][ $nextDestKey ]['itxapi_token'] = $itxapi_token;
pb_backupbuddy::$options['remote_destinations'][ $nextDestKey ]['title'] = 'My BackupBuddy Stash Live'; pb_backupbuddy::$options['remote_destinations'][ $nextDestKey ]['title'] = 'My BackupBuddy Stash Live';
// Notification email. // Notification email.
pb_backupbuddy::$options['remote_destinations'][ $nextDestKey ]['email'] = $_POST['email']; pb_backupbuddy::$options['remote_destinations'][ $nextDestKey ]['email'] = $_POST['email'];
@ -2597,7 +2597,7 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
backupbuddy_live::send_trim_settings(); backupbuddy_live::send_trim_settings();
// Set first run of BackupBuddy Stash Live so it begins immediately. // Set first run of BackupBuddy Stash Live so it begins immediately.
$cronArgs = array(); $cronArgs = array();
$schedule_result = backupbuddy_core::schedule_single_event( time(), 'live_periodic', $cronArgs ); $schedule_result = backupbuddy_core::schedule_single_event( time(), 'live_periodic', $cronArgs );
if ( true === $schedule_result ) { if ( true === $schedule_result ) {
pb_backupbuddy::status( 'details', 'Next Live Periodic chunk step cron event scheduled.' ); pb_backupbuddy::status( 'details', 'Next Live Periodic chunk step cron event scheduled.' );
@ -2627,25 +2627,25 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
} }
function live_save_settings() { function live_save_settings() {
$data = $_POST['data']; $data = $_POST['data'];
$new_destination_id = $_POST['destination_id']; $new_destination_id = $_POST['destination_id'];
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
require_once pb_backupbuddy::plugin_path() . '/destinations/live/live.php'; require_once pb_backupbuddy::plugin_path() . '/destinations/live/live.php';
require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php'; require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php';
$destination_id = backupbuddy_live::getLiveID(); $destination_id = backupbuddy_live::getLiveID();
$destination_settings = isset(pb_backupbuddy::$options['remote_destinations'][ $destination_id ]) ? pb_backupbuddy::$options['remote_destinations'][ $destination_id ] : array(); $destination_settings = isset(pb_backupbuddy::$options['remote_destinations'][ $destination_id ]) ? pb_backupbuddy::$options['remote_destinations'][ $destination_id ] : array();
$check_current = ! empty($destination_settings) ? true : false; $check_current = ! empty($destination_settings) ? true : false;
$error = ''; $error = '';
if ( $new_destination_id && is_array($data) ) { if ( $new_destination_id && is_array($data) ) {
$itxapi_username = isset($destination_settings['itxapi_username']) ? $destination_settings['itxapi_username'] : ''; $itxapi_username = isset($destination_settings['itxapi_username']) ? $destination_settings['itxapi_username'] : '';
$itxapi_token = isset($destination_settings['itxapi_token']) ? $destination_settings['itxapi_token'] : ''; $itxapi_token = isset($destination_settings['itxapi_token']) ? $destination_settings['itxapi_token'] : '';
$destination_settings = array_merge( $destination_settings, $data ); $destination_settings = array_merge( $destination_settings, $data );
$destination_settings['itxapi_username'] = $itxapi_username; $destination_settings['itxapi_username'] = $itxapi_username;
$destination_settings['itxapi_token'] = $itxapi_token; $destination_settings['itxapi_token'] = $itxapi_token;
pb_backupbuddy::$options['remote_destinations'][ $new_destination_id ] = $destination_settings; pb_backupbuddy::$options['remote_destinations'][ $new_destination_id ] = $destination_settings;
if ($check_current && $destination_id != $new_destination_id) { if ($check_current && $destination_id != $new_destination_id) {
@ -2665,7 +2665,7 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
} }
function live_action_disconnect() { function live_action_disconnect() {
$error = ''; $error = '';
$liveDestinationID = $_POST['destination_id']; $liveDestinationID = $_POST['destination_id'];
$return = array(); $return = array();
@ -2694,13 +2694,13 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
function live_action() { function live_action() {
$action = $_POST['live_action']; $action = $_POST['live_action'];
$error = $message = ''; $error = $message = '';
require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php'; require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php';
$state = backupbuddy_live_periodic::get_stats(); $state = backupbuddy_live_periodic::get_stats();
$destination_id = backupbuddy_live::getLiveID(); $destination_id = backupbuddy_live::getLiveID();
$destination = backupbuddy_live_periodic::get_destination_settings(); $destination = backupbuddy_live_periodic::get_destination_settings();
if ( 'clear_log' == $action ) { if ( 'clear_log' == $action ) {
$sumLogFile = backupbuddy_core::getLogDirectory() . 'status-live_periodic_' . pb_backupbuddy::$options['log_serial'] . '.txt'; $sumLogFile = backupbuddy_core::getLogDirectory() . 'status-live_periodic_' . pb_backupbuddy::$options['log_serial'] . '.txt';
@ -2726,10 +2726,10 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats.
} elseif ( 'resume_periodic' == $action ) { } elseif ( 'resume_periodic' == $action ) {
$launchNowText = ' ' . __( 'Unpaused but not running now.', 'it-l10n-backupbuddy' ); $launchNowText = ' ' . __( 'Unpaused but not running now.', 'it-l10n-backupbuddy' );
$start_run = false; $start_run = false;
if ( '1' != pb_backupbuddy::_GET( 'skip_run_live_now' ) ) { if ( '1' != pb_backupbuddy::_GET( 'skip_run_live_now' ) ) {
$launchNowText = ''; $launchNowText = '';
$start_run = true; $start_run = true;
} }
backupbuddy_api::setLiveStatus( $pause_continuous = '', $pause_periodic = false, $start_run ); backupbuddy_api::setLiveStatus( $pause_continuous = '', $pause_periodic = false, $start_run );
@ -2764,7 +2764,7 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
function download_troubleshooting() { function download_troubleshooting() {
require pb_backupbuddy::plugin_path() . '/destinations/live/_troubleshooting.php'; require pb_backupbuddy::plugin_path() . '/destinations/live/_troubleshooting.php';
backupbuddy_live_troubleshooting::run(); backupbuddy_live_troubleshooting::run();
$output = "**File best viewed with wordwrap OFF**\n\n" . print_r( backupbuddy_live_troubleshooting::get_raw_results(), true ); $output = "**File best viewed with wordwrap OFF**\n\n" . print_r( backupbuddy_live_troubleshooting::get_raw_results(), true );
$backup_prefix = backupbuddy_core::backup_prefix(); $backup_prefix = backupbuddy_core::backup_prefix();
return array( return array(
'output' => $output, 'output' => $output,
@ -2788,11 +2788,11 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
if ( 'live' == $destination['type'] ) { if ( 'live' == $destination['type'] ) {
$remotePath = 'snapshot-';// . backupbuddy_core::backup_prefix(); $remotePath = 'snapshot-';// . backupbuddy_core::backup_prefix();
$site_only = true; $site_only = true;
} else { } else {
// Get list of files for this site. // Get list of files for this site.
$remotePath = 'backup-';// . backupbuddy_core::backup_prefix(); $remotePath = 'backup-';// . backupbuddy_core::backup_prefix();
$site_only = true; $site_only = true;
} }
$files = pb_backupbuddy_destination_stash2::listFiles( $settings, '', $site_only ); //2nd param was $remotePath. $files = pb_backupbuddy_destination_stash2::listFiles( $settings, '', $site_only ); //2nd param was $remotePath.
@ -2808,8 +2808,8 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
} }
$last_modified = $file['uploaded_timestamp']; $last_modified = $file['uploaded_timestamp'];
$size = (float) $file['size']; $size = (float) $file['size'];
$backup_type = backupbuddy_core::getBackupTypeFromFile( $file['filename'], $quiet = false, $skip_fileoptions = true ); $backup_type = backupbuddy_core::getBackupTypeFromFile( $file['filename'], $quiet = false, $skip_fileoptions = true );
// Generate array of table rows. // Generate array of table rows.
while ( isset( $backup_list_temp[ $last_modified ] ) ) { // Avoid collisions. while ( isset( $backup_list_temp[ $last_modified ] ) ) { // Avoid collisions.
@ -2846,7 +2846,7 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
function copy_file_to_local() { function copy_file_to_local() {
$file = base64_decode( $_POST['cpy_file'] ); $file = base64_decode( $_POST['cpy_file'] );
$destination_id = $_POST['destination_id']; $destination_id = $_POST['destination_id'];
// Load required files. // Load required files.
@ -2869,7 +2869,7 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
function delete_file_backup() { function delete_file_backup() {
// Handle deletion. // Handle deletion.
$files = $_POST['items']; $files = $_POST['items'];
$destination_id = $_POST['destination_id']; $destination_id = $_POST['destination_id'];
// Load required files. // Load required files.
@ -2886,7 +2886,7 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
$file = base64_decode( $file ); $file = base64_decode( $file );
$startPos = pb_backupbuddy_destination_stash2::strrpos_count( $file, '/', 2 ) + 1; // next to last slash. $startPos = pb_backupbuddy_destination_stash2::strrpos_count( $file, '/', 2 ) + 1; // next to last slash.
$file = substr( $file, $startPos ); $file = substr( $file, $startPos );
if ( false !== strstr( $file, '?' ) ) { if ( false !== strstr( $file, '?' ) ) {
$file = substr( $file, 0, strpos( $file, '?' ) ); $file = substr( $file, 0, strpos( $file, '?' ) );
} }
@ -2939,7 +2939,7 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
pb_backupbuddy::status( 'warning', 'BackupBuddy Stash Live process appears timed out while user it viewing Live page. Forcing run now.' ); pb_backupbuddy::status( 'warning', 'BackupBuddy Stash Live process appears timed out while user it viewing Live page. Forcing run now.' );
$cronArgs = array(); $cronArgs = array();
$schedule_result = backupbuddy_core::schedule_single_event( time(), 'live_periodic', $cronArgs ); $schedule_result = backupbuddy_core::schedule_single_event( time(), 'live_periodic', $cronArgs );
if ( true === $schedule_result ) { if ( true === $schedule_result ) {
pb_backupbuddy::status( 'details', 'Next Live Periodic chunk step cron event scheduled.' ); pb_backupbuddy::status( 'details', 'Next Live Periodic chunk step cron event scheduled.' );
@ -2971,7 +2971,7 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
} }
function load_products_license() { function load_products_license() {
$packages = array(); $packages = array();
$packages_name = array(); $packages_name = array();
if (isset($GLOBALS['ithemes_updater_path'])) { if (isset($GLOBALS['ithemes_updater_path'])) {
@ -2981,7 +2981,7 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
require_once $GLOBALS['ithemes_updater_path'] . '/packages.php'; require_once $GLOBALS['ithemes_updater_path'] . '/packages.php';
$details = Ithemes_Updater_Packages::get_full_details(); $details = Ithemes_Updater_Packages::get_full_details();
$packages = isset($details['packages']) ? $details['packages'] : array(); $packages = isset($details['packages']) ? $details['packages'] : array();
if (is_array($packages)) { if (is_array($packages)) {
foreach ( $packages as $path => $data ) { foreach ( $packages as $path => $data ) {
@ -3015,13 +3015,13 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
$response = Ithemes_Updater_API::activate_package( $username, $password, $packages ); $response = Ithemes_Updater_API::activate_package( $username, $password, $packages );
if ( is_wp_error( $response ) ) { if ( is_wp_error( $response ) ) {
$errors[] = $this->get_error_explanation( $response ); $errors[] = $this->get_error_explanation( $response );
$return['errors'] = $errors; $return['errors'] = $errors;
return $return; return $return;
} }
if ( empty( $response['packages'] ) ) { if ( empty( $response['packages'] ) ) {
$errors[] = __( 'An unknown server error occurred. Please try to license your products again at another time.', 'it-l10n-backupbuddy' ); $errors[] = __( 'An unknown server error occurred. Please try to license your products again at another time.', 'it-l10n-backupbuddy' );
$return['errors'] = $errors; $return['errors'] = $errors;
return $return; return $return;
} }
@ -3029,8 +3029,8 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
uksort( $response['packages'], 'strnatcasecmp' ); uksort( $response['packages'], 'strnatcasecmp' );
$success = array(); $success = array();
$warn = array(); $warn = array();
$fail = array(); $fail = array();
foreach ( $response['packages'] as $package => $data ) { foreach ( $response['packages'] as $package => $data ) {
if ( preg_match( '/ \|\|\| \d+$/', $package ) ) { if ( preg_match( '/ \|\|\| \d+$/', $package ) ) {
@ -3049,7 +3049,7 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
} }
if ( ! empty( $success ) ) { if ( ! empty( $success ) ) {
$messages[] = wp_sprintf( __( 'Successfully licensed %l.', 'it-l10n-backupbuddy' ), $success ); $messages[] = wp_sprintf( __( 'Successfully licensed %l.', 'it-l10n-backupbuddy' ), $success );
$return['messages'] = $messages; $return['messages'] = $messages;
} }
@ -3090,13 +3090,13 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
$response = Ithemes_Updater_API::deactivate_package($username, $password, $packages ); $response = Ithemes_Updater_API::deactivate_package($username, $password, $packages );
if ( is_wp_error( $response ) ) { if ( is_wp_error( $response ) ) {
$errors[] = $this->get_error_explanation( $response ); $errors[] = $this->get_error_explanation( $response );
$return['errors'] = $errors; $return['errors'] = $errors;
return $return; return $return;
} }
if ( empty( $response['packages'] ) ) { if ( empty( $response['packages'] ) ) {
$errors[] = __( 'An unknown server error occurred. Please try to remove licenses from your products again at another time.', 'it-l10n-mainwp-backupbuddy' ); $errors[] = __( 'An unknown server error occurred. Please try to remove licenses from your products again at another time.', 'it-l10n-mainwp-backupbuddy' );
$return['errors'] = $errors; $return['errors'] = $errors;
return $return; return $return;
} }
@ -3104,7 +3104,7 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
uksort( $response['packages'], 'strnatcasecmp' ); uksort( $response['packages'], 'strnatcasecmp' );
$success = array(); $success = array();
$fail = array(); $fail = array();
foreach ( $response['packages'] as $package => $data ) { foreach ( $response['packages'] as $package => $data ) {
if ( preg_match( '/ \|\|\| \d+$/', $package ) ) { if ( preg_match( '/ \|\|\| \d+$/', $package ) ) {
@ -3123,7 +3123,7 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
} }
if ( ! empty( $success ) ) { if ( ! empty( $success ) ) {
$messages[] = wp_sprintf( _n( 'Successfully removed license from %l.', 'Successfully removed licenses from %l.', count( $success ), 'it-l10n-mainwp-backupbuddy' ), $success ); $messages[] = wp_sprintf( _n( 'Successfully removed license from %l.', 'Successfully removed licenses from %l.', count( $success ), 'it-l10n-mainwp-backupbuddy' ), $success );
$return['messages'] = $messages; $return['messages'] = $messages;
} }
@ -3140,9 +3140,9 @@ echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
} }
private function get_error_explanation( $error, $package = '' ) { private function get_error_explanation( $error, $package = '' ) {
$code = $error->get_error_code(); $code = $error->get_error_code();
$package_name = Ithemes_Updater_Functions::get_package_name( $package ); $package_name = Ithemes_Updater_Functions::get_package_name( $package );
$message = ''; $message = '';
switch ( $code ) { switch ( $code ) {
case 'ITXAPI_Updater_Bad_Login': case 'ITXAPI_Updater_Bad_Login':

View file

@ -18,7 +18,7 @@
*/ */
class MainWP_Child_Back_Up_Wordpress { class MainWP_Child_Back_Up_Wordpress {
public static $instance = null; public static $instance = null;
public $is_plugin_installed = false; public $is_plugin_installed = false;
static function Instance() { static function Instance() {
if ( null === self::$instance ) { if ( null === self::$instance ) {
@ -224,7 +224,7 @@ return;
foreach ($schedules as $schedule) { foreach ($schedules as $schedule) {
foreach ( $schedule->get_backups() as $file ) { foreach ( $schedule->get_backups() as $file ) {
$backup_type = $schedule->get_type(); $backup_type = $schedule->get_type();
$message = 'BackupWordpres backup ' . $backup_type . ' finished'; $message = 'BackupWordpres backup ' . $backup_type . ' finished';
$destination = 'N/A'; $destination = 'N/A';
if ( file_exists( $file ) ) { if ( file_exists( $file ) ) {
$date = @filemtime( $file ); $date = @filemtime( $file );
@ -295,7 +295,7 @@ return;
$information['scheduleStatus'] = $status->get_status(); $information['scheduleStatus'] = $status->get_status();
} }
$information['result'] = 'SUCCESS'; $information['result'] = 'SUCCESS';
return $information; return $information;
} }
@ -307,11 +307,11 @@ return;
if (method_exists($schedule, 'get_running_backup_filename' )) { if (method_exists($schedule, 'get_running_backup_filename' )) {
$information['scheduleStatus'] = $schedule->get_status(); $information['scheduleStatus'] = $schedule->get_status();
} else { } else {
$status = $schedule->get_status(); $status = $schedule->get_status();
$information['scheduleStatus'] = $status->get_status(); $information['scheduleStatus'] = $status->get_status();
} }
$information['result'] = 'SUCCESS'; $information['result'] = 'SUCCESS';
return $information; return $information;
} }
@ -352,9 +352,9 @@ return;
continue; continue;
} }
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) ); $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(); $started_ago = method_exists($schedule, 'get_schedule_running_start_time') ? $schedule->get_schedule_running_start_time() : $schedule->get_schedule_start_time();
$out = array( $out = array(
'b' => $this->get_backupslist_html( $schedule ), 'b' => $this->get_backupslist_html( $schedule ),
'count' => count( $schedule->get_backups() ), 'count' => count( $schedule->get_backups() ),
'file_size_text' => $this->hmbkp_get_site_size_text( $schedule ), 'file_size_text' => $this->hmbkp_get_site_size_text( $schedule ),
@ -364,7 +364,7 @@ return;
if (method_exists($schedule, 'get_running_backup_filename' )) { if (method_exists($schedule, 'get_running_backup_filename' )) {
$out['scheduleStatus'] = $schedule->get_status(); $out['scheduleStatus'] = $schedule->get_status();
} else { } else {
$status = $schedule->get_status(); $status = $schedule->get_status();
$out['scheduleStatus'] = $status->get_status(); $out['scheduleStatus'] = $status->get_status();
} }
@ -380,7 +380,7 @@ return;
$current_option = get_option( 'hmbkp_schedule_' . $sch_id ); $current_option = get_option( 'hmbkp_schedule_' . $sch_id );
if ( is_array( $current_option ) ) { if ( is_array( $current_option ) ) {
unset( $current_option['excludes'] ); // not send this value 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(); $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( $send_back_schedules[ $sch_id ] = array(
'options' => $current_option, 'options' => $current_option,
'b' => $this->get_backupslist_html( $schedule ), 'b' => $this->get_backupslist_html( $schedule ),
@ -392,7 +392,7 @@ return;
if (method_exists($schedule, 'get_running_backup_filename' )) { if (method_exists($schedule, 'get_running_backup_filename' )) {
$send_back_schedules['scheduleStatus'] = $schedule->get_status(); $send_back_schedules['scheduleStatus'] = $schedule->get_status();
} else { } else {
$status = $schedule->get_status(); $status = $schedule->get_status();
$send_back_schedules['scheduleStatus'] = $status->get_status(); $send_back_schedules['scheduleStatus'] = $status->get_status();
} }
} }
@ -436,7 +436,7 @@ return;
if (method_exists($schedule, 'get_running_backup_filename' )) { if (method_exists($schedule, 'get_running_backup_filename' )) {
$ret['scheduleStatus'] = $schedule->get_status(); $ret['scheduleStatus'] = $schedule->get_status();
} else { } else {
$status = $schedule->get_status(); $status = $schedule->get_status();
$ret['scheduleStatus'] = $status->get_status(); $ret['scheduleStatus'] = $status->get_status();
} }
return $ret; return $ret;
@ -570,14 +570,14 @@ return;
$new_version = true; $new_version = true;
if (method_exists($schedule, 'get_running_backup_filename' )) { if (method_exists($schedule, 'get_running_backup_filename' )) {
$new_version = false; $new_version = false;
$user_excludes = array_diff( $schedule->get_excludes(), $schedule->backup->default_excludes() ); $user_excludes = array_diff( $schedule->get_excludes(), $schedule->backup->default_excludes() );
$root_dir = $schedule->backup->get_root(); $root_dir = $schedule->backup->get_root();
$is_size_calculated = $schedule->is_site_size_being_calculated(); $is_size_calculated = $schedule->is_site_size_being_calculated();
} else { } else {
$excludes = $schedule->get_excludes(); $excludes = $schedule->get_excludes();
$user_excludes = $excludes->get_user_excludes(); $user_excludes = $excludes->get_user_excludes();
$root_dir = HM\BackUpWordPress\Path::get_root(); $root_dir = HM\BackUpWordPress\Path::get_root();
$is_size_calculated = HM\BackUpWordPress\Site_Size::is_site_size_being_calculated(); $is_size_calculated = HM\BackUpWordPress\Site_Size::is_site_size_being_calculated();
} }
@ -690,7 +690,7 @@ return;
} }
} else { } else {
$files = $schedule->list_directory_by_total_filesize( $directory ); $files = $schedule->list_directory_by_total_filesize( $directory );
$exclude_string = $schedule->backup->exclude_string( 'regex' ); $exclude_string = $schedule->backup->exclude_string( 'regex' );
} }
@ -1076,7 +1076,7 @@ return;
$schedule_id = $this->check_schedule(); $schedule_id = $this->check_schedule();
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $schedule_id ) ); $schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $schedule_id ) );
$excludes = $schedule->get_excludes(); $excludes = $schedule->get_excludes();
$exclude_rule_to_remove = stripslashes( sanitize_text_field( $_POST['remove_rule'] ) ); $exclude_rule_to_remove = stripslashes( sanitize_text_field( $_POST['remove_rule'] ) );
if (method_exists($excludes, 'get_user_excludes')) { if (method_exists($excludes, 'get_user_excludes')) {
@ -1104,7 +1104,7 @@ return;
function general_exclude_add_rule() { function general_exclude_add_rule() {
$sch_id = $this->check_schedule(); $sch_id = $this->check_schedule();
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $sch_id ) ); $schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $sch_id ) );
$exclude_paths = urldecode( $_POST['exclude_paths'] ); $exclude_paths = urldecode( $_POST['exclude_paths'] );
@ -1119,7 +1119,7 @@ return;
} }
$exclude_rule = ABSPATH . $excl_rule; $exclude_rule = ABSPATH . $excl_rule;
$path = realpath($exclude_rule); $path = realpath($exclude_rule);
// If it exist // If it exist
if ($path !== false) { if ($path !== false) {
$schedule->set_excludes( $exclude_rule, true ); $schedule->set_excludes( $exclude_rule, true );
@ -1225,7 +1225,7 @@ return;
if ( empty($sch_id) || ! isset( $sch['options'] ) || ! is_array( $sch['options'] ) ) { if ( empty($sch_id) || ! isset( $sch['options'] ) || ! is_array( $sch['options'] ) ) {
continue; continue;
} }
$options = $sch['options']; $options = $sch['options'];
$filter_opts = array( $filter_opts = array(
'type', 'type',
'email', 'email',

View file

@ -22,11 +22,11 @@ if ( ! defined( 'MAINWP_BACKWPUP_DEVELOPMENT' ) ) {
class MainWP_Child_Back_WP_Up { class MainWP_Child_Back_WP_Up {
public $is_backwpup_installed = false; public $is_backwpup_installed = false;
public $is_backwpup_pro = false; public $is_backwpup_pro = false;
public $plugin_translate = 'mainwp-backwpup-extension'; public $plugin_translate = 'mainwp-backwpup-extension';
public static $instance = null; public static $instance = null;
protected $software_version = '0.1'; protected $software_version = '0.1';
public static $information = array(); public static $information = array();
protected $exclusions = array( protected $exclusions = array(
'cron' => array( 'cron' => array(
@ -116,7 +116,7 @@ class MainWP_Child_Back_WP_Up {
error_reporting( 0 ); error_reporting( 0 );
function mainwp_backwpup_handle_fatal_error() { function mainwp_backwpup_handle_fatal_error() {
$error = error_get_last(); $error = error_get_last();
$info = self::$information; $info = self::$information;
if ( isset( $error['type'] ) && E_ERROR === $error['type'] && isset( $error['message'] ) ) { if ( isset( $error['type'] ) && E_ERROR === $error['type'] && isset( $error['message'] ) ) {
MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) ); MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
} elseif ( ! empty( $info ) ) { } elseif ( ! empty( $info ) ) {
@ -281,7 +281,7 @@ return;
continue; // do not logging backups have errors continue; // do not logging backups have errors
} }
$log_items[ $mtime ] = $meta; $log_items[ $mtime ] = $meta;
$log_items[ $mtime ]['file'] = $logfile; $log_items[ $mtime ]['file'] = $logfile;
} }
@ -303,7 +303,7 @@ return;
continue; continue;
} }
$job_job_types = explode('+', $log['type']); $job_job_types = explode('+', $log['type']);
$backup_type = ''; $backup_type = '';
foreach ($job_job_types as $typeid) { foreach ($job_job_types as $typeid) {
if (isset( $job_types[ $typeid ] )) { if (isset( $job_types[ $typeid ] )) {
$backup_type .= ' + ' . $job_types[ $typeid ]; $backup_type .= ' + ' . $job_types[ $typeid ];
@ -336,7 +336,7 @@ return;
function syncOthersData( $information, $data = array() ) { function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncBackwpupData'] ) && $data['syncBackwpupData'] ) { if ( isset( $data['syncBackwpupData'] ) && $data['syncBackwpupData'] ) {
try { try {
$lastbackup = MainWP_Helper::get_lasttime_backup('backwpup'); $lastbackup = MainWP_Helper::get_lasttime_backup('backwpup');
$information['syncBackwpupData'] = array( $information['syncBackwpupData'] = array(
'lastbackup' => $lastbackup, 'lastbackup' => $lastbackup,
); );
@ -630,7 +630,7 @@ return;
$log_folder = get_site_option( 'backwpup_cfg_logfolder' ); $log_folder = get_site_option( 'backwpup_cfg_logfolder' );
$log_folder = BackWPup_File::get_absolute_path( $log_folder ); $log_folder = BackWPup_File::get_absolute_path( $log_folder );
$log_file = $log_folder . basename( $_POST['settings']['logfile'] ); $log_file = $log_folder . basename( $_POST['settings']['logfile'] );
if ( ! is_readable( $log_file ) && ! is_readable( $log_file . '.gz' ) && ! is_readable( $log_file . '.bz2' ) ) { if ( ! is_readable( $log_file ) && ! is_readable( $log_file . '.gz' ) && ! is_readable( $log_file . '.bz2' ) ) {
$output = __( 'Log file doesn\'t exists', $this->plugin_translate ); $output = __( 'Log file doesn\'t exists', $this->plugin_translate );
@ -708,13 +708,13 @@ return;
if ( is_null($dest_class) ) { if ( is_null($dest_class) ) {
continue; continue;
} }
$items = $dest_class->file_get_list( $jobid . '_' . $dest ); $items = $dest_class->file_get_list( $jobid . '_' . $dest );
if ( ! empty( $items ) ) { if ( ! empty( $items ) ) {
foreach ( $items as $item ) { foreach ( $items as $item ) {
$temp_single_item = $item; $temp_single_item = $item;
$temp_single_item['dest'] = $jobid . '_' . $dest; $temp_single_item['dest'] = $jobid . '_' . $dest;
$temp_single_item['timeloc'] = sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ), $temp_single_item['time'], true ), date_i18n( get_option( 'time_format' ), $temp_single_item['time'], true ) ); $temp_single_item['timeloc'] = sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ), $temp_single_item['time'], true ), date_i18n( get_option( 'time_format' ), $temp_single_item['time'], true ) );
$output->items[] = $temp_single_item; $output->items[] = $temp_single_item;
} }
} }
} }
@ -787,7 +787,7 @@ return;
error_log('not match'); error_log('not match');
} }
$temp_array['website_id'] = $website_id; $temp_array['website_id'] = $website_id;
if ( ! isset( $without_dupes[ $temp_array['file'] ] ) ) { if ( ! isset( $without_dupes[ $temp_array['file'] ] ) ) {
$array[] = $temp_array; $array[] = $temp_array;
@ -1335,13 +1335,13 @@ return;
// From BackWPup_JobType_File::edit_form_post_save with some tweaks // From BackWPup_JobType_File::edit_form_post_save with some tweaks
public function edit_form_post_save( $post_data, $id ) { public function edit_form_post_save( $post_data, $id ) {
// Parse and save files to exclude // Parse and save files to exclude
$exclude_input = $post_data['fileexclude']; $exclude_input = $post_data['fileexclude'];
$to_exclude_list = $exclude_input ? str_replace( array( "\r\n", "\r" ), ',', $exclude_input ) : array(); $to_exclude_list = $exclude_input ? str_replace( array( "\r\n", "\r" ), ',', $exclude_input ) : array();
$to_exclude_list and $to_exclude_list = sanitize_text_field( stripslashes( $to_exclude_list ) ); $to_exclude_list and $to_exclude_list = sanitize_text_field( stripslashes( $to_exclude_list ) );
$to_exclude = $to_exclude_list ? explode( ',', $to_exclude_list ) : array(); $to_exclude = $to_exclude_list ? explode( ',', $to_exclude_list ) : array();
$to_exclude_parsed = array(); $to_exclude_parsed = array();
foreach ( $to_exclude as $key => $value ) { foreach ( $to_exclude as $key => $value ) {
$normalized = wp_normalize_path( trim( $value ) ); $normalized = wp_normalize_path( trim( $value ) );
$normalized and $to_exclude_parsed[ $key ] = $normalized; $normalized and $to_exclude_parsed[ $key ] = $normalized;
} }
sort( $to_exclude_parsed ); sort( $to_exclude_parsed );
@ -1349,14 +1349,14 @@ return;
unset( $exclude_input, $to_exclude_list, $to_exclude, $to_exclude_parsed, $normalized ); unset( $exclude_input, $to_exclude_list, $to_exclude, $to_exclude_parsed, $normalized );
// Parse and save folders to include // Parse and save folders to include
$include_input = $post_data['dirinclude']; $include_input = $post_data['dirinclude'];
$include_list = $include_input ? str_replace( array( "\r\n", "\r" ), ',', $include_input ) : array(); $include_list = $include_input ? str_replace( array( "\r\n", "\r" ), ',', $include_input ) : array();
$to_include = $include_list ? explode( ',', $include_list ) : array(); $to_include = $include_list ? explode( ',', $include_list ) : array();
$to_include_parsed = array(); $to_include_parsed = array();
foreach ( $to_include as $key => $value ) { foreach ( $to_include as $key => $value ) {
$normalized = trailingslashit( wp_normalize_path( trim( $value ) ) ); $normalized = trailingslashit( wp_normalize_path( trim( $value ) ) );
$normalized and $normalized = filter_var( $normalized, FILTER_SANITIZE_URL ); $normalized and $normalized = filter_var( $normalized, FILTER_SANITIZE_URL );
$realpath = $normalized && $normalized !== '/' ? realpath( $normalized ) : false; $realpath = $normalized && $normalized !== '/' ? realpath( $normalized ) : false;
$realpath and $to_include_parsed[ $key ] = $realpath; $realpath and $to_include_parsed[ $key ] = $realpath;
} }
sort( $to_include_parsed ); sort( $to_include_parsed );
@ -1536,7 +1536,7 @@ return;
update_site_option( 'backwpup_messages', array() ); update_site_option( 'backwpup_messages', array() );
$settings_views = array(); $settings_views = array();
$settings_updaters = array(); $settings_updaters = array();
$backwpup = new BackWPup_Page_Settings($settings_views, $settings_updaters); $backwpup = new BackWPup_Page_Settings($settings_views, $settings_updaters);

View file

@ -33,8 +33,8 @@ class MainWP_Child_Branding {
$label = stripslashes( $label ); $label = stripslashes( $label );
} }
$opts['contact_label'] = $label; $opts['contact_label'] = $label;
$opts['extra_settings'] = get_option( 'mainwp_branding_extra_settings' ); $opts['extra_settings'] = get_option( 'mainwp_branding_extra_settings' );
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $opts ); MainWP_Helper::update_option( 'mainwp_child_branding_settings', $opts );
} }
@ -42,11 +42,11 @@ class MainWP_Child_Branding {
$opts['contact_label'] = 'Contact Support'; $opts['contact_label'] = 'Contact Support';
} }
$disconnected = isset( $opts['branding_disconnected'] ) ? $opts['branding_disconnected'] : ''; $disconnected = isset( $opts['branding_disconnected'] ) ? $opts['branding_disconnected'] : '';
$preserve_branding = isset( $opts['preserve_branding'] ) ? $opts['preserve_branding'] : ''; $preserve_branding = isset( $opts['preserve_branding'] ) ? $opts['preserve_branding'] : '';
$cancelled_branding = ( $disconnected === 'yes' ) && ! $preserve_branding; $cancelled_branding = ( $disconnected === 'yes' ) && ! $preserve_branding;
$opts['cancelled_branding'] = $cancelled_branding; $opts['cancelled_branding'] = $cancelled_branding;
$opts['branding_preserve_title'] = ''; $opts['branding_preserve_title'] = '';
if ( ! $cancelled_branding ) { if ( ! $cancelled_branding ) {
@ -171,7 +171,7 @@ class MainWP_Child_Branding {
return $information; return $information;
} }
$current_settings = $this->child_branding_options; $current_settings = $this->child_branding_options;
$current_extra_setting = $this->child_branding_options['extra_settings']; $current_extra_setting = $this->child_branding_options['extra_settings'];
//MainWP_Helper::update_option( 'mainwp_branding_ext_enabled', 'Y' ); //MainWP_Helper::update_option( 'mainwp_branding_ext_enabled', 'Y' );
@ -204,21 +204,21 @@ class MainWP_Child_Branding {
// MainWP_Helper::update_option( 'mainwp_branding_disable_wp_branding', $settings['child_disable_wp_branding'] ); // MainWP_Helper::update_option( 'mainwp_branding_disable_wp_branding', $settings['child_disable_wp_branding'] );
// } // }
$current_settings['preserve_branding'] = $settings['child_preserve_branding']; $current_settings['preserve_branding'] = $settings['child_preserve_branding'];
$current_settings['branding_header'] = $header; $current_settings['branding_header'] = $header;
$current_settings['support_email'] = $settings['child_support_email']; $current_settings['support_email'] = $settings['child_support_email'];
$current_settings['support_message'] = $settings['child_support_message']; $current_settings['support_message'] = $settings['child_support_message'];
$current_settings['remove_restore'] = $settings['child_remove_restore']; $current_settings['remove_restore'] = $settings['child_remove_restore'];
$current_settings['remove_setting'] = $settings['child_remove_setting']; $current_settings['remove_setting'] = $settings['child_remove_setting'];
$current_settings['remove_server_info'] = $settings['child_remove_server_info']; $current_settings['remove_server_info'] = $settings['child_remove_server_info'];
$current_settings['remove_connection_detail'] = isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0; $current_settings['remove_connection_detail'] = isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0;
$current_settings['remove_wp_tools'] = $settings['child_remove_wp_tools']; $current_settings['remove_wp_tools'] = $settings['child_remove_wp_tools'];
$current_settings['remove_wp_setting'] = $settings['child_remove_wp_setting']; $current_settings['remove_wp_setting'] = $settings['child_remove_wp_setting'];
$current_settings['remove_permalink'] = $settings['child_remove_permalink']; $current_settings['remove_permalink'] = $settings['child_remove_permalink'];
$current_settings['contact_label'] = $settings['child_button_contact_label']; $current_settings['contact_label'] = $settings['child_button_contact_label'];
$current_settings['email_message'] = $settings['child_send_email_message']; $current_settings['email_message'] = $settings['child_send_email_message'];
$current_settings['return_sender'] = $settings['child_message_return_sender']; $current_settings['return_sender'] = $settings['child_message_return_sender'];
$current_settings['submit_button_title'] = $settings['child_submit_button_title']; $current_settings['submit_button_title'] = $settings['child_submit_button_title'];
if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) { if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) {
$current_settings['disable_wp_branding'] = $settings['child_disable_wp_branding']; $current_settings['disable_wp_branding'] = $settings['child_disable_wp_branding'];
@ -341,9 +341,9 @@ class MainWP_Child_Branding {
// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', '' ); // MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', '' );
// } // }
$current_settings['hide'] = $settings['child_plugin_hide'] ? 'T' : ''; $current_settings['hide'] = $settings['child_plugin_hide'] ? 'T' : '';
$current_settings['show_support'] = ( $settings['child_show_support_button'] && ! empty($settings['child_support_email']) ) ? 'T' : ''; $current_settings['show_support'] = ( $settings['child_show_support_button'] && ! empty($settings['child_support_email']) ) ? 'T' : '';
$current_settings['disable_change'] = $settings['child_disable_change'] ? 'T' : ''; $current_settings['disable_change'] = $settings['child_disable_change'] ? 'T' : '';
$current_settings['disable_switching_theme'] = $settings['child_disable_switching_theme'] ? 'T' : ''; $current_settings['disable_switching_theme'] = $settings['child_disable_switching_theme'] ? 'T' : '';
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $current_settings ); MainWP_Helper::update_option( 'mainwp_child_branding_settings', $current_settings );
@ -807,11 +807,11 @@ class MainWP_Child_Branding {
public function send_support_mail() { public function send_support_mail() {
$email = $this->child_branding_options['support_email']; $email = $this->child_branding_options['support_email'];
$sub = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_subject'] ) ) ); $sub = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_subject'] ) ) );
$from = trim($_POST['mainwp_branding_contact_send_from']); $from = trim($_POST['mainwp_branding_contact_send_from']);
$subject = ! empty( $sub ) ? $sub : 'MainWP - Support Contact'; $subject = ! empty( $sub ) ? $sub : 'MainWP - Support Contact';
$content = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_content'] ) ) ); $content = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_content'] ) ) );
$mail = $headers = ''; $mail = $headers = '';
if ( ! empty( $_POST['mainwp_branding_contact_message_content'] ) && ! empty( $email ) ) { if ( ! empty( $_POST['mainwp_branding_contact_message_content'] ) && ! empty( $email ) ) {
global $current_user; global $current_user;
$headers .= "Content-Type: text/html;charset=utf-8\r\n"; $headers .= "Content-Type: text/html;charset=utf-8\r\n";
@ -886,7 +886,7 @@ class MainWP_Child_Branding {
$support_message = $opts['support_message']; $support_message = $opts['support_message'];
$support_message = nl2br( stripslashes( $support_message ) ); $support_message = nl2br( stripslashes( $support_message ) );
$from_email = $current_user ? $current_user->user_email : ''; $from_email = $current_user ? $current_user->user_email : '';
?> ?>
<form action="" method="post"> <form action="" method="post">
<div style="width: 99%;"> <div style="width: 99%;">
@ -968,9 +968,9 @@ class MainWP_Child_Branding {
return false; return false;
} }
$is_hide = isset( $opts['hide'] ) ? $opts['hide'] : ''; $is_hide = isset( $opts['hide'] ) ? $opts['hide'] : '';
$cancelled_branding = $opts['cancelled_branding']; $cancelled_branding = $opts['cancelled_branding'];
$branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : ''; $branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : '';
if ( $cancelled_branding ) { if ( $cancelled_branding ) {
return false; return false;
@ -1147,9 +1147,9 @@ class MainWP_Child_Branding {
public function modify_plugin_header( $plugins ) { public function modify_plugin_header( $plugins ) {
$opts = $this->child_branding_options; $opts = $this->child_branding_options;
if ( is_array($opts) ) { if ( is_array($opts) ) {
$is_hide = isset( $opts['hide'] ) ? $opts['hide'] : ''; $is_hide = isset( $opts['hide'] ) ? $opts['hide'] : '';
$cancelled_branding = $opts['cancelled_branding']; $cancelled_branding = $opts['cancelled_branding'];
$branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : ''; $branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : '';
if ( $cancelled_branding ) { if ( $cancelled_branding ) {
return $plugins; return $plugins;

View file

@ -16,7 +16,7 @@
*/ */
class MainWP_Child_iThemes_Security { class MainWP_Child_iThemes_Security {
public static $instance = null; public static $instance = null;
public $is_plugin_installed = false; public $is_plugin_installed = false;
static function Instance() { static function Instance() {
@ -205,11 +205,11 @@ class MainWP_Child_iThemes_Security {
); );
$require_permalinks = false; $require_permalinks = false;
$updated = false; $updated = false;
$errors = array(); $errors = array();
$nbf_settings = array(); $nbf_settings = array();
$update_settings = maybe_unserialize( base64_decode( $_POST['settings'] ) ); $update_settings = maybe_unserialize( base64_decode( $_POST['settings'] ) );
foreach ($update_settings as $module => $settings) { foreach ($update_settings as $module => $settings) {
$do_not_save = false; $do_not_save = false;
@ -227,7 +227,7 @@ class MainWP_Child_iThemes_Security {
} else { } else {
$result = $this->validate_directory('log_location', $settings['log_location']); $result = $this->validate_directory('log_location', $settings['log_location']);
if ($result !== true) { if ($result !== true) {
$errors[] = $result; $errors[] = $result;
$settings['log_location'] = ITSEC_Modules::get_setting( $module, 'log_location' ); // no change $settings['log_location'] = ITSEC_Modules::get_setting( $module, 'log_location' ); // no change
} }
} }
@ -238,7 +238,7 @@ class MainWP_Child_iThemes_Security {
} else { } else {
$result = $this->validate_directory('location', $settings['location']); $result = $this->validate_directory('location', $settings['location']);
if ($result !== true) { if ($result !== true) {
$errors[] = $result; $errors[] = $result;
$settings['location'] = ITSEC_Modules::get_setting( $module, 'location' ); // no change $settings['location'] = ITSEC_Modules::get_setting( $module, 'location' ); // no change
} }
} }
@ -250,9 +250,9 @@ class MainWP_Child_iThemes_Security {
if (isset($settings['enabled']) && ! empty($settings['enabled'])) { if (isset($settings['enabled']) && ! empty($settings['enabled'])) {
$permalink_structure = get_option( 'permalink_structure', false ); $permalink_structure = get_option( 'permalink_structure', false );
if ( empty( $permalink_structure ) && ! is_multisite() ) { if ( empty( $permalink_structure ) && ! is_multisite() ) {
$errors[] = __( 'You must change <strong>WordPress permalinks</strong> to a setting other than "Plain" in order to use "Hide Backend" feature.', 'better-wp-security' ); $errors[] = __( 'You must change <strong>WordPress permalinks</strong> to a setting other than "Plain" in order to use "Hide Backend" feature.', 'better-wp-security' );
$require_permalinks = true; $require_permalinks = true;
$do_not_save = true; $do_not_save = true;
} }
} }
} elseif ($module == 'network-brute-force') { } elseif ($module == 'network-brute-force') {
@ -261,7 +261,7 @@ class MainWP_Child_iThemes_Security {
$result = $this->activate_api_key($settings); $result = $this->activate_api_key($settings);
if ($result === false) { if ($result === false) {
$nbf_settings = $settings; $nbf_settings = $settings;
$errors[] = 'Error: Active iThemes Network Brute Force Protection Api Key'; $errors[] = 'Error: Active iThemes Network Brute Force Protection Api Key';
} else { } else {
$nbf_settings = $result; $nbf_settings = $result;
} }
@ -270,9 +270,9 @@ class MainWP_Child_iThemes_Security {
// update 'enable_ban' field only // update 'enable_ban' field only
if (isset($settings['enable_ban'])) { if (isset($settings['enable_ban'])) {
$previous_settings['enable_ban'] = $settings['enable_ban']; $previous_settings['enable_ban'] = $settings['enable_ban'];
$nbf_settings = $previous_settings; $nbf_settings = $previous_settings;
} else { } else {
$do_not_save = true; $do_not_save = true;
$nbf_settings = $previous_settings; $nbf_settings = $previous_settings;
} }
} }
@ -291,7 +291,7 @@ class MainWP_Child_iThemes_Security {
} }
} }
} }
$updated = true; $updated = true;
ITSEC_Modules::set_settings( $module, $current_settings ); ITSEC_Modules::set_settings( $module, $current_settings );
} }
continue; continue;
@ -299,7 +299,7 @@ class MainWP_Child_iThemes_Security {
if ( ! $do_not_save ) { if ( ! $do_not_save ) {
ITSEC_Modules::set_settings( $module, $settings ); ITSEC_Modules::set_settings( $module, $settings );
$updated = true; $updated = true;
} }
} }
} }
@ -356,14 +356,14 @@ class MainWP_Child_iThemes_Security {
} }
public static function activate_network_brute_force() { public static function activate_network_brute_force() {
$data = maybe_unserialize( base64_decode( $_POST['data'] ) ); $data = maybe_unserialize( base64_decode( $_POST['data'] ) );
$information = array(); $information = array();
if (is_array($data)) { if (is_array($data)) {
$settings = ITSEC_Modules::get_settings( 'network-brute-force' ); $settings = ITSEC_Modules::get_settings( 'network-brute-force' );
$settings['email'] = $data['email']; $settings['email'] = $data['email'];
$settings['updates_optin'] = $data['updates_optin']; $settings['updates_optin'] = $data['updates_optin'];
$settings['api_nag'] = false; $settings['api_nag'] = false;
$results = ITSEC_Modules::set_settings( 'network-brute-force', $settings ); $results = ITSEC_Modules::set_settings( 'network-brute-force', $settings );
if ( is_wp_error( $results ) ) { if ( is_wp_error( $results ) ) {
$information['error'] = 'Error: Active iThemes Network Brute Force Protection Api Key'; $information['error'] = 'Error: Active iThemes Network Brute Force Protection Api Key';
} elseif ( $results['saved'] ) { } elseif ( $results['saved'] ) {
@ -374,7 +374,7 @@ class MainWP_Child_iThemes_Security {
} }
if ($nbf_settings !== null) { if ($nbf_settings !== null) {
$information['nbf_settings'] = $nbf_settings; $information['nbf_settings'] = $nbf_settings;
$information['result'] = 'success'; $information['result'] = 'success';
} }
return $information; return $information;
} }
@ -419,7 +419,7 @@ class MainWP_Child_iThemes_Security {
// $this->set_can_save( false ); // $this->set_can_save( false );
// $this->add_error( $secret ); // $this->add_error( $secret );
} else { } else {
$settings['api_key'] = $key; $settings['api_key'] = $key;
$settings['api_secret'] = $secret; $settings['api_secret'] = $secret;
$settings['api_nag'] = false; $settings['api_nag'] = false;
@ -503,10 +503,10 @@ class MainWP_Child_iThemes_Security {
$itsec_backup->run(); $itsec_backup->run();
} }
$return = array(); $return = array();
$str_error = ''; $str_error = '';
$result = $itsec_backup->do_backup( true ); $result = $itsec_backup->do_backup( true );
if ( is_wp_error( $result ) ) { if ( is_wp_error( $result ) ) {
$errors = ITSEC_Response::get_error_strings( $result ); $errors = ITSEC_Response::get_error_strings( $result );
@ -515,7 +515,7 @@ class MainWP_Child_iThemes_Security {
$str_error .= $error . '<br />'; $str_error .= $error . '<br />';
} }
} elseif ( is_string( $result ) ) { } elseif ( is_string( $result ) ) {
$return['result'] = 'success'; $return['result'] = 'success';
$return['message'] = $result; $return['message'] = $result;
} else { } else {
$str_error = sprintf( __( 'The backup request returned an unexpected response. It returned a response of type <code>%1$s</code>.', 'better-wp-security' ), gettype( $result ) ); $str_error = sprintf( __( 'The backup request returned an unexpected response. It returned a response of type <code>%1$s</code>.', 'better-wp-security' ), gettype( $result ) );
@ -534,7 +534,7 @@ class MainWP_Child_iThemes_Security {
if ( ! class_exists( 'ITSEC_WordPress_Salts_Utilities' ) ) { if ( ! class_exists( 'ITSEC_WordPress_Salts_Utilities' ) ) {
require $mainwp_itsec_modules_path . 'salts/utilities.php'; require $mainwp_itsec_modules_path . 'salts/utilities.php';
} }
$result = ITSEC_WordPress_Salts_Utilities::generate_new_salts(); $result = ITSEC_WordPress_Salts_Utilities::generate_new_salts();
$str_error = ''; $str_error = '';
if ( is_wp_error( $result ) ) { if ( is_wp_error( $result ) ) {
$errors = ITSEC_Response::get_error_strings( $result ); $errors = ITSEC_Response::get_error_strings( $result );
@ -543,9 +543,9 @@ class MainWP_Child_iThemes_Security {
$str_error .= $error . '<br />'; $str_error .= $error . '<br />';
} }
} else { } else {
$return['result'] = 'success'; $return['result'] = 'success';
$return['message'] = __( 'The WordPress salts were successfully regenerated.', 'better-wp-security' ); $return['message'] = __( 'The WordPress salts were successfully regenerated.', 'better-wp-security' );
$last_generated = ITSEC_Core::get_current_time_gmt(); $last_generated = ITSEC_Core::get_current_time_gmt();
ITSEC_Modules::set_setting( 'wordpress-salts', 'last_generated', $last_generated ); ITSEC_Modules::set_setting( 'wordpress-salts', 'last_generated', $last_generated );
} }
if ( ! empty($str_error)) { if ( ! empty($str_error)) {
@ -620,7 +620,7 @@ class MainWP_Child_iThemes_Security {
$row[] = sprintf( '%o', $suggested_permissions ); $row[] = sprintf( '%o', $suggested_permissions );
$permissions = fileperms( $path ) & 0777; $permissions = fileperms( $path ) & 0777;
$row[] = sprintf( '%o', $permissions ); $row[] = sprintf( '%o', $permissions );
if ( ! $permissions || $permissions != $suggested_permissions ) { if ( ! $permissions || $permissions != $suggested_permissions ) {
$row[] = __( 'WARNING', 'better-wp-security' ); $row[] = __( 'WARNING', 'better-wp-security' );
@ -680,7 +680,7 @@ class MainWP_Child_iThemes_Security {
} }
$result = ITSEC_File_Change_Scanner::run_scan( false ); $result = ITSEC_File_Change_Scanner::run_scan( false );
if ($result === false || $result === true || $result === -1) { if ($result === false || $result === true || $result === -1) {
$return['result'] = 'success'; $return['result'] = 'success';
$return['scan_result'] = $result; $return['scan_result'] = $result;
} }
return $return; return $return;
@ -695,7 +695,7 @@ class MainWP_Child_iThemes_Security {
} }
$new_username = isset( $settings['new_username'] ) ? $settings['new_username'] : ''; $new_username = isset( $settings['new_username'] ) ? $settings['new_username'] : '';
$change_id = isset( $settings['change_id'] ) && $settings['change_id'] ? true : false; $change_id = isset( $settings['change_id'] ) && $settings['change_id'] ? true : false;
//load utility functions //load utility functions
if ( ! class_exists( 'ITSEC_Lib' ) ) { if ( ! class_exists( 'ITSEC_Lib' ) ) {
@ -732,7 +732,7 @@ class MainWP_Child_iThemes_Security {
// } // }
$admin_success = true; $admin_success = true;
$return = array(); $return = array();
if ( strlen( $new_username ) >= 1 && $username_exists ) { if ( strlen( $new_username ) >= 1 && $username_exists ) {
$admin_success = $this->change_admin_user( $new_username, $change_id ); $admin_success = $this->change_admin_user( $new_username, $change_id );
@ -881,7 +881,7 @@ class MainWP_Child_iThemes_Security {
global $mainwp_itsec_modules_path; global $mainwp_itsec_modules_path;
require_once $mainwp_itsec_modules_path . 'database-prefix/utility.php'; require_once $mainwp_itsec_modules_path . 'database-prefix/utility.php';
$str_error = ''; $str_error = '';
$return = array(); $return = array();
if ( isset( $_POST['change_prefix'] ) && 'yes' === $_POST['change_prefix'] ) { if ( isset( $_POST['change_prefix'] ) && 'yes' === $_POST['change_prefix'] ) {
$result = ITSEC_Database_Prefix_Utility::change_database_prefix(); $result = ITSEC_Database_Prefix_Utility::change_database_prefix();
@ -900,7 +900,7 @@ class MainWP_Child_iThemes_Security {
if ( false === $result['new_prefix'] ) { if ( false === $result['new_prefix'] ) {
$return['error'] = $str_error; $return['error'] = $str_error;
} else { } else {
$return['result'] = 'success'; $return['result'] = 'success';
$return['message'] = sprintf( __( 'The database table prefix was successfully changed to <code>%1$s</code>.', 'better-wp-security' ), $result['new_prefix'] ); $return['message'] = sprintf( __( 'The database table prefix was successfully changed to <code>%1$s</code>.', 'better-wp-security' ), $result['new_prefix'] );
} }
@ -914,7 +914,7 @@ class MainWP_Child_iThemes_Security {
$settings = array(); $settings = array();
} }
$settings['reset'] = true; $settings['reset'] = true;
$return = array(); $return = array();
if ( update_site_option( 'itsec_ipcheck', $settings ) ) { if ( update_site_option( 'itsec_ipcheck', $settings ) ) {
$return['result'] = 'success'; $return['result'] = 'success';
} else { } else {
@ -927,7 +927,7 @@ class MainWP_Child_iThemes_Security {
public function reset_api_key() { public function reset_api_key() {
$defaults = ITSEC_Modules::get_defaults( 'network-brute-force' ); $defaults = ITSEC_Modules::get_defaults( 'network-brute-force' );
$results = ITSEC_Modules::set_settings( 'network-brute-force', $defaults ); $results = ITSEC_Modules::set_settings( 'network-brute-force', $defaults );
ITSEC_Response::set_response( $results['saved'] ); ITSEC_Response::set_response( $results['saved'] );
ITSEC_Response::add_errors( $results['errors'] ); ITSEC_Response::add_errors( $results['errors'] );
@ -935,7 +935,7 @@ class MainWP_Child_iThemes_Security {
$information = array(); $information = array();
if ( $results['saved'] ) { if ( $results['saved'] ) {
$information['result'] = 'success'; $information['result'] = 'success';
$information['nbf_settings'] = ITSEC_Modules::get_settings( 'network-brute-force'); $information['nbf_settings'] = ITSEC_Modules::get_settings( 'network-brute-force');
} elseif ( empty( $results['errors'] ) ) { } elseif ( empty( $results['errors'] ) ) {
$information['error_reset_api'] = 1; $information['error_reset_api'] = 1;
@ -955,7 +955,7 @@ class MainWP_Child_iThemes_Security {
if ( ! ITSEC_Core::current_user_can_manage() ) { if ( ! ITSEC_Core::current_user_can_manage() ) {
$response['error'] = 'The currently logged in user does not have sufficient permissions to run this scan.'; $response['error'] = 'The currently logged in user does not have sufficient permissions to run this scan.';
} else { } else {
$results = ITSEC_Malware_Scanner::scan(); $results = ITSEC_Malware_Scanner::scan();
$response['html'] = ITSEC_Malware_Scan_Results_Template::get_html( $results, true ); $response['html'] = ITSEC_Malware_Scan_Results_Template::get_html( $results, true );
} }
@ -969,8 +969,8 @@ class MainWP_Child_iThemes_Security {
require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php'; require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php';
require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php'; require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php';
} }
$response = array(); $response = array();
$results = ITSEC_Malware_Scanner::scan(); $results = ITSEC_Malware_Scanner::scan();
$response['html'] = ITSEC_Malware_Scan_Results_Template::get_html( $results, true ); $response['html'] = ITSEC_Malware_Scan_Results_Template::get_html( $results, true );
return $response; return $response;
} }
@ -1134,7 +1134,7 @@ class MainWP_Child_iThemes_Security {
private function get_excludable_tables() { private function get_excludable_tables() {
global $wpdb; global $wpdb;
$all_sites = ITSEC_Modules::get_setting( 'backup', 'all_sites' ); $all_sites = ITSEC_Modules::get_setting( 'backup', 'all_sites' );
$ignored_tables = array( $ignored_tables = array(
'commentmeta', 'commentmeta',
'comments', 'comments',
@ -1155,7 +1155,7 @@ class MainWP_Child_iThemes_Security {
$query = $wpdb->prepare( 'SHOW TABLES LIKE %s', "{$wpdb->base_prefix}%" ); $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', "{$wpdb->base_prefix}%" );
} }
$tables = $wpdb->get_results( $query, ARRAY_N ); $tables = $wpdb->get_results( $query, ARRAY_N );
$excludes = array(); $excludes = array();
foreach ( $tables as $table ) { foreach ( $tables as $table ) {

View file

@ -15,7 +15,7 @@
class MainWP_Child_Links_Checker { class MainWP_Child_Links_Checker {
public static $instance = null; public static $instance = null;
public $is_plugin_installed = false; public $is_plugin_installed = false;
static function Instance() { static function Instance() {
@ -114,8 +114,8 @@ class MainWP_Child_Links_Checker {
} }
function save_settings() { function save_settings() {
$information = array(); $information = array();
$check_threshold = intval( $_POST['check_threshold'] ); $check_threshold = intval( $_POST['check_threshold'] );
if ( $check_threshold > 0 ) { if ( $check_threshold > 0 ) {
$conf = blc_get_configuration(); $conf = blc_get_configuration();
$conf->options['check_threshold'] = $check_threshold; $conf->options['check_threshold'] = $check_threshold;
@ -245,16 +245,16 @@ return;
MainWP_Helper::check_classes_exists('blcLinkQuery'); MainWP_Helper::check_classes_exists('blcLinkQuery');
MainWP_Helper::check_methods('blcLinkQuery', 'getInstance'); MainWP_Helper::check_methods('blcLinkQuery', 'getInstance');
$blc_link_query = blcLinkQuery::getInstance(); $blc_link_query = blcLinkQuery::getInstance();
MainWP_Helper::check_methods($blc_link_query, 'get_filter_links'); MainWP_Helper::check_methods($blc_link_query, 'get_filter_links');
$total = $blc_link_query->get_filter_links( 'all', array( 'count_only' => true ) ); $total = $blc_link_query->get_filter_links( 'all', array( 'count_only' => true ) );
$max_results = isset($_POST['max_results']) ? intval($_POST['max_results']) : 50; $max_results = isset($_POST['max_results']) ? intval($_POST['max_results']) : 50;
$offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0; $offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0;
$params = array( $params = array(
array( 'load_instances' => true ), array( 'load_instances' => true ),
'max_results' => $max_results, 'max_results' => $max_results,
); );
@ -282,9 +282,9 @@ return;
if ($total > $offset + $max_results ) { if ($total > $offset + $max_results ) {
$information['sync_offset'] = $offset + $max_results; $information['sync_offset'] = $offset + $max_results;
} else { } else {
$information['last_sync'] = 1; $information['last_sync'] = 1;
$information['total_sync'] = $total_sync; $information['total_sync'] = $total_sync;
$information['data'] = $this->get_count_links(); $information['data'] = $this->get_count_links();
} }
$information['result'] = 'success'; $information['result'] = 'success';
@ -307,16 +307,16 @@ return;
MainWP_Helper::check_classes_exists('blcLinkQuery'); MainWP_Helper::check_classes_exists('blcLinkQuery');
MainWP_Helper::check_methods('blcLinkQuery', 'getInstance'); MainWP_Helper::check_methods('blcLinkQuery', 'getInstance');
$data = array(); $data = array();
$blc_link_query = blcLinkQuery::getInstance(); $blc_link_query = blcLinkQuery::getInstance();
MainWP_Helper::check_methods($blc_link_query, 'get_filter_links'); MainWP_Helper::check_methods($blc_link_query, 'get_filter_links');
$data['broken'] = $blc_link_query->get_filter_links( 'broken', array( 'count_only' => true ) ); $data['broken'] = $blc_link_query->get_filter_links( 'broken', array( 'count_only' => true ) );
$data['redirects'] = $blc_link_query->get_filter_links( 'redirects', array( 'count_only' => true ) ); $data['redirects'] = $blc_link_query->get_filter_links( 'redirects', array( 'count_only' => true ) );
$data['dismissed'] = $blc_link_query->get_filter_links( 'dismissed', array( 'count_only' => true ) ); $data['dismissed'] = $blc_link_query->get_filter_links( 'dismissed', array( 'count_only' => true ) );
$data['warning'] = $blc_link_query->get_filter_links( 'warning', array( 'count_only' => true ) ); $data['warning'] = $blc_link_query->get_filter_links( 'warning', array( 'count_only' => true ) );
$data['all'] = $blc_link_query->get_filter_links( 'all', array( 'count_only' => true ) ); $data['all'] = $blc_link_query->get_filter_links( 'all', array( 'count_only' => true ) );
return $data; return $data;
} }
@ -325,7 +325,7 @@ return;
MainWP_Helper::check_functions('blc_get_links'); MainWP_Helper::check_functions('blc_get_links');
MainWP_Helper::check_classes_exists('blcLink'); MainWP_Helper::check_classes_exists('blcLink');
$links = blc_get_links( $params ); $links = blc_get_links( $params );
$filter_fields = array( $filter_fields = array(
'link_id', 'link_id',
@ -351,7 +351,7 @@ return;
'status_code', 'status_code',
'log', 'log',
); );
$return = array(); $return = array();
$blc_option = get_option( 'wsblc_options' ); $blc_option = get_option( 'wsblc_options' );
@ -384,7 +384,7 @@ return;
} }
} }
$extra_info['days_broken'] = $days_broken; $extra_info['days_broken'] = $days_broken;
$instances = false; $instances = false;
$get_link = new blcLink( intval( $link->link_id ) ); $get_link = new blcLink( intval( $link->link_id ) );
if ( $get_link->valid() ) { if ( $get_link->valid() ) {
@ -393,13 +393,13 @@ return;
} }
if ( ! empty( $instances ) ) { if ( ! empty( $instances ) ) {
$first_instance = reset( $instances ); $first_instance = reset( $instances );
MainWP_Helper::check_methods($first_instance, array( 'ui_get_link_text', 'get_container', 'is_link_text_editable', 'is_url_editable' ) ); MainWP_Helper::check_methods($first_instance, array( 'ui_get_link_text', 'get_container', 'is_link_text_editable', 'is_url_editable' ) );
$new_link->link_text = $first_instance->ui_get_link_text(); $new_link->link_text = $first_instance->ui_get_link_text();
$extra_info['count_instance'] = count( $instances ); $extra_info['count_instance'] = count( $instances );
$container = $first_instance->get_container(); $container = $first_instance->get_container();
/** @var blcContainer $container */ /** @var blcContainer $container */
@ -407,8 +407,8 @@ return;
if (true === MainWP_Helper::check_properties($first_instance, array( 'container_field' ), true )) { if (true === MainWP_Helper::check_properties($first_instance, array( 'container_field' ), true )) {
if (true === MainWP_Helper::check_properties($container, array( 'container_type', 'container_id' ), true )) { if (true === MainWP_Helper::check_properties($container, array( 'container_type', 'container_id' ), true )) {
$extra_info['container_type'] = $container->container_type; $extra_info['container_type'] = $container->container_type;
$extra_info['container_id'] = $container->container_id; $extra_info['container_id'] = $container->container_id;
$extra_info['source_data'] = $this->ui_get_source( $container, $first_instance->container_field ); $extra_info['source_data'] = $this->ui_get_source( $container, $first_instance->container_field );
} }
} }
} }
@ -438,15 +438,15 @@ return;
$data_link_text = esc_attr( $link_text ); $data_link_text = esc_attr( $link_text );
} }
$extra_info['data_link_text'] = $data_link_text; $extra_info['data_link_text'] = $data_link_text;
$extra_info['can_edit_url'] = $can_edit_url; $extra_info['can_edit_url'] = $can_edit_url;
$extra_info['can_edit_text'] = $can_edit_text; $extra_info['can_edit_text'] = $can_edit_text;
} else { } else {
$new_link->link_text = ''; $new_link->link_text = '';
$extra_info['count_instance'] = 0; $extra_info['count_instance'] = 0;
} }
$new_link->extra_info = base64_encode(serialize($extra_info)); $new_link->extra_info = base64_encode(serialize($extra_info));
$new_link->synced = 1; $new_link->synced = 1;
$return[] = $new_link; $return[] = $new_link;
} }
} else { } else {
return array(); return array();

View file

@ -17,7 +17,7 @@
class MainWP_Child_Pagespeed { class MainWP_Child_Pagespeed {
public static $instance = null; public static $instance = null;
public $is_plugin_installed = false; public $is_plugin_installed = false;
static function Instance() { static function Instance() {
@ -159,7 +159,7 @@ class MainWP_Child_Pagespeed {
function save_settings() { function save_settings() {
$current_values = get_option( 'gpagespeedi_options' ); $current_values = get_option( 'gpagespeedi_options' );
$checkstatus = apply_filters( 'gpi_check_status', false ); $checkstatus = apply_filters( 'gpi_check_status', false );
if ( $checkstatus ) { if ( $checkstatus ) {
return array( 'result' => 'RUNNING' ); return array( 'result' => 'RUNNING' );
} }
@ -216,9 +216,9 @@ class MainWP_Child_Pagespeed {
if ( isset( $settings['check_report'] ) ) { if ( isset( $settings['check_report'] ) ) {
if ( is_array( $settings['check_report'] ) ) { if ( is_array( $settings['check_report'] ) ) {
$current_values['check_pages'] = in_array( 'page', $settings['check_report'] ) ? true : false; $current_values['check_pages'] = in_array( 'page', $settings['check_report'] ) ? true : false;
$current_values['check_posts'] = in_array( 'post', $settings['check_report'] ) ? true : false; $current_values['check_posts'] = in_array( 'post', $settings['check_report'] ) ? true : false;
$current_values['check_categories'] = in_array( 'category', $settings['check_report'] ) ? true : false; $current_values['check_categories'] = in_array( 'category', $settings['check_report'] ) ? true : false;
$current_values['check_custom_urls'] = in_array( 'custom_urls', $settings['check_report'] ) ? true : false; $current_values['check_custom_urls'] = in_array( 'custom_urls', $settings['check_report'] ) ? true : false;
} else { } else {
$current_values['check_pages'] = $current_values['check_posts'] = $current_values['check_categories'] = $current_values['check_custom_urls'] = false; $current_values['check_pages'] = $current_values['check_posts'] = $current_values['check_categories'] = $current_values['check_custom_urls'] = false;
@ -301,7 +301,7 @@ class MainWP_Child_Pagespeed {
} }
$current_values = get_option( 'gpagespeedi_options' ); $current_values = get_option( 'gpagespeedi_options' );
$checkstatus = apply_filters( 'gpi_check_status', false ); $checkstatus = apply_filters( 'gpi_check_status', false );
if ( $checkstatus ) { if ( $checkstatus ) {
return array( 'result' => 'RUNNING' ); return array( 'result' => 'RUNNING' );
} }
@ -311,7 +311,7 @@ class MainWP_Child_Pagespeed {
$data = array( 'bad_api_key' => $bad_key ); $data = array( 'bad_api_key' => $bad_key );
if ( 'both' === $strategy || 'desktop' === $strategy ) { if ( 'both' === $strategy || 'desktop' === $strategy ) {
$result = self::cal_pagespeed_data( 'desktop' ); $result = self::cal_pagespeed_data( 'desktop' );
if ( ! empty($result) && is_array($result) ) { if ( ! empty($result) && is_array($result) ) {
$data['desktop_score'] = $result['average_score']; $data['desktop_score'] = $result['average_score'];
$data['desktop_total_pages'] = $result['total_pages']; $data['desktop_total_pages'] = $result['total_pages'];
@ -319,7 +319,7 @@ class MainWP_Child_Pagespeed {
} }
} }
if ( 'both' === $strategy || 'mobile' === $strategy ) { if ( 'both' === $strategy || 'mobile' === $strategy ) {
$result = self::cal_pagespeed_data( 'mobile' ); $result = self::cal_pagespeed_data( 'mobile' );
if ( ! empty($result) && is_array($result) ) { if ( ! empty($result) && is_array($result) ) {
$data['mobile_score'] = $result['average_score']; $data['mobile_score'] = $result['average_score'];
$data['mobile_total_pages'] = $result['total_pages']; $data['mobile_total_pages'] = $result['total_pages'];
@ -342,7 +342,7 @@ class MainWP_Child_Pagespeed {
return false; return false;
} }
$score_column = $strategy . '_score'; $score_column = $strategy . '_score';
//$page_stats_column = $strategy . '_page_stats'; //$page_stats_column = $strategy . '_page_stats';
$data_typestocheck = self::get_filter_options( 'all' ); $data_typestocheck = self::get_filter_options( 'all' );
@ -440,28 +440,28 @@ class MainWP_Child_Pagespeed {
static function get_filter_options( $restrict_type = 'all') { static function get_filter_options( $restrict_type = 'all') {
$types = array(); $types = array();
$gpi_options = get_option('gpagespeedi_options'); $gpi_options = get_option('gpagespeedi_options');
$typestocheck = array(); $typestocheck = array();
if ($gpi_options['check_pages']) { if ($gpi_options['check_pages']) {
if ($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'pages') { if ($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'pages') {
$typestocheck[] = 'type = %s'; $typestocheck[] = 'type = %s';
$types[1][] = 'page'; $types[1][] = 'page';
} }
} }
if ($gpi_options['check_posts']) { if ($gpi_options['check_posts']) {
if ($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'posts') { if ($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'posts') {
$typestocheck[] = 'type = %s'; $typestocheck[] = 'type = %s';
$types[1][] = 'post'; $types[1][] = 'post';
} }
} }
if ($gpi_options['check_categories']) { if ($gpi_options['check_categories']) {
if ($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'categories') { if ($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'categories') {
$typestocheck[] = 'type = %s'; $typestocheck[] = 'type = %s';
$types[1][] = 'category'; $types[1][] = 'category';
} }
} }
if ($gpi_options['cpt_whitelist']) { if ($gpi_options['cpt_whitelist']) {
@ -471,7 +471,7 @@ class MainWP_Child_Pagespeed {
if ( ! empty($gpi_options['cpt_whitelist'])) { if ( ! empty($gpi_options['cpt_whitelist'])) {
$cpt_whitelist_arr = unserialize($gpi_options['cpt_whitelist']); $cpt_whitelist_arr = unserialize($gpi_options['cpt_whitelist']);
} }
$args = array( $args = array(
'public' => true, 'public' => true,
'_builtin' => false, '_builtin' => false,
); );
@ -482,7 +482,7 @@ class MainWP_Child_Pagespeed {
if ($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) { if ($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) {
if ($post_type == $restrict_type) { if ($post_type == $restrict_type) {
$typestocheck[] = 'type = %s'; $typestocheck[] = 'type = %s';
$types[1][] = $custom_post_types[ $post_type ]; $types[1][] = $custom_post_types[ $post_type ];
} }
} }
} }
@ -490,7 +490,7 @@ class MainWP_Child_Pagespeed {
foreach ($custom_post_types as $post_type) { foreach ($custom_post_types as $post_type) {
if ($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) { if ($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) {
$typestocheck[] = 'type = %s'; $typestocheck[] = 'type = %s';
$types[1][] = $custom_post_types[ $post_type ]; $types[1][] = $custom_post_types[ $post_type ];
} }
} }
} }
@ -500,7 +500,7 @@ class MainWP_Child_Pagespeed {
if ( $gpi_options['check_custom_urls'] ) { if ( $gpi_options['check_custom_urls'] ) {
global $wpdb; global $wpdb;
$gpi_custom_urls = $wpdb->prefix . 'gpi_custom_urls'; $gpi_custom_urls = $wpdb->prefix . 'gpi_custom_urls';
$custom_url_types = $wpdb->get_col( $custom_url_types = $wpdb->get_col(
" "
SELECT DISTINCT type SELECT DISTINCT type
@ -511,7 +511,7 @@ class MainWP_Child_Pagespeed {
if ( ! empty( $custom_url_types ) ) { if ( ! empty( $custom_url_types ) ) {
foreach ( $custom_url_types as $custom_url_type ) { foreach ( $custom_url_types as $custom_url_type ) {
$typestocheck[] = 'type = %s'; $typestocheck[] = 'type = %s';
$types[1][] = $custom_url_type; $types[1][] = $custom_url_type;
} }
} }
} }
@ -523,7 +523,7 @@ class MainWP_Child_Pagespeed {
$types[0] .= $type . ' OR '; $types[0] .= $type . ' OR ';
} else { } else {
foreach ($type as $custom_post_type) { foreach ($type as $custom_post_type) {
$types[0] .= 'type = %s OR '; $types[0] .= 'type = %s OR ';
$types[1][] = $custom_post_type; $types[1][] = $custom_post_type;
} }
} }

View file

@ -158,7 +158,7 @@ class MainWP_Child_Plugins_Check {
//See if this specific plugin is in the known list //See if this specific plugin is in the known list
if ( array_key_exists( $plugin_file, $plugin_info ) ) { if ( array_key_exists( $plugin_file, $plugin_info ) ) {
//Get now //Get now
$now = new \DateTime(); $now = new \DateTime();
$last_updated = $plugin_info[ $plugin_file ]['last_updated']; $last_updated = $plugin_info[ $plugin_file ]['last_updated'];
//Last updated is stored as timestamp, get a real date //Last updated is stored as timestamp, get a real date
@ -216,7 +216,7 @@ class MainWP_Child_Plugins_Check {
$avoid_plugins = array( 'sitepress-multilingual-cms/sitepress.php' ); $avoid_plugins = array( 'sitepress-multilingual-cms/sitepress.php' );
//Grab a small number of plugins to scan //Grab a small number of plugins to scan
$plugins_to_scan = array_splice( $all_plugins, 0, apply_filters( 'mainwp_child_plugin_health_check_max_plugins_to_batch', 10 ) ); $plugins_to_scan = array_splice( $all_plugins, 0, apply_filters( 'mainwp_child_plugin_health_check_max_plugins_to_batch', 10 ) );
$tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 ); $tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 );
//Loop through each known plugin //Loop through each known plugin

View file

@ -23,12 +23,12 @@ class MainWP_Child_Robot {
$comment_author = $comment['author']; $comment_author = $comment['author'];
$comment_author_url = ''; $comment_author_url = '';
$comment_content = ''; $comment_content = '';
$comment_content .= $comment['content']; $comment_content .= $comment['content'];
$comment_type = ''; $comment_type = '';
$user_ID = ''; $user_ID = '';
$comment_approved = 1; $comment_approved = 1;
$commentdata = compact( 'comment_post_ID', 'comment_date', 'comment_date_gmt', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'user_ID', 'comment_approved' ); $commentdata = compact( 'comment_post_ID', 'comment_date', 'comment_date_gmt', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'user_ID', 'comment_approved' );
$comment_id = wp_insert_comment( $commentdata ); $comment_id = wp_insert_comment( $commentdata );
} }
} }
} }

View file

@ -2,7 +2,7 @@
class MainWP_Child_Server_Information { class MainWP_Child_Server_Information {
const WARNING = 1; const WARNING = 1;
const ERROR = 2; const ERROR = 2;
public static function init() { public static function init() {
add_action( 'wp_ajax_mainwp-child_dismiss_warnings', array( add_action( 'wp_ajax_mainwp-child_dismiss_warnings', array(
@ -35,7 +35,7 @@ class MainWP_Child_Server_Information {
return; return;
} }
$warnings = self::getWarnings(); $warnings = self::getWarnings();
$dismissWarnings = get_option( 'mainwp_child_dismiss_warnings' ); $dismissWarnings = get_option( 'mainwp_child_dismiss_warnings' );
if ( ! is_array( $dismissWarnings ) ) { if ( ! is_array( $dismissWarnings ) ) {
@ -544,10 +544,10 @@ class MainWP_Child_Server_Information {
public static function render() { public static function render() {
$branding_title = MainWP_Child_Branding::Instance()->get_branding_title(); $branding_title = MainWP_Child_Branding::Instance()->get_branding_title();
$isBranding = true; $isBranding = true;
if ( $branding_title == '' ) { if ( $branding_title == '' ) {
$branding_title = 'MainWP Child'; $branding_title = 'MainWP Child';
$isBranding = false; $isBranding = false;
} }
?> ?>
@ -579,7 +579,7 @@ class MainWP_Child_Server_Information {
</tr> </tr>
<?php <?php
self::checkDirectoryMainWPDirectory(); self::checkDirectoryMainWPDirectory();
$server = get_option( 'mainwp_child_server' ); $server = get_option( 'mainwp_child_server' );
?> ?>
<tr> <tr>
<td></td> <td></td>
@ -1134,9 +1134,9 @@ class MainWP_Child_Server_Information {
protected static function getSSLWarning() { protected static function getSSLWarning() {
$conf = array( 'private_key_bits' => 2048 ); $conf = array( 'private_key_bits' => 2048 );
$str = ''; $str = '';
if ( function_exists( 'openssl_pkey_new' ) ) { if ( function_exists( 'openssl_pkey_new' ) ) {
$res = @openssl_pkey_new( $conf ); $res = @openssl_pkey_new( $conf );
@openssl_pkey_export( $res, $privkey ); @openssl_pkey_export( $res, $privkey );
$str = openssl_error_string(); $str = openssl_error_string();
@ -1328,15 +1328,15 @@ class MainWP_Child_Server_Information {
} }
protected static function serverSelfConnect() { protected static function serverSelfConnect() {
$url = site_url( 'wp-cron.php' ); $url = site_url( 'wp-cron.php' );
$query_args = array( 'mainwp_child_run' => 'test' ); $query_args = array( 'mainwp_child_run' => 'test' );
$url = add_query_arg( $query_args, $url ); $url = add_query_arg( $query_args, $url );
$args = array( $args = array(
'blocking' => true, 'blocking' => true,
'sslverify' => apply_filters( 'https_local_ssl_verify', true ), 'sslverify' => apply_filters( 'https_local_ssl_verify', true ),
'timeout' => 15, 'timeout' => 15,
); );
$response = wp_remote_post( $url, $args ); $response = wp_remote_post( $url, $args );
$test_result = ''; $test_result = '';
if ( is_wp_error( $response ) ) { if ( is_wp_error( $response ) ) {
$test_result .= sprintf( __( 'The HTTP response test get an error "%s"', 'mainwp-child' ), $response->get_error_message() ); $test_result .= sprintf( __( 'The HTTP response test get an error "%s"', 'mainwp-child' ), $response->get_error_message() );
@ -1556,7 +1556,7 @@ class MainWP_Child_Server_Information {
// read them to $data and then move the file pointer // read them to $data and then move the file pointer
// back to where we were. // back to where we were.
fseek( $fh, - $can_read, SEEK_CUR ); fseek( $fh, - $can_read, SEEK_CUR );
$data = fread( $fh, $can_read ); $data = fread( $fh, $can_read );
$data .= $leftover; $data .= $leftover;
fseek( $fh, - $can_read, SEEK_CUR ); fseek( $fh, - $can_read, SEEK_CUR );
@ -1590,7 +1590,7 @@ class MainWP_Child_Server_Information {
if ( file_exists( ABSPATH . 'wp-config.php' ) ) { if ( file_exists( ABSPATH . 'wp-config.php' ) ) {
@show_source( ABSPATH . 'wp-config.php' ); @show_source( ABSPATH . 'wp-config.php' );
} else { } else {
$files = @get_included_files(); $files = @get_included_files();
$configFound = false; $configFound = false;
if ( is_array( $files ) ) { if ( is_array( $files ) ) {
foreach ( $files as $file ) { foreach ( $files as $file ) {
@ -1634,7 +1634,7 @@ class MainWP_Child_Server_Information {
global $current_user; global $current_user;
$uniqueId = get_option('mainwp_child_uniqueId'); $uniqueId = get_option('mainwp_child_uniqueId');
$details = array( $details = array(
'siteurl' => array( 'siteurl' => array(
'title' => __('Site URL', 'mainwp-child'), 'title' => __('Site URL', 'mainwp-child'),
'value' => get_bloginfo( 'url' ), 'value' => get_bloginfo( 'url' ),

View file

@ -2,9 +2,9 @@
class MainWP_Child_Skeleton_Key { class MainWP_Child_Skeleton_Key {
public static $instance = null; public static $instance = null;
public static $information = array(); public static $information = array();
public $plugin_translate = 'mainwp-child'; public $plugin_translate = 'mainwp-child';
static function Instance() { static function Instance() {
if ( null === self::$instance ) { if ( null === self::$instance ) {
@ -70,20 +70,20 @@ class MainWP_Child_Skeleton_Key {
$secure = is_ssl(); $secure = is_ssl();
if ( $secure ) { if ( $secure ) {
$auth_cookie_name = SECURE_AUTH_COOKIE; $auth_cookie_name = SECURE_AUTH_COOKIE;
$scheme = 'secure_auth'; $scheme = 'secure_auth';
} else { } else {
$auth_cookie_name = AUTH_COOKIE; $auth_cookie_name = AUTH_COOKIE;
$scheme = 'auth'; $scheme = 'auth';
} }
$auth_cookie = wp_generate_auth_cookie( $current_user->ID, $expiration, $scheme, $token ); $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 ); $logged_in_cookie = wp_generate_auth_cookie( $current_user->ID, $expiration, 'logged_in', $token );
$_COOKIE[ $auth_cookie_name ] = $auth_cookie; $_COOKIE[ $auth_cookie_name ] = $auth_cookie;
$_COOKIE[ LOGGED_IN_COOKIE ] = $logged_in_cookie; $_COOKIE[ LOGGED_IN_COOKIE ] = $logged_in_cookie;
$post_args = array(); $post_args = array();
$post_args['body'] = array(); $post_args['body'] = array();
$post_args['redirection'] = 5; $post_args['redirection'] = 5;
$post_args['decompress'] = false; // For gzinflate() data error bug $post_args['decompress'] = false; // For gzinflate() data error bug
$post_args['cookies'] = array( $post_args['cookies'] = array(
new WP_Http_Cookie( array( new WP_Http_Cookie( array(
'name' => $auth_cookie_name, 'name' => $auth_cookie_name,
'value' => $auth_cookie, 'value' => $auth_cookie,

View file

@ -18,7 +18,7 @@
class MainWP_Child_Staging { class MainWP_Child_Staging {
public static $instance = null; public static $instance = null;
public $is_plugin_installed = false; public $is_plugin_installed = false;
static function Instance() { static function Instance() {
@ -158,7 +158,7 @@ class MainWP_Child_Staging {
function save_settings() { function save_settings() {
$settings = $_POST['settings']; $settings = $_POST['settings'];
$filters = array( $filters = array(
'queryLimit', 'queryLimit',
'fileLimit', 'fileLimit',
'batchSize', 'batchSize',
@ -178,7 +178,7 @@ class MainWP_Child_Staging {
$save_fields = array(); $save_fields = array();
foreach ($filters as $field) { foreach ($filters as $field) {
if (isset($settings[ $field ])) { if (isset($settings[ $field ])) {
$save_fields[ $field ] = $settings[ $field ]; $save_fields[ $field ] = $settings[ $field ];
} }
} }
update_option('wpstg_settings', $save_fields ); update_option('wpstg_settings', $save_fields );
@ -210,9 +210,9 @@ class MainWP_Child_Staging {
public function ajaxCheckCloneName() { public function ajaxCheckCloneName() {
$cloneName = sanitize_key( $_POST['cloneID'] ); $cloneName = sanitize_key( $_POST['cloneID'] );
$cloneNameLength = strlen( $cloneName ); $cloneNameLength = strlen( $cloneName );
$clones = get_option( 'wpstg_existing_clones_beta', array() ); $clones = get_option( 'wpstg_existing_clones_beta', array() );
// Check clone name length // Check clone name length
if ( $cloneNameLength < 1 || $cloneNameLength > 16 ) { if ( $cloneNameLength < 1 || $cloneNameLength > 16 ) {
@ -233,7 +233,7 @@ class MainWP_Child_Staging {
public function ajaxStartClone() { public function ajaxStartClone() {
$this->url = ''; // to fix warning $this->url = ''; // to fix warning
$cloning = new WPStaging\Backend\Modules\Jobs\Cloning(); $cloning = new WPStaging\Backend\Modules\Jobs\Cloning();
if ( ! $cloning->save() ) { if ( ! $cloning->save() ) {
return; return;
@ -285,9 +285,9 @@ class MainWP_Child_Staging {
*/ */
public function ajaxFinish() { public function ajaxFinish() {
$cloning = new WPStaging\Backend\Modules\Jobs\Cloning(); $cloning = new WPStaging\Backend\Modules\Jobs\Cloning();
$this->url = ''; // to fix warning $this->url = ''; // to fix warning
$return = $cloning->start(); $return = $cloning->start();
$return->blogInfoName = get_bloginfo('name'); $return->blogInfoName = get_bloginfo('name');
return $return; return $return;
@ -300,7 +300,7 @@ class MainWP_Child_Staging {
$delete = new WPStaging\Backend\Modules\Jobs\Delete(); $delete = new WPStaging\Backend\Modules\Jobs\Delete();
$delete->setData(); $delete->setData();
$clone = $delete->getClone(); $clone = $delete->getClone();
$result = array( $result = array(
'clone' => $clone, 'clone' => $clone,
'deleteTables' => $delete->getTables(), 'deleteTables' => $delete->getTables(),
@ -383,11 +383,11 @@ class MainWP_Child_Staging {
return ''; return '';
} }
$units = array( 'B', 'KB', 'MB', 'GB', 'TB' ); $units = array( 'B', 'KB', 'MB', 'GB', 'TB' );
$bytes = (float) $bytes; $bytes = (float) $bytes;
$base = log($bytes) / log(1000); // 1024 would be for MiB KiB etc $base = log($bytes) / log(1000); // 1024 would be for MiB KiB etc
$pow = pow(1000, $base - floor($base)); // Same rule for 1000 $pow = pow(1000, $base - floor($base)); // Same rule for 1000
return round($pow, $precision) . ' ' . $units[ (int) floor($base) ]; return round($pow, $precision) . ' ' . $units[ (int) floor($base) ];
} }

View file

@ -158,7 +158,7 @@ class MainWP_Child_Themes_Check {
//If there wasn't a previous cache //If there wasn't a previous cache
if ( false === $all_themes || ! is_array( $all_themes ) ) { if ( false === $all_themes || ! is_array( $all_themes ) ) {
$all_themes = array(); $all_themes = array();
$themes = wp_get_themes(); $themes = wp_get_themes();
if ( is_array( $themes ) ) { if ( is_array( $themes ) ) {
foreach ( $themes as $theme ) { foreach ( $themes as $theme ) {
$slug = $theme->get_stylesheet(); $slug = $theme->get_stylesheet();
@ -172,8 +172,8 @@ class MainWP_Child_Themes_Check {
$responses = array(); $responses = array();
} }
$avoid_themes = array( 'superstore' ); $avoid_themes = array( 'superstore' );
$themes_to_scan = array_splice( $all_themes, 0, apply_filters( 'mainwp_child_theme_health_check_max_themes_to_batch', 10 ) ); $themes_to_scan = array_splice( $all_themes, 0, apply_filters( 'mainwp_child_theme_health_check_max_themes_to_batch', 10 ) );
$tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 ); $tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 );
foreach ( $themes_to_scan as $slug => $v ) { foreach ( $themes_to_scan as $slug => $v ) {

View file

@ -15,7 +15,7 @@
*/ */
class MainWP_Child_Timecapsule { class MainWP_Child_Timecapsule {
public static $instance = null; public static $instance = null;
public $is_plugin_installed = false; public $is_plugin_installed = false;
static function Instance() { static function Instance() {
@ -73,10 +73,10 @@ class MainWP_Child_Timecapsule {
$information = array(); $information = array();
$options_helper = new Wptc_Options_Helper(); $options_helper = new Wptc_Options_Helper();
$options = WPTC_Factory::get('config'); $options = WPTC_Factory::get('config');
$is_user_logged_in = $options->get_option('is_user_logged_in'); $is_user_logged_in = $options->get_option('is_user_logged_in');
$privileges_wptc = $options_helper->get_unserialized_privileges(); $privileges_wptc = $options_helper->get_unserialized_privileges();
if ( isset( $_POST['mwp_action'] ) ) { if ( isset( $_POST['mwp_action'] ) ) {
@ -260,20 +260,20 @@ class MainWP_Child_Timecapsule {
MainWP_Helper::check_methods($config, 'get_option'); MainWP_Helper::check_methods($config, 'get_option');
$main_account_email_var = $config->get_option('main_account_email'); $main_account_email_var = $config->get_option('main_account_email');
$last_backup_time = $config->get_option('last_backup_time'); $last_backup_time = $config->get_option('last_backup_time');
$wptc_settings = WPTC_Base_Factory::get('Wptc_Settings'); $wptc_settings = WPTC_Base_Factory::get('Wptc_Settings');
$options_helper = new Wptc_Options_Helper(); $options_helper = new Wptc_Options_Helper();
MainWP_Helper::check_methods($options_helper, array( 'get_plan_interval_from_subs_info', 'get_is_user_logged_in' )); MainWP_Helper::check_methods($options_helper, array( 'get_plan_interval_from_subs_info', 'get_is_user_logged_in' ));
MainWP_Helper::check_methods($wptc_settings, array( 'get_connected_cloud_info' )); MainWP_Helper::check_methods($wptc_settings, array( 'get_connected_cloud_info' ));
$all_backups = $this->getBackups(); $all_backups = $this->getBackups();
$backups_count = 0; $backups_count = 0;
if (is_array($all_backups)) { if (is_array($all_backups)) {
$formatted_backups = array(); $formatted_backups = array();
foreach ($all_backups as $key => $value) { foreach ($all_backups as $key => $value) {
$value_array = (array) $value; $value_array = (array) $value;
$formatted_backups[ $value_array['backupID'] ][] = $value_array; $formatted_backups[ $value_array['backupID'] ][] = $value_array;
} }
$backups_count = count($formatted_backups); $backups_count = count($formatted_backups);
@ -311,7 +311,7 @@ class MainWP_Child_Timecapsule {
} }
public function get_tables() { public function get_tables() {
$category = $_POST['category']; $category = $_POST['category'];
$exclude_class_obj = new Wptc_ExcludeOption($category); $exclude_class_obj = new Wptc_ExcludeOption($category);
$exclude_class_obj->get_tables(); $exclude_class_obj->get_tables();
die(); die();
@ -321,7 +321,7 @@ class MainWP_Child_Timecapsule {
if ( ! isset($_POST['data'])) { if ( ! isset($_POST['data'])) {
wptc_die_with_json_encode( array( 'status' => 'no data found' ) ); wptc_die_with_json_encode( array( 'status' => 'no data found' ) );
} }
$category = $_POST['category']; $category = $_POST['category'];
$exclude_class_obj = new Wptc_ExcludeOption($category); $exclude_class_obj = new Wptc_ExcludeOption($category);
$exclude_class_obj->exclude_file_list($_POST['data']); $exclude_class_obj->exclude_file_list($_POST['data']);
die(); die();
@ -337,17 +337,17 @@ class MainWP_Child_Timecapsule {
$processed_files = WPTC_Factory::get('processed-files'); $processed_files = WPTC_Factory::get('processed-files');
$return_array = array(); $return_array = array();
$return_array['stored_backups'] = $processed_files->get_stored_backups(); $return_array['stored_backups'] = $processed_files->get_stored_backups();
$return_array['backup_progress'] = array(); $return_array['backup_progress'] = array();
$return_array['starting_first_backup'] = $config->get_option('starting_first_backup'); $return_array['starting_first_backup'] = $config->get_option('starting_first_backup');
$return_array['meta_data_backup_process'] = $config->get_option('meta_data_backup_process'); $return_array['meta_data_backup_process'] = $config->get_option('meta_data_backup_process');
$return_array['backup_before_update_progress'] = $config->get_option('backup_before_update_progress'); $return_array['backup_before_update_progress'] = $config->get_option('backup_before_update_progress');
$return_array['is_staging_running'] = apply_filters('is_any_staging_process_going_on', ''); $return_array['is_staging_running'] = apply_filters('is_any_staging_process_going_on', '');
$cron_status = $config->get_option('wptc_own_cron_status'); $cron_status = $config->get_option('wptc_own_cron_status');
if ( ! empty($cron_status)) { if ( ! empty($cron_status)) {
$return_array['wptc_own_cron_status'] = unserialize($cron_status); $return_array['wptc_own_cron_status'] = unserialize($cron_status);
$return_array['wptc_own_cron_status_notified'] = (int) $config->get_option('wptc_own_cron_status_notified'); $return_array['wptc_own_cron_status_notified'] = (int) $config->get_option('wptc_own_cron_status_notified');
} }
@ -360,21 +360,21 @@ class MainWP_Child_Timecapsule {
$processed_files->get_current_backup_progress($return_array); $processed_files->get_current_backup_progress($return_array);
$return_array['user_came_from_existing_ver'] = (int) $config->get_option('user_came_from_existing_ver'); $return_array['user_came_from_existing_ver'] = (int) $config->get_option('user_came_from_existing_ver');
$return_array['show_user_php_error'] = $config->get_option('show_user_php_error'); $return_array['show_user_php_error'] = $config->get_option('show_user_php_error');
$return_array['bbu_setting_status'] = apply_filters('get_backup_before_update_setting_wptc', ''); $return_array['bbu_setting_status'] = apply_filters('get_backup_before_update_setting_wptc', '');
$return_array['bbu_note_view'] = apply_filters('get_bbu_note_view', ''); $return_array['bbu_note_view'] = apply_filters('get_bbu_note_view', '');
$return_array['staging_status'] = apply_filters('staging_status_wptc', ''); $return_array['staging_status'] = apply_filters('staging_status_wptc', '');
$processed_files = WPTC_Factory::get('processed-files'); $processed_files = WPTC_Factory::get('processed-files');
$last_backup_time = $config->get_option('last_backup_time'); $last_backup_time = $config->get_option('last_backup_time');
if ( ! empty($last_backup_time)) { if ( ! empty($last_backup_time)) {
$user_time = $config->cnvt_UTC_to_usrTime($last_backup_time); $user_time = $config->cnvt_UTC_to_usrTime($last_backup_time);
$processed_files->modify_schedule_backup_time($user_time); $processed_files->modify_schedule_backup_time($user_time);
$formatted_date = date('M d @ g:i a', $user_time); $formatted_date = date('M d @ g:i a', $user_time);
$return_array['last_backup_time'] = $formatted_date; $return_array['last_backup_time'] = $formatted_date;
} else { } else {
$return_array['last_backup_time'] = 'No Backup Taken'; $return_array['last_backup_time'] = 'No Backup Taken';
} }
return array( 'result' => $return_array ); return array( 'result' => $return_array );
@ -383,7 +383,7 @@ class MainWP_Child_Timecapsule {
function wptc_cron_status() { function wptc_cron_status() {
$config = WPTC_Factory::get('config'); $config = WPTC_Factory::get('config');
wptc_own_cron_status(); wptc_own_cron_status();
$status = array(); $status = array();
$cron_status = $config->get_option('wptc_own_cron_status'); $cron_status = $config->get_option('wptc_own_cron_status');
if ( ! empty($cron_status)) { if ( ! empty($cron_status)) {
$cron_status = unserialize($cron_status); $cron_status = unserialize($cron_status);
@ -391,11 +391,11 @@ class MainWP_Child_Timecapsule {
if ($cron_status['status'] == 'success') { if ($cron_status['status'] == 'success') {
$status['status'] = 'success'; $status['status'] = 'success';
} else { } else {
$status['status'] = 'failed'; $status['status'] = 'failed';
$status['status_code'] = $cron_status['statusCode']; $status['status_code'] = $cron_status['statusCode'];
$status['err_msg'] = $cron_status['body']; $status['err_msg'] = $cron_status['body'];
$status['cron_url'] = $cron_status['cron_url']; $status['cron_url'] = $cron_status['cron_url'];
$status['ips'] = $cron_status['ips']; $status['ips'] = $cron_status['ips'];
} }
return array( 'result' => $status ); return array( 'result' => $status );
} }
@ -403,11 +403,11 @@ class MainWP_Child_Timecapsule {
} }
function get_this_backups_html() { function get_this_backups_html() {
$this_backup_ids = $_POST['this_backup_ids']; $this_backup_ids = $_POST['this_backup_ids'];
$specific_dir = $_POST['specific_dir']; $specific_dir = $_POST['specific_dir'];
$type = $_POST['type']; $type = $_POST['type'];
$treeRecursiveCount = $_POST['treeRecursiveCount']; $treeRecursiveCount = $_POST['treeRecursiveCount'];
$processed_files = WPTC_Factory::get('processed-files'); $processed_files = WPTC_Factory::get('processed-files');
$result = $processed_files->get_this_backups_html($this_backup_ids, $specific_dir, $type, $treeRecursiveCount); $result = $processed_files->get_this_backups_html($this_backup_ids, $specific_dir, $type, $treeRecursiveCount);
return array( 'result' => $result ); return array( 'result' => $result );
@ -429,9 +429,9 @@ function start_restore_tc_callback_wptc() {
function get_sibling_files_callback_wptc() { function get_sibling_files_callback_wptc() {
//note that we are getting the ajax function data via $_POST. //note that we are getting the ajax function data via $_POST.
$file_name = $_POST['data']['file_name']; $file_name = $_POST['data']['file_name'];
$file_name = wp_normalize_path($file_name); $file_name = wp_normalize_path($file_name);
$backup_id = $_POST['data']['backup_id']; $backup_id = $_POST['data']['backup_id'];
$recursive_count = $_POST['data']['recursive_count']; $recursive_count = $_POST['data']['recursive_count'];
// //getting the backups // //getting the backups
@ -447,7 +447,7 @@ function get_sibling_files_callback_wptc() {
function get_logs_rows() { function get_logs_rows() {
$result = $this->prepare_items(); $result = $this->prepare_items();
$result['display_rows'] = base64_encode(serialize($this->get_display_rows($result['items']))); $result['display_rows'] = base64_encode(serialize($this->get_display_rows($result['items'])));
return $result; return $result;
} }
@ -489,7 +489,7 @@ function get_sibling_files_callback_wptc() {
-- Ordering parameters -- */ -- Ordering parameters -- */
//Parameters that are going to be used to order the result //Parameters that are going to be used to order the result
$orderby = ! empty($_POST['orderby']) ? mysql_real_escape_string($_POST['orderby']) : 'id'; $orderby = ! empty($_POST['orderby']) ? mysql_real_escape_string($_POST['orderby']) : 'id';
$order = ! empty($_POST['order']) ? mysql_real_escape_string($_POST['order']) : 'DESC'; $order = ! empty($_POST['order']) ? mysql_real_escape_string($_POST['order']) : 'DESC';
if ( ! empty($orderby) & ! empty($order)) { if ( ! empty($orderby) & ! empty($order)) {
$query .= ' ORDER BY ' . $orderby . ' ' . $order;} $query .= ' ORDER BY ' . $orderby . ' ' . $order;}
@ -567,7 +567,7 @@ $paged = 1;} //Page Number
return ''; return '';
} }
$i = 0; $i = 0;
$limit = WPTC_Factory::get('config')->get_option('activity_log_lazy_load_limit'); $limit = WPTC_Factory::get('config')->get_option('activity_log_lazy_load_limit');
//Get the columns registered in the get_columns and get_sortable_columns methods //Get the columns registered in the get_columns and get_sortable_columns methods
// $columns = $this->get_columns(); // $columns = $this->get_columns();
@ -580,16 +580,16 @@ $paged = 1;} //Page Number
$more_logs = false; $more_logs = false;
$load_more = false; $load_more = false;
if ($rec->action_id != '') { if ($rec->action_id != '') {
$sql = 'SELECT * FROM ' . $wpdb->base_prefix . 'wptc_activity_log WHERE action_id=' . $rec->action_id . ' AND show_user = 1 ORDER BY id DESC LIMIT 0 , ' . $limit; $sql = 'SELECT * FROM ' . $wpdb->base_prefix . 'wptc_activity_log WHERE action_id=' . $rec->action_id . ' AND show_user = 1 ORDER BY id DESC LIMIT 0 , ' . $limit;
$sub_records = $wpdb->get_results($sql); $sub_records = $wpdb->get_results($sql);
$row_count = count($sub_records); $row_count = count($sub_records);
if ($row_count == $limit) { if ($row_count == $limit) {
$load_more = true; $load_more = true;
} }
if ($row_count > 0) { if ($row_count > 0) {
$more_logs = true; $more_logs = true;
$detailed = '<table>'; $detailed = '<table>';
$detailed .= $this->get_activity_log($sub_records); $detailed .= $this->get_activity_log($sub_records);
if (isset($load_more) && $load_more) { if (isset($load_more) && $load_more) {
$detailed .= '<tr><td></td><td><a style="cursor:pointer; position:relative" class="mainwp_wptc_activity_log_load_more" action_id="' . $rec->action_id . '" limit="' . $limit . '">Load more</a></td><td></td></tr>'; $detailed .= '<tr><td></td><td><a style="cursor:pointer; position:relative" class="mainwp_wptc_activity_log_load_more" action_id="' . $rec->action_id . '" limit="' . $limit . '">Load more</a></td><td></td></tr>';
@ -599,15 +599,15 @@ $paged = 1;} //Page Number
} }
} }
//Open the line //Open the line
$html .= '<tr class="act-tr">'; $html .= '<tr class="act-tr">';
$Ldata = unserialize($rec->log_data); $Ldata = unserialize($rec->log_data);
$user_time = WPTC_Factory::get('config')->cnvt_UTC_to_usrTime($Ldata['log_time']); $user_time = WPTC_Factory::get('config')->cnvt_UTC_to_usrTime($Ldata['log_time']);
WPTC_Factory::get('processed-files')->modify_schedule_backup_time($user_time); WPTC_Factory::get('processed-files')->modify_schedule_backup_time($user_time);
// $user_tz = new DateTime('@' . $Ldata['log_time'], new DateTimeZone(date_default_timezone_get())); // $user_tz = new DateTime('@' . $Ldata['log_time'], new DateTimeZone(date_default_timezone_get()));
// $user_tz->setTimeZone(new DateTimeZone($timezone)); // $user_tz->setTimeZone(new DateTimeZone($timezone));
// $user_tz_now = $user_tz->format("M d, Y @ g:i:s a"); // $user_tz_now = $user_tz->format("M d, Y @ g:i:s a");
$user_tz_now = date('M d, Y @ g:i:s a', $user_time); $user_tz_now = date('M d, Y @ g:i:s a', $user_time);
$msg = ''; $msg = '';
if ( ! ( strpos($rec->type, 'backup') === false )) { if ( ! ( strpos($rec->type, 'backup') === false )) {
//Backup process //Backup process
$msg = 'Backup Process'; $msg = 'Backup Process';
@ -658,7 +658,7 @@ $paged = 1;} //Page Number
$user_tmz = new DateTime('@' . $Moredata['log_time'], new DateTimeZone(date_default_timezone_get())); $user_tmz = new DateTime('@' . $Moredata['log_time'], new DateTimeZone(date_default_timezone_get()));
$user_tmz->setTimeZone(new DateTimeZone($timezone)); $user_tmz->setTimeZone(new DateTimeZone($timezone));
$user_tmz_now = $user_tmz->format('M d @ g:i:s a'); $user_tmz_now = $user_tmz->format('M d @ g:i:s a');
$detailed .= '<tr><td>' . $user_tmz_now . '</td><td>' . $Moredata['msg'] . '</td><td></td></tr>'; $detailed .= '<tr><td>' . $user_tmz_now . '</td><td>' . $Moredata['msg'] . '</td><td></td></tr>';
} }
return $detailed; return $detailed;
} }
@ -676,14 +676,14 @@ $paged = 1;} //Page Number
function stop_fresh_backup_tc_callback_wptc() { function stop_fresh_backup_tc_callback_wptc() {
//for backup during update //for backup during update
$deactivated_plugin = null; $deactivated_plugin = null;
$backup = new WPTC_BackupController(); $backup = new WPTC_BackupController();
$backup->stop($deactivated_plugin); $backup->stop($deactivated_plugin);
return array( 'result' => 'ok' ); return array( 'result' => 'ok' );
} }
function get_root_files() { function get_root_files() {
$category = $_POST['category']; $category = $_POST['category'];
$exclude_class_obj = new Wptc_ExcludeOption($category); $exclude_class_obj = new Wptc_ExcludeOption($category);
$exclude_class_obj->get_root_files(); $exclude_class_obj->get_root_files();
die(); die();
@ -694,7 +694,7 @@ $paged = 1;} //Page Number
if ( ! isset($_POST['data'])) { if ( ! isset($_POST['data'])) {
wptc_die_with_json_encode( array( 'status' => 'no data found' ) ); wptc_die_with_json_encode( array( 'status' => 'no data found' ) );
} }
$category = $_POST['data']['category']; $category = $_POST['data']['category'];
$exclude_class_obj = new Wptc_ExcludeOption($category); $exclude_class_obj = new Wptc_ExcludeOption($category);
$exclude_class_obj->exclude_table_list($_POST['data']); $exclude_class_obj->exclude_table_list($_POST['data']);
die(); die();
@ -732,7 +732,7 @@ return;
MainWP_Helper::update_lasttime_backup( 'wptimecapsule', $backup_time ); // to support backup before update feature MainWP_Helper::update_lasttime_backup( 'wptimecapsule', $backup_time ); // to support backup before update feature
} }
$last_time = time() - 24 * 7 * 2 * 60 * 60; // 2 weeks ago $last_time = time() - 24 * 7 * 2 * 60 * 60; // 2 weeks ago
$lasttime_logged = MainWP_Helper::get_lasttime_backup('wptimecapsule'); $lasttime_logged = MainWP_Helper::get_lasttime_backup('wptimecapsule');
if (empty($lasttime_logged)) { if (empty($lasttime_logged)) {
$last_time = time() - 24 * 7 * 8 * 60 * 60; // 8 weeks ago $last_time = time() - 24 * 7 * 8 * 60 * 60; // 8 weeks ago
@ -743,10 +743,10 @@ return;
if (is_array($all_last_backups)) { if (is_array($all_last_backups)) {
$formatted_backups = array(); $formatted_backups = array();
foreach ($all_last_backups as $key => $value) { foreach ($all_last_backups as $key => $value) {
$value_array = (array) $value; $value_array = (array) $value;
$formatted_backups[ $value_array['backupID'] ][] = $value_array; $formatted_backups[ $value_array['backupID'] ][] = $value_array;
} }
$message = 'WP Time Capsule backup finished'; $message = 'WP Time Capsule backup finished';
$backup_type = 'WP Time Capsule backup'; $backup_type = 'WP Time Capsule backup';
if (count($formatted_backups) > 0) { if (count($formatted_backups) > 0) {
foreach ($formatted_backups as $key => $value) { foreach ($formatted_backups as $key => $value) {
@ -765,7 +765,7 @@ return;
if ( ! isset($_POST['data'])) { if ( ! isset($_POST['data'])) {
wptc_die_with_json_encode( array( 'status' => 'no data found' ) ); wptc_die_with_json_encode( array( 'status' => 'no data found' ) );
} }
$category = $_POST['data']['category']; $category = $_POST['data']['category'];
$exclude_class_obj = new Wptc_ExcludeOption($category); $exclude_class_obj = new Wptc_ExcludeOption($category);
$exclude_class_obj->include_table_list($_POST['data']); $exclude_class_obj->include_table_list($_POST['data']);
die(); die();
@ -777,7 +777,7 @@ return;
wptc_die_with_json_encode( array( 'status' => 'no data found' ) ); wptc_die_with_json_encode( array( 'status' => 'no data found' ) );
} }
$category = $_POST['data']['category']; $category = $_POST['data']['category'];
$exclude_class_obj = new Wptc_ExcludeOption($category); $exclude_class_obj = new Wptc_ExcludeOption($category);
$exclude_class_obj->include_table_structure_only($_POST['data']); $exclude_class_obj->include_table_structure_only($_POST['data']);
die(); die();
@ -788,15 +788,15 @@ return;
if ( ! isset($_POST['data'])) { if ( ! isset($_POST['data'])) {
wptc_die_with_json_encode( array( 'status' => 'no data found' ) ); wptc_die_with_json_encode( array( 'status' => 'no data found' ) );
} }
$category = $_POST['category']; $category = $_POST['category'];
$exclude_class_obj = new Wptc_ExcludeOption($category); $exclude_class_obj = new Wptc_ExcludeOption($category);
$exclude_class_obj->include_file_list($_POST['data']); $exclude_class_obj->include_file_list($_POST['data']);
die(); die();
} }
public function get_files_by_key() { public function get_files_by_key() {
$key = $_POST['key']; $key = $_POST['key'];
$category = $_POST['category']; $category = $_POST['category'];
$exclude_class_obj = new Wptc_ExcludeOption($category); $exclude_class_obj = new Wptc_ExcludeOption($category);
$exclude_class_obj->get_files_by_key($key); $exclude_class_obj->get_files_by_key($key);
die(); die();
@ -813,13 +813,13 @@ return;
} }
$email = $_POST['acc_email']; $email = $_POST['acc_email'];
$pwd = $_POST['acc_pwd']; $pwd = $_POST['acc_pwd'];
if (empty( $email ) || empty($pwd)) { if (empty( $email ) || empty($pwd)) {
return array( 'error' => 'Username and password cannot be empty' ); return array( 'error' => 'Username and password cannot be empty' );
} }
$config = WPTC_Base_Factory::get('Wptc_InitialSetup_Config'); $config = WPTC_Base_Factory::get('Wptc_InitialSetup_Config');
$options = WPTC_Factory::get('config'); $options = WPTC_Factory::get('config');
$config->set_option('wptc_main_acc_email_temp', base64_encode($email)); $config->set_option('wptc_main_acc_email_temp', base64_encode($email));
@ -837,7 +837,7 @@ return;
) )
); );
$is_user_logged_in = $options->get_option('is_user_logged_in'); $is_user_logged_in = $options->get_option('is_user_logged_in');
if ( ! $is_user_logged_in) { if ( ! $is_user_logged_in) {
return array( 'error' => 'Login failed.' ); return array( 'error' => 'Login failed.' );
@ -851,7 +851,7 @@ return;
function get_installed_plugins() { function get_installed_plugins() {
$backup_before_auto_update_settings = WPTC_Pro_Factory::get('Wptc_Backup_Before_Auto_Update_Settings'); $backup_before_auto_update_settings = WPTC_Pro_Factory::get('Wptc_Backup_Before_Auto_Update_Settings');
$plugins = $backup_before_auto_update_settings->get_installed_plugins(); $plugins = $backup_before_auto_update_settings->get_installed_plugins();
if ($plugins) { if ($plugins) {
return array( 'results' => $plugins ); return array( 'results' => $plugins );
@ -877,8 +877,8 @@ return;
} }
function get_staging_details_wptc() { function get_staging_details_wptc() {
$staging = WPTC_Pro_Factory::get('Wptc_Staging'); $staging = WPTC_Pro_Factory::get('Wptc_Staging');
$details = $staging->get_staging_details(); $details = $staging->get_staging_details();
$details['is_running'] = $staging->is_any_staging_process_going_on(); $details['is_running'] = $staging->is_any_staging_process_going_on();
wptc_die_with_json_encode( $details, 1 ); wptc_die_with_json_encode( $details, 1 );
} }
@ -972,7 +972,7 @@ return;
$data = unserialize(base64_decode($_POST['data'])); $data = unserialize(base64_decode($_POST['data']));
$tabName = $_POST['tabname']; $tabName = $_POST['tabname'];
$is_general = $_POST['is_general']; $is_general = $_POST['is_general'];
$saved = false; $saved = false;
@ -1014,27 +1014,27 @@ return;
$current = $config->get_option('wptc_auto_update_settings'); $current = $config->get_option('wptc_auto_update_settings');
$current = unserialize($current); $current = unserialize($current);
$new = unserialize($data['wptc_auto_update_settings']); $new = unserialize($data['wptc_auto_update_settings']);
$current['update_settings']['status'] = $new['update_settings']['status']; $current['update_settings']['status'] = $new['update_settings']['status'];
$current['update_settings']['schedule']['enabled'] = $new['update_settings']['schedule']['enabled']; $current['update_settings']['schedule']['enabled'] = $new['update_settings']['schedule']['enabled'];
$current['update_settings']['schedule']['time'] = $new['update_settings']['schedule']['time']; $current['update_settings']['schedule']['time'] = $new['update_settings']['schedule']['time'];
$current['update_settings']['core']['major']['status'] = $new['update_settings']['core']['major']['status']; $current['update_settings']['core']['major']['status'] = $new['update_settings']['core']['major']['status'];
$current['update_settings']['core']['minor']['status'] = $new['update_settings']['core']['minor']['status']; $current['update_settings']['core']['minor']['status'] = $new['update_settings']['core']['minor']['status'];
$current['update_settings']['themes']['status'] = $new['update_settings']['themes']['status']; $current['update_settings']['themes']['status'] = $new['update_settings']['themes']['status'];
$current['update_settings']['plugins']['status'] = $new['update_settings']['plugins']['status']; $current['update_settings']['plugins']['status'] = $new['update_settings']['plugins']['status'];
if ( ! $is_general) { if ( ! $is_general) {
if (isset($new['update_settings']['plugins']['included'])) { if (isset($new['update_settings']['plugins']['included'])) {
$current['update_settings']['plugins']['included'] = $new['update_settings']['plugins']['included']; $current['update_settings']['plugins']['included'] = $new['update_settings']['plugins']['included'];
} else { } else {
$current['update_settings']['plugins']['included'] = array(); $current['update_settings']['plugins']['included'] = array();
} }
if (isset($new['update_settings']['themes']['included'])) { if (isset($new['update_settings']['themes']['included'])) {
$current['update_settings']['themes']['included'] = $new['update_settings']['themes']['included']; $current['update_settings']['themes']['included'] = $new['update_settings']['themes']['included'];
} else { } else {
$current['update_settings']['themes']['included'] = array(); $current['update_settings']['themes']['included'] = array();
} }
} }
$config->set_option('wptc_auto_update_settings', serialize($current)); $config->set_option('wptc_auto_update_settings', serialize($current));
@ -1043,11 +1043,11 @@ return;
} elseif ( $tabName == 'vulns_update' ) { } elseif ( $tabName == 'vulns_update' ) {
$current = $config->get_option('vulns_settings'); $current = $config->get_option('vulns_settings');
$current = unserialize($current); $current = unserialize($current);
$new = unserialize($data['vulns_settings']); $new = unserialize($data['vulns_settings']);
$current['status'] = $new['status']; $current['status'] = $new['status'];
$current['core']['status'] = $new['core']['status']; $current['core']['status'] = $new['core']['status'];
$current['themes']['status'] = $new['themes']['status']; $current['themes']['status'] = $new['themes']['status'];
$current['plugins']['status'] = $new['plugins']['status']; $current['plugins']['status'] = $new['plugins']['status'];
if ( ! $is_general) { if ( ! $is_general) {
@ -1070,13 +1070,13 @@ return;
$vulns_themes_included = ! empty($new['themes']['vulns_themes_included']) ? $new['themes']['vulns_themes_included'] : array(); $vulns_themes_included = ! empty($new['themes']['vulns_themes_included']) ? $new['themes']['vulns_themes_included'] : array();
$themes_include_array = array(); $themes_include_array = array();
if ( ! empty($vulns_themes_included)) { if ( ! empty($vulns_themes_included)) {
$themes_include_array = explode(',', $vulns_themes_included); $themes_include_array = explode(',', $vulns_themes_included);
} }
$included_themes = $this->filter_themes($themes_include_array); $included_themes = $this->filter_themes($themes_include_array);
$current['themes']['excluded'] = serialize($included_themes); $current['themes']['excluded'] = serialize($included_themes);
} }
$config->set_option('vulns_settings', serialize($current)); $config->set_option('vulns_settings', serialize($current));
@ -1104,8 +1104,8 @@ return;
} }
private function filter_plugins( $included_plugins) { private function filter_plugins( $included_plugins) {
$app_functions = WPTC_Base_Factory::get('Wptc_App_Functions'); $app_functions = WPTC_Base_Factory::get('Wptc_App_Functions');
$plugins_data = $app_functions->get_all_plugins_data($specific = true, $attr = 'slug'); $plugins_data = $app_functions->get_all_plugins_data($specific = true, $attr = 'slug');
$not_included_plugin = array_diff($plugins_data, $included_plugins); $not_included_plugin = array_diff($plugins_data, $included_plugins);
wptc_log($plugins_data, '--------$plugins_data--------'); wptc_log($plugins_data, '--------$plugins_data--------');
wptc_log($not_included_plugin, '--------$not_included_plugin--------'); wptc_log($not_included_plugin, '--------$not_included_plugin--------');
@ -1114,8 +1114,8 @@ return;
private function filter_themes( $included_themes) { private function filter_themes( $included_themes) {
$app_functions = WPTC_Base_Factory::get('Wptc_App_Functions'); $app_functions = WPTC_Base_Factory::get('Wptc_App_Functions');
$themes_data = $app_functions->get_all_themes_data($specific = true, $attr = 'slug'); $themes_data = $app_functions->get_all_themes_data($specific = true, $attr = 'slug');
$not_included_theme = array_diff($themes_data, $included_themes); $not_included_theme = array_diff($themes_data, $included_themes);
wptc_log($themes_data, '--------$themes_data--------'); wptc_log($themes_data, '--------$themes_data--------');
wptc_log($not_included_theme, '--------$not_included_theme--------'); wptc_log($not_included_theme, '--------$not_included_theme--------');
@ -1140,8 +1140,8 @@ return;
public function get_enabled_themes() { public function get_enabled_themes() {
$vulns_obj = WPTC_Base_Factory::get('Wptc_Vulns'); $vulns_obj = WPTC_Base_Factory::get('Wptc_Vulns');
$themes = $vulns_obj->get_enabled_themes(); $themes = $vulns_obj->get_enabled_themes();
$themes = WPTC_Base_Factory::get('Wptc_App_Functions')->fancytree_format($themes, 'themes'); $themes = WPTC_Base_Factory::get('Wptc_App_Functions')->fancytree_format($themes, 'themes');
return array( 'results' => $themes ); return array( 'results' => $themes );
} }
@ -1246,7 +1246,7 @@ return;
} }
public function save_manual_backup_name_wptc() { public function save_manual_backup_name_wptc() {
$backup_name = $_POST['backup_name']; $backup_name = $_POST['backup_name'];
$processed_files = WPTC_Factory::get('processed-files'); $processed_files = WPTC_Factory::get('processed-files');
$processed_files->save_manual_backup_name_wptc($backup_name); $processed_files->save_manual_backup_name_wptc($backup_name);
die(); die();

View file

@ -16,7 +16,7 @@
*/ */
class MainWP_Child_Updraft_Plus_Backups { class MainWP_Child_Updraft_Plus_Backups {
public static $instance = null; public static $instance = null;
public $is_plugin_installed = false; public $is_plugin_installed = false;
static function Instance() { static function Instance() {
if ( null === self::$instance ) { if ( null === self::$instance ) {
@ -262,7 +262,7 @@ class MainWP_Child_Updraft_Plus_Backups {
'e' => __( 'An unknown error occurred when trying to connect to UpdraftPlus.Com', 'updraftplus' ), 'e' => __( 'An unknown error occurred when trying to connect to UpdraftPlus.Com', 'updraftplus' ),
); );
if ( is_wp_error( $connect ) ) { if ( is_wp_error( $connect ) ) {
$response['e'] = $connect->get_error_message(); $response['e'] = $connect->get_error_message();
$response['code'] = $connect->get_error_code(); $response['code'] = $connect->get_error_code();
$response['data'] = serialize( $connect->get_error_data() ); $response['data'] = serialize( $connect->get_error_data() );
} }
@ -280,7 +280,7 @@ class MainWP_Child_Updraft_Plus_Backups {
return ''; return '';
} }
$ret = ''; $ret = '';
$ret .= '<p style="padding-top: 0px; margin-top: 0px;">'; $ret .= '<p style="padding-top: 0px; margin-top: 0px;">';
$ret .= __( 'This site is <strong>connected</strong> to UpdraftPlus Vault.', 'updraftplus' ) . ' ' . __( "Well done - there's nothing more needed to set up.", 'updraftplus' ) . '</p><p><strong>' . __( 'Vault owner', 'updraftplus' ) . ':</strong> ' . htmlspecialchars( $vault_settings['email'] ); $ret .= __( 'This site is <strong>connected</strong> to UpdraftPlus Vault.', 'updraftplus' ) . ' ' . __( "Well done - there's nothing more needed to set up.", 'updraftplus' ) . '</p><p><strong>' . __( 'Vault owner', 'updraftplus' ) . ':</strong> ' . htmlspecialchars( $vault_settings['email'] );
@ -528,27 +528,27 @@ $post_body['token'] = (string) $vault_settings['token'];
$opts = array(); $opts = array();
} }
if (is_array($opts) && isset($opts['settings'])) { if (is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']); $settings_key = key($opts['settings']);
$opts['settings'][ $settings_key ]['accesskey'] = $settings[ $key ]['accesskey']; $opts['settings'][ $settings_key ]['accesskey'] = $settings[ $key ]['accesskey'];
$opts['settings'][ $settings_key ]['secretkey'] = $settings[ $key ]['secretkey']; $opts['settings'][ $settings_key ]['secretkey'] = $settings[ $key ]['secretkey'];
$opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']); $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)) { 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); $opts['settings'][ $settings_key ]['path'] = substr($opts['settings'][ $settings_key ]['path'], 1);
} }
if (isset($settings[ $key ]['rrs'])) { // premium settings if (isset($settings[ $key ]['rrs'])) { // premium settings
$opts['settings'][ $settings_key ]['rrs'] = $settings[ $key ]['rrs']; $opts['settings'][ $settings_key ]['rrs'] = $settings[ $key ]['rrs'];
$opts['settings'][ $settings_key ]['server_side_encryption'] = $settings[ $key ]['server_side_encryption']; $opts['settings'][ $settings_key ]['server_side_encryption'] = $settings[ $key ]['server_side_encryption'];
} }
} else { } else {
$opts['accesskey'] = $settings[ $key ]['accesskey']; $opts['accesskey'] = $settings[ $key ]['accesskey'];
$opts['secretkey'] = $settings[ $key ]['secretkey']; $opts['secretkey'] = $settings[ $key ]['secretkey'];
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']); $opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
if ( ! empty($opts['path']) && '/' == substr($opts['path'], 0, 1)) { if ( ! empty($opts['path']) && '/' == substr($opts['path'], 0, 1)) {
$opts['path'] = substr($opts['path'], 1); $opts['path'] = substr($opts['path'], 1);
} }
if (isset($settings[ $key ]['rrs'])) { // premium settings if (isset($settings[ $key ]['rrs'])) { // premium settings
$opts['rrs'] = $settings[ $key ]['rrs']; $opts['rrs'] = $settings[ $key ]['rrs'];
$opts['server_side_encryption'] = $settings[ $key ]['server_side_encryption']; $opts['server_side_encryption'] = $settings[ $key ]['server_side_encryption'];
} }
} }
@ -559,16 +559,16 @@ $post_body['token'] = (string) $vault_settings['token'];
$opts = array(); $opts = array();
} }
if (is_array($opts) && isset($opts['settings'])) { if (is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']); $settings_key = key($opts['settings']);
$opts['settings'][ $settings_key ]['endpoint'] = $settings[ $key ]['endpoint']; $opts['settings'][ $settings_key ]['endpoint'] = $settings[ $key ]['endpoint'];
$opts['settings'][ $settings_key ]['accesskey'] = $settings[ $key ]['accesskey']; $opts['settings'][ $settings_key ]['accesskey'] = $settings[ $key ]['accesskey'];
$opts['settings'][ $settings_key ]['secretkey'] = $settings[ $key ]['secretkey']; $opts['settings'][ $settings_key ]['secretkey'] = $settings[ $key ]['secretkey'];
$opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']); $opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']);
} else { } else {
$opts['endpoint'] = $settings[ $key ]['endpoint']; $opts['endpoint'] = $settings[ $key ]['endpoint'];
$opts['accesskey'] = $settings[ $key ]['accesskey']; $opts['accesskey'] = $settings[ $key ]['accesskey'];
$opts['secretkey'] = $settings[ $key ]['secretkey']; $opts['secretkey'] = $settings[ $key ]['secretkey'];
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']); $opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
} }
UpdraftPlus_Options::update_updraft_option( $key, $opts ); UpdraftPlus_Options::update_updraft_option( $key, $opts );
@ -578,12 +578,12 @@ $post_body['token'] = (string) $vault_settings['token'];
$opts = array(); $opts = array();
} }
if (is_array($opts) && isset($opts['settings'])) { if (is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']); $settings_key = key($opts['settings']);
$opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']); $opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']);
$opts['settings'][ $settings_key ]['endpoint'] = $settings[ $key ]['endpoint']; $opts['settings'][ $settings_key ]['endpoint'] = $settings[ $key ]['endpoint'];
} else { } else {
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']); $opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
$opts['endpoint'] = $settings[ $key ]['endpoint']; $opts['endpoint'] = $settings[ $key ]['endpoint'];
} }
UpdraftPlus_Options::update_updraft_option( $key, $opts ); UpdraftPlus_Options::update_updraft_option( $key, $opts );
} elseif ( 'updraft_ftp' === $key ) { } elseif ( 'updraft_ftp' === $key ) {
@ -594,18 +594,18 @@ $post_body['token'] = (string) $vault_settings['token'];
if (is_array($opts) && isset($opts['settings'])) { if (is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']); $settings_key = key($opts['settings']);
if ( isset( $settings[ $key ]['path'] ) ) { if ( isset( $settings[ $key ]['path'] ) ) {
$opts['settings'][ $settings_key ]['host'] = $settings[ $key ]['host']; $opts['settings'][ $settings_key ]['host'] = $settings[ $key ]['host'];
$opts['settings'][ $settings_key ]['user'] = $settings[ $key ]['user']; $opts['settings'][ $settings_key ]['user'] = $settings[ $key ]['user'];
$opts['settings'][ $settings_key ]['pass'] = $settings[ $key ]['pass']; $opts['settings'][ $settings_key ]['pass'] = $settings[ $key ]['pass'];
$opts['settings'][ $settings_key ]['path'] = $this->replace_tokens( $settings[ $key ]['path'] ); $opts['settings'][ $settings_key ]['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
$opts['settings'][ $settings_key ]['passive'] = isset($settings[ $key ]['passive']) ? $settings[ $key ]['passive'] : 0; $opts['settings'][ $settings_key ]['passive'] = isset($settings[ $key ]['passive']) ? $settings[ $key ]['passive'] : 0;
} }
} else { } else {
if ( isset( $settings[ $key ]['path'] ) ) { if ( isset( $settings[ $key ]['path'] ) ) {
$opts['host'] = $settings[ $key ]['host']; $opts['host'] = $settings[ $key ]['host'];
$opts['user'] = $settings[ $key ]['user']; $opts['user'] = $settings[ $key ]['user'];
$opts['pass'] = $settings[ $key ]['pass']; $opts['pass'] = $settings[ $key ]['pass'];
$opts['path'] = $this->replace_tokens( $settings[ $key ]['path'] ); $opts['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
$opts['passive'] = isset($settings[ $key ]['passive']) ? $settings[ $key ]['passive'] : 0; $opts['passive'] = isset($settings[ $key ]['passive']) ? $settings[ $key ]['passive'] : 0;
} }
} }
@ -623,9 +623,9 @@ $post_body['token'] = (string) $vault_settings['token'];
$opts['settings'][ $settings_key ]['port'] = $settings[ $key ]['port']; $opts['settings'][ $settings_key ]['port'] = $settings[ $key ]['port'];
$opts['settings'][ $settings_key ]['user'] = $settings[ $key ]['user']; $opts['settings'][ $settings_key ]['user'] = $settings[ $key ]['user'];
$opts['settings'][ $settings_key ]['pass'] = $settings[ $key ]['pass']; $opts['settings'][ $settings_key ]['pass'] = $settings[ $key ]['pass'];
$opts['settings'][ $settings_key ]['key'] = $settings[ $key ]['key']; $opts['settings'][ $settings_key ]['key'] = $settings[ $key ]['key'];
$opts['settings'][ $settings_key ]['path'] = $this->replace_tokens( $settings[ $key ]['path'] ); $opts['settings'][ $settings_key ]['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
$opts['settings'][ $settings_key ]['scp'] = isset($settings[ $key ]['scp']) ? $settings[ $key ]['scp'] : 0; $opts['settings'][ $settings_key ]['scp'] = isset($settings[ $key ]['scp']) ? $settings[ $key ]['scp'] : 0;
} }
} else { } else {
if ( isset( $settings[ $key ]['path'] ) ) { if ( isset( $settings[ $key ]['path'] ) ) {
@ -633,9 +633,9 @@ $post_body['token'] = (string) $vault_settings['token'];
$opts['port'] = $settings[ $key ]['port']; $opts['port'] = $settings[ $key ]['port'];
$opts['user'] = $settings[ $key ]['user']; $opts['user'] = $settings[ $key ]['user'];
$opts['pass'] = $settings[ $key ]['pass']; $opts['pass'] = $settings[ $key ]['pass'];
$opts['key'] = $settings[ $key ]['key']; $opts['key'] = $settings[ $key ]['key'];
$opts['path'] = $this->replace_tokens( $settings[ $key ]['path'] ); $opts['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
$opts['scp'] = isset($settings[ $key ]['scp']) ? $settings[ $key ]['scp'] : 0; $opts['scp'] = isset($settings[ $key ]['scp']) ? $settings[ $key ]['scp'] : 0;
} }
} }
UpdraftPlus_Options::update_updraft_option( 'updraft_sftp', $opts ); UpdraftPlus_Options::update_updraft_option( 'updraft_sftp', $opts );
@ -646,7 +646,7 @@ $post_body['token'] = (string) $vault_settings['token'];
} }
if (is_array($opts) && isset($opts['settings'])) { if (is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']); $settings_key = key($opts['settings']);
$opts['settings'][ $settings_key ]['url'] = $this->replace_tokens( $settings[ $key ]['url'] ); $opts['settings'][ $settings_key ]['url'] = $this->replace_tokens( $settings[ $key ]['url'] );
UpdraftPlus_Options::update_updraft_option( 'updraft_webdav', $opts ); UpdraftPlus_Options::update_updraft_option( 'updraft_webdav', $opts );
} }
@ -657,9 +657,9 @@ $post_body['token'] = (string) $vault_settings['token'];
$opts = array(); $opts = array();
} }
if (is_array($opts) && isset($opts['settings'])) { if (is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']); $settings_key = key($opts['settings']);
$opts['settings'][ $settings_key ]['account_id'] = $settings[ $key ]['account_id']; $opts['settings'][ $settings_key ]['account_id'] = $settings[ $key ]['account_id'];
$opts['settings'][ $settings_key ]['key'] = $settings[ $key ]['key']; $opts['settings'][ $settings_key ]['key'] = $settings[ $key ]['key'];
$bname = $this->replace_tokens( $settings[ $key ]['bucket_name'] ); $bname = $this->replace_tokens( $settings[ $key ]['bucket_name'] );
$bpath = $this->replace_tokens( $settings[ $key ]['backup_path'] ); $bpath = $this->replace_tokens( $settings[ $key ]['backup_path'] );
$bname = str_replace('.', '-', $bname); $bname = str_replace('.', '-', $bname);
@ -714,14 +714,14 @@ $post_body['token'] = (string) $vault_settings['token'];
$replace_token = get_bloginfo( 'name' ); $replace_token = get_bloginfo( 'name' );
$replace_token = sanitize_file_name($replace_token); $replace_token = sanitize_file_name($replace_token);
$replace_token = strtolower($replace_token); $replace_token = strtolower($replace_token);
$str = str_ireplace('%sitename%', $replace_token, $str); $str = str_ireplace('%sitename%', $replace_token, $str);
} }
if (stripos($str, '%siteurl%') !== false) { if (stripos($str, '%siteurl%') !== false) {
$replace_token = get_bloginfo( 'url' ); $replace_token = get_bloginfo( 'url' );
$replace_token = preg_replace('/^https?:\/\//i', '', $replace_token); $replace_token = preg_replace('/^https?:\/\//i', '', $replace_token);
$replace_token = sanitize_file_name($replace_token); $replace_token = sanitize_file_name($replace_token);
$str = str_ireplace('%siteurl%', $replace_token, $str); $str = str_ireplace('%siteurl%', $replace_token, $str);
} }
return $str; return $str;
} }
@ -871,7 +871,7 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php';
$wpdb_obj = new UpdraftPlus_WPDB_OtherDB_Test( $_POST['user_db'], $_POST['pass'], $_POST['name'], $_POST['host'] ); $wpdb_obj = new UpdraftPlus_WPDB_OtherDB_Test( $_POST['user_db'], $_POST['pass'], $_POST['name'], $_POST['host'] );
if ( ! empty( $wpdb_obj->error ) ) { if ( ! empty( $wpdb_obj->error ) ) {
$failed = true; $failed = true;
$ret .= '<p>'; $ret .= '<p>';
$dbinfo['user'] . '@' . $dbinfo['host'] . '/' . $dbinfo['name'] . ' : ' . __( 'database connection attempt failed', 'updraftplus' ) . '</p>'; $dbinfo['user'] . '@' . $dbinfo['host'] . '/' . $dbinfo['name'] . ' : ' . __( 'database connection attempt failed', 'updraftplus' ) . '</p>';
if ( is_wp_error( $wpdb_obj->error ) || is_string( $wpdb_obj->error ) ) { if ( is_wp_error( $wpdb_obj->error ) || is_string( $wpdb_obj->error ) ) {
$ret .= '<ul style="list-style: disc inside;">'; $ret .= '<ul style="list-style: disc inside;">';
@ -882,7 +882,7 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php';
if ( 'db_connect_fail' === $code ) { if ( 'db_connect_fail' === $code ) {
$ret .= '<li>' . __( 'Connection failed: check your access details, that the database server is up, and that the network connection is not firewalled.', 'updraftplus' ) . '</li>'; $ret .= '<li>' . __( 'Connection failed: check your access details, that the database server is up, and that the network connection is not firewalled.', 'updraftplus' ) . '</li>';
} else { } else {
$err = $wpdb_obj->error->get_error_message( $code ); $err = $wpdb_obj->error->get_error_message( $code );
$ret .= '<li>' . $err . '</li>'; $ret .= '<li>' . $err . '</li>';
} }
} }
@ -1068,8 +1068,8 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php';
// Show errors + warnings // Show errors + warnings
if ( is_array( $updraft_last_backup['errors'] ) ) { if ( is_array( $updraft_last_backup['errors'] ) ) {
foreach ( $updraft_last_backup['errors'] as $err ) { foreach ( $updraft_last_backup['errors'] as $err ) {
$level = ( is_array( $err ) ) ? $err['level'] : 'error'; $level = ( is_array( $err ) ) ? $err['level'] : 'error';
$message = ( is_array( $err ) ) ? $err['message'] : $err; $message = ( is_array( $err ) ) ? $err['message'] : $err;
$last_backup_text .= ( 'warning' === $level ) ? '<span style="color:orange;">' : '<span style="color:red;">'; $last_backup_text .= ( 'warning' === $level ) ? '<span style="color:orange;">' : '<span style="color:red;">';
if ( 'warning' === $level ) { if ( 'warning' === $level ) {
$message = sprintf( __( 'Warning: %s', 'updraftplus' ), make_clickable( htmlspecialchars( $message ) ) ); $message = sprintf( __( 'Warning: %s', 'updraftplus' ), make_clickable( htmlspecialchars( $message ) ) );
@ -1165,7 +1165,7 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php';
$out['nextsched_database_timezone'] = $next_scheduled_backup_database; $out['nextsched_database_timezone'] = $next_scheduled_backup_database;
} }
$bh = $this->build_historystatus(); $bh = $this->build_historystatus();
// to fix performance issue // to fix performance issue
if ( $with_hist ) { if ( $with_hist ) {
@ -1197,16 +1197,16 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php';
// $next_scheduled_backup = date_i18n('D, F j, Y H:i', $next_scheduled_backup); // $next_scheduled_backup = date_i18n('D, F j, Y H:i', $next_scheduled_backup);
} else { } else {
$next_scheduled_backup = __('Nothing currently scheduled', 'updraftplus'); $next_scheduled_backup = __('Nothing currently scheduled', 'updraftplus');
$files_not_scheduled = true; $files_not_scheduled = true;
} }
$next_scheduled_backup_database = wp_next_scheduled('updraft_backup_database'); $next_scheduled_backup_database = wp_next_scheduled('updraft_backup_database');
if (UpdraftPlus_Options::get_updraft_option('updraft_interval_database', UpdraftPlus_Options::get_updraft_option('updraft_interval')) == UpdraftPlus_Options::get_updraft_option('updraft_interval')) { if (UpdraftPlus_Options::get_updraft_option('updraft_interval_database', UpdraftPlus_Options::get_updraft_option('updraft_interval')) == UpdraftPlus_Options::get_updraft_option('updraft_interval')) {
if (isset($files_not_scheduled)) { if (isset($files_not_scheduled)) {
$next_scheduled_backup_database = $next_scheduled_backup; $next_scheduled_backup_database = $next_scheduled_backup;
$database_not_scheduled = true; $database_not_scheduled = true;
} else { } else {
$next_scheduled_backup_database = __('At the same time as the files backup', 'updraftplus'); $next_scheduled_backup_database = __('At the same time as the files backup', 'updraftplus');
$next_scheduled_backup_database_same_time = true; $next_scheduled_backup_database_same_time = true;
} }
} else { } else {
@ -1218,7 +1218,7 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php';
// $next_scheduled_backup_database = date_i18n('D, F j, Y H:i', $next_scheduled_backup_database); // $next_scheduled_backup_database = date_i18n('D, F j, Y H:i', $next_scheduled_backup_database);
} else { } else {
$next_scheduled_backup_database = __('Nothing currently scheduled', 'updraftplus'); $next_scheduled_backup_database = __('Nothing currently scheduled', 'updraftplus');
$database_not_scheduled = true; $database_not_scheduled = true;
} }
} }
@ -1272,7 +1272,7 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php';
global $updraftplus; global $updraftplus;
if (method_exists($updraftplus, 'get_backup_history')) { if (method_exists($updraftplus, 'get_backup_history')) {
$backups = $updraftplus->get_backup_history(); $backups = $updraftplus->get_backup_history();
} elseif (class_exists('UpdraftPlus_Backup_History')) { } elseif (class_exists('UpdraftPlus_Backup_History')) {
$backups = UpdraftPlus_Backup_History::get_history(); $backups = UpdraftPlus_Backup_History::get_history();
} }
@ -1410,7 +1410,7 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php';
$backup_history = UpdraftPlus_Backup_History::get_history(); $backup_history = UpdraftPlus_Backup_History::get_history();
$output = $this->existing_backup_table( $backup_history ); $output = $this->existing_backup_table( $backup_history );
if ( ! empty( $messages ) && is_array( $messages ) ) { if ( ! empty( $messages ) && is_array( $messages ) ) {
$noutput = '<div style="margin-left: 100px; margin-top: 10px;"><ul style="list-style: disc inside;">'; $noutput = '<div style="margin-left: 100px; margin-top: 10px;"><ul style="list-style: disc inside;">';
@ -1418,7 +1418,7 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php';
$noutput .= '<li>' . ( ( $msg['desc'] ) ? $msg['desc'] . ': ' : '' ) . '<em>' . $msg['message'] . '</em></li>'; $noutput .= '<li>' . ( ( $msg['desc'] ) ? $msg['desc'] . ': ' : '' ) . '<em>' . $msg['message'] . '</em></li>';
} }
$noutput .= '</ul></div>'; $noutput .= '</ul></div>';
$output = $noutput . $output; $output = $noutput . $output;
} }
return array( return array(
@ -1446,7 +1446,7 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php';
$noutput .= '<li>' . ( ( $msg['desc'] ) ? $msg['desc'] . ': ' : '' ) . '<em>' . $msg['message'] . '</em></li>'; $noutput .= '<li>' . ( ( $msg['desc'] ) ? $msg['desc'] . ': ' : '' ) . '<em>' . $msg['message'] . '</em></li>';
} }
$noutput .= '</ul></div>'; $noutput .= '</ul></div>';
$output = $noutput . $output; $output = $noutput . $output;
} }
return array( return array(
@ -1500,7 +1500,7 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php';
// Retrieve the information from our backup history // Retrieve the information from our backup history
if (method_exists($updraftplus, 'get_backup_history')) { if (method_exists($updraftplus, 'get_backup_history')) {
$backup_history = $updraftplus->get_backup_history(); $backup_history = $updraftplus->get_backup_history();
} elseif (class_exists('UpdraftPlus_Backup_History')) { } elseif (class_exists('UpdraftPlus_Backup_History')) {
$backup_history = UpdraftPlus_Backup_History::get_history(); $backup_history = UpdraftPlus_Backup_History::get_history();
} }
@ -1660,7 +1660,7 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php';
global $updraftplus; global $updraftplus;
if (method_exists($updraftplus, 'get_backup_history')) { if (method_exists($updraftplus, 'get_backup_history')) {
$backups = $updraftplus->get_backup_history(); $backups = $updraftplus->get_backup_history();
} elseif (class_exists('UpdraftPlus_Backup_History')) { } elseif (class_exists('UpdraftPlus_Backup_History')) {
$backups = UpdraftPlus_Backup_History::get_history(); $backups = UpdraftPlus_Backup_History::get_history();
} }
@ -2379,7 +2379,7 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php';
$updraftplus->get_max_packet_size(); $updraftplus->get_max_packet_size();
if (method_exists($updraftplus, 'get_backup_history')) { if (method_exists($updraftplus, 'get_backup_history')) {
$backup = $updraftplus->get_backup_history($timestamp); $backup = $updraftplus->get_backup_history($timestamp);
} elseif (class_exists('UpdraftPlus_Backup_History')) { } elseif (class_exists('UpdraftPlus_Backup_History')) {
$backup = UpdraftPlus_Backup_History::get_history($timestamp); $backup = UpdraftPlus_Backup_History::get_history($timestamp);
} }
@ -2600,10 +2600,10 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php';
public function analyse_db_file( $timestamp, $res, $db_file = false, $header_only = false) { public function analyse_db_file( $timestamp, $res, $db_file = false, $header_only = false) {
global $updraftplus; global $updraftplus;
$mess = array(); $mess = array();
$warn = array(); $warn = array();
$err = array(); $err = array();
$info = array(); $info = array();
$wp_version = $updraftplus->get_wordpress_version(); $wp_version = $updraftplus->get_wordpress_version();
global $wpdb; global $wpdb;
@ -2667,16 +2667,16 @@ return array( $mess, $warn, $err, $info );
// Analyse the file, print the results. // Analyse the file, print the results.
$line = 0; $line = 0;
$old_siteurl = ''; $old_siteurl = '';
$old_home = ''; $old_home = '';
$old_table_prefix = ''; $old_table_prefix = '';
$old_siteinfo = array(); $old_siteinfo = array();
$gathering_siteinfo = true; $gathering_siteinfo = true;
$old_wp_version = ''; $old_wp_version = '';
$old_php_version = ''; $old_php_version = '';
$tables_found = array(); $tables_found = array();
$db_charsets_found = array(); $db_charsets_found = array();
// TODO: If the backup is the right size/checksum, then we could restore the $line <= 100 in the 'while' condition and not bother scanning the whole thing? Or better: sort the core tables to be first so that this usually terminates early // TODO: If the backup is the right size/checksum, then we could restore the $line <= 100 in the 'while' condition and not bother scanning the whole thing? Or better: sort the core tables to be first so that this usually terminates early
@ -2685,26 +2685,26 @@ return array( $mess, $warn, $err, $info );
$migration_warning = false; $migration_warning = false;
$processing_create = false; $processing_create = false;
$db_version = $wpdb->db_version(); $db_version = $wpdb->db_version();
// Don't set too high - we want a timely response returned to the browser // Don't set too high - we want a timely response returned to the browser
// Until April 2015, this was always 90. But we've seen a few people with ~1GB databases (uncompressed), and 90s is not enough. Note that we don't bother checking here if it's compressed - having a too-large timeout when unexpected is harmless, as it won't be hit. On very large dbs, they're expecting it to take a while. // Until April 2015, this was always 90. But we've seen a few people with ~1GB databases (uncompressed), and 90s is not enough. Note that we don't bother checking here if it's compressed - having a too-large timeout when unexpected is harmless, as it won't be hit. On very large dbs, they're expecting it to take a while.
// "120 or 240" is a first attempt at something more useful than just fixed at 90 - but should be sufficient (as 90 was for everyone without ~1GB databases) // "120 or 240" is a first attempt at something more useful than just fixed at 90 - but should be sufficient (as 90 was for everyone without ~1GB databases)
$default_dbscan_timeout = ( filesize($db_file) < 31457280 ) ? 120 : 240; $default_dbscan_timeout = ( filesize($db_file) < 31457280 ) ? 120 : 240;
$dbscan_timeout = ( defined('UPDRAFTPLUS_DBSCAN_TIMEOUT') && is_numeric(UPDRAFTPLUS_DBSCAN_TIMEOUT) ) ? UPDRAFTPLUS_DBSCAN_TIMEOUT : $default_dbscan_timeout; $dbscan_timeout = ( defined('UPDRAFTPLUS_DBSCAN_TIMEOUT') && is_numeric(UPDRAFTPLUS_DBSCAN_TIMEOUT) ) ? UPDRAFTPLUS_DBSCAN_TIMEOUT : $default_dbscan_timeout;
@set_time_limit($dbscan_timeout); @set_time_limit($dbscan_timeout);
// We limit the time that we spend scanning the file for character sets // We limit the time that we spend scanning the file for character sets
$db_charset_collate_scan_timeout = ( defined('UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT') && is_numeric(UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT) ) ? UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT : 10; $db_charset_collate_scan_timeout = ( defined('UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT') && is_numeric(UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT) ) ? UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT : 10;
$charset_scan_start_time = microtime(true); $charset_scan_start_time = microtime(true);
$db_supported_character_sets_res = $GLOBALS['wpdb']->get_results('SHOW CHARACTER SET', OBJECT_K); $db_supported_character_sets_res = $GLOBALS['wpdb']->get_results('SHOW CHARACTER SET', OBJECT_K);
$db_supported_character_sets = ( null !== $db_supported_character_sets_res ) ? $db_supported_character_sets_res : array(); $db_supported_character_sets = ( null !== $db_supported_character_sets_res ) ? $db_supported_character_sets_res : array();
$db_charsets_found = array(); $db_charsets_found = array();
$db_supported_collations_res = $GLOBALS['wpdb']->get_results('SHOW COLLATION', OBJECT_K); $db_supported_collations_res = $GLOBALS['wpdb']->get_results('SHOW COLLATION', OBJECT_K);
$db_supported_collations = ( null !== $db_supported_collations_res ) ? $db_supported_collations_res : array(); $db_supported_collations = ( null !== $db_supported_collations_res ) ? $db_supported_collations_res : array();
$db_charsets_found = array(); $db_charsets_found = array();
$db_collates_found = array(); $db_collates_found = array();
$db_supported_charset_related_to_unsupported_collation = false; $db_supported_charset_related_to_unsupported_collation = false;
$db_supported_charsets_related_to_unsupported_collations = array(); $db_supported_charsets_related_to_unsupported_collations = array();
while (( ( $is_plain && ! feof($dbhandle) ) || ( ! $is_plain && ! gzeof($dbhandle) ) ) && ( $line < 100 || ( ! $header_only && count($wanted_tables) > 0 ) || ( ( microtime(true) - $charset_scan_start_time ) < $db_charset_collate_scan_timeout && ! empty($db_supported_character_sets) ) )) { while (( ( $is_plain && ! feof($dbhandle) ) || ( ! $is_plain && ! gzeof($dbhandle) ) ) && ( $line < 100 || ( ! $header_only && count($wanted_tables) > 0 ) || ( ( microtime(true) - $charset_scan_start_time ) < $db_charset_collate_scan_timeout && ! empty($db_supported_character_sets) ) )) {
$line++; $line++;
@ -2715,7 +2715,7 @@ return array( $mess, $warn, $err, $info );
$processing_create = false; $processing_create = false;
if ('' == $old_siteurl && preg_match('/^\# Backup of: (http(.*))$/', $buffer, $matches)) { if ('' == $old_siteurl && preg_match('/^\# Backup of: (http(.*))$/', $buffer, $matches)) {
$old_siteurl = untrailingslashit($matches[1]); $old_siteurl = untrailingslashit($matches[1]);
$mess[] = __('Backup of:', 'updraftplus') . ' ' . htmlspecialchars($old_siteurl) . ( ( ! empty($old_wp_version) ) ? ' ' . sprintf(__('(version: %s)', 'updraftplus'), $old_wp_version) : '' ); $mess[] = __('Backup of:', 'updraftplus') . ' ' . htmlspecialchars($old_siteurl) . ( ( ! empty($old_wp_version) ) ? ' ' . sprintf(__('(version: %s)', 'updraftplus'), $old_wp_version) : '' );
// Check for should-be migration // Check for should-be migration
if (untrailingslashit(site_url()) != $old_siteurl) { if (untrailingslashit(site_url()) != $old_siteurl) {
if ( ! $migration_warning) { if ( ! $migration_warning) {
@ -2724,8 +2724,8 @@ return array( $mess, $warn, $err, $info );
// && !class_exists('UpdraftPlus_Addons_Migrator') // && !class_exists('UpdraftPlus_Addons_Migrator')
if (UpdraftPlus_Manipulation_Functions::normalise_url($old_siteurl) == UpdraftPlus_Manipulation_Functions::normalise_url(site_url())) { if (UpdraftPlus_Manipulation_Functions::normalise_url($old_siteurl) == UpdraftPlus_Manipulation_Functions::normalise_url(site_url())) {
// Same site migration with only http/https difference // Same site migration with only http/https difference
$info['same_url'] = false; $info['same_url'] = false;
$old_siteurl_parsed = parse_url($old_siteurl); $old_siteurl_parsed = parse_url($old_siteurl);
$actual_siteurl_parsed = parse_url(site_url()); $actual_siteurl_parsed = parse_url(site_url());
if (( stripos($old_siteurl_parsed['host'], 'www.') === 0 && stripos($actual_siteurl_parsed['host'], 'www.') !== 0 ) || ( stripos($old_siteurl_parsed['host'], 'www.') !== 0 && stripos($actual_siteurl_parsed['host'], 'www.') === 0 )) { if (( stripos($old_siteurl_parsed['host'], 'www.') === 0 && stripos($actual_siteurl_parsed['host'], 'www.') !== 0 ) || ( stripos($old_siteurl_parsed['host'], 'www.') !== 0 && stripos($actual_siteurl_parsed['host'], 'www.') === 0 )) {
$powarn = sprintf(__('The website address in the backup set (%1$s) is slightly different from that of the site now (%2$s). This is not expected to be a problem for restoring the site, as long as visits to the former address still reach the site.', 'updraftplus'), $old_siteurl, site_url()) . ' '; $powarn = sprintf(__('The website address in the backup set (%1$s) is slightly different from that of the site now (%2$s). This is not expected to be a problem for restoring the site, as long as visits to the former address still reach the site.', 'updraftplus'), $old_siteurl, site_url()) . ' ';
@ -2746,7 +2746,7 @@ return array( $mess, $warn, $err, $info );
} else { } else {
// For completely different site migration // For completely different site migration
$info['same_url'] = false; $info['same_url'] = false;
$warn[] = apply_filters('updraftplus_dbscan_urlchange', '<a href="https://updraftplus.com/shop/migrator/">' . __('This backup set is from a different site - this is not a restoration, but a migration. You need the Migrator add-on in order to make this work.', 'updraftplus') . '</a>', $old_siteurl, $res); $warn[] = apply_filters('updraftplus_dbscan_urlchange', '<a href="https://updraftplus.com/shop/migrator/">' . __('This backup set is from a different site - this is not a restoration, but a migration. You need the Migrator add-on in order to make this work.', 'updraftplus') . '</a>', $old_siteurl, $res);
} }
if ( ! class_exists('UpdraftPlus_Addons_Migrator')) { if ( ! class_exists('UpdraftPlus_Addons_Migrator')) {
$warn[] .= '<strong><a href="' . apply_filters('updraftplus_com_link', 'https://updraftplus.com/faqs/tell-me-more-about-the-search-and-replace-site-location-in-the-database-option/') . '">' . __('You can search and replace your database (for migrating a website to a new location/URL) with the Migrator add-on - follow this link for more information', 'updraftplus') . '</a></strong>'; $warn[] .= '<strong><a href="' . apply_filters('updraftplus_com_link', 'https://updraftplus.com/faqs/tell-me-more-about-the-search-and-replace-site-location-in-the-database-option/') . '">' . __('You can search and replace your database (for migrating a website to a new location/URL) with the Migrator add-on - follow this link for more information', 'updraftplus') . '</a></strong>';
@ -2766,7 +2766,7 @@ return array( $mess, $warn, $err, $info );
// Check for should-be migration // Check for should-be migration
if ( ! $migration_warning && home_url() != $old_home) { if ( ! $migration_warning && home_url() != $old_home) {
$migration_warning = true; $migration_warning = true;
$powarn = apply_filters('updraftplus_dbscan_urlchange', '<a href="https://updraftplus.com/shop/migrator/">' . __('This backup set is from a different site - this is not a restoration, but a migration. You need the Migrator add-on in order to make this work.', 'updraftplus') . '</a>', $old_home, $res); $powarn = apply_filters('updraftplus_dbscan_urlchange', '<a href="https://updraftplus.com/shop/migrator/">' . __('This backup set is from a different site - this is not a restoration, but a migration. You need the Migrator add-on in order to make this work.', 'updraftplus') . '</a>', $old_home, $res);
if ( ! empty($powarn)) { if ( ! empty($powarn)) {
$warn[] = $powarn; $warn[] = $powarn;
} }
@ -2783,7 +2783,7 @@ $old_wp_version .= substr($matches[3], 0, strlen($matches[3]) - 1);
$warn[] = sprintf(__('You are importing from a newer version of WordPress (%1$s) into an older one (%2$s). There are no guarantees that WordPress can handle this.', 'updraftplus'), $old_wp_version, $wp_version); $warn[] = sprintf(__('You are importing from a newer version of WordPress (%1$s) into an older one (%2$s). There are no guarantees that WordPress can handle this.', 'updraftplus'), $old_wp_version, $wp_version);
} }
if (preg_match('/running on PHP ([0-9]+\.[0-9]+)(\s|\.)/', $matches[4], $nmatches) && preg_match('/^([0-9]+\.[0-9]+)(\s|\.)/', PHP_VERSION, $cmatches)) { if (preg_match('/running on PHP ([0-9]+\.[0-9]+)(\s|\.)/', $matches[4], $nmatches) && preg_match('/^([0-9]+\.[0-9]+)(\s|\.)/', PHP_VERSION, $cmatches)) {
$old_php_version = $nmatches[1]; $old_php_version = $nmatches[1];
$current_php_version = $cmatches[1]; $current_php_version = $cmatches[1];
if (version_compare($old_php_version, $current_php_version, '>')) { if (version_compare($old_php_version, $current_php_version, '>')) {
// $mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version); // $mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version);
@ -2795,7 +2795,7 @@ $old_wp_version .= substr($matches[3], 0, strlen($matches[3]) - 1);
// echo '<strong>'.__('Old table prefix:', 'updraftplus').'</strong> '.htmlspecialchars($old_table_prefix).'<br>'; // echo '<strong>'.__('Old table prefix:', 'updraftplus').'</strong> '.htmlspecialchars($old_table_prefix).'<br>';
} elseif (empty($info['label']) && preg_match('/^\# Label: (.*)$/', $buffer, $matches)) { } elseif (empty($info['label']) && preg_match('/^\# Label: (.*)$/', $buffer, $matches)) {
$info['label'] = $matches[1]; $info['label'] = $matches[1];
$mess[] = __('Backup label:', 'updraftplus') . ' ' . htmlspecialchars($info['label']); $mess[] = __('Backup label:', 'updraftplus') . ' ' . htmlspecialchars($info['label']);
} elseif ($gathering_siteinfo && preg_match('/^\# Site info: (\S+)$/', $buffer, $matches)) { } elseif ($gathering_siteinfo && preg_match('/^\# Site info: (\S+)$/', $buffer, $matches)) {
if ('end' == $matches[1]) { if ('end' == $matches[1]) {
$gathering_siteinfo = false; $gathering_siteinfo = false;
@ -2832,7 +2832,7 @@ $mess[] = '<strong>' . __('Site information:', 'updraftplus') . '</strong> ' . '
} }
} elseif (preg_match('/^\s*create table \`?([^\`\(]*)\`?\s*\(/i', $buffer, $matches)) { } elseif (preg_match('/^\s*create table \`?([^\`\(]*)\`?\s*\(/i', $buffer, $matches)) {
$table = $matches[1]; $table = $matches[1];
$tables_found[] = $table; $tables_found[] = $table;
if ($old_table_prefix) { if ($old_table_prefix) {
// Remove prefix // Remove prefix
@ -2842,7 +2842,7 @@ $mess[] = '<strong>' . __('Site information:', 'updraftplus') . '</strong> ' . '
} }
} }
if (';' != substr($buffer, -1, 1)) { if (';' != substr($buffer, -1, 1)) {
$processing_create = true; $processing_create = true;
$db_supported_charset_related_to_unsupported_collation = true; $db_supported_charset_related_to_unsupported_collation = true;
} }
} elseif ($processing_create) { } elseif ($processing_create) {
@ -2875,13 +2875,13 @@ $mess[] = '<strong>' . __('Site information:', 'updraftplus') . '</strong> ' . '
} }
} }
if (';' == substr($buffer, -1, 1)) { if (';' == substr($buffer, -1, 1)) {
$processing_create = false; $processing_create = false;
$db_supported_charset_related_to_unsupported_collation = false; $db_supported_charset_related_to_unsupported_collation = false;
} }
static $mysql_version_warned = false; static $mysql_version_warned = false;
if ( ! $mysql_version_warned && version_compare($db_version, '5.2.0', '<') && preg_match('/(CHARSET|COLLATE)[= ]utf8mb4/', $buffer)) { if ( ! $mysql_version_warned && version_compare($db_version, '5.2.0', '<') && preg_match('/(CHARSET|COLLATE)[= ]utf8mb4/', $buffer)) {
$mysql_version_warned = true; $mysql_version_warned = true;
$err[] = sprintf(__('Error: %s', 'updraftplus'), sprintf(__('The database backup uses MySQL features not available in the old MySQL version (%s) that this site is running on.', 'updraftplus'), $db_version) . ' ' . __('You must upgrade MySQL to be able to use this database.', 'updraftplus')); $err[] = sprintf(__('Error: %s', 'updraftplus'), sprintf(__('The database backup uses MySQL features not available in the old MySQL version (%s) that this site is running on.', 'updraftplus'), $db_version) . ' ' . __('You must upgrade MySQL to be able to use this database.', 'updraftplus'));
} }
} }
} }
@ -2892,27 +2892,27 @@ $mess[] = '<strong>' . __('Site information:', 'updraftplus') . '</strong> ' . '
} }
if ( ! empty($db_supported_character_sets)) { if ( ! empty($db_supported_character_sets)) {
$db_charsets_found_unique = array_unique($db_charsets_found); $db_charsets_found_unique = array_unique($db_charsets_found);
$db_unsupported_charset = array(); $db_unsupported_charset = array();
$db_charset_forbidden = false; $db_charset_forbidden = false;
foreach ($db_charsets_found_unique as $db_charset) { foreach ($db_charsets_found_unique as $db_charset) {
if ( ! isset($db_supported_character_sets[ $db_charset ])) { if ( ! isset($db_supported_character_sets[ $db_charset ])) {
$db_unsupported_charset[] = $db_charset; $db_unsupported_charset[] = $db_charset;
$db_charset_forbidden = true; $db_charset_forbidden = true;
} }
} }
if ($db_charset_forbidden) { if ($db_charset_forbidden) {
$db_unsupported_charset_unique = array_unique($db_unsupported_charset); $db_unsupported_charset_unique = array_unique($db_unsupported_charset);
$warn[] = sprintf(_n("The database server that this WordPress site is running on doesn't support the character set (%s) which you are trying to import.", "The database server that this WordPress site is running on doesn't support the character sets (%s) which you are trying to import.", count($db_unsupported_charset_unique), 'updraftplus'), implode(', ', $db_unsupported_charset_unique)) . ' ' . __('You can choose another suitable character set instead and continue with the restoration at your own risk.', 'updraftplus') . ' <a target="_blank" href="https://updraftplus.com/faqs/implications-changing-tables-character-set/">' . __('Go here for more information.', 'updraftplus') . '</a>' . ' <a target="_blank" href="https://updraftplus.com/faqs/implications-changing-tables-character-set/">' . __('Go here for more information.', 'updraftplus') . '</a>'; $warn[] = sprintf(_n("The database server that this WordPress site is running on doesn't support the character set (%s) which you are trying to import.", "The database server that this WordPress site is running on doesn't support the character sets (%s) which you are trying to import.", count($db_unsupported_charset_unique), 'updraftplus'), implode(', ', $db_unsupported_charset_unique)) . ' ' . __('You can choose another suitable character set instead and continue with the restoration at your own risk.', 'updraftplus') . ' <a target="_blank" href="https://updraftplus.com/faqs/implications-changing-tables-character-set/">' . __('Go here for more information.', 'updraftplus') . '</a>' . ' <a target="_blank" href="https://updraftplus.com/faqs/implications-changing-tables-character-set/">' . __('Go here for more information.', 'updraftplus') . '</a>';
$db_supported_character_sets = array_keys($db_supported_character_sets); $db_supported_character_sets = array_keys($db_supported_character_sets);
$similar_type_charset = UpdraftPlus_Manipulation_Functions::get_matching_str_from_array_elems($db_unsupported_charset_unique, $db_supported_character_sets, true); $similar_type_charset = UpdraftPlus_Manipulation_Functions::get_matching_str_from_array_elems($db_unsupported_charset_unique, $db_supported_character_sets, true);
if (empty($similar_type_charset)) { if (empty($similar_type_charset)) {
$row = $GLOBALS['wpdb']->get_row('show variables like "character_set_database"'); $row = $GLOBALS['wpdb']->get_row('show variables like "character_set_database"');
$similar_type_charset = ( null !== $row ) ? $row->Value : ''; $similar_type_charset = ( null !== $row ) ? $row->Value : '';
} }
if (empty($similar_type_charset) && ! empty($db_supported_character_sets[0])) { if (empty($similar_type_charset) && ! empty($db_supported_character_sets[0])) {
$similar_type_charset = $db_supported_character_sets[0]; $similar_type_charset = $db_supported_character_sets[0];
} }
$charset_select_html = '<label>' . __('Your chosen character set to use instead:', 'updraftplus') . '</label> '; $charset_select_html = '<label>' . __('Your chosen character set to use instead:', 'updraftplus') . '</label> ';
$charset_select_html .= '<select name="updraft_restorer_charset" id="updraft_restorer_charset">'; $charset_select_html .= '<select name="updraft_restorer_charset" id="updraft_restorer_charset">';
if (is_array($db_supported_character_sets)) { if (is_array($db_supported_character_sets)) {
foreach ($db_supported_character_sets as $character_set) { foreach ($db_supported_character_sets as $character_set) {
@ -2928,18 +2928,18 @@ $info['addui'] = '';
} }
if ( ! empty($db_supported_collations)) { if ( ! empty($db_supported_collations)) {
$db_collates_found_unique = array_unique($db_collates_found); $db_collates_found_unique = array_unique($db_collates_found);
$db_unsupported_collate = array(); $db_unsupported_collate = array();
$db_collate_forbidden = false; $db_collate_forbidden = false;
foreach ($db_collates_found_unique as $db_collate) { foreach ($db_collates_found_unique as $db_collate) {
if ( ! isset($db_supported_collations[ $db_collate ])) { if ( ! isset($db_supported_collations[ $db_collate ])) {
$db_unsupported_collate[] = $db_collate; $db_unsupported_collate[] = $db_collate;
$db_collate_forbidden = true; $db_collate_forbidden = true;
} }
} }
if ($db_collate_forbidden) { if ($db_collate_forbidden) {
$db_unsupported_collate_unique = array_unique($db_unsupported_collate); $db_unsupported_collate_unique = array_unique($db_unsupported_collate);
$warn[] = sprintf(_n("The database server that this WordPress site is running on doesn't support the collation (%s) used in the database which you are trying to import.", "The database server that this WordPress site is running on doesn't support multiple collations (%s) used in the database which you are trying to import.", count($db_unsupported_collate_unique), 'updraftplus'), implode(', ', $db_unsupported_collate_unique)) . ' ' . __('You can choose another suitable collation instead and continue with the restoration (at your own risk).', 'updraftplus'); $warn[] = sprintf(_n("The database server that this WordPress site is running on doesn't support the collation (%s) used in the database which you are trying to import.", "The database server that this WordPress site is running on doesn't support multiple collations (%s) used in the database which you are trying to import.", count($db_unsupported_collate_unique), 'updraftplus'), implode(', ', $db_unsupported_collate_unique)) . ' ' . __('You can choose another suitable collation instead and continue with the restoration (at your own risk).', 'updraftplus');
$similar_type_collate = ''; $similar_type_collate = '';
if ($db_charset_forbidden && ! empty($similar_type_charset)) { if ($db_charset_forbidden && ! empty($similar_type_charset)) {
$similar_type_collate = $updraftplus->get_similar_collate_related_to_charset($db_supported_collations, $db_unsupported_collate_unique, $similar_type_charset); $similar_type_collate = $updraftplus->get_similar_collate_related_to_charset($db_supported_collations, $db_unsupported_collate_unique, $similar_type_charset);
} }
@ -2961,7 +2961,7 @@ $info['addui'] = '';
$similar_type_collate = UpdraftPlus_Manipulation_Functions::get_matching_str_from_array_elems($db_unsupported_collate_unique, array_keys($db_supported_collations), false); $similar_type_collate = UpdraftPlus_Manipulation_Functions::get_matching_str_from_array_elems($db_unsupported_collate_unique, array_keys($db_supported_collations), false);
} }
$collate_select_html = '<label>' . __('Your chosen replacement collation', 'updraftplus') . ':</label>'; $collate_select_html = '<label>' . __('Your chosen replacement collation', 'updraftplus') . ':</label>';
$collate_select_html .= '<select name="updraft_restorer_collate" id="updraft_restorer_collate">'; $collate_select_html .= '<select name="updraft_restorer_collate" id="updraft_restorer_collate">';
foreach ($db_supported_collations as $collate => $collate_info_obj) { foreach ($db_supported_collations as $collate => $collate_info_obj) {
$option_other_attr = array(); $option_other_attr = array();
@ -2983,7 +2983,7 @@ $info['addui'] = '';
'db_unsupported_collate_unique' => $db_unsupported_collate_unique, 'db_unsupported_collate_unique' => $db_unsupported_collate_unique,
'db_collates_found' => $db_collates_found, 'db_collates_found' => $db_collates_found,
); );
$info['addui'] .= '<input type="hidden" name="collate_change_on_charset_selection_data" id="collate_change_on_charset_selection_data" value="' . esc_attr(json_encode($collate_change_on_charset_selection_data)) . '">'; $info['addui'] .= '<input type="hidden" name="collate_change_on_charset_selection_data" id="collate_change_on_charset_selection_data" value="' . esc_attr(json_encode($collate_change_on_charset_selection_data)) . '">';
} }
} }
} }
@ -3116,7 +3116,7 @@ $skipped_tables = array();
if ( ! rename( $file . '.tmp', $file ) ) { if ( ! rename( $file . '.tmp', $file ) ) {
$err_msg = __( 'The attempt to undo the double-compression failed.', 'updraftplus' ); $err_msg = __( 'The attempt to undo the double-compression failed.', 'updraftplus' );
} else { } else {
$mess .= ' ' . __( 'The attempt to undo the double-compression succeeded.', 'updraftplus' ); $mess .= ' ' . __( 'The attempt to undo the double-compression succeeded.', 'updraftplus' );
$messkey = 'doublecompressfixed'; $messkey = 'doublecompressfixed';
$what_to_return = gzopen( $file, 'r' ); $what_to_return = gzopen( $file, 'r' );
} }
@ -3177,7 +3177,7 @@ $skipped_tables = array();
$esc_pretty_date = esc_attr( $pretty_date ); $esc_pretty_date = esc_attr( $pretty_date );
$entities = ''; $entities = '';
$non = $backup['nonce']; $non = $backup['nonce'];
// $rawbackup = "<h2>$esc_pretty_date ($key)</h2><pre><p>" . esc_attr( print_r( $backup, true ) ); // $rawbackup = "<h2>$esc_pretty_date ($key)</h2><pre><p>" . esc_attr( print_r( $backup, true ) );
// if ( ! empty( $non ) ) { // if ( ! empty( $non ) ) {
@ -3387,10 +3387,10 @@ ENDHERE;
if ( isset( $accept[ $backup['meta_foreign'] ] ) ) { if ( isset( $accept[ $backup['meta_foreign'] ] ) ) {
$desc_source = $accept[ $backup['meta_foreign'] ]['desc']; $desc_source = $accept[ $backup['meta_foreign'] ]['desc'];
$ide .= sprintf( __( 'Backup created by: %s.', 'updraftplus' ), $accept[ $backup['meta_foreign'] ]['desc'] ) . ' '; $ide .= sprintf( __( 'Backup created by: %s.', 'updraftplus' ), $accept[ $backup['meta_foreign'] ]['desc'] ) . ' ';
} else { } else {
$desc_source = __( 'unknown source', 'updraftplus' ); $desc_source = __( 'unknown source', 'updraftplus' );
$ide .= __( 'Backup created by unknown source (%s) - cannot be restored.', 'updraftplus' ) . ' '; $ide .= __( 'Backup created by unknown source (%s) - cannot be restored.', 'updraftplus' ) . ' ';
} }
$sdescrip = ( empty( $accept[ $backup['meta_foreign'] ]['separatedb'] ) ) ? sprintf( __( 'Files and database WordPress backup (created by %s)', 'updraftplus' ), $desc_source ) : sprintf( __( 'Files backup (created by %s)', 'updraftplus' ), $desc_source ); $sdescrip = ( empty( $accept[ $backup['meta_foreign'] ]['separatedb'] ) ) ? sprintf( __( 'Files and database WordPress backup (created by %s)', 'updraftplus' ), $desc_source ) : sprintf( __( 'Files backup (created by %s)', 'updraftplus' ), $desc_source );
@ -3409,8 +3409,8 @@ ENDHERE;
$expected_index = 0; $expected_index = 0;
$index_missing = false; $index_missing = false;
$set_contents = ''; $set_contents = '';
$entities .= "/$type="; $entities .= "/$type=";
$whatfiles = $backup[ $type ]; $whatfiles = $backup[ $type ];
ksort( $whatfiles ); ksort( $whatfiles );
foreach ( $whatfiles as $findex => $bfile ) { foreach ( $whatfiles as $findex => $bfile ) {
$set_contents .= ( '' === $set_contents ) ? $findex : ",$findex"; $set_contents .= ( '' === $set_contents ) ? $findex : ",$findex";
@ -3425,7 +3425,7 @@ ENDHERE;
} }
$first_printed = true; $first_printed = true;
foreach ( $whatfiles as $findex => $bfile ) { foreach ( $whatfiles as $findex => $bfile ) {
$ide .= __( 'Press here to download', 'updraftplus' ) . ' ' . strtolower( $info['description'] ); $ide .= __( 'Press here to download', 'updraftplus' ) . ' ' . strtolower( $info['description'] );
$pdescrip = ( $findex > 0 ) ? $sdescrip . ' (' . ( $findex + 1 ) . ')' : $sdescrip; $pdescrip = ( $findex > 0 ) ? $sdescrip . ' (' . ( $findex + 1 ) . ')' : $sdescrip;
if ( ! $first_printed ) { if ( ! $first_printed ) {
$ret .= '<div style="display:none;">'; $ret .= '<div style="display:none;">';
@ -3581,7 +3581,7 @@ ENDHERE;
$size += @filesize( $dir ); $size += @filesize( $dir );
} else { } else {
$suffix = ( '' !== $basedir ) ? ( ( 0 === strpos( $dir, $basedir . '/' ) ) ? substr( $dir, 1 + strlen( $basedir ) ) : '' ) : ''; $suffix = ( '' !== $basedir ) ? ( ( 0 === strpos( $dir, $basedir . '/' ) ) ? substr( $dir, 1 + strlen( $basedir ) ) : '' ) : '';
$size += $this->recursive_directory_size_raw( $basedir, $exclude, $suffix ); $size += $this->recursive_directory_size_raw( $basedir, $exclude, $suffix );
} }
} }
} }
@ -3749,11 +3749,11 @@ ENDHERE;
$stage = 4; $stage = 4;
$curstage = __( 'Uploading files to remote storage', 'updraftplus' ); $curstage = __( 'Uploading files to remote storage', 'updraftplus' );
if ( isset( $jobdata['uploading_substatus']['t'] ) && isset( $jobdata['uploading_substatus']['i'] ) ) { if ( isset( $jobdata['uploading_substatus']['t'] ) && isset( $jobdata['uploading_substatus']['i'] ) ) {
$t = max( (int) $jobdata['uploading_substatus']['t'], 1 ); $t = max( (int) $jobdata['uploading_substatus']['t'], 1 );
$i = min( $jobdata['uploading_substatus']['i'] / $t, 1 ); $i = min( $jobdata['uploading_substatus']['i'] / $t, 1 );
$p = min( $jobdata['uploading_substatus']['p'], 1 ); $p = min( $jobdata['uploading_substatus']['p'], 1 );
$pd = $i + $p / $t; $pd = $i + $p / $t;
$stage = 4 + $pd; $stage = 4 + $pd;
$curstage .= ' ' . sprintf( __( '(%1$s%%, file %2$s of %3$s)', 'updraftplus' ), floor( 100 * $pd ), $jobdata['uploading_substatus']['i'] + 1, $t ); $curstage .= ' ' . sprintf( __( '(%1$s%%, file %2$s of %3$s)', 'updraftplus' ), floor( 100 * $pd ), $jobdata['uploading_substatus']['i'] + 1, $t );
} }
break; break;
@ -3801,7 +3801,7 @@ ENDHERE;
$curstage .= ' (' . sprintf( __( 'table: %s', 'updraftplus' ), $jobdata['dbcreating_substatus']['t'] ) . ')'; $curstage .= ' (' . sprintf( __( 'table: %s', 'updraftplus' ), $jobdata['dbcreating_substatus']['t'] ) . ')';
if ( ! empty( $jobdata['dbcreating_substatus']['i'] ) && ! empty( $jobdata['dbcreating_substatus']['a'] ) ) { if ( ! empty( $jobdata['dbcreating_substatus']['i'] ) && ! empty( $jobdata['dbcreating_substatus']['a'] ) ) {
$substage = max( 0.001, ( $jobdata['dbcreating_substatus']['i'] / max( $jobdata['dbcreating_substatus']['a'], 1 ) ) ); $substage = max( 0.001, ( $jobdata['dbcreating_substatus']['i'] / max( $jobdata['dbcreating_substatus']['a'], 1 ) ) );
$stage += $substage * $perdbspace * 0.5; $stage += $substage * $perdbspace * 0.5;
} }
} }
} elseif ( 'dbencrypting' === substr( $jobstatus, 0, 12 ) ) { } elseif ( 'dbencrypting' === substr( $jobstatus, 0, 12 ) ) {
@ -4014,14 +4014,14 @@ ENDHERE;
if ( $file_age > 20 ) { if ( $file_age > 20 ) {
$response['a'] = time() - filemtime( $matches[2] ); $response['a'] = time() - filemtime( $matches[2] );
} }
$response['t'] = $total_size; $response['t'] = $total_size;
$response['m'] .= __( 'Download in progress', 'updraftplus' ) . ' (' . round( $cur_size / 1024 ) . ' / ' . round( ( $total_size / 1024 ) ) . ' Kb)'; $response['m'] .= __( 'Download in progress', 'updraftplus' ) . ' (' . round( $cur_size / 1024 ) . ' / ' . round( ( $total_size / 1024 ) ) . ' Kb)';
$response['p'] = round( 100 * $cur_size / $total_size ); $response['p'] = round( 100 * $cur_size / $total_size );
} else { } else {
$response['m'] .= __( 'No local copy present.', 'updraftplus' ); $response['m'] .= __( 'No local copy present.', 'updraftplus' );
$response['p'] = 0; $response['p'] = 0;
$response['s'] = 0; $response['s'] = 0;
$response['t'] = 1; $response['t'] = 1;
} }
} }

View file

@ -19,7 +19,7 @@
class MainWP_Child_Vulnerability_Checker { class MainWP_Child_Vulnerability_Checker {
public static $instance = null; public static $instance = null;
private $wpvulndb_api = 'https://wpvulndb.com/api/v3/'; private $wpvulndb_api = 'https://wpvulndb.com/api/v3/';
private $wpvulndb_token = false; private $wpvulndb_token = false;
static function Instance() { static function Instance() {
@ -50,12 +50,12 @@ class MainWP_Child_Vulnerability_Checker {
} }
function vulner_recheck() { function vulner_recheck() {
$result = array(); $result = array();
$force = ( isset($_POST['force']) && ! empty($_POST['force']) ) ? true : false; $force = ( isset($_POST['force']) && ! empty($_POST['force']) ) ? true : false;
$result['plugin'] = $this->check_plugins($force); $result['plugin'] = $this->check_plugins($force);
$result['wp'] = $this->check_wp($force); $result['wp'] = $this->check_wp($force);
$result['theme'] = $this->check_themes($force); $result['theme'] = $this->check_themes($force);
$information = array( $information = array(
'result' => $result, 'result' => $result,
'ok' => 1, 'ok' => 1,
); );
@ -63,23 +63,23 @@ class MainWP_Child_Vulnerability_Checker {
} }
function check_plugins( $force = false) { function check_plugins( $force = false) {
$result = array(); $result = array();
$active_plugins = get_option('active_plugins'); $active_plugins = get_option('active_plugins');
if ( ! empty($active_plugins) ) { if ( ! empty($active_plugins) ) {
foreach ($active_plugins as $plug) { foreach ($active_plugins as $plug) {
$plugin_file = WP_CONTENT_DIR . '/plugins/' . $plug; $plugin_file = WP_CONTENT_DIR . '/plugins/' . $plug;
$plugin_info = get_plugin_data($plugin_file); $plugin_info = get_plugin_data($plugin_file);
$plugin_version = isset($plugin_info['Version']) ? $plugin_info['Version'] : ''; $plugin_version = isset($plugin_info['Version']) ? $plugin_info['Version'] : '';
$string = explode('/', $plug); $string = explode('/', $plug);
$plug_vuln = get_transient('mainwp_vulnche_trans_plug_' . $string[0]); $plug_vuln = get_transient('mainwp_vulnche_trans_plug_' . $string[0]);
if (false === $plug_vuln || $force) { if (false === $plug_vuln || $force) {
$plug_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'plugins/' . $string[0]); $plug_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'plugins/' . $string[0]);
set_transient('mainwp_vulnche_trans_plug_' . $string[0], $plug_vuln, 1 * DAY_IN_SECONDS); set_transient('mainwp_vulnche_trans_plug_' . $string[0], $plug_vuln, 1 * DAY_IN_SECONDS);
} }
if ($plug_vuln) { if ($plug_vuln) {
$plug_vuln = json_decode($plug_vuln, true); $plug_vuln = json_decode($plug_vuln, true);
$plug_vuln_filter = $plug_vuln; $plug_vuln_filter = $plug_vuln;
foreach ($plug_vuln as $slug => $pl_data) { foreach ($plug_vuln as $slug => $pl_data) {
@ -95,9 +95,9 @@ class MainWP_Child_Vulnerability_Checker {
if (count($plug_vulner_data) == 0) { if (count($plug_vulner_data) == 0) {
unset($plug_vuln_filter[ $slug ]); unset($plug_vuln_filter[ $slug ]);
} else { } else {
$plug_vuln_filter[ $slug ]['vulnerabilities'] = $plug_vulner_data; $plug_vuln_filter[ $slug ]['vulnerabilities'] = $plug_vulner_data;
$plug_vuln_filter[ $slug ]['detected_version'] = $plugin_version; $plug_vuln_filter[ $slug ]['detected_version'] = $plugin_version;
$plug_vuln_filter[ $slug ]['plugin_slug'] = $plug; $plug_vuln_filter[ $slug ]['plugin_slug'] = $plug;
} }
} else { } else {
@ -121,7 +121,7 @@ class MainWP_Child_Vulnerability_Checker {
} }
function check_wp( $force = false) { function check_wp( $force = false) {
$wp_vuln = get_transient('mainwp_vulnche_trans_wp_json'); $wp_vuln = get_transient('mainwp_vulnche_trans_wp_json');
$wp_version = str_replace('.', '', get_bloginfo('version')); $wp_version = str_replace('.', '', get_bloginfo('version'));
if (false === $wp_vuln || $force) { if (false === $wp_vuln || $force) {
$wp_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'wordpresses/' . $wp_version); $wp_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'wordpresses/' . $wp_version);
@ -152,7 +152,7 @@ class MainWP_Child_Vulnerability_Checker {
} }
if ($th_vuln) { if ($th_vuln) {
$th_vuln = json_decode($th_vuln, true); $th_vuln = json_decode($th_vuln, true);
$th_vuln_filter = $th_vuln; $th_vuln_filter = $th_vuln;
foreach ($th_vuln as $slug => $th_data) { foreach ($th_vuln as $slug => $th_data) {
if (isset($th_data['vulnerabilities']) && count($th_data['vulnerabilities']) > 0) { if (isset($th_data['vulnerabilities']) && count($th_data['vulnerabilities']) > 0) {
@ -189,9 +189,9 @@ class MainWP_Child_Vulnerability_Checker {
continue; continue;
} }
$result[ $th['id'] ]['vulner_data'] = $th_vuln; $result[ $th['id'] ]['vulner_data'] = $th_vuln;
$result[ $th['id'] ]['name'] = $th['name']; $result[ $th['id'] ]['name'] = $th['name'];
$result[ $th['id'] ]['author'] = $th['author']; $result[ $th['id'] ]['author'] = $th['author'];
$result[ $th['id'] ]['detected_version'] = $th['version']; $result[ $th['id'] ]['detected_version'] = $th['version'];
} }
} }
@ -211,7 +211,7 @@ class MainWP_Child_Vulnerability_Checker {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch); $output = curl_exec($ch);
$info = curl_getinfo($ch, CURLINFO_HTTP_CODE); $info = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch); curl_close($ch);
if ($output === false || $info != 200) { if ($output === false || $info != 200) {

View file

@ -190,7 +190,7 @@ class MainWP_Child_WooCommerce_Status {
$end_date = $_POST['end_date']; $end_date = $_POST['end_date'];
$start_date = date( 'Y-m-d H:i:s', $start_date ); $start_date = date( 'Y-m-d H:i:s', $start_date );
$end_date = date( 'Y-m-d H:i:s', $end_date ); $end_date = date( 'Y-m-d H:i:s', $end_date );
// Get sales // Get sales
$sales = $wpdb->get_var( "SELECT SUM( postmeta.meta_value ) FROM {$wpdb->posts} as posts $sales = $wpdb->get_var( "SELECT SUM( postmeta.meta_value ) FROM {$wpdb->posts} as posts
@ -300,10 +300,10 @@ class MainWP_Child_WooCommerce_Status {
function sync_data_two() { function sync_data_two() {
// sync data for current month // sync data for current month
$start_date = date( 'Y-m-01 00:00:00', time() ); $start_date = date( 'Y-m-01 00:00:00', time() );
$end_date = date( 'Y-m-d H:i:s', time() ); $end_date = date( 'Y-m-d H:i:s', time() );
$start_date = strtotime( $start_date ); $start_date = strtotime( $start_date );
$end_date = strtotime( $end_date ); $end_date = strtotime( $end_date );
return $this->get_woocom_data( $start_date, $end_date ); return $this->get_woocom_data( $start_date, $end_date );
} }
@ -332,7 +332,7 @@ class MainWP_Child_WooCommerce_Status {
} }
$start_date = date( 'Y-m-d H:i:s', $start_date ); $start_date = date( 'Y-m-d H:i:s', $start_date );
$end_date = date( 'Y-m-d H:i:s', $end_date ); $end_date = date( 'Y-m-d H:i:s', $end_date );
$reports = new WC_Admin_Report(); $reports = new WC_Admin_Report();
// Sales // Sales
@ -352,22 +352,22 @@ class MainWP_Child_WooCommerce_Status {
$sales = $wpdb->get_var( implode( ' ', apply_filters( 'woocommerce_dashboard_status_widget_sales_query', $query ) ) ); $sales = $wpdb->get_var( implode( ' ', apply_filters( 'woocommerce_dashboard_status_widget_sales_query', $query ) ) );
// Get top seller // Get top seller
$query = array(); $query = array();
$query['fields'] = "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id $query['fields'] = "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id
FROM {$wpdb->posts} as posts"; FROM {$wpdb->posts} as posts";
$query['join'] = "INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_id "; $query['join'] = "INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_id ";
$query['join'] .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id "; $query['join'] .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id ";
$query['join'] .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_2 ON order_items.order_item_id = order_item_meta_2.order_item_id "; $query['join'] .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_2 ON order_items.order_item_id = order_item_meta_2.order_item_id ";
$query['where'] = "WHERE posts.post_type IN ( '" . implode( "','", wc_get_order_types( 'order-count' ) ) . "' ) "; $query['where'] = "WHERE posts.post_type IN ( '" . implode( "','", wc_get_order_types( 'order-count' ) ) . "' ) ";
$query['where'] .= "AND posts.post_status IN ( 'wc-" . implode( "','wc-", apply_filters( 'woocommerce_reports_order_statuses', array( $query['where'] .= "AND posts.post_status IN ( 'wc-" . implode( "','wc-", apply_filters( 'woocommerce_reports_order_statuses', array(
'completed', 'completed',
'processing', 'processing',
'on-hold', 'on-hold',
) ) ) . "' ) "; ) ) ) . "' ) ";
$query['where'] .= "AND order_item_meta.meta_key = '_qty' "; $query['where'] .= "AND order_item_meta.meta_key = '_qty' ";
$query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' "; $query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' ";
$query['where'] .= 'AND posts.post_date >= STR_TO_DATE(' . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') "; $query['where'] .= 'AND posts.post_date >= STR_TO_DATE(' . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') ";
$query['where'] .= 'AND posts.post_date <= STR_TO_DATE(' . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') "; $query['where'] .= 'AND posts.post_date <= STR_TO_DATE(' . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') ";
$query['groupby'] = 'GROUP BY product_id'; $query['groupby'] = 'GROUP BY product_id';
$query['orderby'] = 'ORDER BY qty DESC'; $query['orderby'] = 'ORDER BY qty DESC';
$query['limits'] = 'LIMIT 1'; $query['limits'] = 'LIMIT 1';
@ -383,8 +383,8 @@ class MainWP_Child_WooCommerce_Status {
$processing_count = 0; $processing_count = 0;
foreach ( wc_get_order_types( 'order-count' ) as $type ) { foreach ( wc_get_order_types( 'order-count' ) as $type ) {
$counts = (array) wp_count_posts( $type ); $counts = (array) wp_count_posts( $type );
$on_hold_count += isset( $counts['wc-on-hold'] ) ? $counts['wc-on-hold'] : 0; $on_hold_count += isset( $counts['wc-on-hold'] ) ? $counts['wc-on-hold'] : 0;
$processing_count += isset( $counts['wc-processing'] ) ? $counts['wc-processing'] : 0; $processing_count += isset( $counts['wc-processing'] ) ? $counts['wc-processing'] : 0;
} }
@ -424,7 +424,7 @@ class MainWP_Child_WooCommerce_Status {
$outofstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) ); $outofstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) );
$data = array( $data = array(
'sales' => $sales, 'sales' => $sales,
'formated_sales' => wc_price( $sales ), 'formated_sales' => wc_price( $sales ),
'top_seller' => $top_seller, 'top_seller' => $top_seller,
@ -435,7 +435,7 @@ class MainWP_Child_WooCommerce_Status {
'lowstock' => $lowinstock_count, 'lowstock' => $lowinstock_count,
'outstock' => $outofstock_count, 'outstock' => $outofstock_count,
); );
$information['data'] = $data; $information['data'] = $data;
$information['need_db_update'] = $this->check_db_update(); $information['need_db_update'] = $this->check_db_update();
return $information; return $information;
} }

View file

@ -15,19 +15,19 @@
*/ */
class MainWP_Child_Wordfence { class MainWP_Child_Wordfence {
public static $instance = null; public static $instance = null;
public $is_wordfence_installed = false; public $is_wordfence_installed = false;
public $plugin_translate = 'mainwp-child'; public $plugin_translate = 'mainwp-child';
const OPTIONS_TYPE_GLOBAL = 'global'; const OPTIONS_TYPE_GLOBAL = 'global';
const OPTIONS_TYPE_FIREWALL = 'firewall'; const OPTIONS_TYPE_FIREWALL = 'firewall';
const OPTIONS_TYPE_BLOCKING = 'blocking'; const OPTIONS_TYPE_BLOCKING = 'blocking';
const OPTIONS_TYPE_SCANNER = 'scanner'; const OPTIONS_TYPE_SCANNER = 'scanner';
const OPTIONS_TYPE_TWO_FACTOR = 'twofactor'; const OPTIONS_TYPE_TWO_FACTOR = 'twofactor';
const OPTIONS_TYPE_LIVE_TRAFFIC = 'livetraffic'; const OPTIONS_TYPE_LIVE_TRAFFIC = 'livetraffic';
const OPTIONS_TYPE_COMMENT_SPAM = 'commentspam'; const OPTIONS_TYPE_COMMENT_SPAM = 'commentspam';
const OPTIONS_TYPE_DIAGNOSTICS = 'diagnostics'; const OPTIONS_TYPE_DIAGNOSTICS = 'diagnostics';
const OPTIONS_TYPE_ALL = 'alloptions'; const OPTIONS_TYPE_ALL = 'alloptions';
public static $options_filter = array( public static $options_filter = array(
'alertEmails', 'alertEmails',
@ -541,7 +541,7 @@ class MainWP_Child_Wordfence {
'learningModeGracePeriod', 'learningModeGracePeriod',
); );
$scan_opts = array( $scan_opts = array(
'scansEnabled_checkGSB', //paid 'scansEnabled_checkGSB', //paid
'spamvertizeCheck', //paid 'spamvertizeCheck', //paid
'checkSpamIP', // paid 'checkSpamIP', // paid
@ -689,7 +689,7 @@ return;
$table_wfStatus = wfDB::networkTable('wfStatus'); $table_wfStatus = wfDB::networkTable('wfStatus');
// to fix prepare sql empty // to fix prepare sql empty
$sql = sprintf( "SELECT * FROM {$table_wfStatus} WHERE ctime >= %d AND level = 1 AND type = 'info' AND msg LIKE ", $lastcheck ); $sql = sprintf( "SELECT * FROM {$table_wfStatus} WHERE ctime >= %d AND level = 1 AND type = 'info' AND msg LIKE ", $lastcheck );
$sql .= " 'Scan Complete.%';"; $sql .= " 'Scan Complete.%';";
$rows = MainWP_Child_DB::_query( $sql, $wpdb->dbh ); $rows = MainWP_Child_DB::_query( $sql, $wpdb->dbh );
@ -703,11 +703,11 @@ return;
if ($scan_time) { if ($scan_time) {
$message = 'Wordfence scan completed'; $message = 'Wordfence scan completed';
foreach ($scan_time as $ctime => $details) { foreach ($scan_time as $ctime => $details) {
$sql = sprintf( "SELECT * FROM {$table_wfStatus} WHERE ctime > %d AND ctime < %d AND level = 10 AND type = 'info' AND msg LIKE ", $ctime, $ctime + 100 ); // to get nearest SUM_FINAL msg $sql = sprintf( "SELECT * FROM {$table_wfStatus} WHERE ctime > %d AND ctime < %d AND level = 10 AND type = 'info' AND msg LIKE ", $ctime, $ctime + 100 ); // to get nearest SUM_FINAL msg
$sql .= " 'SUM_FINAL:Scan complete.%';"; $sql .= " 'SUM_FINAL:Scan complete.%';";
$sum_rows = MainWP_Child_DB::_query( $sql, $wpdb->dbh ); $sum_rows = MainWP_Child_DB::_query( $sql, $wpdb->dbh );
$result = ''; $result = '';
if ($sum_rows) { if ($sum_rows) {
$sum_row = MainWP_Child_DB::fetch_array( $sum_rows ); $sum_row = MainWP_Child_DB::fetch_array( $sum_rows );
if (is_array($sum_row) && isset($sum_row['msg'])) { if (is_array($sum_row) && isset($sum_row['msg'])) {
@ -770,7 +770,7 @@ return;
$information = array(); $information = array();
$wfLog = wordfence::getLog(); $wfLog = wordfence::getLog();
if ( $wfLog ) { if ( $wfLog ) {
$information['events'] = $wfLog->getStatusEvents( 0 ); $information['events'] = $wfLog->getStatusEvents( 0 );
if (method_exists($wfLog, 'getSummaryEvents')) { if (method_exists($wfLog, 'getSummaryEvents')) {
$information['summary'] = $wfLog->getSummaryEvents(); $information['summary'] = $wfLog->getSummaryEvents();
@ -791,10 +791,10 @@ return;
// not used // not used
public function load_issues() { public function load_issues() {
$offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0; $offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0;
$limit = isset($_POST['limit']) ? intval($_POST['limit']) : WORDFENCE_SCAN_ISSUES_PER_PAGE; $limit = isset($_POST['limit']) ? intval($_POST['limit']) : WORDFENCE_SCAN_ISSUES_PER_PAGE;
$i = new wfIssues(); $i = new wfIssues();
$iss = $i->getIssues($offset, $limit); $iss = $i->getIssues($offset, $limit);
$counts = $i->getIssueCounts(); $counts = $i->getIssueCounts();
return array( return array(
@ -814,10 +814,10 @@ return;
public static function ajax_loadIssues_callback() { public static function ajax_loadIssues_callback() {
$offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0; $offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0;
$limit = isset($_POST['limit']) ? intval($_POST['limit']) : WORDFENCE_SCAN_ISSUES_PER_PAGE; $limit = isset($_POST['limit']) ? intval($_POST['limit']) : WORDFENCE_SCAN_ISSUES_PER_PAGE;
$i = new wfIssues(); $i = new wfIssues();
$iss = $i->getIssues($offset, $limit); $iss = $i->getIssues($offset, $limit);
$counts = $i->getIssueCounts(); $counts = $i->getIssueCounts();
$return = array( $return = array(
'issuesLists' => $iss, 'issuesLists' => $iss,
@ -844,7 +844,7 @@ return;
); );
if (class_exists('wfFirewall')) { if (class_exists('wfFirewall')) {
$firewall = new wfFirewall(); $firewall = new wfFirewall();
$return['isSubDirectoryInstallation'] = $firewall->isSubDirectoryInstallation(); $return['isSubDirectoryInstallation'] = $firewall->isSubDirectoryInstallation();
} }
return $return; return $return;
@ -853,7 +853,7 @@ return;
public function count_attacks_blocked( $maxAgeDays) { public function count_attacks_blocked( $maxAgeDays) {
global $wpdb; global $wpdb;
$table_wfBlockedIPLog = wfDB::networkTable('wfBlockedIPLog'); $table_wfBlockedIPLog = wfDB::networkTable('wfBlockedIPLog');
$interval = 'FLOOR(UNIX_TIMESTAMP(DATE_SUB(NOW(), interval ' . $maxAgeDays . ' day)) / 86400)'; $interval = 'FLOOR(UNIX_TIMESTAMP(DATE_SUB(NOW(), interval ' . $maxAgeDays . ' day)) / 86400)';
return $wpdb->get_var(<<<SQL return $wpdb->get_var(<<<SQL
SELECT SUM(blockCount) as blockCount SELECT SUM(blockCount) as blockCount
FROM {$table_wfBlockedIPLog} FROM {$table_wfBlockedIPLog}
@ -864,9 +864,9 @@ SQL
function get_lastscan() { function get_lastscan() {
$wfdb = new wfDB(); $wfdb = new wfDB();
$table_wfStatus = wfDB::networkTable('wfStatus'); $table_wfStatus = wfDB::networkTable('wfStatus');
$ctime = $wfdb->querySingle("SELECT MAX(ctime) FROM {$table_wfStatus} WHERE msg LIKE '%SUM_PREP:Preparing a new scan.%'"); $ctime = $wfdb->querySingle("SELECT MAX(ctime) FROM {$table_wfStatus} WHERE msg LIKE '%SUM_PREP:Preparing a new scan.%'");
return $ctime; return $ctime;
} }
@ -888,8 +888,8 @@ SQL
function updateIssueStatus() { function updateIssueStatus() {
$wfIssues = new wfIssues(); $wfIssues = new wfIssues();
$status = $_POST['status']; $status = $_POST['status'];
$issueID = $_POST['id']; $issueID = $_POST['id'];
if ( ! preg_match('/^(?:new|delete|ignoreP|ignoreC)$/', $status)) { if ( ! preg_match('/^(?:new|delete|ignoreP|ignoreC)$/', $status)) {
return array( 'errorMsg' => 'An invalid status was specified when trying to update that issue.' ); return array( 'errorMsg' => 'An invalid status was specified when trying to update that issue.' );
} }
@ -1108,10 +1108,10 @@ SQL
for ( $i = 0; $i < strlen($string); $i++) { for ( $i = 0; $i < strlen($string); $i++) {
$c = ord(substr($string, $i)); $c = ord(substr($string, $i));
if ($action == 'encrypt') { if ($action == 'encrypt') {
$c += ord(substr($key, ( ( $i + 1 ) % strlen($key) ))); $c += ord(substr($key, ( ( $i + 1 ) % strlen($key) )));
$res .= chr($c & 0xFF); $res .= chr($c & 0xFF);
} else { } else {
$c -= ord(substr($key, ( ( $i + 1 ) % strlen($key) ))); $c -= ord(substr($key, ( ( $i + 1 ) % strlen($key) )));
$res .= chr(abs($c) & 0xFF); $res .= chr(abs($c) & 0xFF);
} }
} }
@ -1129,15 +1129,15 @@ SQL
$settings = maybe_unserialize( base64_decode( $_POST['settings'] ) ); $settings = maybe_unserialize( base64_decode( $_POST['settings'] ) );
} }
$section = isset($_POST['savingSection']) ? $_POST['savingSection'] : ''; $section = isset($_POST['savingSection']) ? $_POST['savingSection'] : '';
$saving_opts = self::getSectionSettings($section); $saving_opts = self::getSectionSettings($section);
$result = array(); $result = array();
if ( is_array( $settings ) && count( $settings ) > 0 && count($saving_opts) > 0 ) { if ( is_array( $settings ) && count( $settings ) > 0 && count($saving_opts) > 0 ) {
$reload = ''; $reload = '';
$opts = $settings; $opts = $settings;
// if saving then validate data // if saving then validate data
if (in_array('liveTraf_ignoreUsers', $saving_opts)) { if (in_array('liveTraf_ignoreUsers', $saving_opts)) {
@ -1169,7 +1169,7 @@ SQL
// if saving then validate data // if saving then validate data
if (in_array('other_WFNet', $saving_opts)) { if (in_array('other_WFNet', $saving_opts)) {
if ( ! $opts['other_WFNet'] ) { if ( ! $opts['other_WFNet'] ) {
$wfdb = new wfDB(); $wfdb = new wfDB();
$table_wfBlocks7 = wfDB::networkTable('wfBlocks7'); $table_wfBlocks7 = wfDB::networkTable('wfBlocks7');
$wfdb->queryWrite( "delete from {$table_wfBlocks7} where wfsn=1 and permanent=0" ); $wfdb->queryWrite( "delete from {$table_wfBlocks7} where wfsn=1 and permanent=0" );
} }
@ -1291,8 +1291,8 @@ SQL
// if saving then validate data // if saving then validate data
if (in_array('apiKey', $saving_opts)) { if (in_array('apiKey', $saving_opts)) {
$apiKey = trim( $_POST['apiKey'] ); $apiKey = trim( $_POST['apiKey'] );
$apiKey = strtolower(trim($apiKey)); $apiKey = strtolower(trim($apiKey));
$existingAPIKey = wfConfig::get('apiKey', ''); $existingAPIKey = wfConfig::get('apiKey', '');
$ping = false; $ping = false;
@ -1345,7 +1345,7 @@ SQL
$result['paidKeyMsg'] = true; $result['paidKeyMsg'] = true;
} }
$ping = true; $ping = true;
$reload = 'reload'; $reload = 'reload';
} else { } else {
throw new Exception( 'We could not understand the Wordfence API server reply when updating your API key.' ); throw new Exception( 'We could not understand the Wordfence API server reply when updating your API key.' );
@ -1355,7 +1355,7 @@ SQL
return $result; return $result;
} }
} else { } else {
$ping = true; $ping = true;
$apiKey = $existingAPIKey; $apiKey = $existingAPIKey;
} }
@ -1393,7 +1393,7 @@ SQL
wfConfig::set('keyType', $keyType); wfConfig::set('keyType', $keyType);
if ( ! isset($result['apiKey'])) { if ( ! isset($result['apiKey'])) {
$isPaid = ( $keyType == wfAPI::KEY_TYPE_FREE ) ? false : true; $isPaid = ( $keyType == wfAPI::KEY_TYPE_FREE ) ? false : true;
$result['apiKey'] = $apiKey; $result['apiKey'] = $apiKey;
$result['isPaid'] = $isPaid; $result['isPaid'] = $isPaid;
if ( $isPaid ) { if ( $isPaid ) {
@ -1460,7 +1460,7 @@ SQL
} }
if ( ! $opts['other_WFNet'] ) { if ( ! $opts['other_WFNet'] ) {
$wfdb = new wfDB(); $wfdb = new wfDB();
$table_wfBlocks7 = wfDB::networkTable('wfBlocks7'); $table_wfBlocks7 = wfDB::networkTable('wfBlocks7');
$wfdb->queryWrite( "delete from {$table_wfBlocks7} where wfsn=1 and permanent=0" ); $wfdb->queryWrite( "delete from {$table_wfBlocks7} where wfsn=1 and permanent=0" );
} }
@ -1622,13 +1622,13 @@ SQL
$res = $api->call('import_options', array(), array( 'token' => $token )); $res = $api->call('import_options', array(), array( 'token' => $token ));
if ($res['ok'] && $res['export']) { if ($res['ok'] && $res['export']) {
$totalSet = 0; $totalSet = 0;
$import = @json_decode($res['export'], true); $import = @json_decode($res['export'], true);
if ( ! is_array($import)) { if ( ! is_array($import)) {
return array( 'errorImport' => __('An error occurred: Invalid options format received.', 'wordfence') ); return array( 'errorImport' => __('An error occurred: Invalid options format received.', 'wordfence') );
} }
//Basic Options //Basic Options
$keys = wfConfig::getExportableOptionsKeys(); $keys = wfConfig::getExportableOptionsKeys();
$toSet = array(); $toSet = array();
foreach ($keys as $key) { foreach ($keys as $key) {
if (isset($import[ $key ])) { if (isset($import[ $key ])) {
@ -1638,7 +1638,7 @@ SQL
if (count($toSet)) { if (count($toSet)) {
$validation = wfConfig::validate($toSet); $validation = wfConfig::validate($toSet);
$skipped = array(); $skipped = array();
if ($validation !== true) { if ($validation !== true) {
foreach ($validation as $error) { foreach ($validation as $error) {
$skipped[ $error['option'] ] = $error['error']; $skipped[ $error['option'] ] = $error['error'];
@ -1679,7 +1679,7 @@ SQL
} }
function get_settings() { function get_settings() {
$keys = wfConfig::getExportableOptionsKeys(); $keys = wfConfig::getExportableOptionsKeys();
$settings = array(); $settings = array();
foreach ($keys as $key) { foreach ($keys as $key) {
$settings[ $key ] = wfConfig::get($key, ''); $settings[ $key ] = wfConfig::get($key, '');
@ -1696,14 +1696,14 @@ SQL
$table_wfStatus = wfDB::networkTable('wfStatus'); $table_wfStatus = wfDB::networkTable('wfStatus');
$jsonData = array( $jsonData = array(
'serverTime' => $serverTime, 'serverTime' => $serverTime,
'serverMicrotime' => microtime(true), 'serverMicrotime' => microtime(true),
'msg' => $wfdb->querySingle( "select msg from {$table_wfStatus} where level < 3 order by ctime desc limit 1" ), 'msg' => $wfdb->querySingle( "select msg from {$table_wfStatus} where level < 3 order by ctime desc limit 1" ),
); );
$events = array(); $events = array();
$alsoGet = $_POST['alsoGet']; $alsoGet = $_POST['alsoGet'];
if ( preg_match( '/^logList_(404|hit|human|ruser|crawler|gCrawler|loginLogout)$/', $alsoGet, $m ) ) { if ( preg_match( '/^logList_(404|hit|human|ruser|crawler|gCrawler|loginLogout)$/', $alsoGet, $m ) ) {
$type = $m[1]; $type = $m[1];
$newestEventTime = $_POST['otherParams']; $newestEventTime = $_POST['otherParams'];
@ -1720,7 +1720,7 @@ SQL
wordfence::syncAttackData(false); wordfence::syncAttackData(false);
} }
$results = wordfence::ajax_loadLiveTraffic_callback(); $results = wordfence::ajax_loadLiveTraffic_callback();
$events = $results['data']; $events = $results['data'];
if (isset($results['sql'])) { if (isset($results['sql'])) {
$jsonData['sql'] = $results['sql']; $jsonData['sql'] = $results['sql'];
} }
@ -1732,10 +1732,10 @@ SQL
} }
public static function loadLiveTraffic() { public static function loadLiveTraffic() {
$wfdb = new wfDB(); $wfdb = new wfDB();
$serverTime = $wfdb->querySingle( 'select unix_timestamp()' ); $serverTime = $wfdb->querySingle( 'select unix_timestamp()' );
$return = wordfence::ajax_loadLiveTraffic_callback(); $return = wordfence::ajax_loadLiveTraffic_callback();
$return['serverTime'] = $serverTime; $return['serverTime'] = $serverTime;
$return['serverMicrotime'] = microtime(true); $return['serverMicrotime'] = microtime(true);
return $return; return $return;
} }
@ -1846,17 +1846,17 @@ SQL
// end if custom // end if custom
$data['learningMode'] = wfWAF::getInstance()->isInLearningMode(); $data['learningMode'] = wfWAF::getInstance()->isInLearningMode();
$data['rules'] = wfWAF::getInstance()->getRules(); $data['rules'] = wfWAF::getInstance()->getRules();
/** @var wfWAFRule $rule */ /** @var wfWAFRule $rule */
foreach ($data['rules'] as $ruleID => $rule) { foreach ($data['rules'] as $ruleID => $rule) {
$data['rules'][ $ruleID ] = $rule->toArray(); $data['rules'][ $ruleID ] = $rule->toArray();
} }
$whitelistedURLParams = wfWAF::getInstance()->getStorageEngine()->getConfig('whitelistedURLParams', array()); $whitelistedURLParams = wfWAF::getInstance()->getStorageEngine()->getConfig('whitelistedURLParams', array());
$data['whitelistedURLParams'] = array(); $data['whitelistedURLParams'] = array();
foreach ($whitelistedURLParams as $urlParamKey => $rules) { foreach ($whitelistedURLParams as $urlParamKey => $rules) {
list($path, $paramKey) = explode('|', $urlParamKey); list($path, $paramKey) = explode('|', $urlParamKey);
$whitelistData = null; $whitelistData = null;
foreach ($rules as $ruleID => $whitelistedData) { foreach ($rules as $ruleID => $whitelistedData) {
if ($whitelistData === null) { if ($whitelistData === null) {
$whitelistData = $whitelistedData; $whitelistData = $whitelistedData;
@ -2078,7 +2078,7 @@ SQL
$cacheType = $_POST['cacheType']; $cacheType = $_POST['cacheType'];
if ($cacheType == 'falcon' || $cacheType == 'php') { if ($cacheType == 'falcon' || $cacheType == 'php') {
$plugins = get_plugins(); $plugins = get_plugins();
$badPlugins = array(); $badPlugins = array();
foreach ($plugins as $pluginFile => $data) { foreach ($plugins as $pluginFile => $data) {
if (is_plugin_active($pluginFile)) { if (is_plugin_active($pluginFile)) {
@ -2110,7 +2110,7 @@ SQL
} }
$warnHtaccess = false; $warnHtaccess = false;
if ($cacheType == 'disable' || $cacheType == 'php') { if ($cacheType == 'disable' || $cacheType == 'php') {
$removeError = wfCache::addHtaccessCode('remove'); $removeError = wfCache::addHtaccessCode('remove');
$removeError2 = wfCache::updateBlockedIPs('remove'); $removeError2 = wfCache::updateBlockedIPs('remove');
if ($removeError || $removeError2) { if ($removeError || $removeError2) {
$warnHtaccess = true; $warnHtaccess = true;
@ -2371,9 +2371,9 @@ SQL
if ( ! $ex) { if ( ! $ex) {
return array( 'ok' => 1 ); return array( 'ok' => 1 );
} }
$ex = unserialize($ex); $ex = unserialize($ex);
$rewriteHtaccess = false; $rewriteHtaccess = false;
$removed = false; $removed = false;
for ($i = 0; $i < sizeof($ex); $i++) { for ($i = 0; $i < sizeof($ex); $i++) {
if ( (string) $ex[ $i ]['id'] == (string) $id) { if ( (string) $ex[ $i ]['id'] == (string) $id) {
if (wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $ex[ $i ]['pt'])) { if (wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $ex[ $i ]['pt'])) {
@ -2402,14 +2402,14 @@ SQL
public function getDiagnostics() { public function getDiagnostics() {
$diagnostic = new wfDiagnostic(); $diagnostic = new wfDiagnostic();
$plugins = get_plugins(); $plugins = get_plugins();
$activePlugins = array_flip(get_option('active_plugins')); $activePlugins = array_flip(get_option('active_plugins'));
$activeNetworkPlugins = is_multisite() ? array_flip(wp_get_active_network_plugins()) : array(); $activeNetworkPlugins = is_multisite() ? array_flip(wp_get_active_network_plugins()) : array();
$muPlugins = get_mu_plugins(); $muPlugins = get_mu_plugins();
$themes = wp_get_themes(); $themes = wp_get_themes();
$currentTheme = wp_get_theme(); $currentTheme = wp_get_theme();
$cols = 3; $cols = 3;
$w = new wfConfig(); $w = new wfConfig();
@ -2422,7 +2422,7 @@ SQL
<form id="wfConfigForm" style="overflow-x: auto;"> <form id="wfConfigForm" style="overflow-x: auto;">
<?php <?php
foreach ($diagnostic->getResults() as $title => $tests) : foreach ($diagnostic->getResults() as $title => $tests) :
$key = sanitize_key('wf-diagnostics-' . $title); $key = sanitize_key('wf-diagnostics-' . $title);
$hasFailingTest = false; $hasFailingTest = false;
foreach ($tests['results'] as $result) { foreach ($tests['results'] as $result) {
if ( ! $result['test']) { if ( ! $result['test']) {
@ -2511,9 +2511,9 @@ SQL
<?php endforeach ?> <?php endforeach ?>
<?php <?php
$howGet = wfConfig::get('howGetIPs', false); $howGet = wfConfig::get('howGetIPs', false);
list($currentIP, $currentServerVarForIP) = wfUtils::getIPAndServerVariable(); list($currentIP, $currentServerVarForIP) = wfUtils::getIPAndServerVariable();
$howGetHasErrors = false; $howGetHasErrors = false;
foreach (array( foreach (array(
'REMOTE_ADDR' => 'REMOTE_ADDR', 'REMOTE_ADDR' => 'REMOTE_ADDR',
'HTTP_CF_CONNECTING_IP' => 'CF-Connecting-IP', 'HTTP_CF_CONNECTING_IP' => 'CF-Connecting-IP',
@ -2550,7 +2550,7 @@ SQL
</tbody> </tbody>
<tbody> <tbody>
<?php <?php
$howGet = wfConfig::get('howGetIPs', false); $howGet = wfConfig::get('howGetIPs', false);
list($currentIP, $currentServerVarForIP) = wfUtils::getIPAndServerVariable(); list($currentIP, $currentServerVarForIP) = wfUtils::getIPAndServerVariable();
foreach (array( foreach (array(
'REMOTE_ADDR' => 'REMOTE_ADDR', 'REMOTE_ADDR' => 'REMOTE_ADDR',
@ -2567,10 +2567,10 @@ SQL
echo '(not set)'; echo '(not set)';
} else { } else {
if (strpos($_SERVER[ $variable ], ',') !== false) { if (strpos($_SERVER[ $variable ], ',') !== false) {
$trustedProxies = explode("\n", wfConfig::get('howGetIPs_trusted_proxies', '')); $trustedProxies = explode("\n", wfConfig::get('howGetIPs_trusted_proxies', ''));
$items = preg_replace('/[\s,]/', '', explode(',', $_SERVER[ $variable ])); $items = preg_replace('/[\s,]/', '', explode(',', $_SERVER[ $variable ]));
$items = array_reverse($items); $items = array_reverse($items);
$output = ''; $output = '';
$markedSelectedAddress = false; $markedSelectedAddress = false;
foreach ($items as $index => $i) { foreach ($items as $index => $i) {
foreach ($trustedProxies as $proxy) { foreach ($trustedProxies as $proxy) {
@ -2583,7 +2583,7 @@ SQL
} }
if ( ! $markedSelectedAddress) { if ( ! $markedSelectedAddress) {
$output = '<strong>' . esc_html($i) . '</strong>, ' . $output; $output = '<strong>' . esc_html($i) . '</strong>, ' . $output;
$markedSelectedAddress = true; $markedSelectedAddress = true;
} else { } else {
$output = esc_html($i) . ', ' . $output; $output = esc_html($i) . ', ' . $output;
@ -2629,7 +2629,7 @@ SQL
<tbody> <tbody>
<?php <?php
require ABSPATH . 'wp-includes/version.php'; require ABSPATH . 'wp-includes/version.php';
$postRevisions = ( defined('WP_POST_REVISIONS') ? WP_POST_REVISIONS : true ); $postRevisions = ( defined('WP_POST_REVISIONS') ? WP_POST_REVISIONS : true );
$wordPressValues = array( $wordPressValues = array(
'WordPress Version' => array( 'WordPress Version' => array(
'description' => '', 'description' => '',
@ -2780,9 +2780,9 @@ SQL
); );
foreach ($wordPressValues as $settingName => $settingData) : foreach ($wordPressValues as $settingName => $settingData) :
$escapedName = esc_html($settingName); $escapedName = esc_html($settingName);
$escapedDescription = ''; $escapedDescription = '';
$escapedValue = '(not set)'; $escapedValue = '(not set)';
if (is_array($settingData)) { if (is_array($settingData)) {
$escapedDescription = esc_html($settingData['description']); $escapedDescription = esc_html($settingData['description']);
if (isset($settingData['value'])) { if (isset($settingData['value'])) {
@ -2964,7 +2964,7 @@ SQL
$wfdb = new wfDB(); $wfdb = new wfDB();
//This must be done this way because MySQL with InnoDB tables does a full regeneration of all metadata if we don't. That takes a long time with a large table count. //This must be done this way because MySQL with InnoDB tables does a full regeneration of all metadata if we don't. That takes a long time with a large table count.
$tables = $wfdb->querySelect('SELECT SQL_CALC_FOUND_ROWS TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE() ORDER BY TABLE_NAME ASC LIMIT 250'); $tables = $wfdb->querySelect('SELECT SQL_CALC_FOUND_ROWS TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE() ORDER BY TABLE_NAME ASC LIMIT 250');
$total = $wfdb->querySingle('SELECT FOUND_ROWS()'); $total = $wfdb->querySingle('SELECT FOUND_ROWS()');
foreach ($tables as &$t) { foreach ($tables as &$t) {
$t = "'" . esc_sql($t['TABLE_NAME']) . "'"; $t = "'" . esc_sql($t['TABLE_NAME']) . "'";
} }

View file

@ -16,7 +16,7 @@
*/ */
class MainWP_Child_WP_Rocket { class MainWP_Child_WP_Rocket {
public static $instance = null; public static $instance = null;
public $is_plugin_installed = false; public $is_plugin_installed = false;
public static function Instance() { public static function Instance() {
@ -138,7 +138,7 @@ class MainWP_Child_WP_Rocket {
public function syncOthersData( $information, $data = array() ) { public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncWPRocketData'] ) && ( 'yes' === $data['syncWPRocketData'] ) ) { if ( isset( $data['syncWPRocketData'] ) && ( 'yes' === $data['syncWPRocketData'] ) ) {
try { try {
$data = array( 'rocket_boxes' => get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true ) ); $data = array( 'rocket_boxes' => get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true ) );
$information['syncWPRocketData'] = $data; $information['syncWPRocketData'] = $data;
} catch (Exception $e) { } catch (Exception $e) {
} }
@ -383,8 +383,8 @@ class MainWP_Child_WP_Rocket {
)); ));
$critical_css = new WP_Rocket\Optimization\CSS\Critical_CSS( new WP_Rocket\Optimization\CSS\Critical_CSS_Generation() ); $critical_css = new WP_Rocket\Optimization\CSS\Critical_CSS( new WP_Rocket\Optimization\CSS\Critical_CSS_Generation() );
$options_api = new WP_Rocket\Admin\Options( 'wp_rocket_' ); $options_api = new WP_Rocket\Admin\Options( 'wp_rocket_' );
$options = new WP_Rocket\Admin\Options_Data( $options_api->get( 'settings', array() ) ); $options = new WP_Rocket\Admin\Options_Data( $options_api->get( 'settings', array() ) );
$sitemap_preload = new WP_Rocket\Subscriber\Optimization\Critical_CSS_Subscriber( $critical_css, $options ); $sitemap_preload = new WP_Rocket\Subscriber\Optimization\Critical_CSS_Subscriber( $critical_css, $options );
@ -429,7 +429,7 @@ class MainWP_Child_WP_Rocket {
'WP_Rocket\Admin\Options_Data', 'WP_Rocket\Admin\Options_Data',
)); ));
$process = new WP_Rocket\Admin\Database\Optimization_Process(); $process = new WP_Rocket\Admin\Database\Optimization_Process();
$optimization = new WP_Rocket\Admin\Database\Optimization( $process ); $optimization = new WP_Rocket\Admin\Database\Optimization( $process );
MainWP_Helper::check_methods( $optimization, array( 'process_handler', 'get_options' ) ); MainWP_Helper::check_methods( $optimization, array( 'process_handler', 'get_options' ) );
@ -453,7 +453,7 @@ class MainWP_Child_WP_Rocket {
'WP_Rocket\Admin\Database\Optimization_Process', 'WP_Rocket\Admin\Database\Optimization_Process',
)); ));
$process = new WP_Rocket\Admin\Database\Optimization_Process(); $process = new WP_Rocket\Admin\Database\Optimization_Process();
$optimization = new WP_Rocket\Admin\Database\Optimization( $process ); $optimization = new WP_Rocket\Admin\Database\Optimization( $process );
MainWP_Helper::check_methods($optimization, 'count_cleanup_items'); MainWP_Helper::check_methods($optimization, 'count_cleanup_items');

View file

@ -2,7 +2,7 @@
class MainWP_Child_WPvivid_BackupRestore { class MainWP_Child_WPvivid_BackupRestore {
public static $instance = null; public static $instance = null;
public $is_plugin_installed = false; public $is_plugin_installed = false;
public $public_intetface; public $public_intetface;
static function Instance() { static function Instance() {
@ -34,12 +34,12 @@ class MainWP_Child_WPvivid_BackupRestore {
try { try {
if ( isset( $data['syncWPvividData'] )) { if ( isset( $data['syncWPvividData'] )) {
$information['syncWPvividData'] = 1; $information['syncWPvividData'] = 1;
$data = WPvivid_Setting::get_sync_data(); $data = WPvivid_Setting::get_sync_data();
$information['syncWPvividSettingData'] = $data['setting']; $information['syncWPvividSettingData'] = $data['setting'];
$information['syncWPvividRemoteData'] = $data['remote']; $information['syncWPvividRemoteData'] = $data['remote'];
$information['syncWPvividScheduleData'] = $data['schedule']; $information['syncWPvividScheduleData'] = $data['schedule'];
$information['syncWPvividSetting'] = $data; $information['syncWPvividSetting'] = $data;
} }
} catch (Exception $e) { } catch (Exception $e) {

View file

@ -116,7 +116,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
} }
class MainWP_Child { class MainWP_Child {
public static $version = '4.0.7'; public static $version = '4.0.7';
private $update_version = '1.5'; private $update_version = '1.5';
private $callableFunctions = array( private $callableFunctions = array(
@ -202,7 +202,7 @@ class MainWP_Child {
private $slug; private $slug;
private $maxHistory = 5; private $maxHistory = 5;
private $filterFunction = null; private $filterFunction = null;
public static $brandingTitle = null; public static $brandingTitle = null;
public static $subPages; public static $subPages;
@ -221,8 +221,8 @@ return false; }
}; };
$this->plugin_dir = dirname( $plugin_file ); $this->plugin_dir = dirname( $plugin_file );
$this->plugin_slug = plugin_basename( $plugin_file ); $this->plugin_slug = plugin_basename( $plugin_file );
list ( $t1, $t2 ) = explode( '/', $this->plugin_slug ); list ( $t1, $t2 ) = explode( '/', $this->plugin_slug );
$this->slug = str_replace( '.php', '', $t2 ); $this->slug = str_replace( '.php', '', $t2 );
$this->posts_where_suffix = ''; $this->posts_where_suffix = '';
$this->comments_and_clauses = ''; $this->comments_and_clauses = '';
@ -285,7 +285,7 @@ return false; }
if ( ! isset($alloptions['mainwp_db_version']) ) { if ( ! isset($alloptions['mainwp_db_version']) ) {
$suppress = $wpdb->suppress_errors(); $suppress = $wpdb->suppress_errors();
$options = array( $options = array(
'mainwp_child_auth', 'mainwp_child_auth',
'mainwp_branding_plugin_header', 'mainwp_branding_plugin_header',
'mainwp_child_reports_db', 'mainwp_child_reports_db',
@ -320,11 +320,11 @@ return false; }
'mainwp_child_branding_settings', 'mainwp_child_branding_settings',
'mainwp_child_plugintheme_days_outdate', 'mainwp_child_plugintheme_days_outdate',
); );
$query = "SELECT option_name, option_value FROM $wpdb->options WHERE option_name in ("; $query = "SELECT option_name, option_value FROM $wpdb->options WHERE option_name in (";
foreach ($options as $option) { foreach ($options as $option) {
$query .= "'" . $option . "', "; $query .= "'" . $option . "', ";
} }
$query = substr($query, 0, strlen($query) - 2); $query = substr($query, 0, strlen($query) - 2);
$query .= ')'; $query .= ')';
$alloptions_db = $wpdb->get_results( $query ); $alloptions_db = $wpdb->get_results( $query );
@ -509,7 +509,7 @@ $alloptions = array();
$convertBranding = array(); $convertBranding = array();
foreach ( $brandingOptions as $option => $old ) { foreach ( $brandingOptions as $option => $old ) {
$value = get_option( $old ); $value = get_option( $old );
$convertBranding[ $option ] = $value; $convertBranding[ $option ] = $value;
} }
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $convertBranding ); MainWP_Helper::update_option( 'mainwp_child_branding_settings', $convertBranding );
@ -541,24 +541,24 @@ $alloptions = array();
public function admin_notice() { public function admin_notice() {
//Admin Notice... //Admin Notice...
if ( ! get_option( 'mainwp_child_pubkey' ) && MainWP_Helper::isAdmin() && is_admin() ) { if ( ! get_option( 'mainwp_child_pubkey' ) && MainWP_Helper::isAdmin() && is_admin() ) {
$branding_opts = MainWP_Child_Branding::Instance()->get_branding_options(); $branding_opts = MainWP_Child_Branding::Instance()->get_branding_options();
$child_name = ( $branding_opts['branding_preserve_title'] === '' ) ? 'MainWP Child' : $branding_opts['branding_preserve_title']; $child_name = ( $branding_opts['branding_preserve_title'] === '' ) ? 'MainWP Child' : $branding_opts['branding_preserve_title'];
$dashboard_name = ( $branding_opts['branding_preserve_title'] === '' ) ? 'MainWP Dashboard' : $branding_opts['branding_preserve_title'] . ' Dashboard'; $dashboard_name = ( $branding_opts['branding_preserve_title'] === '' ) ? 'MainWP Dashboard' : $branding_opts['branding_preserve_title'] . ' Dashboard';
$msg = '<div class="wrap"><div class="postbox" style="margin-top: 4em;"><p style="background: #a00; color: #fff; font-size: 22px; font-weight: bold; margin: 0; padding: .3em;">'; $msg = '<div class="wrap"><div class="postbox" style="margin-top: 4em;"><p style="background: #a00; color: #fff; font-size: 22px; font-weight: bold; margin: 0; padding: .3em;">';
$msg .= __( 'Attention!', 'mainwp-child' ); $msg .= __( 'Attention!', 'mainwp-child' );
$msg .= '</p><div style="padding-left: 1em; padding-right: 1em;"><p style="font-size: 16px;">'; $msg .= '</p><div style="padding-left: 1em; padding-right: 1em;"><p style="font-size: 16px;">';
$msg .= __( 'Please add this site to your ', 'mainwp-child' ) . $dashboard_name . ' ' . __( '<b>NOW</b> or deactivate the ', 'mainwp-child' ) . $child_name . __( ' plugin until you are ready to connect this site to your Dashboard in order to avoid unexpected security issues.', 'mainwp-child' ); $msg .= __( 'Please add this site to your ', 'mainwp-child' ) . $dashboard_name . ' ' . __( '<b>NOW</b> or deactivate the ', 'mainwp-child' ) . $child_name . __( ' plugin until you are ready to connect this site to your Dashboard in order to avoid unexpected security issues.', 'mainwp-child' );
$msg .= '</p>'; $msg .= '</p>';
$msg .= '<p style="font-size: 16px;">'; $msg .= '<p style="font-size: 16px;">';
$msg .= __( 'If you are not sure how to add this site to your Dashboard, <a href="https://mainwp.com/help/docs/set-up-the-mainwp-plugin/add-site-to-your-dashboard/" target="_blank">please review these instructions</a>.', 'mainwp-child' ); $msg .= __( 'If you are not sure how to add this site to your Dashboard, <a href="https://mainwp.com/help/docs/set-up-the-mainwp-plugin/add-site-to-your-dashboard/" target="_blank">please review these instructions</a>.', 'mainwp-child' );
$msg .= '</p>'; $msg .= '</p>';
if ( ! MainWP_Child_Branding::Instance()->is_branding() ) { if ( ! MainWP_Child_Branding::Instance()->is_branding() ) {
$msg .= '<p>'; $msg .= '<p>';
$msg .= __( 'You can also turn on the unique security ID option in <a href="admin.php?page=mainwp_child_tab">', 'mainwp-child' ) . $child_name . __( ' settings</a> if you would like extra security and additional time to add this site to your Dashboard. <br/>Find out more in this help document <a href="https://mainwp.com/help/docs/set-up-the-mainwp-plugin/set-unique-security-id/" target="_blank">How do I use the child unique security ID?</a>', 'mainwp-child' ); $msg .= __( 'You can also turn on the unique security ID option in <a href="admin.php?page=mainwp_child_tab">', 'mainwp-child' ) . $child_name . __( ' settings</a> if you would like extra security and additional time to add this site to your Dashboard. <br/>Find out more in this help document <a href="https://mainwp.com/help/docs/set-up-the-mainwp-plugin/set-unique-security-id/" target="_blank">How do I use the child unique security ID?</a>', 'mainwp-child' );
$msg .= '</p>'; $msg .= '</p>';
} }
$msg .= '</div></div></div>'; $msg .= '</div></div></div>';
echo wp_kses_post( $msg ); echo wp_kses_post( $msg );
} }
MainWP_Child_Server_Information::showWarnings(); MainWP_Child_Server_Information::showWarnings();
@ -665,8 +665,8 @@ $alloptions = array();
} }
function admin_menu() { function admin_menu() {
$branding_opts = MainWP_Child_Branding::Instance()->get_branding_options(); $branding_opts = MainWP_Child_Branding::Instance()->get_branding_options();
$is_hide = isset( $branding_opts['hide'] ) ? $branding_opts['hide'] : ''; $is_hide = isset( $branding_opts['hide'] ) ? $branding_opts['hide'] : '';
$cancelled_branding = $branding_opts['cancelled_branding']; $cancelled_branding = $branding_opts['cancelled_branding'];
if ( isset($branding_opts['remove_wp_tools']) && $branding_opts['remove_wp_tools'] && ! $cancelled_branding ) { if ( isset($branding_opts['remove_wp_tools']) && $branding_opts['remove_wp_tools'] && ! $cancelled_branding ) {
@ -711,10 +711,10 @@ $alloptions = array();
if ( ( ! $remove_all_child_menu && $is_hide !== 'T' ) || $cancelled_branding ) { if ( ( ! $remove_all_child_menu && $is_hide !== 'T' ) || $cancelled_branding ) {
$branding_header = isset( $branding_opts['branding_header'] ) ? $branding_opts['branding_header'] : array(); $branding_header = isset( $branding_opts['branding_header'] ) ? $branding_opts['branding_header'] : array();
if ( ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) && ! $cancelled_branding ) { if ( ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) && ! $cancelled_branding ) {
self::$brandingTitle = $child_menu_title = stripslashes( $branding_header['name'] ); self::$brandingTitle = $child_menu_title = stripslashes( $branding_header['name'] );
$child_page_title = $child_menu_title . ' Settings'; $child_page_title = $child_menu_title . ' Settings';
} else { } else {
$child_menu_title = 'MainWP Child'; $child_menu_title = 'MainWP Child';
$child_page_title = 'MainWPSettings'; $child_page_title = 'MainWPSettings';
} }
@ -742,13 +742,13 @@ $alloptions = array();
if ( empty( $slug ) ) { if ( empty( $slug ) ) {
continue; continue;
} }
$subpage = array(); $subpage = array();
$subpage['slug'] = $slug; $subpage['slug'] = $slug;
$subpage['title'] = $page['title']; $subpage['title'] = $page['title'];
$subpage['page'] = 'mainwp-' . str_replace( ' ', '-', strtolower( str_replace( '-', ' ', $slug ) ) ); $subpage['page'] = 'mainwp-' . str_replace( ' ', '-', strtolower( str_replace( '-', ' ', $slug ) ) );
if ( isset( $page['callback'] ) ) { if ( isset( $page['callback'] ) ) {
$subpage['callback'] = $page['callback']; $subpage['callback'] = $page['callback'];
$created_page = add_submenu_page( 'options-general.php', $subpage['title'], '<div class="mainwp-hidden">' . $subpage['title'] . '</div>', 'manage_options', $subpage['page'], $subpage['callback'] ); $created_page = add_submenu_page( 'options-general.php', $subpage['title'], '<div class="mainwp-hidden">' . $subpage['title'] . '</div>', 'manage_options', $subpage['page'], $subpage['callback'] );
if ( isset( $page['load_callback'] ) ) { if ( isset( $page['load_callback'] ) ) {
$subpage['load_callback'] = $page['load_callback']; $subpage['load_callback'] = $page['load_callback'];
add_action( 'load-' . $created_page, $subpage['load_callback'] ); add_action( 'load-' . $created_page, $subpage['load_callback'] );
@ -756,7 +756,7 @@ $alloptions = array();
} }
$sub_pages[] = $subpage; $sub_pages[] = $subpage;
} }
self::$subPages = $sub_pages; self::$subPages = $sub_pages;
self::$subPagesLoaded = true; self::$subPagesLoaded = true;
//MainWP_Helper::update_option( 'mainwp_child_subpages', self::$subPages ); // to fix error for some case //MainWP_Helper::update_option( 'mainwp_child_subpages', self::$subPages ); // to fix error for some case
} }
@ -781,9 +781,9 @@ $alloptions = array();
} }
$branding_opts = MainWP_Child_Branding::Instance()->get_branding_options(); $branding_opts = MainWP_Child_Branding::Instance()->get_branding_options();
$hide_settings = isset( $branding_opts['remove_setting'] ) && $branding_opts['remove_setting'] ? true : false; $hide_settings = isset( $branding_opts['remove_setting'] ) && $branding_opts['remove_setting'] ? true : false;
$hide_restore = isset( $branding_opts['remove_restore'] ) && $branding_opts['remove_restore'] ? true : false; $hide_restore = isset( $branding_opts['remove_restore'] ) && $branding_opts['remove_restore'] ? true : false;
$hide_server_info = isset( $branding_opts['remove_server_info'] ) && $branding_opts['remove_server_info'] ? true : false; $hide_server_info = isset( $branding_opts['remove_server_info'] ) && $branding_opts['remove_server_info'] ? true : false;
$hide_connection_detail = isset( $branding_opts['remove_connection_detail'] ) && $branding_opts['remove_connection_detail'] ? true : false; $hide_connection_detail = isset( $branding_opts['remove_connection_detail'] ) && $branding_opts['remove_connection_detail'] ? true : false;
$hide_style = 'style="display:none"'; $hide_style = 'style="display:none"';
@ -858,9 +858,9 @@ $alloptions = array();
$branding_opts = MainWP_Child_Branding::Instance()->get_branding_options(); $branding_opts = MainWP_Child_Branding::Instance()->get_branding_options();
$hide_settings = isset( $branding_opts['remove_setting'] ) && $branding_opts['remove_setting'] ? true : false; $hide_settings = isset( $branding_opts['remove_setting'] ) && $branding_opts['remove_setting'] ? true : false;
$hide_restore = isset( $branding_opts['remove_restore'] ) && $branding_opts['remove_restore'] ? true : false; $hide_restore = isset( $branding_opts['remove_restore'] ) && $branding_opts['remove_restore'] ? true : false;
$hide_server_info = isset( $branding_opts['remove_server_info'] ) && $branding_opts['remove_server_info'] ? true : false; $hide_server_info = isset( $branding_opts['remove_server_info'] ) && $branding_opts['remove_server_info'] ? true : false;
$hide_connection_detail = isset( $branding_opts['remove_connection_detail'] ) && $branding_opts['remove_connection_detail'] ? true : false; $hide_connection_detail = isset( $branding_opts['remove_connection_detail'] ) && $branding_opts['remove_connection_detail'] ? true : false;
$sitesToClone = get_option( 'mainwp_child_clone_sites' ); $sitesToClone = get_option( 'mainwp_child_clone_sites' );
@ -1097,7 +1097,7 @@ echo 'checked'; }
$home_root = '/'; $home_root = '/';
} }
$rules = "<IfModule mod_rewrite.c>\n"; $rules = "<IfModule mod_rewrite.c>\n";
$rules .= "RewriteEngine On\n"; $rules .= "RewriteEngine On\n";
$rules .= "RewriteBase $home_root\n"; $rules .= "RewriteBase $home_root\n";
@ -1140,7 +1140,7 @@ echo 'checked'; }
} }
function check_login() { function check_login() {
$file = ''; $file = '';
if ( isset( $_REQUEST['f'] ) ) { if ( isset( $_REQUEST['f'] ) ) {
$file = $_REQUEST['f']; $file = $_REQUEST['f'];
} elseif ( isset( $_REQUEST['file'] ) ) { } elseif ( isset( $_REQUEST['file'] ) ) {
@ -1172,14 +1172,14 @@ echo 'checked'; }
if ( isset( $_POST['alt_user'] ) && ! empty( $_POST['alt_user'] ) ) { if ( isset( $_POST['alt_user'] ) && ! empty( $_POST['alt_user'] ) ) {
if ( $this->check_login_as( $_POST['alt_user'] ) ) { if ( $this->check_login_as( $_POST['alt_user'] ) ) {
$auth_user = $_POST['alt_user']; $auth_user = $_POST['alt_user'];
$user = get_user_by( 'login', $auth_user ); $user = get_user_by( 'login', $auth_user );
} }
} }
// if not valid alternative admin // if not valid alternative admin
if ( ! $user ) { if ( ! $user ) {
// check connected admin existed // check connected admin existed
$user = get_user_by( 'login', $_POST['user'] ); $user = get_user_by( 'login', $_POST['user'] );
$auth_user = $_POST['user']; $auth_user = $_POST['user'];
} }
@ -1359,7 +1359,7 @@ echo 'checked'; }
//Login the user //Login the user
if ( isset( $_REQUEST['login_required'] ) && ( '1' === $_REQUEST['login_required'] ) && isset( $_REQUEST['user'] ) ) { if ( isset( $_REQUEST['login_required'] ) && ( '1' === $_REQUEST['login_required'] ) && isset( $_REQUEST['user'] ) ) {
$alter_login_required = false; $alter_login_required = false;
$username = rawurldecode( $_REQUEST['user'] ); $username = rawurldecode( $_REQUEST['user'] );
if ( isset( $_REQUEST['alt_user'] ) && ! empty( $_REQUEST['alt_user'] ) ) { if ( isset( $_REQUEST['alt_user'] ) && ! empty( $_REQUEST['alt_user'] ) ) {
$alter_login_required = $this->check_login_as( $_REQUEST['alt_user'] ); $alter_login_required = $this->check_login_as( $_REQUEST['alt_user'] );
@ -1496,14 +1496,14 @@ echo 'checked'; }
if ( isset( $_POST['alt_user'] ) && ! empty( $_POST['alt_user'] ) ) { if ( isset( $_POST['alt_user'] ) && ! empty( $_POST['alt_user'] ) ) {
if ( $this->check_login_as( $_POST['alt_user'] ) ) { if ( $this->check_login_as( $_POST['alt_user'] ) ) {
$auth_user = $_POST['alt_user']; $auth_user = $_POST['alt_user'];
$user = get_user_by( 'login', $auth_user ); $user = get_user_by( 'login', $auth_user );
} }
} }
// if alternative admin not existed // if alternative admin not existed
if ( ! $user ) { if ( ! $user ) {
// check connected admin existed // check connected admin existed
$user = get_user_by( 'login', $_POST['user'] ); $user = get_user_by( 'login', $_POST['user'] );
$auth_user = $_POST['user']; $auth_user = $_POST['user'];
} }
@ -1692,7 +1692,7 @@ echo 'checked'; }
public function http_request_reject_unsafe_urls( $r, $url ) { public function http_request_reject_unsafe_urls( $r, $url ) {
$r['reject_unsafe_urls'] = false; $r['reject_unsafe_urls'] = false;
if ( isset($_POST['wpadmin_user']) && ! empty($_POST['wpadmin_user']) && isset($_POST['wpadmin_passwd']) && ! empty($_POST['wpadmin_passwd']) ) { if ( isset($_POST['wpadmin_user']) && ! empty($_POST['wpadmin_user']) && isset($_POST['wpadmin_passwd']) && ! empty($_POST['wpadmin_passwd']) ) {
$auth = base64_encode( $_POST['wpadmin_user'] . ':' . $_POST['wpadmin_passwd'] ); $auth = base64_encode( $_POST['wpadmin_user'] . ':' . $_POST['wpadmin_passwd'] );
$r['headers']['Authorization'] = "Basic $auth"; $r['headers']['Authorization'] = "Basic $auth";
} }
return $r; return $r;
@ -1727,7 +1727,7 @@ echo 'checked'; }
$result = array(); $result = array();
foreach ( $urls as $url ) { foreach ( $urls as $url ) {
$installer = new WP_Upgrader(); $installer = new WP_Upgrader();
$ssl_verify = true; $ssl_verify = true;
//@see wp-admin/includes/class-wp-upgrader.php //@see wp-admin/includes/class-wp-upgrader.php
if ( isset( $_POST['sslVerify'] ) && '0' === $_POST['sslVerify'] ) { if ( isset( $_POST['sslVerify'] ) && '0' === $_POST['sslVerify'] ) {
@ -1751,7 +1751,7 @@ echo 'checked'; }
// retry // retry
add_filter( 'http_request_args', array( &$this, 'noSSLFilterFunction' ), 99, 2 ); add_filter( 'http_request_args', array( &$this, 'noSSLFilterFunction' ), 99, 2 );
$ssl_verify = false; $ssl_verify = false;
$result = $installer->run( array( $result = $installer->run( array(
'package' => $url, 'package' => $url,
'destination' => ( 'plugin' === $_POST['type'] ? WP_PLUGIN_DIR 'destination' => ( 'plugin' === $_POST['type'] ? WP_PLUGIN_DIR
: WP_CONTENT_DIR . '/themes' ), : WP_CONTENT_DIR . '/themes' ),
@ -1956,8 +1956,8 @@ echo 'checked'; }
@wp_update_themes(); @wp_update_themes();
@wp_update_plugins(); @wp_update_plugins();
$upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) ); $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
$translations = explode( ',', urldecode( $_POST['list'] ) ); $translations = explode( ',', urldecode( $_POST['list'] ) );
$all_language_updates = wp_get_translation_updates(); $all_language_updates = wp_get_translation_updates();
$language_updates = array(); $language_updates = array();
@ -2079,7 +2079,7 @@ echo 'checked'; }
//@see wp-admin/update.php //@see wp-admin/update.php
$failed = true; $failed = true;
// to fix update of Yithemes premiums plugins that hooked to upgrader_pre_download // to fix update of Yithemes premiums plugins that hooked to upgrader_pre_download
$url = 'update.php?action=update-selected&amp;plugins=' . urlencode(implode(',', $plugins)); $url = 'update.php?action=update-selected&amp;plugins=' . urlencode(implode(',', $plugins));
$nonce = 'bulk-update-plugins'; $nonce = 'bulk-update-plugins';
$upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) ); $upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
@ -2208,7 +2208,7 @@ echo 'checked'; }
// } // }
// @wp_update_themes(); // @wp_update_themes();
$failed = true; $failed = true;
$upgrader = new Theme_Upgrader( new Bulk_Theme_Upgrader_Skin( compact( 'nonce', 'url' ) ) ); $upgrader = new Theme_Upgrader( new Bulk_Theme_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
$result = $upgrader->bulk_upgrade( $themes ); $result = $upgrader->bulk_upgrade( $themes );
if ( ! empty( $result ) ) { if ( ! empty( $result ) ) {
@ -2357,13 +2357,13 @@ echo 'checked'; }
$_transient_data = new stdClass(); $_transient_data = new stdClass();
} }
$pre = false; $pre = false;
$cached_update_info = get_site_transient( 'mainwp_update_plugins_cached' ); $cached_update_info = get_site_transient( 'mainwp_update_plugins_cached' );
if ( is_array($cached_update_info) && count($cached_update_info) > 0 ) { if ( is_array($cached_update_info) && count($cached_update_info) > 0 ) {
foreach ( $cached_update_info as $slug => $info ) { foreach ( $cached_update_info as $slug => $info ) {
if ( ! isset( $_transient_data->response[ $slug ] ) && isset($info->update) ) { if ( ! isset( $_transient_data->response[ $slug ] ) && isset($info->update) ) {
$_transient_data->response[ $slug ] = $info->update; $_transient_data->response[ $slug ] = $info->update;
$pre = true; $pre = true;
} }
} }
} }
@ -2381,13 +2381,13 @@ echo 'checked'; }
$_transient_data = new stdClass(); $_transient_data = new stdClass();
} }
$pre = false; $pre = false;
$cached_update_info = get_site_transient( 'mainwp_update_themes_cached' ); $cached_update_info = get_site_transient( 'mainwp_update_themes_cached' );
if ( is_array($cached_update_info) && count($cached_update_info) > 0 ) { if ( is_array($cached_update_info) && count($cached_update_info) > 0 ) {
foreach ( $cached_update_info as $slug => $info ) { foreach ( $cached_update_info as $slug => $info ) {
if ( ! isset( $_transient_data->response[ $slug ] ) && isset($info->update) ) { if ( ! isset( $_transient_data->response[ $slug ] ) && isset($info->update) ) {
$_transient_data->response[ $slug ] = $info->update; $_transient_data->response[ $slug ] = $info->update;
$pre = true; $pre = true;
} }
} }
} }
@ -2510,7 +2510,7 @@ echo 'checked'; }
$others['featured_image_data'] = unserialize(base64_decode( $_POST['featured_image_data'] )); $others['featured_image_data'] = unserialize(base64_decode( $_POST['featured_image_data'] ));
} }
$res = MainWP_Helper::createPost( $new_post, $post_custom, $post_category, $post_featured_image, $upload_dir, $post_tags, $others ); $res = MainWP_Helper::createPost( $new_post, $post_custom, $post_category, $post_featured_image, $upload_dir, $post_tags, $others );
if (is_array($res) && isset($res['error'])) { if (is_array($res) && isset($res['error'])) {
MainWP_Helper::error( $res['error'] ); MainWP_Helper::error( $res['error'] );
@ -2532,8 +2532,8 @@ echo 'checked'; }
function post_action() { function post_action() {
//Read form data //Read form data
$action = $_POST['action']; $action = $_POST['action'];
$postId = $_POST['id']; $postId = $_POST['id'];
$my_post = array(); $my_post = array();
if ( 'publish' === $action ) { if ( 'publish' === $action ) {
@ -2586,7 +2586,7 @@ echo 'checked'; }
} }
} }
} elseif ( 'get_edit' === $action ) { } elseif ( 'get_edit' === $action ) {
$postId = $_POST['id']; $postId = $_POST['id'];
$post_type = $_POST['post_type']; $post_type = $_POST['post_type'];
if ( $post_type == 'post' ) { if ( $post_type == 'post' ) {
$my_post = $this->get_post_edit( $postId ); $my_post = $this->get_post_edit( $postId );
@ -2607,8 +2607,8 @@ echo 'checked'; }
function get_post_edit( $id) { function get_post_edit( $id) {
$post = get_post( $id ); $post = get_post( $id );
if ( $post ) { if ( $post ) {
$categoryObjects = get_the_category( $post->ID ); $categoryObjects = get_the_category( $post->ID );
$categories = ''; $categories = '';
foreach ( $categoryObjects as $cat ) { foreach ( $categoryObjects as $cat ) {
if ( '' !== $categories ) { if ( '' !== $categories ) {
$categories .= ', '; $categories .= ', ';
@ -2631,7 +2631,7 @@ echo 'checked'; }
$post_custom = get_post_custom( $id ); $post_custom = get_post_custom( $id );
$galleries = get_post_gallery( $id, false ); $galleries = get_post_gallery( $id, false );
$post_gallery_images = array(); $post_gallery_images = array();
if ( is_array($galleries) && isset($galleries['ids']) ) { if ( is_array($galleries) && isset($galleries['ids']) ) {
@ -2653,8 +2653,8 @@ echo 'checked'; }
include_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php'; include_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php';
$post_featured_image = get_post_thumbnail_id( $id ); $post_featured_image = get_post_thumbnail_id( $id );
$child_upload_dir = wp_upload_dir(); $child_upload_dir = wp_upload_dir();
$new_post = array( $new_post = array(
'edit_id' => $id, 'edit_id' => $id,
'is_sticky' => is_sticky( $id ) ? 1 : 0, 'is_sticky' => is_sticky( $id ) ? 1 : 0,
'post_title' => $post->post_title, 'post_title' => $post->post_title,
@ -2698,7 +2698,7 @@ echo 'checked'; }
//post_slug = base64_decode( get_post_meta( $id, '_slug', true ) ); //post_slug = base64_decode( get_post_meta( $id, '_slug', true ) );
include_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php'; include_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php';
$post_featured_image = get_post_thumbnail_id( $id ); $post_featured_image = get_post_thumbnail_id( $id );
$child_upload_dir = wp_upload_dir(); $child_upload_dir = wp_upload_dir();
$new_post = array( $new_post = array(
'edit_id' => $id, 'edit_id' => $id,
@ -2715,11 +2715,11 @@ echo 'checked'; }
); );
if ( $post_featured_image != null ) { //Featured image is set, retrieve URL if ( $post_featured_image != null ) { //Featured image is set, retrieve URL
$img = wp_get_attachment_image_src( $post_featured_image, 'full' ); $img = wp_get_attachment_image_src( $post_featured_image, 'full' );
$post_featured_image = $img[0]; $post_featured_image = $img[0];
} }
$galleries = get_post_gallery( $id, false ); $galleries = get_post_gallery( $id, false );
$post_gallery_images = array(); $post_gallery_images = array();
if ( is_array($galleries) && isset($galleries['ids']) ) { if ( is_array($galleries) && isset($galleries['ids']) ) {
@ -2761,7 +2761,7 @@ echo 'checked'; }
$extra = $_POST['extra']; $extra = $_POST['extra'];
$userId = $_POST['id']; $userId = $_POST['id'];
$user_pass = $_POST['user_pass']; $user_pass = $_POST['user_pass'];
$failed = false; $failed = false;
global $current_user; global $current_user;
$reassign = ( isset( $current_user ) && isset( $current_user->ID ) ) ? $current_user->ID : 0; $reassign = ( isset( $current_user ) && isset( $current_user->ID ) ) ? $current_user->ID : 0;
@ -2821,13 +2821,13 @@ echo 'checked'; }
function edit_user( $user_id, $data) { function edit_user( $user_id, $data) {
$wp_roles = wp_roles(); $wp_roles = wp_roles();
$user = new stdClass(); $user = new stdClass();
$update = true; $update = true;
if ( $user_id ) { if ( $user_id ) {
$user->ID = (int) $user_id; $user->ID = (int) $user_id;
$userdata = get_userdata( $user_id ); $userdata = get_userdata( $user_id );
$user->user_login = wp_slash( $userdata->user_login ); $user->user_login = wp_slash( $userdata->user_login );
} else { } else {
return array( 'error' => 'ERROR: Empty user id.' ); return array( 'error' => 'ERROR: Empty user id.' );
@ -2842,7 +2842,7 @@ echo 'checked'; }
} }
if ( isset( $data['role'] ) && current_user_can( 'edit_users' ) ) { if ( isset( $data['role'] ) && current_user_can( 'edit_users' ) ) {
$new_role = sanitize_text_field( $data['role'] ); $new_role = sanitize_text_field( $data['role'] );
$potential_role = isset($wp_roles->role_objects[ $new_role ]) ? $wp_roles->role_objects[ $new_role ] : false; $potential_role = isset($wp_roles->role_objects[ $new_role ]) ? $wp_roles->role_objects[ $new_role ] : false;
// Don't let anyone with 'edit_users' (admins) edit their own role to something without it. // Don't let anyone with 'edit_users' (admins) edit their own role to something without it.
// Multisite super admins can freely edit their blog roles -- they possess all caps. // Multisite super admins can freely edit their blog roles -- they possess all caps.
@ -2873,7 +2873,7 @@ echo 'checked'; }
$user->user_url = ''; $user->user_url = '';
} else { } else {
$user->user_url = esc_url_raw( $data['url'] ); $user->user_url = esc_url_raw( $data['url'] );
$protocols = implode( '|', array_map( 'preg_quote', wp_allowed_protocols() ) ); $protocols = implode( '|', array_map( 'preg_quote', wp_allowed_protocols() ) );
$user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://' . $user->user_url; $user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://' . $user->user_url;
} }
} }
@ -2966,16 +2966,16 @@ echo 'checked'; }
$edit_data = array(); $edit_data = array();
if (is_object($profileuser)) { if (is_object($profileuser)) {
$user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) ); $user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) );
$user_role = reset( $user_roles ); $user_role = reset( $user_roles );
$edit_data['role'] = $user_role; $edit_data['role'] = $user_role;
$edit_data['first_name'] = $profileuser->first_name; $edit_data['first_name'] = $profileuser->first_name;
$edit_data['last_name'] = $profileuser->last_name; $edit_data['last_name'] = $profileuser->last_name;
$edit_data['nickname'] = $profileuser->nickname; $edit_data['nickname'] = $profileuser->nickname;
$public_display = array(); $public_display = array();
$public_display['display_nickname'] = $profileuser->nickname; $public_display['display_nickname'] = $profileuser->nickname;
$public_display['display_username'] = $profileuser->user_login; $public_display['display_username'] = $profileuser->user_login;
if ( ! empty($profileuser->first_name) ) { if ( ! empty($profileuser->first_name) ) {
$public_display['display_firstname'] = $profileuser->first_name; $public_display['display_firstname'] = $profileuser->first_name;
@ -2998,9 +2998,9 @@ echo 'checked'; }
$public_display = array_unique( $public_display ); $public_display = array_unique( $public_display );
$edit_data['public_display'] = $public_display; $edit_data['public_display'] = $public_display;
$edit_data['display_name'] = $profileuser->display_name; $edit_data['display_name'] = $profileuser->display_name;
$edit_data['user_email'] = $profileuser->user_email; $edit_data['user_email'] = $profileuser->user_email;
$edit_data['user_url'] = $profileuser->user_url; $edit_data['user_url'] = $profileuser->user_url;
foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) { foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) {
$edit_data['contact_methods'][ $name ] = $profileuser->$name; $edit_data['contact_methods'][ $name ] = $profileuser->$name;
} }
@ -3124,7 +3124,7 @@ echo 'checked'; }
// we want to reverse this for the plain text arena of emails. // we want to reverse this for the plain text arena of emails.
$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
$message = sprintf( __( 'Username: %s' ), $user_login ) . "\r\n"; $message = sprintf( __( 'Username: %s' ), $user_login ) . "\r\n";
$message .= sprintf( __( 'Password: %s' ), $new_user['user_pass'] ) . "\r\n"; $message .= sprintf( __( 'Password: %s' ), $new_user['user_pass'] ) . "\r\n";
$message .= wp_login_url() . "\r\n"; $message .= wp_login_url() . "\r\n";
@ -3534,15 +3534,15 @@ echo 'checked'; }
} }
if ( 'all' === $_POST['feature'] || 'versions' === $_POST['feature'] ) { if ( 'all' === $_POST['feature'] || 'versions' === $_POST['feature'] ) {
$security['scripts_version'] = true; $security['scripts_version'] = true;
$security['styles_version'] = true; $security['styles_version'] = true;
$security['generator_version'] = true; $security['generator_version'] = true;
MainWP_Security::remove_generator_version( true ); MainWP_Security::remove_generator_version( true );
$information['versions'] = 'Y'; $information['versions'] = 'Y';
} }
if ( 'all' === $_POST['feature'] || 'registered_versions' === $_POST['feature'] ) { if ( 'all' === $_POST['feature'] || 'registered_versions' === $_POST['feature'] ) {
$security['registered_versions'] = true; $security['registered_versions'] = true;
$information['registered_versions'] = 'Y'; $information['registered_versions'] = 'Y';
} }
@ -3595,14 +3595,14 @@ echo 'checked'; }
} }
if ( 'all' === $_POST['feature'] || 'versions' === $_POST['feature'] ) { if ( 'all' === $_POST['feature'] || 'versions' === $_POST['feature'] ) {
$security['scripts_version'] = false; $security['scripts_version'] = false;
$security['styles_version'] = false; $security['styles_version'] = false;
$security['generator_version'] = false; $security['generator_version'] = false;
$information['versions'] = 'N'; $information['versions'] = 'N';
} }
if ( 'all' === $_POST['feature'] || 'registered_versions' === $_POST['feature'] ) { if ( 'all' === $_POST['feature'] || 'registered_versions' === $_POST['feature'] ) {
$security['registered_versions'] = false; $security['registered_versions'] = false;
$information['registered_versions'] = 'N'; $information['registered_versions'] = 'N';
} }
if ( 'all' === $_POST['feature'] || 'readme' === $_POST['feature'] ) { if ( 'all' === $_POST['feature'] || 'readme' === $_POST['feature'] ) {
@ -3630,13 +3630,13 @@ echo 'checked'; }
// $information['plugin_updates'] = (!MainWP_Security::remove_plugin_update_ok() ? 'N' : 'Y'); // $information['plugin_updates'] = (!MainWP_Security::remove_plugin_update_ok() ? 'N' : 'Y');
// $information['theme_updates'] = (!MainWP_Security::remove_theme_update_ok() ? 'N' : 'Y'); // $information['theme_updates'] = (!MainWP_Security::remove_theme_update_ok() ? 'N' : 'Y');
// $information['file_perms'] = (!MainWP_Security::fix_file_permissions_ok() ? 'N' : 'Y'); // $information['file_perms'] = (!MainWP_Security::fix_file_permissions_ok() ? 'N' : 'Y');
$information['db_reporting'] = ( ! MainWP_Security::remove_database_reporting_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['php_reporting'] = ( ! MainWP_Security::remove_php_reporting_ok() ? 'N' : 'Y' );
$information['versions'] = ( ! MainWP_Security::remove_scripts_version_ok() || ! MainWP_Security::remove_styles_version_ok() || ! MainWP_Security::remove_generator_version_ok() $information['versions'] = ( ! MainWP_Security::remove_scripts_version_ok() || ! MainWP_Security::remove_styles_version_ok() || ! MainWP_Security::remove_generator_version_ok()
? 'N' : 'Y' ); ? 'N' : 'Y' );
$information['registered_versions'] = ( MainWP_Security::remove_registered_versions_ok() ? 'Y' : 'N' ); $information['registered_versions'] = ( MainWP_Security::remove_registered_versions_ok() ? 'Y' : 'N' );
$information['admin'] = ( MainWP_Security::admin_user_ok() ? 'Y' : 'N' ); $information['admin'] = ( MainWP_Security::admin_user_ok() ? 'Y' : 'N' );
$information['readme'] = ( MainWP_Security::remove_readme_ok() ? 'Y' : 'N' ); $information['readme'] = ( MainWP_Security::remove_readme_ok() ? 'Y' : 'N' );
MainWP_Helper::write( $information ); MainWP_Helper::write( $information );
} }
@ -3699,9 +3699,9 @@ echo 'checked'; }
$information['version'] = self::$version; $information['version'] = self::$version;
$information['wpversion'] = $wp_version; $information['wpversion'] = $wp_version;
$information['siteurl'] = get_option( 'siteurl' ); $information['siteurl'] = get_option( 'siteurl' );
$information['wpe'] = MainWP_Helper::is_wp_engine() ? 1 : 0; $information['wpe'] = MainWP_Helper::is_wp_engine() ? 1 : 0;
$theme_name = wp_get_theme()->get( 'Name' ); $theme_name = wp_get_theme()->get( 'Name' );
$information['site_info'] = array( $information['site_info'] = array(
'wpversion' => $wp_version, 'wpversion' => $wp_version,
'debug_mode' => ( defined('WP_DEBUG') && true === WP_DEBUG ) ? true : false, 'debug_mode' => ( defined('WP_DEBUG') && true === WP_DEBUG ) ? true : false,
'phpversion' => phpversion(), 'phpversion' => phpversion(),
@ -3714,14 +3714,14 @@ echo 'checked'; }
//Try to switch to SSL if SSL is enabled in between! //Try to switch to SSL if SSL is enabled in between!
$pubkey = get_option( 'mainwp_child_pubkey' ); $pubkey = get_option( 'mainwp_child_pubkey' );
$nossl = get_option( 'mainwp_child_nossl' ); $nossl = get_option( 'mainwp_child_nossl' );
if ( 1 == $nossl ) { if ( 1 == $nossl ) {
if ( isset($pubkey) && MainWP_Helper::isSSLEnabled() ) { if ( isset($pubkey) && MainWP_Helper::isSSLEnabled() ) {
MainWP_Helper::update_option( 'mainwp_child_nossl', 0, 'yes' ); MainWP_Helper::update_option( 'mainwp_child_nossl', 0, 'yes' );
$nossl = 0; $nossl = 0;
} }
} }
$information['nossl'] = ( 1 == $nossl ? 1 : 0 ); $information['nossl'] = ( 1 == $nossl ? 1 : 0 );
include_once ABSPATH . '/wp-admin/includes/update.php'; include_once ABSPATH . '/wp-admin/includes/update.php';
@ -3777,8 +3777,8 @@ echo 'checked'; }
$premiumPlugins = array(); $premiumPlugins = array();
$premiumThemes = array(); $premiumThemes = array();
if ( is_array( $informationPremiumUpdates ) ) { if ( is_array( $informationPremiumUpdates ) ) {
$premiumUpdates = array(); $premiumUpdates = array();
$information['premium_updates'] = array(); $information['premium_updates'] = array();
$informationPremiumUpdatesLength = count( $informationPremiumUpdates ); $informationPremiumUpdatesLength = count( $informationPremiumUpdates );
for ( $i = 0; $i < $informationPremiumUpdatesLength; $i ++ ) { for ( $i = 0; $i < $informationPremiumUpdatesLength; $i ++ ) {
if ( ! isset( $informationPremiumUpdates[ $i ]['new_version'] ) ) { if ( ! isset( $informationPremiumUpdates[ $i ]['new_version'] ) ) {
@ -3933,7 +3933,7 @@ echo 'checked'; }
} }
} }
} elseif ( 'theme' === $translation_update->type ) { } elseif ( 'theme' === $translation_update->type ) {
$theme = wp_get_theme($translation_update->slug); $theme = wp_get_theme($translation_update->slug);
$new_translation_update['name'] = $theme->name; $new_translation_update['name'] = $theme->name;
} elseif ( ( 'core' === $translation_update->type ) && ( 'default' === $translation_update->slug ) ) { } elseif ( ( 'core' === $translation_update->type ) && ( 'default' === $translation_update->slug ) ) {
$new_translation_update['name'] = 'WordPress core'; $new_translation_update['name'] = 'WordPress core';
@ -3959,8 +3959,8 @@ echo 'checked'; }
$recent_number = 5; $recent_number = 5;
} }
$information['recent_posts'] = $this->get_recent_posts( array( 'publish', 'draft', 'pending', 'trash', 'future' ), $recent_number ); $information['recent_posts'] = $this->get_recent_posts( array( 'publish', 'draft', 'pending', 'trash', 'future' ), $recent_number );
$information['recent_pages'] = $this->get_recent_posts( array( $information['recent_pages'] = $this->get_recent_posts( array(
'publish', 'publish',
'draft', 'draft',
'pending', 'pending',
@ -4018,14 +4018,14 @@ echo 'checked'; }
$categories[] = $cat->name; $categories[] = $cat->name;
} }
$information['categories'] = $categories; $information['categories'] = $categories;
$get_file_size = apply_filters('mainwp-child-get-total-size', true); $get_file_size = apply_filters('mainwp-child-get-total-size', true);
if ( $get_file_size && isset( $_POST['cloneSites'] ) && ( '0' !== $_POST['cloneSites'] ) ) { if ( $get_file_size && isset( $_POST['cloneSites'] ) && ( '0' !== $_POST['cloneSites'] ) ) {
$max_exe = ini_get( 'max_execution_time' ); // to fix issue of some hosts have limit of execution time $max_exe = ini_get( 'max_execution_time' ); // to fix issue of some hosts have limit of execution time
if ($max_exe > 20) { if ($max_exe > 20) {
$information['totalsize'] = $this->getTotalFileSize(); $information['totalsize'] = $this->getTotalFileSize();
} }
} }
$information['dbsize'] = MainWP_Child_DB::get_size(); $information['dbsize'] = MainWP_Child_DB::get_size();
$auths = get_option( 'mainwp_child_auth' ); $auths = get_option( 'mainwp_child_auth' );
$information['extauth'] = ( $auths && isset( $auths[ $this->maxHistory ] ) ? $auths[ $this->maxHistory ] : null ); $information['extauth'] = ( $auths && isset( $auths[ $this->maxHistory ] ) ? $auths[ $this->maxHistory ] : null );
@ -4040,7 +4040,7 @@ echo 'checked'; }
} }
if (isset($_POST['primaryBackup']) && ! empty($_POST['primaryBackup'])) { if (isset($_POST['primaryBackup']) && ! empty($_POST['primaryBackup'])) {
$primary_bk = $_POST['primaryBackup']; $primary_bk = $_POST['primaryBackup'];
$information['primaryLasttimeBackup'] = MainWP_Helper::get_lasttime_backup($primary_bk); $information['primaryLasttimeBackup'] = MainWP_Helper::get_lasttime_backup($primary_bk);
} }
@ -4099,7 +4099,7 @@ echo 'checked'; }
function get_site_icon() { function get_site_icon() {
$information = array(); $information = array();
$url = $this->get_favicon( true ); $url = $this->get_favicon( true );
if ( ! empty( $url ) ) { if ( ! empty( $url ) ) {
$information['faviIconUrl'] = $url; $information['faviIconUrl'] = $url;
} }
@ -4109,7 +4109,7 @@ echo 'checked'; }
function get_favicon( $parse_page = false ) { function get_favicon( $parse_page = false ) {
$favi_url = ''; $favi_url = '';
$favi = ''; // to compatible $favi = ''; // to compatible
$site_url = get_option( 'siteurl' ); $site_url = get_option( 'siteurl' );
if ( substr( $site_url, - 1 ) != '/' ) { if ( substr( $site_url, - 1 ) != '/' ) {
@ -4136,7 +4136,7 @@ echo 'checked'; }
// try to parse page // try to parse page
if (empty($favi_url)) { if (empty($favi_url)) {
$request = wp_remote_get( $site_url, array( 'timeout' => 50 ) ); $request = wp_remote_get( $site_url, array( 'timeout' => 50 ) );
$favi = ''; $favi = '';
if ( is_array( $request ) && isset( $request['body'] ) ) { if ( is_array( $request ) && isset( $request['body'] ) ) {
// to fix bug // to fix bug
$preg_str1 = '/(<link\s+(?:[^\>]*)(?:rel="shortcut\s+icon"\s*)(?:[^>]*)?href="([^"]+)"(?:[^>]*)?>)/is'; $preg_str1 = '/(<link\s+(?:[^\>]*)(?:rel="shortcut\s+icon"\s*)(?:[^>]*)?href="([^"]+)"(?:[^>]*)?>)/is';
@ -4314,11 +4314,11 @@ echo 'checked'; }
$link_count->set( $post_ids ); $link_count->set( $post_ids );
} }
foreach ( $posts as $post ) { foreach ( $posts as $post ) {
$outPost = array(); $outPost = array();
$outPost['id'] = $post->ID; $outPost['id'] = $post->ID;
$outPost['post_type'] = $post->post_type; $outPost['post_type'] = $post->post_type;
$outPost['status'] = $post->post_status; $outPost['status'] = $post->post_status;
$outPost['title'] = $post->post_title; $outPost['title'] = $post->post_title;
//$outPost['content'] = $post->post_content; // to fix overload memory //$outPost['content'] = $post->post_content; // to fix overload memory
$outPost['comment_count'] = $post->comment_count; $outPost['comment_count'] = $post->comment_count;
// to support extract urls extension // to support extract urls extension
@ -4332,10 +4332,10 @@ echo 'checked'; }
$outPost['dts'] = strtotime( $post->post_date_gmt ); $outPost['dts'] = strtotime( $post->post_date_gmt );
} }
$usr = get_user_by( 'id', $post->post_author ); $usr = get_user_by( 'id', $post->post_author );
$outPost['author'] = ! empty( $usr ) ? $usr->user_nicename : 'removed'; $outPost['author'] = ! empty( $usr ) ? $usr->user_nicename : 'removed';
$categoryObjects = get_the_category( $post->ID ); $categoryObjects = get_the_category( $post->ID );
$categories = ''; $categories = '';
foreach ( $categoryObjects as $cat ) { foreach ( $categoryObjects as $cat ) {
if ( '' !== $categories ) { if ( '' !== $categories ) {
$categories .= ', '; $categories .= ', ';
@ -4369,7 +4369,7 @@ echo 'checked'; }
} }
if ($wp_seo_enabled) { if ($wp_seo_enabled) {
$post_id = $post->ID; $post_id = $post->ID;
$outPost['seo_data'] = array( $outPost['seo_data'] = array(
'count_seo_links' => $link_count->get( $post_id, 'internal_link_count' ), 'count_seo_links' => $link_count->get( $post_id, 'internal_link_count' ),
'count_seo_linked' => $link_count->get( $post_id, 'incoming_link_count' ), 'count_seo_linked' => $link_count->get( $post_id, 'incoming_link_count' ),
@ -4443,7 +4443,7 @@ echo 'checked'; }
} }
if ( ! empty( $keys ) ) { if ( ! empty( $keys ) ) {
$str_keys = '\'' . implode( '\',\'', $keys ) . '\''; $str_keys = '\'' . implode( '\',\'', $keys ) . '\'';
$where .= " AND `meta_key` IN = $str_keys "; $where .= " AND `meta_key` IN = $str_keys ";
} }
if ( ! empty( $meta_value ) ) { if ( ! empty( $meta_value ) ) {
$where .= " AND `meta_value` = $meta_value "; $where .= " AND `meta_value` = $meta_value ";
@ -4467,7 +4467,7 @@ echo 'checked'; }
} }
$where .= " ( p.post_status='publish' OR p.post_status='future' OR p.post_status='draft' ) $where .= " ( p.post_status='publish' OR p.post_status='future' OR p.post_status='draft' )
AND (pm.meta_key='_ezine_keyword' AND pm.meta_value='$keyword_meta')"; AND (pm.meta_key='_ezine_keyword' AND pm.meta_value='$keyword_meta')";
$total = $wpdb->get_var( "SELECT COUNT(*) $total = $wpdb->get_var( "SELECT COUNT(*)
FROM $wpdb->posts p JOIN $wpdb->postmeta pm ON p.ID=pm.post_id FROM $wpdb->posts p JOIN $wpdb->postmeta pm ON p.ID=pm.post_id
$where " ); $where " );
MainWP_Helper::write( $total ); MainWP_Helper::write( $total );
@ -4920,7 +4920,7 @@ echo 'checked'; }
foreach ( $plugins as $pluginslug => $plugin ) { foreach ( $plugins as $pluginslug => $plugin ) {
$out = array(); $out = array();
$out['mainwp'] = ( $pluginslug == $this->plugin_slug ? 'T' : 'F' ); $out['mainwp'] = ( $pluginslug == $this->plugin_slug ? 'T' : 'F' );
$out['name'] = $plugin['Name']; $out['name'] = $plugin['Name'];
$out['slug'] = $pluginslug; $out['slug'] = $pluginslug;
$out['description'] = $plugin['Description']; $out['description'] = $plugin['Description'];
@ -4942,7 +4942,7 @@ echo 'checked'; }
if ( is_array( $muplugins ) ) { if ( is_array( $muplugins ) ) {
foreach ( $muplugins as $pluginslug => $plugin ) { foreach ( $muplugins as $pluginslug => $plugin ) {
$out = array(); $out = array();
$out['mainwp'] = ( $pluginslug == $this->plugin_slug ? 'T' : 'F' ); $out['mainwp'] = ( $pluginslug == $this->plugin_slug ? 'T' : 'F' );
$out['name'] = $plugin['Name']; $out['name'] = $plugin['Name'];
$out['slug'] = $pluginslug; $out['slug'] = $pluginslug;
$out['description'] = $plugin['Description']; $out['description'] = $plugin['Description'];
@ -4965,7 +4965,7 @@ echo 'checked'; }
} }
function get_all_users( $return = false) { function get_all_users( $return = false) {
$roles = explode( ',', $_POST['role'] ); $roles = explode( ',', $_POST['role'] );
$allusers = array(); $allusers = array();
if ( is_array( $roles ) ) { if ( is_array( $roles ) ) {
foreach ( $roles as $role ) { foreach ( $roles as $role ) {
@ -5031,7 +5031,7 @@ echo 'checked'; }
if (isset($_POST['role']) && ! empty($_POST['role'])) { if (isset($_POST['role']) && ! empty($_POST['role'])) {
$check_users_role = true; $check_users_role = true;
$all_users_role = $this->get_all_users(true); $all_users_role = $this->get_all_users(true);
foreach ($all_users_role as $user) { foreach ($all_users_role as $user) {
$search_user_role[] = $user['id']; $search_user_role[] = $user['id'];
} }
@ -5094,7 +5094,7 @@ echo 'checked'; }
global $wp_version; global $wp_version;
$information['version'] = self::$version; $information['version'] = self::$version;
$information['wpversion'] = $wp_version; $information['wpversion'] = $wp_version;
$information['wpe'] = MainWP_Helper::is_wp_engine() ? 1 : 0; $information['wpe'] = MainWP_Helper::is_wp_engine() ? 1 : 0;
MainWP_Helper::write( $information ); MainWP_Helper::write( $information );
} }
@ -5398,8 +5398,8 @@ echo 'checked'; }
// to fix issue of meta_value short length // to fix issue of meta_value short length
$performed_what[] = 'revisions'; //'Posts revisions deleted'; $performed_what[] = 'revisions'; //'Posts revisions deleted';
} else { } else {
$results = MainWP_Helper::getRevisions( $max_revisions ); $results = MainWP_Helper::getRevisions( $max_revisions );
$count_deleted = MainWP_Helper::deleteRevisions( $results, $max_revisions ); $count_deleted = MainWP_Helper::deleteRevisions( $results, $max_revisions );
$performed_what[] = 'revisions'; //'Posts revisions deleted'; $performed_what[] = 'revisions'; //'Posts revisions deleted';
} }
@ -5466,9 +5466,9 @@ echo 'checked'; }
} }
if ( ! empty( $performed_what ) && has_action( 'mainwp_reports_maintenance' ) ) { if ( ! empty( $performed_what ) && has_action( 'mainwp_reports_maintenance' ) ) {
$details = implode( ',', $performed_what ); $details = implode( ',', $performed_what );
$log_time = time(); $log_time = time();
$message = $result = 'Maintenance Performed'; $message = $result = 'Maintenance Performed';
do_action( 'mainwp_reports_maintenance', $message, $log_time, $details, $result); do_action( 'mainwp_reports_maintenance', $message, $log_time, $details, $result);
} }
@ -5899,7 +5899,7 @@ echo 'checked'; }
} }
function extra_execution() { function extra_execution() {
$post = $_POST; $post = $_POST;
$information = array(); $information = array();
$information = apply_filters('mainwp_child_extra_execution', $information, $post); $information = apply_filters('mainwp_child_extra_execution', $information, $post);
MainWP_Helper::write( $information ); MainWP_Helper::write( $information );

View file

@ -665,7 +665,7 @@ class MainWP_Clone_Install {
$data = $_tmp; $data = $_tmp;
unset( $_tmp ); unset( $_tmp );
} elseif ( is_object( $data ) ) { } elseif ( is_object( $data ) ) {
$_tmp = $data; $_tmp = $data;
$props = get_object_vars( $data ); $props = get_object_vars( $data );
foreach ( $props as $key => $value ) { foreach ( $props as $key => $value ) {
$_tmp->{$key} = $this->recursive_unserialize_replace( $from, $to, $value, false ); $_tmp->{$key} = $this->recursive_unserialize_replace( $from, $to, $value, false );

View file

@ -409,7 +409,7 @@ class MainWP_Clone {
$quick_links = array(); $quick_links = array();
foreach ( $quick_dirs as $dir ) { foreach ( $quick_dirs as $dir ) {
list( $text, $adir ) = $dir; list( $text, $adir ) = $dir;
$adir = str_replace( '\\', '/', strtolower( $adir ) ); $adir = str_replace( '\\', '/', strtolower( $adir ) );
if ( strlen( $adir ) > 1 ) { if ( strlen( $adir ) > 1 ) {
$adir = ltrim( $adir, '/' ); $adir = ltrim( $adir, '/' );
} }

View file

@ -1,9 +1,9 @@
<?php <?php
class MainWP_Custom_Post_Type { class MainWP_Custom_Post_Type {
public static $instance = null; public static $instance = null;
public static $information = array(); public static $information = array();
public $plugin_translate = 'mainwp-child'; public $plugin_translate = 'mainwp-child';
static function Instance() { static function Instance() {
if ( self::$instance == null ) { if ( self::$instance == null ) {
@ -68,7 +68,7 @@ class MainWP_Custom_Post_Type {
return array( 'error' => __( 'Cannot decode data', $this->plugin_translate ) ); return array( 'error' => __( 'Cannot decode data', $this->plugin_translate ) );
} }
$edit_id = ( isset($_POST['post_id']) && ! empty($_POST['post_id']) ) ? $_POST['post_id'] : 0; $edit_id = ( isset($_POST['post_id']) && ! empty($_POST['post_id']) ) ? $_POST['post_id'] : 0;
$return = $this->_insert_post($data, $edit_id, $parent_id = 0); $return = $this->_insert_post($data, $edit_id, $parent_id = 0);
if (isset($return['success']) && $return['success'] == 1) { if (isset($return['success']) && $return['success'] == 1) {
if (isset($data['product_variation']) && is_array($data['product_variation'])) { if (isset($data['product_variation']) && is_array($data['product_variation'])) {
foreach ($data['product_variation'] as $product_variation) { foreach ($data['product_variation'] as $product_variation) {

View file

@ -84,15 +84,15 @@ class MainWP_Helper {
for ($i = 0;$i < count($blocks[0]);$i++) { for ($i = 0;$i < count($blocks[0]);$i++) {
// If @media-block, strip declaration and parenthesis // If @media-block, strip declaration and parenthesis
if (substr($blocks[0][ $i ], 0, 6) === '@media') { if (substr($blocks[0][ $i ], 0, 6) === '@media') {
$ordered_key = preg_replace('/^(@media[^\{]+)\{.*\}$/ms', '$1', $blocks[0][ $i ]); $ordered_key = preg_replace('/^(@media[^\{]+)\{.*\}$/ms', '$1', $blocks[0][ $i ]);
$ordered_value = preg_replace('/^@media[^\{]+\{(.*)\}$/ms', '$1', $blocks[0][ $i ]); $ordered_value = preg_replace('/^@media[^\{]+\{(.*)\}$/ms', '$1', $blocks[0][ $i ]);
} }
// Rule-blocks of the sort @import or @font-face // Rule-blocks of the sort @import or @font-face
elseif (substr($blocks[0][ $i ], 0, 1) === '@') { elseif (substr($blocks[0][ $i ], 0, 1) === '@') {
$ordered_key = $blocks[0][ $i ]; $ordered_key = $blocks[0][ $i ];
$ordered_value = $blocks[0][ $i ]; $ordered_value = $blocks[0][ $i ];
} else { } else {
$ordered_key = 'main'; $ordered_key = 'main';
$ordered_value = $blocks[0][ $i ]; $ordered_value = $blocks[0][ $i ];
} }
// Split by parenthesis, ignoring those inside content-quotes // Split by parenthesis, ignoring those inside content-quotes
@ -114,9 +114,9 @@ $new[ $selector ] = array();
foreach ($rules as $rule) { foreach ($rules as $rule) {
$rule = trim($rule, " \r\n\t"); $rule = trim($rule, " \r\n\t");
if ( ! empty($rule)) { if ( ! empty($rule)) {
$rule = array_reverse(explode(':', $rule)); $rule = array_reverse(explode(':', $rule));
$property = trim(array_pop($rule), " \r\n\t"); $property = trim(array_pop($rule), " \r\n\t");
$value = implode(':', array_reverse($rule)); $value = implode(':', array_reverse($rule));
if ( ! isset($new[ $selector ][ $property ]) || ! preg_match('/!important/', $new[ $selector ][ $property ])) { if ( ! isset($new[ $selector ][ $property ]) || ! preg_match('/!important/', $new[ $selector ][ $property ])) {
$new[ $selector ][ $property ] = $value; $new[ $selector ][ $property ] = $value;
@ -135,7 +135,7 @@ $new[ $selector ][ $property ] = $value;
foreach ($parsed as $media => $content) { foreach ($parsed as $media => $content) {
if (substr($media, 0, 6) === '@media') { if (substr($media, 0, 6) === '@media') {
$output .= $media . " {\n"; $output .= $media . " {\n";
$prefix = "\t"; $prefix = "\t";
} else { } else {
$prefix = ''; $prefix = '';
} }
@ -162,14 +162,14 @@ $prefix = '';
$img_data = array(); $img_data = array();
} }
include_once ABSPATH . 'wp-admin/includes/file.php'; //Contains download_url include_once ABSPATH . 'wp-admin/includes/file.php'; //Contains download_url
$upload_dir = wp_upload_dir(); $upload_dir = wp_upload_dir();
//Download $img_url //Download $img_url
$temporary_file = download_url( $img_url ); $temporary_file = download_url( $img_url );
if ( is_wp_error( $temporary_file ) ) { if ( is_wp_error( $temporary_file ) ) {
throw new Exception( 'Error: ' . $temporary_file->get_error_message() ); throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
} else { } else {
$filename = basename( $img_url ); $filename = basename( $img_url );
$local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . $filename; //Local name $local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . $filename; //Local name
$local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path ); $local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
@ -201,8 +201,8 @@ $prefix = '';
if ( is_array( $result ) ) { // found attachment if ( is_array( $result ) ) { // found attachment
$attach = current($result); $attach = current($result);
if (is_object($attach)) { if (is_object($attach)) {
$basedir = $upload_dir['basedir']; $basedir = $upload_dir['basedir'];
$baseurl = $upload_dir['baseurl']; $baseurl = $upload_dir['baseurl'];
$local_img_path = str_replace( $baseurl, $basedir, $attach->guid ); $local_img_path = str_replace( $baseurl, $basedir, $attach->guid );
if ( file_exists($local_img_path) && ( filesize( $local_img_path ) == filesize( $temporary_file ) ) ) { // file exited if ( file_exists($local_img_path) && ( filesize( $local_img_path ) == filesize( $temporary_file ) ) ) { // file exited
@ -224,7 +224,7 @@ $prefix = '';
$local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path ); $local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
} }
$moved = @rename( $temporary_file, $local_img_path ); $moved = @rename( $temporary_file, $local_img_path );
if ( $moved ) { if ( $moved ) {
$wp_filetype = wp_check_filetype( basename( $img_url ), null ); //Get the filetype to set the mimetype $wp_filetype = wp_check_filetype( basename( $img_url ), null ); //Get the filetype to set the mimetype
@ -242,7 +242,7 @@ $prefix = '';
$attachment['post_parent'] = $parent_id; $attachment['post_parent'] = $parent_id;
} }
$attach_id = wp_insert_attachment( $attachment, $local_img_path ); //Insert the image in the database $attach_id = wp_insert_attachment( $attachment, $local_img_path ); //Insert the image in the database
require_once ABSPATH . 'wp-admin/includes/image.php'; require_once ABSPATH . 'wp-admin/includes/image.php';
$attach_data = wp_generate_attachment_metadata( $attach_id, $local_img_path ); $attach_data = wp_generate_attachment_metadata( $attach_id, $local_img_path );
wp_update_attachment_metadata( $attach_id, $attach_data ); //Update generated metadata wp_update_attachment_metadata( $attach_id, $attach_data ); //Update generated metadata
@ -278,7 +278,7 @@ $prefix = '';
static function uploadFile( $file_url, $path, $file_name ) { static function uploadFile( $file_url, $path, $file_name ) {
// to fix uploader extension rename htaccess file issue // to fix uploader extension rename htaccess file issue
if ( $file_name != '.htaccess' && $file_name != '.htpasswd' ) { if ( $file_name != '.htaccess' && $file_name != '.htpasswd' ) {
$file_name = sanitize_file_name( $file_name ); $file_name = sanitize_file_name( $file_name );
} }
$full_file_name = $path . DIRECTORY_SEPARATOR . $file_name; //Local name $full_file_name = $path . DIRECTORY_SEPARATOR . $file_name; //Local name
@ -409,8 +409,8 @@ $prefix = '';
if ( $is_ezine_post || $is_post_plus ) { if ( $is_ezine_post || $is_post_plus ) {
if ( isset( $new_post['post_date_gmt'] ) && ! empty( $new_post['post_date_gmt'] ) && $new_post['post_date_gmt'] != '0000-00-00 00:00:00' ) { 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; $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_date'] = date( 'Y-m-d H:i:s', $post_date_timestamp );
//$new_post['post_status'] = ( $post_date_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future'; //$new_post['post_status'] = ( $post_date_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future';
} }
// else { // else {
@ -431,7 +431,7 @@ $prefix = '';
require_once ABSPATH . 'wp-admin/includes/post.php'; require_once ABSPATH . 'wp-admin/includes/post.php';
if ($edit_post_id) { if ($edit_post_id) {
if ( $user_id = wp_check_post_lock( $edit_post_id ) ) { if ( $user_id = wp_check_post_lock( $edit_post_id ) ) {
$user = get_userdata( $user_id ); $user = get_userdata( $user_id );
$error = sprintf( __( 'This content is currently locked. %s is currently editing.' ), $user->display_name ); $error = sprintf( __( 'This content is currently locked. %s is currently editing.' ), $user->display_name );
return array( 'error' => $error ); return array( 'error' => $error );
} }
@ -515,9 +515,9 @@ $prefix = '';
} }
if (count($replaceAttachedIds) > 0) { if (count($replaceAttachedIds) > 0) {
foreach ( $matches as $match ) { foreach ( $matches as $match ) {
$idsToReplace = $match[1]; $idsToReplace = $match[1];
$idsToReplaceWith = ''; $idsToReplaceWith = '';
$originalIds = explode(',', $idsToReplace); $originalIds = explode(',', $idsToReplace);
foreach ($originalIds as $attached_id) { foreach ($originalIds as $attached_id) {
if ( ! empty($originalIds) && isset($replaceAttachedIds[ $attached_id ])) { if ( ! empty($originalIds) && isset($replaceAttachedIds[ $attached_id ])) {
$idsToReplaceWith .= $replaceAttachedIds[ $attached_id ] . ','; $idsToReplaceWith .= $replaceAttachedIds[ $attached_id ] . ',';
@ -562,10 +562,10 @@ $prefix = '';
$random_date_to = $tmp; $random_date_to = $tmp;
} }
$random_timestamp = rand( $random_date_from, $random_date_to ); $random_timestamp = rand( $random_date_from, $random_date_to );
// $post_status = ( $random_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future'; // $post_status = ( $random_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future';
// $new_post['post_status'] = $post_status; // $new_post['post_status'] = $post_status;
$new_post['post_date'] = date( 'Y-m-d H:i:s', $random_timestamp ); $new_post['post_date'] = date( 'Y-m-d H:i:s', $random_timestamp );
} }
} }
@ -588,7 +588,7 @@ $prefix = '';
$new_post['post_status'] = $post_status; // child reports: to logging as update post $new_post['post_status'] = $post_status; // child reports: to logging as update post
} }
$new_post_id = wp_insert_post( $new_post, $wp_error ); $new_post_id = wp_insert_post( $new_post, $wp_error );
//Show errors if something went wrong //Show errors if something went wrong
if ( is_wp_error( $wp_error ) ) { if ( is_wp_error( $wp_error ) ) {
@ -1100,7 +1100,7 @@ $prefix = '';
public static function return_bytes( $val ) { public static function return_bytes( $val ) {
$val = trim( $val ); $val = trim( $val );
$last = $val[ strlen( $val ) - 1 ]; $last = $val[ strlen( $val ) - 1 ];
$val = rtrim($val, $last); $val = rtrim($val, $last);
$last = strtolower( $last ); $last = strtolower( $last );
switch ( $last ) { switch ( $last ) {
// The 'G' modifier is available since PHP 5.1.0 // The 'G' modifier is available since PHP 5.1.0
@ -1346,19 +1346,19 @@ $prefix = '';
if ( ! is_array( $results ) || 0 === count( $results ) ) { if ( ! is_array( $results ) || 0 === count( $results ) ) {
return; return;
} }
$count_deleted = 0; $count_deleted = 0;
$results_length = count( $results ); $results_length = count( $results );
for ( $i = 0; $i < $results_length; $i ++ ) { for ( $i = 0; $i < $results_length; $i ++ ) {
$number_to_delete = $results[ $i ]->cnt - $max_revisions; $number_to_delete = $results[ $i ]->cnt - $max_revisions;
$count_deleted += $number_to_delete; $count_deleted += $number_to_delete;
$sql_get = " $sql_get = "
SELECT `ID`, `post_modified` SELECT `ID`, `post_modified`
FROM $wpdb->posts FROM $wpdb->posts
WHERE `post_parent`=" . $results[ $i ]->post_parent . " WHERE `post_parent`=" . $results[ $i ]->post_parent . "
AND `post_type`='revision' AND `post_type`='revision'
ORDER BY `post_modified` ASC ORDER BY `post_modified` ASC
"; ";
$results_posts = $wpdb->get_results( $sql_get ); $results_posts = $wpdb->get_results( $sql_get );
$delete_ids = array(); $delete_ids = array();
if ( is_array( $results_posts ) && count( $results_posts ) > 0 ) { if ( is_array( $results_posts ) && count( $results_posts ) > 0 ) {

View file

@ -9,7 +9,7 @@ class MainWP_Keyword_Links {
protected $link_temp; protected $link_temp;
protected $link_count_temp; protected $link_count_temp;
protected $link_count_each_temp; protected $link_count_each_temp;
protected $link_exact_match = 1; protected $link_exact_match = 1;
protected $link_case_sensitive = 1; protected $link_case_sensitive = 1;
static function Instance() { static function Instance() {
@ -75,7 +75,7 @@ class MainWP_Keyword_Links {
$home_root = '/'; $home_root = '/';
} }
$rules = "<IfModule mod_rewrite.c>\n"; $rules = "<IfModule mod_rewrite.c>\n";
$rules .= "RewriteEngine On\n"; $rules .= "RewriteEngine On\n";
$rules .= "RewriteBase $home_root\n"; $rules .= "RewriteBase $home_root\n";
@ -453,7 +453,7 @@ class MainWP_Keyword_Links {
$regular_link = false; $regular_link = false;
if ( empty( $this->link_temp->cloak_path ) ) { if ( empty( $this->link_temp->cloak_path ) ) {
$regular_link = true; $regular_link = true;
$class .= ' kwl-regular-link'; $class .= ' kwl-regular-link';
} }
//return '{MAINWP_LINK HREF="' . ( $this->link_temp->cloak_path ? $this->siteurl . $redirection_folder . '/' . $this->link_temp->cloak_path : $this->link_temp->destination_url) . '" TARGET="' . $target . '" REL="' . $rel . '" LINK-ID="' . (isset($this->link_temp->id) ? $this->link_temp->id : 0) . '" CLASS="' . $class . '" TEXT="' . $matches[1] . '"}'; //return '{MAINWP_LINK HREF="' . ( $this->link_temp->cloak_path ? $this->siteurl . $redirection_folder . '/' . $this->link_temp->cloak_path : $this->link_temp->destination_url) . '" TARGET="' . $target . '" REL="' . $rel . '" LINK-ID="' . (isset($this->link_temp->id) ? $this->link_temp->id : 0) . '" CLASS="' . $class . '" TEXT="' . $matches[1] . '"}';
@ -461,7 +461,7 @@ class MainWP_Keyword_Links {
} }
public function keyword_replace( $matches ) { public function keyword_replace( $matches ) {
$a = '<a href="' . $matches[1] . '"'; $a = '<a href="' . $matches[1] . '"';
$a .= ( $matches[2] ) ? ' target="' . $matches[2] . '"' : ''; $a .= ( $matches[2] ) ? ' target="' . $matches[2] . '"' : '';
$a .= ( $matches[3] ) ? ' rel="' . $matches[3] . '"' : ''; $a .= ( $matches[3] ) ? ' rel="' . $matches[3] . '"' : '';
$a .= ( $matches[4] ) ? ' link-id="' . $matches[4] . '"' : ''; $a .= ( $matches[4] ) ? ' link-id="' . $matches[4] . '"' : '';

View file

@ -24,7 +24,7 @@ class MainWP_Security {
private static function init_listingDirectories() { private static function init_listingDirectories() {
if ( null === self::$listingDirectories ) { if ( null === self::$listingDirectories ) {
$wp_upload_dir = wp_upload_dir(); $wp_upload_dir = wp_upload_dir();
self::$listingDirectories = array( self::$listingDirectories = array(
WP_CONTENT_DIR, WP_CONTENT_DIR,
WP_PLUGIN_DIR, WP_PLUGIN_DIR,

View file

@ -190,7 +190,7 @@ class MainWP_Wordpress_SEO {
// from wordpress-seo plugin // from wordpress-seo plugin
public function parse_column_score_readability( $post_id ) { public function parse_column_score_readability( $post_id ) {
$score = (int) WPSEO_Meta::get_value( 'content_score', $post_id ); $score = (int) WPSEO_Meta::get_value( 'content_score', $post_id );
$rank = WPSEO_Rank::from_numeric_score( $score ); $rank = WPSEO_Rank::from_numeric_score( $score );
return $this->render_score_indicator( $rank ); return $this->render_score_indicator( $rank );
} }

View file

@ -3,7 +3,7 @@
//todo: BZ2; support fseek! //todo: BZ2; support fseek!
class Tar_Archiver { class Tar_Archiver {
const IDLE = 0; const IDLE = 0;
const APPEND = 1; const APPEND = 1;
const CREATE = 2; const CREATE = 2;
@ -16,7 +16,7 @@ class Tar_Archiver {
protected $debug; protected $debug;
protected $chunk = ''; //1024 * 1024 * 4 protected $chunk = ''; //1024 * 1024 * 4
protected $chunkSize = 4194304; //1024 * 1024 * 4 protected $chunkSize = 4194304; //1024 * 1024 * 4
/** @var $backup MainWP_Backup */ /** @var $backup MainWP_Backup */
@ -843,14 +843,14 @@ class Tar_Archiver {
break; break;
} }
$bytesRead += $bytesCurrentlyRead; $bytesRead += $bytesCurrentlyRead;
$bytesToRead -= $bytesCurrentlyRead; $bytesToRead -= $bytesCurrentlyRead;
} }
if ( 0 == $bytesToRead ) { if ( 0 == $bytesToRead ) {
$toRead = ( 512 - $file['stat'][7] % 512 ) == 512 ? 0 : ( 512 - $file['stat'][7] % 512 ); $toRead = ( 512 - $file['stat'][7] % 512 ) == 512 ? 0 : ( 512 - $file['stat'][7] % 512 );
if ( $toRead > 0 ) { if ( $toRead > 0 ) {
$read = strlen( fread( $this->archive, $toRead ) ); $read = strlen( fread( $this->archive, $toRead ) );
$bytesRead += $read; $bytesRead += $read;
} }
} }
@ -961,7 +961,7 @@ class Tar_Archiver {
} }
$lastCorrect += $pos; $lastCorrect += $pos;
$read = substr( $read, $pos ); $read = substr( $read, $pos );
} }
} }
@ -1230,8 +1230,8 @@ class Tar_Archiver {
$contents = ''; $contents = '';
$bytesToRead = $file['stat'][7]; $bytesToRead = $file['stat'][7];
while ( $bytesToRead > 0 ) { while ( $bytesToRead > 0 ) {
$readNow = $bytesToRead > 1024 ? 1024 : $bytesToRead; $readNow = $bytesToRead > 1024 ? 1024 : $bytesToRead;
$contents .= fread( $this->archive, $readNow ); $contents .= fread( $this->archive, $readNow );
$bytesToRead -= $readNow; $bytesToRead -= $readNow;
} }