From 84dd708cc62bf9512db9b4a4955652603d807126 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 26 Mar 2020 19:45:07 +0000 Subject: [PATCH] [CodeFactor] Apply fixes --- class/class-mainwp-backup.php | 4 +- class/class-mainwp-child-back-up-buddy.php | 256 ++++++++-------- .../class-mainwp-child-back-up-wordpress.php | 44 +-- class/class-mainwp-child-back-wp-up.php | 54 ++-- class/class-mainwp-child-branding.php | 62 ++-- class/class-mainwp-child-ithemes-security.php | 82 +++--- class/class-mainwp-child-links-checker.php | 56 ++-- class/class-mainwp-child-pagespeed.php | 40 +-- class/class-mainwp-child-plugins-check.php | 4 +- class/class-mainwp-child-robot.php | 12 +- .../class-mainwp-child-server-information.php | 30 +- class/class-mainwp-child-skeleton-key.php | 26 +- class/class-mainwp-child-staging.php | 28 +- class/class-mainwp-child-themes-check.php | 6 +- class/class-mainwp-child-timecapsule.php | 180 ++++++------ ...lass-mainwp-child-updraft-plus-backups.php | 256 ++++++++-------- ...ass-mainwp-child-vulnerability-checker.php | 40 +-- .../class-mainwp-child-woocommerce-status.php | 38 +-- class/class-mainwp-child-wordfence.php | 156 +++++----- class/class-mainwp-child-wp-rocket.php | 12 +- ...ass-mainwp-child-wpvivid-backuprestore.php | 12 +- class/class-mainwp-child.php | 278 +++++++++--------- class/class-mainwp-clone-install.php | 2 +- class/class-mainwp-clone.php | 2 +- class/class-mainwp-custom-post-type.php | 6 +- class/class-mainwp-helper.php | 52 ++-- class/class-mainwp-keyword-links.php | 8 +- class/class-mainwp-security.php | 2 +- class/class-mainwp-wordpress-seo.php | 2 +- class/class-tar-archiver.php | 14 +- 30 files changed, 882 insertions(+), 882 deletions(-) diff --git a/class/class-mainwp-backup.php b/class/class-mainwp-backup.php index 06f8851..9a076c4 100644 --- a/class/class-mainwp-backup.php +++ b/class/class-mainwp-backup.php @@ -380,7 +380,7 @@ class MainWP_Backup { } $db_files = $this->createBackupDB( dirname( $filepath ) . DIRECTORY_SEPARATOR . 'dbBackup' ); - $error = false; + $error = false; 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 ) ) ) ) { $error = true; @@ -735,7 +735,7 @@ class MainWP_Backup { $table = $curr_table[0]; $currentfile = $filepath_prefix . '-' . MainWP_Helper::sanitize_filename( $table ) . '.sql'; - $db_files[] = $currentfile; + $db_files[] = $currentfile; if ( file_exists( $currentfile ) ) { continue; } diff --git a/class/class-mainwp-child-back-up-buddy.php b/class/class-mainwp-child-back-up-buddy.php index 4824508..c5bdb32 100644 --- a/class/class-mainwp-child-back-up-buddy.php +++ b/class/class-mainwp-child-back-up-buddy.php @@ -16,8 +16,8 @@ */ class MainWP_Child_Back_Up_Buddy { - public static $instance = null; - public $plugin_translate = 'mainwp-child'; + public static $instance = null; + public $plugin_translate = 'mainwp-child'; public $is_backupbuddy_installed = false; static function Instance() { @@ -176,7 +176,7 @@ class MainWP_Child_Back_Up_Buddy { } $finish_time = $backup['finish_time']; - $message = 'BackupBuddy ' . $backupType . ' finished'; + $message = 'BackupBuddy ' . $backupType . ' finished'; if ( ! empty($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']; if ( isset( $resp['success'] ) && $resp['success']) { $finish_time = $state['stats']['last_remote_snapshot']; - $backupType = 'Live Backup to cloud'; - $message = 'BackupBuddy ' . $backupType . ' finished'; + $backupType = 'Live Backup to cloud'; + $message = 'BackupBuddy ' . $backupType . ' finished'; if ( ! empty($finish_time)) { do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time); } @@ -527,7 +527,7 @@ class MainWP_Child_Back_Up_Buddy { } global $wpdb; - $option = 'pb_' . pb_backupbuddy::settings( 'slug' ); + $option = 'pb_' . pb_backupbuddy::settings( 'slug' ); $newOptions = sanitize_option( $option, $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 ) ); $information['backupDirectoryDefault'] = backupbuddy_core::_getBackupDirectoryDefault(); - $information['result'] = 'SUCCESS'; + $information['result'] = 'SUCCESS'; } return $information; @@ -545,12 +545,12 @@ class MainWP_Child_Back_Up_Buddy { // Keep log serial. $old_log_serial = pb_backupbuddy::$options['log_serial']; - $keepDestNote = ''; - $remote_destinations = pb_backupbuddy::$options['remote_destinations']; + $keepDestNote = ''; + $remote_destinations = pb_backupbuddy::$options['remote_destinations']; pb_backupbuddy::$options = pb_backupbuddy::settings( 'default_options' ); if ( '1' == $_POST['keep_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. @@ -563,7 +563,7 @@ class MainWP_Child_Back_Up_Buddy { backupbuddy_core::addNotification( 'settings_reset', 'Plugin settings reset', $resetNote . $keepDestNote ); $information['message'] = $resetNote . $keepDestNote; - $information['result'] = 'SUCCESS'; + $information['result'] = 'SUCCESS'; return $information; } @@ -610,10 +610,10 @@ class MainWP_Child_Back_Up_Buddy { } function schedules_list() { - $information = array(); - $information['schedules'] = pb_backupbuddy::$options['schedules']; + $information = array(); + $information['schedules'] = pb_backupbuddy::$options['schedules']; $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 if (isset(pb_backupbuddy::$options['remote_destinations'])) { // update @@ -648,7 +648,7 @@ class MainWP_Child_Back_Up_Buddy { function save_scheduled_backup() { $schedule_id = intval($_POST['schedule_id']); - $schedule = unserialize(base64_decode($_POST['data'])); + $schedule = unserialize(base64_decode($_POST['data'])); if ( ! is_array($schedule)) { 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.' ); } } 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 ) ) ); 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. pb_backupbuddy::$options['schedules'][ $schedule_id ] = $schedule; } pb_backupbuddy::save(); - $information['result'] = 'SUCCESS'; - $information['schedules'] = pb_backupbuddy::$options['schedules']; + $information['result'] = 'SUCCESS'; + $information['schedules'] = pb_backupbuddy::$options['schedules']; $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; } function save_profile() { $profile_id = $_POST['profile_id']; - $profile = unserialize(base64_decode($_POST['data'])); + $profile = unserialize(base64_decode($_POST['data'])); if ( ! is_array($profile)) { 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 ) { - $item_ids = $_POST['item_ids']; - $item_ids = explode(',', $item_ids); + $item_ids = $_POST['item_ids']; + $item_ids = explode(',', $item_ids); $information = array(); if ( is_array( $item_ids ) && count( $item_ids ) > 0 ) { - $needs_save = false; + $needs_save = false; $deleted_files = array(); foreach ( $item_ids as $item ) { if ( file_exists( backupbuddy_core::getBackupDirectory() . $item ) ) { @@ -727,7 +727,7 @@ class MainWP_Child_Back_Up_Buddy { $backup_files = array(); } 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'; if ( file_exists( $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_api', array( 'getOverview' ) ); - $data = array(); - $data['plugins_root'] = backupbuddy_core::get_plugins_root(); - $data['themes_root'] = backupbuddy_core::get_themes_root(); - $data['media_root'] = backupbuddy_core::get_media_root(); + $data = array(); + $data['plugins_root'] = backupbuddy_core::get_plugins_root(); + $data['themes_root'] = backupbuddy_core::get_themes_root(); + $data['media_root'] = backupbuddy_core::get_media_root(); $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']; if ( isset( $getOverview['lastBackupStats']['finish'] ) ) { - $finish_time = $getOverview['lastBackupStats']['finish']; - $time = $this->localize_time( $finish_time ); + $finish_time = $getOverview['lastBackupStats']['finish']; + $time = $this->localize_time( $finish_time ); $data['lastBackupStats'] = date('M j - g:i A', $time); $data['lasttime_backup'] = $finish_time; MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support Require Backup Before Update feature @@ -819,15 +819,15 @@ class MainWP_Child_Back_Up_Buddy { function backup_list() { require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; - $information = array(); - $information['backup_list'] = $this->get_backup_list(); + $information = array(); + $information['backup_list'] = $this->get_backup_list(); $information['recent_backup_list'] = $this->get_recent_backup_list(); //$information['destinations_list'] = pb_backupbuddy_destinations::get_destinations_list(); - $backup_directory = backupbuddy_core::getBackupDirectory(); - $backup_directory = str_replace( '\\', '/', $backup_directory ); - $backup_directory = rtrim( $backup_directory, '/\\' ) . '/'; + $backup_directory = backupbuddy_core::getBackupDirectory(); + $backup_directory = str_replace( '\\', '/', $backup_directory ); + $backup_directory = rtrim( $backup_directory, '/\\' ) . '/'; $information['backupDirectoryWithinSiteRoot'] = ( false !== stristr( $backup_directory, ABSPATH ) ) ? 'yes' : 'no'; - $information['result'] = 'SUCCESS'; + $information['result'] = 'SUCCESS'; return $information; } @@ -837,14 +837,14 @@ class MainWP_Child_Back_Up_Buddy { pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy( backupbuddy_core::getBackupDirectory() ); } $backup_file = $_POST['backup_file']; - $note = $_POST['note']; - $note = preg_replace( '/[[:space:]]+/', ' ', $note ); - $note = preg_replace( '/[^[:print:]]/', '', $note ); - $note = substr( $note, 0, 200 ); + $note = $_POST['note']; + $note = preg_replace( '/[[:space:]]+/', ' ', $note ); + $note = preg_replace( '/[^[:print:]]/', '', $note ); + $note = substr( $note, 0, 200 ); // Returns true on success, else the error message. - $old_comment = pb_backupbuddy::$classes['zipbuddy']->get_comment( $backup_file ); - $comment = backupbuddy_core::normalize_comment_data( $old_comment ); + $old_comment = pb_backupbuddy::$classes['zipbuddy']->get_comment( $backup_file ); + $comment = backupbuddy_core::normalize_comment_data( $old_comment ); $comment['note'] = $note; //$new_comment = base64_encode( serialize( $comment ) ); @@ -871,7 +871,7 @@ class MainWP_Child_Back_Up_Buddy { function get_hash() { $callback_data = $_POST['callback_data']; - $file = backupbuddy_core::getBackupDirectory() . $callback_data; + $file = backupbuddy_core::getBackupDirectory() . $callback_data; if (file_exists($file)) { return array( 'result' => 'SUCCESS', @@ -888,7 +888,7 @@ class MainWP_Child_Back_Up_Buddy { $max_cache_time = 86400; // This is the root directory we want the listing for - $root = $_POST['dir']; + $root = $_POST['dir']; $root_len = strlen( $root ); // 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.' ); $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 if ( true !== ( $result = $fileoptions->is_ok() ) ) { // Get file listing. require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php'; 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 ) ); - $fileoptions->options = $files; + $files = pb_backupbuddy::$classes['zipbuddy']->get_file_list( backupbuddy_core::getBackupDirectory() . str_replace( '\\/', '', $zip_viewer ) ); + $fileoptions->options = $files; $fileoptions->save(); } else { $files = &$fileoptions->options; @@ -1018,7 +1018,7 @@ class MainWP_Child_Back_Up_Buddy { natcasesort( $files ); // 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. foreach ( $files as $file ) { if ( ( $file == '.' ) || ( $file == '..' ) ) { @@ -1043,7 +1043,7 @@ class MainWP_Child_Back_Up_Buddy { if ( file_exists( str_replace( '//', '/', $root . $file ) ) ) { if ( is_dir( str_replace( '//', '/', $root . $file ) ) ) { // Directory. echo ''; } else { // File. echo '