From 44cdebaf44abed090a88faad36e22220492f82f7 Mon Sep 17 00:00:00 2001
From: codefactor-io
Date: Thu, 26 Mar 2020 17:03:00 +0000
Subject: [PATCH] [CodeFactor] Apply fixes
---
class/class-mainwp-backup.php | 4 +-
class/class-mainwp-child-back-up-buddy.php | 300 ++++++++++--------
.../class-mainwp-child-back-up-wordpress.php | 36 ++-
class/class-mainwp-child-back-wp-up.php | 31 +-
class/class-mainwp-child-branding.php | 70 ++--
class/class-mainwp-child-ithemes-security.php | 42 +--
class/class-mainwp-child-links-checker.php | 16 +-
class/class-mainwp-child-pagespeed.php | 62 ++--
class/class-mainwp-child-plugins-check.php | 13 +-
.../class-mainwp-child-server-information.php | 10 +-
class/class-mainwp-child-skeleton-key.php | 12 +-
class/class-mainwp-child-staging.php | 33 +-
class/class-mainwp-child-themes-check.php | 3 +-
class/class-mainwp-child-timecapsule.php | 114 +++----
...lass-mainwp-child-updraft-plus-backups.php | 183 ++++++-----
...ass-mainwp-child-vulnerability-checker.php | 28 +-
.../class-mainwp-child-woocommerce-status.php | 2 +-
class/class-mainwp-child-wordfence.php | 276 ++++++++--------
class/class-mainwp-child-wp-rocket.php | 16 +-
...ass-mainwp-child-wpvivid-backuprestore.php | 31 +-
class/class-mainwp-child.php | 254 ++++++++-------
class/class-mainwp-clone-install.php | 4 +-
class/class-mainwp-clone.php | 3 +-
class/class-mainwp-custom-post-type.php | 8 +-
class/class-mainwp-helper.php | 152 ++++-----
class/class-mainwp-keyword-links.php | 4 +-
class/class-mainwp-security.php | 7 +-
class/class-mainwp-wordpress-seo.php | 6 +-
28 files changed, 891 insertions(+), 829 deletions(-)
diff --git a/class/class-mainwp-backup.php b/class/class-mainwp-backup.php
index 504cab5..06f8851 100644
--- a/class/class-mainwp-backup.php
+++ b/class/class-mainwp-backup.php
@@ -118,7 +118,7 @@ class MainWP_Backup {
@ini_set( 'max_execution_time', $this->timeout );
// @codingStandardsIgnoreEnd
- if ( !is_array( $files ) ) {
+ if ( ! is_array( $files ) ) {
$files = array( $files );
}
@@ -168,7 +168,7 @@ class MainWP_Backup {
}
}
- return !$error;
+ return ! $error;
}
/**
diff --git a/class/class-mainwp-child-back-up-buddy.php b/class/class-mainwp-child-back-up-buddy.php
index bebcc11..4824508 100644
--- a/class/class-mainwp-child-back-up-buddy.php
+++ b/class/class-mainwp-child-back-up-buddy.php
@@ -34,7 +34,7 @@ class MainWP_Child_Back_Up_Buddy {
$this->is_backupbuddy_installed = true;
}
- if (!$this->is_backupbuddy_installed) {
+ if ( ! $this->is_backupbuddy_installed) {
return;
}
@@ -61,7 +61,7 @@ class MainWP_Child_Back_Up_Buddy {
return $value;
}
- if (! MainWP_Helper::is_screen_with_update()) {
+ if ( ! MainWP_Helper::is_screen_with_update()) {
return $value;
}
@@ -109,7 +109,7 @@ class MainWP_Child_Back_Up_Buddy {
return;
}
- if (!$this->is_backupbuddy_installed) {
+ if ( ! $this->is_backupbuddy_installed) {
return;
}
@@ -132,14 +132,14 @@ class MainWP_Child_Back_Up_Buddy {
// Backup type.
$pretty_type = array(
- 'full' => 'Full',
- 'db' => 'Database',
- 'files' => 'Files',
+ 'full' => 'Full',
+ 'db' => 'Database',
+ 'files' => 'Files',
);
$recentBackups_list = glob( backupbuddy_core::getLogDirectory() . 'fileoptions/*.txt' );
- foreach( $recentBackups_list as $backup_fileoptions ) {
+ foreach ( $recentBackups_list as $backup_fileoptions ) {
$backup = new pb_backupbuddy_fileoptions( $backup_fileoptions, $read_only = true );
if ( method_exists($backup, 'is_ok') && true !== ( $result = $backup->is_ok() ) ) {
@@ -148,7 +148,7 @@ class MainWP_Child_Back_Up_Buddy {
$backup = &$backup->options;
- if ( !isset( $backup['serial'] ) || ( $backup['serial'] == '' ) ) {
+ if ( ! isset( $backup['serial'] ) || ( $backup['serial'] == '' ) ) {
continue;
}
@@ -177,7 +177,7 @@ class MainWP_Child_Back_Up_Buddy {
$finish_time = $backup['finish_time'];
$message = 'BackupBuddy ' . $backupType . ' finished';
- if (!empty($finish_time)) {
+ if ( ! empty($finish_time)) {
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time);
}
}
@@ -198,7 +198,7 @@ class MainWP_Child_Back_Up_Buddy {
$finish_time = $state['stats']['last_remote_snapshot'];
$backupType = 'Live Backup to cloud';
$message = 'BackupBuddy ' . $backupType . ' finished';
- if (!empty($finish_time)) {
+ if ( ! empty($finish_time)) {
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time);
}
@@ -208,7 +208,7 @@ class MainWP_Child_Back_Up_Buddy {
}
}
- } catch( Exception $e ) {
+ } catch ( Exception $e ) {
}
}
@@ -223,7 +223,7 @@ class MainWP_Child_Back_Up_Buddy {
require_once pb_backupbuddy::plugin_path() . '/classes/core.php';
}
- if ( !isset( pb_backupbuddy::$options ) ) {
+ if ( ! isset( pb_backupbuddy::$options ) ) {
pb_backupbuddy::load();
}
@@ -489,26 +489,26 @@ class MainWP_Child_Back_Up_Buddy {
if (is_array($settings)) {
if ($type === 'all' || 'general_settings' === $type) {
- foreach($filter_general_settings as $field) {
- if(isset($settings[ $field ])) {
+ foreach ($filter_general_settings as $field) {
+ if (isset($settings[ $field ])) {
$save_settings[ $field ] = $settings[ $field ];
}
}
}
if ($type === 'all' || 'advanced_settings' === $type) {
- foreach($filter_advanced_settings as $field) {
- if(isset($settings[ $field ])) {
+ foreach ($filter_advanced_settings as $field) {
+ if (isset($settings[ $field ])) {
$save_settings[ $field ] = $settings[ $field ];
}
}
}
}
- if (!empty($save_settings)) {
+ if ( ! empty($save_settings)) {
$newOptions = pb_backupbuddy::$options;
- foreach($newOptions as $key => $val) {
+ foreach ($newOptions as $key => $val) {
if (isset($save_settings[ $key ])) {
$newOptions[ $key ] = $save_settings[ $key ];
}
@@ -632,7 +632,7 @@ class MainWP_Child_Back_Up_Buddy {
$schedule_id = (int) $_POST['schedule_id'];
- if ( !isset( pb_backupbuddy::$options['schedules'][ $schedule_id ] ) || ! is_array( pb_backupbuddy::$options['schedules'][ $schedule_id ] ) ) {
+ if ( ! isset( pb_backupbuddy::$options['schedules'][ $schedule_id ] ) || ! is_array( pb_backupbuddy::$options['schedules'][ $schedule_id ] ) ) {
return array( 'error' => __( 'Error: not found the backup schedule or invalid data', 'mainwp-child' ) );
}
@@ -650,12 +650,12 @@ class MainWP_Child_Back_Up_Buddy {
$schedule_id = intval($_POST['schedule_id']);
$schedule = unserialize(base64_decode($_POST['data']));
- if (!is_array($schedule)) {
+ if ( ! is_array($schedule)) {
return array( 'error' => __( 'Invalid schedule data', 'mainwp-child' ) );
}
$information = array();
// add new
- if (!isset(pb_backupbuddy::$options['schedules'][ $schedule_id ])) {
+ if ( ! isset(pb_backupbuddy::$options['schedules'][ $schedule_id ])) {
$next_index = pb_backupbuddy::$options['next_schedule_index'];
pb_backupbuddy::$options['next_schedule_index']++; // This change will be saved in savesettings function below.
pb_backupbuddy::$options['schedules'][ $schedule_id ] = $schedule;
@@ -683,7 +683,7 @@ class MainWP_Child_Back_Up_Buddy {
$profile_id = $_POST['profile_id'];
$profile = unserialize(base64_decode($_POST['data']));
- if (!is_array($profile)) {
+ if ( ! is_array($profile)) {
return array( 'error' => __( 'Invalid profile data', 'mainwp-child' ) );
}
@@ -714,7 +714,7 @@ class MainWP_Child_Back_Up_Buddy {
if ( is_array( $item_ids ) && count( $item_ids ) > 0 ) {
$needs_save = false;
$deleted_files = array();
- foreach( $item_ids as $item ) {
+ foreach ( $item_ids as $item ) {
if ( file_exists( backupbuddy_core::getBackupDirectory() . $item ) ) {
if ( @unlink( backupbuddy_core::getBackupDirectory() . $item ) === true ) {
$deleted_files[] = $item;
@@ -755,7 +755,7 @@ class MainWP_Child_Back_Up_Buddy {
if ( isset( $data['syncBackupBuddy'] ) && $data['syncBackupBuddy'] ) {
try {
$information['syncBackupBuddy'] = $this->get_sync_data();
- } catch(Exception $e) {
+ } catch (Exception $e) {
}
}
@@ -781,14 +781,14 @@ class MainWP_Child_Back_Up_Buddy {
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['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();
- $data['editsSinceLastBackup'] = $getOverview['editsSinceLastBackup'];
+ $data['editsSinceLastBackup'] = $getOverview['editsSinceLastBackup'];
if ( isset( $getOverview['lastBackupStats']['finish'] ) ) {
$finish_time = $getOverview['lastBackupStats']['finish'];
@@ -801,7 +801,7 @@ class MainWP_Child_Back_Up_Buddy {
}
return $data;
- } catch(Exception $e) {
+ } catch (Exception $e) {
// not exit here
}
@@ -832,7 +832,7 @@ class MainWP_Child_Back_Up_Buddy {
}
function save_note() {
- if ( !isset( pb_backupbuddy::$classes['zipbuddy'] ) ) {
+ if ( ! isset( pb_backupbuddy::$classes['zipbuddy'] ) ) {
require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy( backupbuddy_core::getBackupDirectory() );
}
@@ -874,11 +874,11 @@ class MainWP_Child_Back_Up_Buddy {
$file = backupbuddy_core::getBackupDirectory() . $callback_data;
if (file_exists($file)) {
return array(
- 'result' =>'SUCCESS',
+ 'result' => 'SUCCESS',
'hash' => md5_file( $file ),
);
} else {
- return array( 'error' =>'Not found the file' );
+ return array( 'error' => 'Not found the file' );
}
}
@@ -929,7 +929,7 @@ class MainWP_Child_Back_Up_Buddy {
$subdirs = array();
// Strip out any files/subdirs that are not actually directly under the given root
- foreach( $files as $key => $file ) {
+ foreach ( $files as $key => $file ) {
// If shorter than root length then certainly is not within this (root) directory.
// It's a quick test that is more effective the longer the root (the deeper you go
@@ -976,7 +976,7 @@ class MainWP_Child_Back_Up_Buddy {
$subdir = substr( $unrooted_file, 0, ( $pos + 1 ) );
// Have we already seen it
- if ( !in_array( $subdir, $subdirs ) ) {
+ if ( ! in_array( $subdir, $subdirs ) ) {
// Not already seen so record we have seen it and modify this entry to be
// specific for the subdir/
@@ -1012,7 +1012,7 @@ class MainWP_Child_Back_Up_Buddy {
function exclude_tree() {
$root = substr( ABSPATH, 0, strlen( ABSPATH ) - 1 ) . '/' . ltrim( urldecode( $_POST['dir'] ), '/\\' );
- if( file_exists( $root ) ) {
+ if ( file_exists( $root ) ) {
$files = scandir( $root );
natcasesort( $files );
@@ -1020,11 +1020,11 @@ class MainWP_Child_Back_Up_Buddy {
// Sort with directories first.
$sorted_files = array(); // Temporary holder for sorting files.
$sorted_directories = array(); // Temporary holder for sorting directories.
- foreach( $files as $file ) {
+ foreach ( $files as $file ) {
if ( ( $file == '.' ) || ( $file == '..' ) ) {
continue;
}
- if( is_file( str_replace( '//', '/', $root . $file ) ) ) {
+ if ( is_file( str_replace( '//', '/', $root . $file ) ) ) {
array_push( $sorted_files, $file );
} else {
array_unshift( $sorted_directories, $file );
@@ -1037,10 +1037,10 @@ class MainWP_Child_Back_Up_Buddy {
ob_start();
- if( count( $files ) > 0 ) { // Files found.
+ if ( count( $files ) > 0 ) { // Files found.
echo '';
- foreach( $files as $file ) {
- if( file_exists( str_replace( '//', '/', $root . $file ) ) ) {
+ foreach ( $files as $file ) {
+ if ( file_exists( str_replace( '//', '/', $root . $file ) ) ) {
if ( is_dir( str_replace( '//', '/', $root . $file ) ) ) { // Directory.
echo '- ';
$return = '';
@@ -1091,7 +1091,7 @@ class MainWP_Child_Back_Up_Buddy {
} else {
$results = $wpdb->get_results( 'SELECT table_name FROM information_schema.tables WHERE table_schema = DATABASE()', ARRAY_A );
}
- foreach( $results as $result ) {
+ foreach ( $results as $result ) {
if ( true === $display_size ) {
// Fix up row count and average row length for InnoDB engine which returns inaccurate (and changing) values for these.
@@ -1189,7 +1189,7 @@ class MainWP_Child_Back_Up_Buddy {
$files_array = explode( ',', $files );
$files = array();
- foreach( $files_array as $file ) {
+ foreach ( $files_array as $file ) {
if ( substr( $file, -1 ) == '/' ) { // If directory then add wildcard.
$file = $file . '*';
}
@@ -1230,10 +1230,10 @@ class MainWP_Child_Back_Up_Buddy {
$files = array_merge( $files, $files2 );
- if ( is_array( $files ) && !empty( $files ) ) { // For robustness. Without open_basedir the glob() function returns an empty array for no match. With open_basedir in effect the glob() function returns a boolean false for no match.
+ if ( is_array( $files ) && ! empty( $files ) ) { // For robustness. Without open_basedir the glob() function returns an empty array for no match. With open_basedir in effect the glob() function returns a boolean false for no match.
$backup_prefix = backupbuddy_core::backup_prefix(); // Backup prefix for this site. Used for MS checking that this user can see this backup.
- foreach( $files as $file_id => $file ) {
+ foreach ( $files as $file_id => $file ) {
if ( ( $subsite_mode === true ) && is_multisite() ) { // If a Network and NOT the superadmin must make sure they can only see the specific subsite backups for security purposes.
@@ -1258,19 +1258,19 @@ class MainWP_Child_Back_Up_Buddy {
// Backup status.
$pretty_status = array(
- true => 'Good', // v4.0+ Good.
- 'pass' => 'Good', // Pre-v4.0 Good.
- false => 'Bad', // v4.0+ Bad.
- 'fail' => 'Bad', // Pre-v4.0 Bad.
+ true => 'Good', // v4.0+ Good.
+ 'pass' => 'Good', // Pre-v4.0 Good.
+ false => 'Bad', // v4.0+ Bad.
+ 'fail' => 'Bad', // Pre-v4.0 Bad.
);
// Backup type.
$pretty_type = array(
- 'full' => 'Full',
- 'db' => 'Database',
- 'files' => 'Files',
- 'themes' => 'Themes',
- 'plugins' => 'Plugins',
+ 'full' => 'Full',
+ 'db' => 'Database',
+ 'files' => 'Files',
+ 'themes' => 'Themes',
+ 'plugins' => 'Plugins',
);
// Defaults...
@@ -1331,7 +1331,7 @@ class MainWP_Child_Back_Up_Buddy {
$integrity = pb_backupbuddy::$format->prettify( $status, $pretty_status ) . ' ';
if ( isset( $backup_integrity['scan_notes'] ) && count( (array) $backup_integrity['scan_notes'] ) > 0 ) {
- foreach( (array) $backup_integrity['scan_notes'] as $scan_note ) {
+ foreach ( (array) $backup_integrity['scan_notes'] as $scan_note ) {
$integrity .= $scan_note . ' ';
}
}
@@ -1368,7 +1368,7 @@ class MainWP_Child_Back_Up_Buddy {
arsort( $backup_sort_dates );
// Re-arrange backups based on sort dates.
$sorted_backups = array();
- foreach( $backup_sort_dates as $backup_file => $backup_sort_date ) {
+ foreach ( $backup_sort_dates as $backup_file => $backup_sort_date ) {
$sorted_backups[ $backup_file ] = $backups[ $backup_file ];
unset( $backups[ $backup_file ] );
}
@@ -1387,12 +1387,12 @@ class MainWP_Child_Back_Up_Buddy {
// Backup type.
$pretty_type = array(
- 'full' => 'Full',
- 'db' => 'Database',
- 'files' => 'Files',
+ 'full' => 'Full',
+ 'db' => 'Database',
+ 'files' => 'Files',
);
- foreach( $recentBackups_list as $backup_fileoptions ) {
+ foreach ( $recentBackups_list as $backup_fileoptions ) {
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
pb_backupbuddy::status( 'details', 'Fileoptions instance #1.' );
@@ -1403,7 +1403,7 @@ class MainWP_Child_Back_Up_Buddy {
}
$backup = &$backup->options;
- if ( !isset( $backup['serial'] ) || ( $backup['serial'] == '' ) ) {
+ if ( ! isset( $backup['serial'] ) || ( $backup['serial'] == '' ) ) {
continue;
}
if ( ( $backup['finish_time'] >= $backup['start_time'] ) && ( 0 != $backup['start_time'] ) ) {
@@ -1485,17 +1485,17 @@ class MainWP_Child_Back_Up_Buddy {
);
function pb_backupbuddy_aasort ( &$array, $key) {
- $sorter=array();
- $ret=array();
+ $sorter = array();
+ $ret = array();
reset($array);
foreach ($array as $ii => $va) {
- $sorter[ $ii ]=$va[ $key ];
+ $sorter[ $ii ] = $va[ $key ];
}
asort($sorter);
foreach ($sorter as $ii => $va) {
- $ret[ $ii ]=$array[ $ii ];
+ $ret[ $ii ] = $array[ $ii ];
}
- $array=$ret;
+ $array = $ret;
}
pb_backupbuddy_aasort( $recentBackups, 'start_timestamp' ); // Sort by multidimensional array with key start_timestamp.
@@ -1506,7 +1506,7 @@ class MainWP_Child_Back_Up_Buddy {
}
function delete_scheduled_backup() {
- $schedule_ids = $_POST['schedule_ids'];
+ $schedule_ids = $_POST['schedule_ids'];
$schedule_ids = explode(',', $schedule_ids);
if (empty($schedule_ids)) {
@@ -1537,7 +1537,7 @@ class MainWP_Child_Back_Up_Buddy {
' . __( 'Vault owner', 'updraftplus' ) . ': ' . htmlspecialchars( $vault_settings['email'] );
$ret .= '
' . __( 'Quota:', 'updraftplus' ) . ' ';
- if ( !isset( $vault_settings['quota'] ) || !is_numeric( $vault_settings['quota'] ) || ( $vault_settings['quota'] < 0 ) ) {
+ if ( ! isset( $vault_settings['quota'] ) || ! is_numeric( $vault_settings['quota'] ) || ( $vault_settings['quota'] < 0 ) ) {
$ret .= __( 'Unknown', 'updraftplus' );
} else {
$quota_via_transient = get_transient( 'updraftvault_quota_text' );
@@ -318,12 +318,13 @@ class MainWP_Child_Updraft_Plus_Backups {
)
);
- if ( is_wp_error( $result ) || ( false === $result ) ) { return $result;
+ if ( is_wp_error( $result ) || ( false === $result ) ) {
+return $result;
}
$response = json_decode( $result['body'], true );
- if ( !is_array( $response ) || !isset( $response['mothership'] ) || !isset( $response['loggedin'] ) ) {
+ if ( ! is_array( $response ) || ! isset( $response['mothership'] ) || ! isset( $response['loggedin'] ) ) {
if ( preg_match( '/has banned your IP address \(([\.:0-9a-f]+)\)/', $result['body'], $matches ) ) {
return new WP_Error( 'banned_ip', sprintf( __( "UpdraftPlus.com has responded with 'Access Denied'.", 'updraftplus' ) . '
' . __( "It appears that your web server's IP Address (%s) is blocked.", 'updraftplus' ) . ' ' . __( 'This most likely means that you share a webserver with a hacked website that has been used in previous attacks.', 'updraftplus' ) . '
' . __( 'To remove the block, please go here.', 'updraftplus' ) . ' ', $matches[1] ) );
} else {
@@ -333,26 +334,28 @@ class MainWP_Child_Updraft_Plus_Backups {
switch ( $response['loggedin'] ) {
case 'connected':
- if ( !empty( $response['token'] ) ) {
+ if ( ! empty( $response['token'] ) ) {
// Store it
$vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' );
- if ( !is_array( $vault_settings ) ) { $vault_settings = array();
+ if ( ! is_array( $vault_settings ) ) {
+$vault_settings = array();
}
$vault_settings['email'] = $email;
$vault_settings['token'] = (string) $response['token'];
$vault_settings['quota'] = -1;
unset( $vault_settings['last_config'] );
- if ( isset($response['quota'] ) ) { $vault_settings['quota'] = $response['quota'];
+ if ( isset($response['quota'] ) ) {
+$vault_settings['quota'] = $response['quota'];
}
UpdraftPlus_Options::update_updraft_option( 'updraft_updraftvault', $vault_settings );
- } elseif ( isset( $response['quota'] ) && !$response['quota'] ) {
+ } elseif ( isset( $response['quota'] ) && ! $response['quota'] ) {
return new WP_Error( 'no_quota', __( 'You do not currently have any UpdraftPlus Vault quota', 'updraftplus' ) );
} else {
return new WP_Error( 'unknown_response', __( 'UpdraftPlus.Com returned a response, but we could not understand it', 'updraftplus' ) );
}
break;
case 'authfailed':
- if ( !empty( $response['authproblem'] ) ) {
+ if ( ! empty( $response['authproblem'] ) ) {
if ( 'invalidpassword' == $response['authproblem'] ) {
$authfail_error = new WP_Error( 'authfailed', __( 'Your email address was valid, but your password was not recognised by UpdraftPlus.Com.', 'updraftplus' ) . ' ' . __( 'If you have forgotten your password, then go here to change your password on updraftplus.com.', 'updraftplus' ) . '' );
return $authfail_error;
@@ -396,7 +399,8 @@ class MainWP_Child_Updraft_Plus_Backups {
'su' => base64_encode( home_url() ),
);
- if ( !empty( $vault_settings['token'] ) ) { $post_body['token'] = (string) $vault_settings['token'];
+ if ( ! empty( $vault_settings['token'] ) ) {
+$post_body['token'] = (string) $vault_settings['token'];
}
// Use SSL to prevent snooping
@@ -413,7 +417,7 @@ class MainWP_Child_Updraft_Plus_Backups {
require_once UPDRAFTPLUS_DIR . '/class-updraftplus.php';
}
- if ( ! class_exists( 'UpdraftPlus_Options' ) && file_exists( UPDRAFTPLUS_DIR . '/options.php' ) ) {
+ if ( ! class_exists( 'UpdraftPlus_Options' ) && file_exists( UPDRAFTPLUS_DIR . '/options.php' ) ) {
require_once UPDRAFTPLUS_DIR . '/options.php';
}
}
@@ -432,20 +436,20 @@ class MainWP_Child_Updraft_Plus_Backups {
$settings_key = null;
if ( 'updraft_dropbox' === $key && is_array($settings[ $key ])) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dropbox' );
- if (!is_array($opts)) {
+ if ( ! is_array($opts)) {
$opts = array();
}
- if(is_array($opts) && isset($opts['settings'])) {
+ if (is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
- if (isset($settings['is_general']) && !empty($settings['is_general'])){
+ if (isset($settings['is_general']) && ! empty($settings['is_general'])) {
$opts['settings'][ $settings_key ]['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
} else {
// $opts['settings'][$settings_key]['appkey'] = $settings[ $key ]['appkey'];
// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret'];
$opts['settings'][ $settings_key ]['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
}
- } else {
- if (isset($settings['is_general']) && !empty($settings['is_general'])){
+ } else {
+ if (isset($settings['is_general']) && ! empty($settings['is_general'])) {
$opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
} else {
// $opts['appkey'] = $settings[ $key ]['appkey'];
@@ -520,15 +524,15 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( $key, $value );
} elseif ( 'updraft_s3' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3' );
- if (!is_array($opts)) {
+ if ( ! is_array($opts)) {
$opts = array();
}
- if(is_array($opts) && isset($opts['settings'])) {
+ if (is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
$opts['settings'][ $settings_key ]['accesskey'] = $settings[ $key ]['accesskey'];
$opts['settings'][ $settings_key ]['secretkey'] = $settings[ $key ]['secretkey'];
$opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']);
- if (!empty($opts['settings'][ $settings_key ]['path']) && '/' == substr($opts['settings'][ $settings_key ]['path'], 0, 1)) {
+ if ( ! empty($opts['settings'][ $settings_key ]['path']) && '/' == substr($opts['settings'][ $settings_key ]['path'], 0, 1)) {
$opts['settings'][ $settings_key ]['path'] = substr($opts['settings'][ $settings_key ]['path'], 1);
}
if (isset($settings[ $key ]['rrs'])) { // premium settings
@@ -539,7 +543,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$opts['accesskey'] = $settings[ $key ]['accesskey'];
$opts['secretkey'] = $settings[ $key ]['secretkey'];
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
- if (!empty($opts['path']) && '/' == substr($opts['path'], 0, 1)) {
+ if ( ! empty($opts['path']) && '/' == substr($opts['path'], 0, 1)) {
$opts['path'] = substr($opts['path'], 1);
}
if (isset($settings[ $key ]['rrs'])) { // premium settings
@@ -551,10 +555,10 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} elseif ( 'updraft_s3generic' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3generic' );
- if (!is_array($opts)) {
+ if ( ! is_array($opts)) {
$opts = array();
}
- if(is_array($opts) && isset($opts['settings'])) {
+ if (is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
$opts['settings'][ $settings_key ]['endpoint'] = $settings[ $key ]['endpoint'];
$opts['settings'][ $settings_key ]['accesskey'] = $settings[ $key ]['accesskey'];
@@ -570,10 +574,10 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} elseif ( 'updraft_dreamobjects' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dreamobjects' );
- if (!is_array($opts)) {
+ if ( ! is_array($opts)) {
$opts = array();
}
- if(is_array($opts) && isset($opts['settings'])) {
+ if (is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
$opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']);
$opts['settings'][ $settings_key ]['endpoint'] = $settings[ $key ]['endpoint'];
@@ -584,10 +588,10 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} elseif ( 'updraft_ftp' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_ftp' );
- if (!is_array($opts)) {
+ if ( ! is_array($opts)) {
$opts = array();
}
- if(is_array($opts) && isset($opts['settings'])) {
+ if (is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
if ( isset( $settings[ $key ]['path'] ) ) {
$opts['settings'][ $settings_key ]['host'] = $settings[ $key ]['host'];
@@ -609,10 +613,10 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} elseif ( 'updraft_sftp_settings' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_sftp' );
- if (!is_array($opts)) {
+ if ( ! is_array($opts)) {
$opts = array();
}
- if(is_array($opts) && isset($opts['settings'])) {
+ if (is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
if ( isset( $settings[ $key ]['path'] ) ) {
$opts['settings'][ $settings_key ]['host'] = $settings[ $key ]['host'];
@@ -637,11 +641,11 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( 'updraft_sftp', $opts );
} elseif ('updraft_webdav_settings' == $key) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_webdav' );
- if (!is_array($opts)) {
+ if ( ! is_array($opts)) {
$opts = array();
}
- if(is_array($opts) && isset($opts['settings'])) {
+ if (is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
$opts['settings'][ $settings_key ]['url'] = $this->replace_tokens( $settings[ $key ]['url'] );
UpdraftPlus_Options::update_updraft_option( 'updraft_webdav', $opts );
@@ -649,7 +653,7 @@ class MainWP_Child_Updraft_Plus_Backups {
} elseif ( 'updraft_backblaze' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_backblaze' );
- if (!is_array($opts)) {
+ if ( ! is_array($opts)) {
$opts = array();
}
if (is_array($opts) && isset($opts['settings'])) {
@@ -673,7 +677,7 @@ class MainWP_Child_Updraft_Plus_Backups {
}
}
- if (!isset($settings['do_not_save_remote_settings']) || empty($settings['do_not_save_remote_settings'])) {
+ if ( ! isset($settings['do_not_save_remote_settings']) || empty($settings['do_not_save_remote_settings'])) {
UpdraftPlus_Options::update_updraft_option( 'updraft_service', $settings['updraft_service'] );
}
@@ -724,7 +728,8 @@ class MainWP_Child_Updraft_Plus_Backups {
function addons_connect() {
if ( ! defined( 'UDADDONS2_SLUG' ) ) {
- if (is_file(UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php')) { require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php';
+ if (is_file(UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php')) {
+require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php';
}
if ( ! defined( 'UDADDONS2_SLUG' ) ) {
return array( 'error' => 'NO_PREMIUM' );
@@ -1163,7 +1168,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$bh = $this->build_historystatus();
// to fix performance issue
- if ( $with_hist ) {
+ if ( $with_hist ) {
$out['updraft_historystatus'] = $bh['h'];
}
@@ -2609,13 +2614,15 @@ class MainWP_Child_Updraft_Plus_Backups {
$updraftplus->get_max_packet_size();
$backup = UpdraftPlus_Backup_History::get_history($timestamp);
- if (!isset($backup['nonce']) || !isset($backup['db'])) { return array( $mess, $warn, $err, $info );
+ if ( ! isset($backup['nonce']) || ! isset($backup['db'])) {
+return array( $mess, $warn, $err, $info );
}
$db_file = ( is_string($backup['db']) ) ? $updraft_dir . '/' . $backup['db'] : $updraft_dir . '/' . $backup['db'][0];
}
- if (!is_readable($db_file)) { return array( $mess, $warn, $err, $info );
+ if ( ! is_readable($db_file)) {
+return array( $mess, $warn, $err, $info );
}
// Encrypted - decrypt it
@@ -2623,7 +2630,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$encryption = empty($res['updraft_encryptionphrase']) ? UpdraftPlus_Options::get_updraft_option('updraft_encryptionphrase') : $res['updraft_encryptionphrase'];
- if (!$encryption) {
+ if ( ! $encryption) {
if (class_exists('UpdraftPlus_Addon_MoreDatabase')) {
$err[] = sprintf(__('Error: %s', 'updraftplus'), __('Decryption failed. The database file is encrypted, but you have no encryption key entered.', 'updraftplus'));
} else {
@@ -2644,14 +2651,14 @@ class MainWP_Child_Updraft_Plus_Backups {
// Even the empty schema when gzipped comes to 1565 bytes; a blank WP 3.6 install at 5158. But we go low, in case someone wants to share single tables.
if (filesize($db_file) < 1000) {
- $err[] = sprintf(__('The database is too small to be a valid WordPress database (size: %s Kb).', 'updraftplus'), round(filesize($db_file)/1024, 1));
+ $err[] = sprintf(__('The database is too small to be a valid WordPress database (size: %s Kb).', 'updraftplus'), round(filesize($db_file) / 1024, 1));
return array( $mess, $warn, $err, $info );
}
$is_plain = ( '.gz' == substr($db_file, -3, 3) ) ? false : true;
$dbhandle = ( $is_plain ) ? fopen($db_file, 'r') : $this->gzopen_for_read($db_file, $warn, $err);
- if (!is_resource($dbhandle)) {
+ if ( ! is_resource($dbhandle)) {
$err[] = __('Failed to open database file.', 'updraftplus');
return array( $mess, $warn, $err, $info );
}
@@ -2699,7 +2706,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$db_collates_found = array();
$db_supported_charset_related_to_unsupported_collation = false;
$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++;
// Up to 1MB
$buffer = ( $is_plain ) ? rtrim(fgets($dbhandle, 1048576)) : rtrim(gzgets($dbhandle, 1048576));
@@ -2708,10 +2715,10 @@ class MainWP_Child_Updraft_Plus_Backups {
$processing_create = false;
if ('' == $old_siteurl && preg_match('/^\# Backup of: (http(.*))$/', $buffer, $matches)) {
$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
if (untrailingslashit(site_url()) != $old_siteurl) {
- if (!$migration_warning) {
+ if ( ! $migration_warning) {
$migration_warning = true;
$info['migration'] = true;
// && !class_exists('UpdraftPlus_Addons_Migrator')
@@ -2741,7 +2748,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$info['same_url'] = false;
$warn[] = apply_filters('updraftplus_dbscan_urlchange', '' . __('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') . '', $old_siteurl, $res);
}
- if (!class_exists('UpdraftPlus_Addons_Migrator')) {
+ if ( ! class_exists('UpdraftPlus_Addons_Migrator')) {
$warn[] .= '' . __('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') . '';
}
}
@@ -2757,17 +2764,19 @@ class MainWP_Child_Updraft_Plus_Backups {
} elseif ('' == $old_home && preg_match('/^\# Home URL: (http(.*))$/', $buffer, $matches)) {
$old_home = untrailingslashit($matches[1]);
// Check for should-be migration
- if (!$migration_warning && home_url() != $old_home) {
+ if ( ! $migration_warning && home_url() != $old_home) {
$migration_warning = true;
$powarn = apply_filters('updraftplus_dbscan_urlchange', '' . __('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') . '', $old_home, $res);
- if (!empty($powarn)) { $warn[] = $powarn;
+ if ( ! empty($powarn)) {
+$warn[] = $powarn;
}
}
- } elseif (!isset($info['created_by_version']) && preg_match('/^\# Created by UpdraftPlus version ([\d\.]+)/', $buffer, $matches)) {
+ } elseif ( ! isset($info['created_by_version']) && preg_match('/^\# Created by UpdraftPlus version ([\d\.]+)/', $buffer, $matches)) {
$info['created_by_version'] = trim($matches[1]);
} elseif ('' == $old_wp_version && preg_match('/^\# WordPress Version: ([0-9]+(\.[0-9]+)+)(-[-a-z0-9]+,)?(.*)$/', $buffer, $matches)) {
$old_wp_version = $matches[1];
- if (!empty($matches[3])) { $old_wp_version .= substr($matches[3], 0, strlen($matches[3])-1);
+ if ( ! empty($matches[3])) {
+$old_wp_version .= substr($matches[3], 0, strlen($matches[3]) - 1);
}
if (version_compare($old_wp_version, $wp_version, '>')) {
// $mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version);
@@ -2791,7 +2800,7 @@ class MainWP_Child_Updraft_Plus_Backups {
if ('end' == $matches[1]) {
$gathering_siteinfo = false;
// Sanity checks
- if (isset($old_siteinfo['multisite']) && !$old_siteinfo['multisite'] && is_multisite()) {
+ if (isset($old_siteinfo['multisite']) && ! $old_siteinfo['multisite'] && is_multisite()) {
// Just need to check that you're crazy
// if (!defined('UPDRAFTPLUS_EXPERIMENTAL_IMPORTINTOMULTISITE') || !UPDRAFTPLUS_EXPERIMENTAL_IMPORTINTOMULTISITE) {
// $err[] = sprintf(__('Error: %s', 'updraftplus'), __('You are running on WordPress multisite - but your backup is not of a multisite site.', 'updraftplus'));
@@ -2800,11 +2809,11 @@ class MainWP_Child_Updraft_Plus_Backups {
$warn[] = __('You are running on WordPress multisite - but your backup is not of a multisite site.', 'updraftplus') . ' ' . __('It will be imported as a new site.', 'updraftplus') . ' ' . __('Please read this link for important information on this process.', 'updraftplus') . '';
// }
// Got the needed code?
- if (!class_exists('UpdraftPlusAddOn_MultiSite') || !class_exists('UpdraftPlus_Addons_Migrator')) {
+ if ( ! class_exists('UpdraftPlusAddOn_MultiSite') || ! class_exists('UpdraftPlus_Addons_Migrator')) {
$err[] = sprintf(__('Error: %s', 'updraftplus'), sprintf(__('To import an ordinary WordPress site into a multisite installation requires %s.', 'updraftplus'), 'UpdraftPlus Premium'));
return array( $mess, $warn, $err, $info );
}
- } elseif (isset($old_siteinfo['multisite']) && $old_siteinfo['multisite'] && !is_multisite()) {
+ } elseif (isset($old_siteinfo['multisite']) && $old_siteinfo['multisite'] && ! is_multisite()) {
$warn[] = __('Warning:', 'updraftplus') . ' ' . __('Your backup is of a WordPress multisite install; but this site is not. Only the first site of the network will be accessible.', 'updraftplus') . ' ' . __('If you want to restore a multisite backup, you should first set up your WordPress installation as a multisite.', 'updraftplus') . '';
}
} elseif (preg_match('/^([^=]+)=(.*)$/', $matches[1], $kvmatches)) {
@@ -2812,7 +2821,8 @@ class MainWP_Child_Updraft_Plus_Backups {
$val = $kvmatches[2];
if ('multisite' == $key) {
$info['multisite'] = $val ? true : false;
- if ($val) { $mess[] = '' . __('Site information:', 'updraftplus') . ' ' . 'backup is of a WordPress Network';
+ if ($val) {
+$mess[] = '' . __('Site information:', 'updraftplus') . ' ' . 'backup is of a WordPress Network';
}
}
$old_siteinfo[ $key ] = $val;
@@ -2836,30 +2846,30 @@ class MainWP_Child_Updraft_Plus_Backups {
$db_supported_charset_related_to_unsupported_collation = true;
}
} elseif ($processing_create) {
- if (!empty($db_supported_collations)) {
+ if ( ! empty($db_supported_collations)) {
if (preg_match('/ COLLATE=([^\s;]+)/i', $buffer, $collate_match)) {
$db_collates_found[] = $collate_match[1];
- if (!isset($db_supported_collations[ $collate_match[1] ])) {
+ if ( ! isset($db_supported_collations[ $collate_match[1] ])) {
$db_supported_charset_related_to_unsupported_collation = true;
}
}
if (preg_match('/ COLLATE ([a-zA-Z0-9._-]+),/i', $buffer, $collate_match)) {
$db_collates_found[] = $collate_match[1];
- if (!isset($db_supported_collations[ $collate_match[1] ])) {
+ if ( ! isset($db_supported_collations[ $collate_match[1] ])) {
$db_supported_charset_related_to_unsupported_collation = true;
}
}
if (preg_match('/ COLLATE ([a-zA-Z0-9._-]+) /i', $buffer, $collate_match)) {
$db_collates_found[] = $collate_match[1];
- if (!isset($db_supported_collations[ $collate_match[1] ])) {
+ if ( ! isset($db_supported_collations[ $collate_match[1] ])) {
$db_supported_charset_related_to_unsupported_collation = true;
}
}
}
- if (!empty($db_supported_character_sets)) {
+ if ( ! empty($db_supported_character_sets)) {
if (preg_match('/ CHARSET=([^\s;]+)/i', $buffer, $charset_match)) {
$db_charsets_found[] = $charset_match[1];
- if ($db_supported_charset_related_to_unsupported_collation && !in_array($charset_match[1], $db_supported_charsets_related_to_unsupported_collations)) {
+ if ($db_supported_charset_related_to_unsupported_collation && ! in_array($charset_match[1], $db_supported_charsets_related_to_unsupported_collations)) {
$db_supported_charsets_related_to_unsupported_collations[] = $charset_match[1];
}
}
@@ -2869,7 +2879,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$db_supported_charset_related_to_unsupported_collation = 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;
$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'));
}
@@ -2880,12 +2890,12 @@ class MainWP_Child_Updraft_Plus_Backups {
} else {
@gzclose($dbhandle);
}
- if (!empty($db_supported_character_sets)) {
+ if ( ! empty($db_supported_character_sets)) {
$db_charsets_found_unique = array_unique($db_charsets_found);
$db_unsupported_charset = array();
$db_charset_forbidden = false;
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_charset_forbidden = true;
}
@@ -2899,7 +2909,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$row = $GLOBALS['wpdb']->get_row('show variables like "character_set_database"');
$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];
}
$charset_select_html = ' ';
@@ -2910,17 +2920,18 @@ class MainWP_Child_Updraft_Plus_Backups {
}
}
$charset_select_html .= '';
- if (empty($info['addui'])) { $info['addui'] = '';
+ if (empty($info['addui'])) {
+$info['addui'] = '';
}
$info['addui'] .= $charset_select_html;
}
}
- if (!empty($db_supported_collations)) {
+ if ( ! empty($db_supported_collations)) {
$db_collates_found_unique = array_unique($db_collates_found);
$db_unsupported_collate = array();
$db_collate_forbidden = false;
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_collate_forbidden = true;
}
@@ -2929,17 +2940,17 @@ class MainWP_Child_Updraft_Plus_Backups {
$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');
$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);
}
- if (empty($similar_type_collate) && !empty($db_supported_charsets_related_to_unsupported_collations)) {
+ if (empty($similar_type_collate) && ! empty($db_supported_charsets_related_to_unsupported_collations)) {
$db_supported_collations_related_to_charset = array();
foreach ($db_supported_collations as $db_supported_collation => $db_supported_collations_info_obj) {
if (isset($db_supported_collations_info_obj->Charset) && in_array($db_supported_collations_info_obj->Charset, $db_supported_charsets_related_to_unsupported_collations)) {
$db_supported_collations_related_to_charset[] = $db_supported_collation;
}
}
- if (!empty($db_supported_collations_related_to_charset)) {
+ if ( ! empty($db_supported_collations_related_to_charset)) {
$similar_type_collate = UpdraftPlus_Manipulation_Functions::get_matching_str_from_array_elems($db_unsupported_collate_unique, $db_supported_collations_related_to_charset, false);
}
}
@@ -2996,13 +3007,14 @@ class MainWP_Child_Updraft_Plus_Backups {
CREATE TABLE $wpdb->sitemeta (
CREATE TABLE $wpdb->signups (
*/
- if (!isset($skipped_tables)) { $skipped_tables = array();
+ if ( ! isset($skipped_tables)) {
+$skipped_tables = array();
}
$missing_tables = array();
if ($old_table_prefix) {
- if (!$header_only) {
+ if ( ! $header_only) {
foreach ($wanted_tables as $table) {
- if (!in_array($old_table_prefix . $table, $tables_found)) {
+ if ( ! in_array($old_table_prefix . $table, $tables_found)) {
$missing_tables[] = $table;
}
}
@@ -3013,10 +3025,10 @@ class MainWP_Child_Updraft_Plus_Backups {
}
}
- if (count($missing_tables)>0) {
+ if (count($missing_tables) > 0) {
$warn[] = sprintf(__('This database backup is missing core WordPress tables: %s', 'updraftplus'), implode(', ', $missing_tables));
}
- if (count($skipped_tables)>0) {
+ if (count($skipped_tables) > 0) {
$warn[] = sprintf(__('This database backup has the following WordPress tables excluded: %s', 'updraftplus'), implode(', ', $skipped_tables));
}
}
@@ -3186,9 +3198,11 @@ class MainWP_Child_Updraft_Plus_Backups {
$date_label = $this->date_label( $pretty_date, $key, $backup, $jobdata, $non );
$service_title = '';
- if (!isset($backup['service'])) { $backup['service'] = array();
+ if ( ! isset($backup['service'])) {
+$backup['service'] = array();
}
- if (!is_array($backup['service'])) { $backup['service'] = array( $backup['service'] );
+ if ( ! is_array($backup['service'])) {
+$backup['service'] = array( $backup['service'] );
}
foreach ($backup['service'] as $service) {
if ('none' === $service || '' === $service || ( is_array($service) && ( empty($service) || array( 'none' ) === $service || array( '' ) === $service ) )) {
@@ -3220,7 +3234,8 @@ ENDHERE;
$db = is_array( $backup['db'] ) ? $backup['db'][0] : $backup['db'];
if ( class_exists( 'UpdraftPlus_Encryption')) {
if ( method_exists('UpdraftPlus_Encryption', 'is_file_encrypted')) {
- if (UpdraftPlus_Encryption::is_file_encrypted($db)) { $entities .= '/dbcrypted=1/';
+ if (UpdraftPlus_Encryption::is_file_encrypted($db)) {
+$entities .= '/dbcrypted=1/';
}
}
} elseif ( method_exists($updraftplus, 'is_db_encrypted') && $updraftplus->is_db_encrypted( $db ) ) {
@@ -4017,7 +4032,7 @@ ENDHERE;
if (isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true) :
$output = json_encode( $txt );
- else:
+ else :
$output = serialize( $txt );
endif;
@@ -4038,7 +4053,7 @@ ENDHERE;
}
public function updraftplus_init() {
- if (!$this->is_plugin_installed) {
+ if ( ! $this->is_plugin_installed) {
return;
}
@@ -4102,7 +4117,7 @@ ENDHERE;
if ( isset( $_POST['mainwpsignature'] ) ) {
return $value;
}
- if (! MainWP_Helper::is_screen_with_update()) {
+ if ( ! MainWP_Helper::is_screen_with_update()) {
return $value;
}
diff --git a/class/class-mainwp-child-vulnerability-checker.php b/class/class-mainwp-child-vulnerability-checker.php
index b438570..a4086f8 100644
--- a/class/class-mainwp-child-vulnerability-checker.php
+++ b/class/class-mainwp-child-vulnerability-checker.php
@@ -51,7 +51,7 @@ class MainWP_Child_Vulnerability_Checker {
function vulner_recheck() {
$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['wp'] = $this->check_wp($force);
$result['theme'] = $this->check_themes($force);
@@ -66,15 +66,15 @@ class MainWP_Child_Vulnerability_Checker {
$result = array();
$active_plugins = get_option('active_plugins');
- if( !empty($active_plugins) ){
- foreach($active_plugins as $plug){
+ if ( ! empty($active_plugins) ) {
+ foreach ($active_plugins as $plug) {
$plugin_file = WP_CONTENT_DIR . '/plugins/' . $plug;
$plugin_info = get_plugin_data($plugin_file);
$plugin_version = isset($plugin_info['Version']) ? $plugin_info['Version'] : '';
$string = explode('/', $plug);
$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]);
set_transient('mainwp_vulnche_trans_plug_' . $string[0], $plug_vuln, 1 * DAY_IN_SECONDS);
}
@@ -85,14 +85,14 @@ class MainWP_Child_Vulnerability_Checker {
foreach ($plug_vuln as $slug => $pl_data) {
if (isset($pl_data['vulnerabilities']) && count($pl_data['vulnerabilities']) > 0) {
$plug_vulner_data = array();
- foreach($pl_data['vulnerabilities'] as $vuln_data) {
+ foreach ($pl_data['vulnerabilities'] as $vuln_data) {
if ( isset($vuln_data['fixed_in']) && version_compare( $plugin_version, $vuln_data['fixed_in'] ) >= 0 ) {
continue;
}
$plug_vulner_data[] = $vuln_data;
}
- if(count($plug_vulner_data) == 0) {
+ if (count($plug_vulner_data) == 0) {
unset($plug_vuln_filter[ $slug ]);
} else {
$plug_vuln_filter[ $slug ]['vulnerabilities'] = $plug_vulner_data;
@@ -123,7 +123,7 @@ class MainWP_Child_Vulnerability_Checker {
function check_wp( $force = false) {
$wp_vuln = get_transient('mainwp_vulnche_trans_wp_json');
$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);
set_transient('mainwp_vulnche_trans_wp_json', $wp_vuln, 1 * DAY_IN_SECONDS);
}
@@ -142,9 +142,9 @@ class MainWP_Child_Vulnerability_Checker {
}
wp_reset_vars( array( 'theme', 'search' ) );
$result = array();
- if(!empty($themes)){
- foreach($themes as $th){
- if(empty($th['parent'])) {
+ if ( ! empty($themes)) {
+ foreach ($themes as $th) {
+ if (empty($th['parent'])) {
$th_vuln = get_transient('mainwp_vulnche_trans_theme_' . $th['id']);
if (false === $th_vuln || $force) {
$th_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'themes/' . $th['id']);
@@ -158,7 +158,7 @@ class MainWP_Child_Vulnerability_Checker {
if (isset($th_data['vulnerabilities']) && count($th_data['vulnerabilities']) > 0) {
$th_vulner_data = array();
- foreach($th_data['vulnerabilities'] as $vuln_data) {
+ foreach ($th_data['vulnerabilities'] as $vuln_data) {
if (empty($vuln_data)) {
continue;
}
@@ -170,7 +170,7 @@ class MainWP_Child_Vulnerability_Checker {
$th_vulner_data[] = $vuln_data;
}
- if(count($th_vulner_data) == 0) {
+ if (count($th_vulner_data) == 0) {
unset($th_vuln_filter[ $slug ]);
} else {
$th_vuln_filter[ $slug ]['vulnerabilities'] = $th_vulner_data;
@@ -237,9 +237,9 @@ class MainWP_Child_Vulnerability_Checker {
'Mozilla/4.01 (compatible; MSIE 6.0; Windows NT 5.1)',
);
- srand( (float) microtime()*1000000);
+ srand( (float) microtime() * 1000000);
- return $someUA[ rand(0, count($someUA)-1) ];
+ return $someUA[ rand(0, count($someUA) - 1) ];
}
diff --git a/class/class-mainwp-child-woocommerce-status.php b/class/class-mainwp-child-woocommerce-status.php
index c16c56f..ca4a8fd 100644
--- a/class/class-mainwp-child-woocommerce-status.php
+++ b/class/class-mainwp-child-woocommerce-status.php
@@ -34,7 +34,7 @@ class MainWP_Child_WooCommerce_Status {
public function action() {
$information = array();
- if ( ! class_exists( 'WooCommerce' ) || !defined('WC_VERSION')) {
+ if ( ! class_exists( 'WooCommerce' ) || ! defined('WC_VERSION')) {
$information['error'] = 'NO_WOOCOMMERCE';
MainWP_Helper::write( $information );
}
diff --git a/class/class-mainwp-child-wordfence.php b/class/class-mainwp-child-wordfence.php
index 77c24cf..ab92cc7 100644
--- a/class/class-mainwp-child-wordfence.php
+++ b/class/class-mainwp-child-wordfence.php
@@ -590,7 +590,7 @@ class MainWP_Child_Wordfence {
$options = array();
- switch($section) {
+ switch ($section) {
case self::OPTIONS_TYPE_GLOBAL:
$options = $general_opts;
break;
@@ -654,7 +654,8 @@ class MainWP_Child_Wordfence {
public function wordfence_init() {
- if ( ! $this->is_wordfence_installed ) { return;
+ if ( ! $this->is_wordfence_installed ) {
+return;
}
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
@@ -671,9 +672,11 @@ class MainWP_Child_Wordfence {
}
// ok
public function do_reports_log( $ext = '') {
- if ( $ext !== 'wordfence' ) { return;
+ if ( $ext !== 'wordfence' ) {
+return;
}
- if ( ! $this->is_wordfence_installed ) { return;
+ if ( ! $this->is_wordfence_installed ) {
+return;
}
global $wpdb;
@@ -699,7 +702,7 @@ class MainWP_Child_Wordfence {
if ($scan_time) {
$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 .= " 'SUM_FINAL:Scan complete.%';";
@@ -887,7 +890,7 @@ SQL
$wfIssues = new wfIssues();
$status = $_POST['status'];
$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.' );
}
$wfIssues->updateIssue($issueID, $status);
@@ -1097,23 +1100,23 @@ SQL
function simple_crypt( $key, $data, $action = 'encrypt') {
$res = '';
- if($action == 'encrypt'){
+ if ($action == 'encrypt') {
$string = base64_encode( serialize($data) );
} else {
$string = $data;
}
- for( $i = 0; $i < strlen($string); $i++){
+ for ( $i = 0; $i < strlen($string); $i++) {
$c = ord(substr($string, $i));
- if($action == 'encrypt'){
+ if ($action == 'encrypt') {
$c += ord(substr($key, ( ( $i + 1 ) % strlen($key) )));
$res .= chr($c & 0xFF);
- }else{
+ } else {
$c -= ord(substr($key, ( ( $i + 1 ) % strlen($key) )));
$res .= chr(abs($c) & 0xFF);
}
}
- if($action !== 'encrypt'){
+ if ($action !== 'encrypt') {
$res = unserialize( base64_decode($res) );
}
return $res;
@@ -1131,7 +1134,7 @@ SQL
$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 = '';
$opts = $settings;
@@ -1314,7 +1317,7 @@ SQL
return $result;
}
- } elseif ( !empty( $apiKey ) && $existingAPIKey != $apiKey ) {
+ } elseif ( ! empty( $apiKey ) && $existingAPIKey != $apiKey ) {
$api = new wfAPI( $apiKey, wfUtils::getWPVersion() );
try {
$res = $api->call('check_api_key', array(), array( 'previousLicense' => $existingAPIKey ));
@@ -1332,7 +1335,7 @@ SQL
wfConfig::set('apiKey', $apiKey);
wfConfig::set('isPaid', $isPaid); //res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools.
wordfence::licenseStatusChanged();
- if (!$isPaid) {
+ if ( ! $isPaid) {
wfConfig::set('keyType', wfAPI::KEY_TYPE_FREE);
}
@@ -1389,7 +1392,7 @@ SQL
wfConfig::set('keyType', $keyType);
- if (!isset($result['apiKey'])) {
+ if ( ! isset($result['apiKey'])) {
$isPaid = ( $keyType == wfAPI::KEY_TYPE_FREE ) ? false : true;
$result['apiKey'] = $apiKey;
$result['isPaid'] = $isPaid;
@@ -1602,15 +1605,12 @@ SQL
'ok' => 1,
'token' => $res['token'],
);
- }
- elseif ($res['err']) {
+ } elseif ($res['err']) {
return array( 'errorExport' => __('An error occurred: ', 'wordfence') . $res['err'] );
- }
- else {
+ } else {
throw new Exception(__('Invalid response: ', 'wordfence') . var_export($res, true));
}
- }
- catch (Exception $e) {
+ } catch (Exception $e) {
return array( 'errorExport' => __('An error occurred: ', 'wordfence') . $e->getMessage() );
}
}
@@ -1623,7 +1623,7 @@ SQL
if ($res['ok'] && $res['export']) {
$totalSet = 0;
$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') );
}
@@ -1668,15 +1668,12 @@ SQL
'totalSet' => $totalSet,
'settings' => $this->get_settings(),
);
- }
- elseif ($res['err']) {
+ } elseif ($res['err']) {
return array( 'errorImport' => 'An error occurred: ' . $res['err'] );
- }
- else {
+ } else {
throw new Exception('Invalid response: ' . var_export($res, true));
}
- }
- catch (Exception $e) {
+ } catch (Exception $e) {
return array( 'errorImport' => 'An error occurred: ' . $e->getMessage() );
}
}
@@ -1684,7 +1681,7 @@ SQL
function get_settings() {
$keys = wfConfig::getExportableOptionsKeys();
$settings = array();
- foreach($keys as $key){
+ foreach ($keys as $key) {
$settings[ $key ] = wfConfig::get($key, '');
}
$settings['apiKey'] = wfConfig::get('apiKey'); //get more apiKey
@@ -1843,7 +1840,7 @@ SQL
// credit of Wordfence
private static function _getWAFData( $updated = null) {
// custom
- if(!class_exists('wfWAF')) {
+ if ( ! class_exists('wfWAF')) {
return false;
}
// end if custom
@@ -1914,17 +1911,17 @@ SQL
public function saveOptions() {
- if (!empty($_POST['changes']) && ( $changes = json_decode(stripslashes($_POST['changes']), true) ) !== false) {
+ if ( ! empty($_POST['changes']) && ( $changes = json_decode(stripslashes($_POST['changes']), true) ) !== false) {
try {
if (is_array($changes) && isset($changes['whitelistedURLParams']) && isset($changes['whitelistedURLParams']['add'])) {
$user = wp_get_current_user();
- foreach($changes['whitelistedURLParams']['add'] as $key => &$value) :
+ foreach ($changes['whitelistedURLParams']['add'] as $key => &$value) :
if (isset($value['data'])) {
- if(isset($value['data']['userID'])) {
+ if (isset($value['data']['userID'])) {
$value['data']['userID'] = $user->ID;
}
- if(isset($value['data']['username'])) {
+ if (isset($value['data']['username'])) {
$value['data']['username'] = $user->user_login;
}
}
@@ -1938,8 +1935,7 @@ SQL
return array(
'error' => sprintf(__('An error occurred while saving the configuration: %s', 'wordfence'), $errors[0]['error']),
);
- }
- elseif (count($errors) > 1) {
+ } elseif (count($errors) > 1) {
$compoundMessage = array();
foreach ($errors as $e) {
$compoundMessage[] = $e['error'];
@@ -1956,13 +1952,11 @@ SQL
wfConfig::save($changes);
return array( 'success' => true );
- }
- catch (wfWAFStorageFileException $e) {
+ } catch (wfWAFStorageFileException $e) {
return array(
'error' => __('An error occurred while saving the configuration.', 'wordfence'),
);
- }
- catch (Exception $e) {
+ } catch (Exception $e) {
return array(
'error' => $e->getMessage(),
);
@@ -2011,7 +2005,7 @@ SQL
}
public static function saveCountryBlocking() {
- if(! wfConfig::get('isPaid')){
+ if ( ! wfConfig::get('isPaid')) {
return array( 'error' => 'Sorry but this feature is only available for paid customers.' );
}
$settings = $_POST['settings'];
@@ -2073,7 +2067,7 @@ SQL
public static function saveCacheConfig() {
$noEditHtaccess = '1';
- if (isset($_POST['needToCheckFalconHtaccess']) && !empty($_POST['needToCheckFalconHtaccess'])) {
+ if (isset($_POST['needToCheckFalconHtaccess']) && ! empty($_POST['needToCheckFalconHtaccess'])) {
$checkHtaccess = self::checkFalconHtaccess();
if (isset($checkHtaccess['ok'])) {
$noEditHtaccess = '0';
@@ -2083,48 +2077,48 @@ SQL
}
$cacheType = $_POST['cacheType'];
- if($cacheType == 'falcon' || $cacheType == 'php'){
+ if ($cacheType == 'falcon' || $cacheType == 'php') {
$plugins = get_plugins();
$badPlugins = array();
- foreach($plugins as $pluginFile => $data){
- if(is_plugin_active($pluginFile)){
- if($pluginFile == 'w3-total-cache/w3-total-cache.php'){
+ foreach ($plugins as $pluginFile => $data) {
+ if (is_plugin_active($pluginFile)) {
+ if ($pluginFile == 'w3-total-cache/w3-total-cache.php') {
$badPlugins[] = 'W3 Total Cache';
- } elseif($pluginFile == 'quick-cache/quick-cache.php'){
+ } elseif ($pluginFile == 'quick-cache/quick-cache.php') {
$badPlugins[] = 'Quick Cache';
- } elseif($pluginFile == 'wp-super-cache/wp-cache.php'){
+ } elseif ($pluginFile == 'wp-super-cache/wp-cache.php') {
$badPlugins[] = 'WP Super Cache';
- } elseif($pluginFile == 'wp-fast-cache/wp-fast-cache.php'){
+ } elseif ($pluginFile == 'wp-fast-cache/wp-fast-cache.php') {
$badPlugins[] = 'WP Fast Cache';
- } elseif($pluginFile == 'wp-fastest-cache/wpFastestCache.php'){
+ } elseif ($pluginFile == 'wp-fastest-cache/wpFastestCache.php') {
$badPlugins[] = 'WP Fastest Cache';
}
}
}
- if(count($badPlugins) > 0){
+ if (count($badPlugins) > 0) {
return array( 'errorMsg' => 'You can not enable caching in Wordfence with other caching plugins enabled. This may cause conflicts. You need to disable other caching plugins first. Wordfence caching is very fast and does not require other caching plugins to be active. The plugins you have that conflict are: ' . implode(', ', $badPlugins) . '. Disable these plugins, then return to this page and enable Wordfence caching.' );
}
$siteURL = site_url();
- if(preg_match('/^https?:\/\/[^\/]+\/[^\/]+\/[^\/]+\/.+/i', $siteURL)){
+ if (preg_match('/^https?:\/\/[^\/]+\/[^\/]+\/[^\/]+\/.+/i', $siteURL)) {
return array( 'errorMsg' => "Wordfence caching currently does not support sites that are installed in a subdirectory and have a home page that is more than 2 directory levels deep. e.g. we don't support sites who's home page is http://example.com/levelOne/levelTwo/levelThree" );
}
}
- if($cacheType == 'falcon'){
- if(! get_option('permalink_structure', '')){
+ if ($cacheType == 'falcon') {
+ if ( ! get_option('permalink_structure', '')) {
return array( 'errorMsg' => 'You need to enable Permalinks for your site to use Falcon Engine. You can enable Permalinks in WordPress by going to the Settings - Permalinks menu and enabling it there. Permalinks change your site URL structure from something that looks like /p=123 to pretty URLs like /my-new-post-today/ that are generally more search engine friendly.' );
}
}
$warnHtaccess = false;
- if($cacheType == 'disable' || $cacheType == 'php'){
+ if ($cacheType == 'disable' || $cacheType == 'php') {
$removeError = wfCache::addHtaccessCode('remove');
$removeError2 = wfCache::updateBlockedIPs('remove');
- if($removeError || $removeError2){
+ if ($removeError || $removeError2) {
$warnHtaccess = true;
}
}
- if($cacheType == 'php' || $cacheType == 'falcon'){
+ if ($cacheType == 'php' || $cacheType == 'falcon') {
$err = wfCache::cacheDirectoryTest();
- if($err){
+ if ($err) {
return array(
'ok' => 1,
'heading' => 'Could not write to cache directory',
@@ -2134,31 +2128,31 @@ SQL
}
//Mainly we clear the cache here so that any footer cache diagnostic comments are rebuilt. We could just leave it intact unless caching is being disabled.
- if($cacheType != wfConfig::get('cacheType', false)){
+ if ($cacheType != wfConfig::get('cacheType', false)) {
wfCache::scheduleCacheClear();
}
$htMsg = '';
- if($warnHtaccess){
+ if ($warnHtaccess) {
$htMsg = " Warning: We could not remove the caching code from your .htaccess file. you need to remove this manually yourself. ";
}
- if($cacheType == 'disable'){
+ if ($cacheType == 'disable') {
wfConfig::set('cacheType', false);
return array(
'ok' => 1,
'heading' => 'Caching successfully disabled.',
'body' => "{$htMsg}Caching has been disabled on your system.
",
);
- } elseif($cacheType == 'php'){
+ } elseif ($cacheType == 'php') {
wfConfig::set('cacheType', 'php');
return array(
'ok' => 1,
'heading' => 'Wordfence Basic Caching Enabled',
'body' => "{$htMsg}Wordfence basic caching has been enabled on your system.
",
);
- } elseif($cacheType == 'falcon'){
- if($noEditHtaccess != '1'){
+ } elseif ($cacheType == 'falcon') {
+ if ($noEditHtaccess != '1') {
$err = wfCache::addHtaccessCode('add');
- if($err){
+ if ($err) {
return array(
'ok' => 1,
'heading' => 'Wordfence could not edit .htaccess',
@@ -2178,18 +2172,18 @@ SQL
}
public static function checkFalconHtaccess() {
- if(wfUtils::isNginx()){
+ if (wfUtils::isNginx()) {
return array( 'nginx' => 1 );
}
$file = wfCache::getHtaccessPath();
- if(! $file){
+ if ( ! $file) {
return array(
'err' => 'We could not find your .htaccess file to modify it.',
'code' => wfCache::getHtaccessCode(),
);
}
$fh = @fopen($file, 'r+');
- if(! $fh){
+ if ( ! $fh) {
$err = error_get_last();
return array(
'err' => 'We found your .htaccess file but could not open it for writing: ' . $err['message'],
@@ -2204,15 +2198,15 @@ SQL
}
public static function checkHtaccess() {
- if(wfUtils::isNginx()){
+ if (wfUtils::isNginx()) {
return array( 'nginx' => 1 );
}
$file = wfCache::getHtaccessPath();
- if(! $file){
+ if ( ! $file) {
return array( 'err' => 'We could not find your .htaccess file to modify it.' );
}
$fh = @fopen($file, 'r+');
- if(! $fh){
+ if ( ! $fh) {
$err = error_get_last();
return array( 'err' => 'We found your .htaccess file but could not open it for writing: ' . $err['message'] );
}
@@ -2242,15 +2236,15 @@ SQL
public static function saveCacheOptions() {
$changed = false;
- if($_POST['allowHTTPSCaching'] != wfConfig::get('allowHTTPSCaching', false)){
+ if ($_POST['allowHTTPSCaching'] != wfConfig::get('allowHTTPSCaching', false)) {
$changed = true;
}
wfConfig::set('allowHTTPSCaching', $_POST['allowHTTPSCaching'] == '1' ? 1 : 0);
//wfConfig::set('addCacheComment', $_POST['addCacheComment'] == 1 ? '1' : 0);
wfConfig::set('clearCacheSched', $_POST['clearCacheSched'] == 1 ? '1' : 0);
- if($changed && wfConfig::get('cacheType', false) == 'falcon'){
+ if ($changed && wfConfig::get('cacheType', false) == 'falcon') {
$err = wfCache::addHtaccessCode('add');
- if($err){
+ if ($err) {
return array(
'updateErr' => 'Wordfence could not edit your .htaccess file. The error was: ' . $err,
'code' => wfCache::getHtaccessCode(),
@@ -2263,7 +2257,7 @@ SQL
public static function clearPageCache() {
$stats = wfCache::clearPageCache();
- if($stats['error']){
+ if ($stats['error']) {
$body = 'A total of ' . $stats['totalErrors'] . ' errors occurred while trying to clear your cache. The last error was: ' . $stats['error'];
return array(
'ok' => 1,
@@ -2272,8 +2266,8 @@ SQL
);
}
$body = 'A total of ' . $stats['filesDeleted'] . ' files were deleted and ' . $stats['dirsDeleted'] . ' directories were removed. We cleared a total of ' . $stats['totalData'] . 'KB of data in the cache.';
- if($stats['totalErrors'] > 0){
- $body .= ' A total of ' . $stats['totalErrors'] . ' errors were encountered. This probably means that we could not remove some of the files or directories in the cache. Please use your CPanel or file manager to remove the rest of the files in the directory: ' . WP_CONTENT_DIR . '/wfcache/';
+ if ($stats['totalErrors'] > 0) {
+ $body .= ' A total of ' . $stats['totalErrors'] . ' errors were encountered. This probably means that we could not remove some of the files or directories in the cache. Please use your CPanel or file manager to remove the rest of the files in the directory: ' . WP_CONTENT_DIR . '/wfcache/';
}
return array(
'ok' => 1,
@@ -2284,7 +2278,7 @@ SQL
public static function getCacheStats() {
$s = wfCache::getCacheStats();
- if($s['files'] == 0){
+ if ($s['files'] == 0) {
return array(
'ok' => 1,
'heading' => 'Cache Stats',
@@ -2294,26 +2288,26 @@ SQL
$body = 'Total files in cache: ' . $s['files'] .
'
Total directories in cache: ' . $s['dirs'] .
'
Total data: ' . $s['data'] . 'KB';
- if($s['compressedFiles'] > 0){
+ if ($s['compressedFiles'] > 0) {
$body .= '
Files: ' . $s['uncompressedFiles'] .
'
Data: ' . $s['uncompressedKBytes'] . 'KB' .
'
Compressed files: ' . $s['compressedFiles'] .
'
Compressed data: ' . $s['compressedKBytes'] . 'KB';
}
- if($s['largestFile'] > 0){
+ if ($s['largestFile'] > 0) {
$body .= '
Largest file: ' . $s['largestFile'] . 'KB';
}
- if($s['oldestFile'] !== false){
+ if ($s['oldestFile'] !== false) {
$body .= '
Oldest file in cache created ';
- if(time() - $s['oldestFile'] < 300){
+ if (time() - $s['oldestFile'] < 300) {
$body .= ( time() - $s['oldestFile'] ) . ' seconds ago';
} else {
$body .= human_time_diff($s['oldestFile']) . ' ago.';
}
}
- if($s['newestFile'] !== false){
+ if ($s['newestFile'] !== false) {
$body .= '
Newest file in cache created ';
- if(time() - $s['newestFile'] < 300){
+ if (time() - $s['newestFile'] < 300) {
$body .= ( time() - $s['newestFile'] ) . ' seconds ago';
} else {
$body .= human_time_diff($s['newestFile']) . ' ago.';
@@ -2329,7 +2323,7 @@ SQL
public static function addCacheExclusion() {
$ex = wfConfig::get('cacheExclusions', false);
- if($ex){
+ if ($ex) {
$ex = unserialize($ex);
} else {
$ex = array();
@@ -2345,8 +2339,8 @@ SQL
}
wfConfig::set('cacheExclusions', serialize($ex));
wfCache::scheduleCacheClear();
- if(wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $_POST['patternType'])){
- if(wfCache::addHtaccessCode('add')){ //rewrites htaccess rules
+ if (wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $_POST['patternType'])) {
+ if (wfCache::addHtaccessCode('add')) { //rewrites htaccess rules
return array(
'errorMsg' => 'We added the rule you requested but could not modify your .htaccess file. Please delete this rule, check the permissions on your .htaccess file and then try again.',
'ex' => $ex,
@@ -2361,7 +2355,7 @@ SQL
public static function loadCacheExclusions() {
$ex = wfConfig::get('cacheExclusions', false);
- if(! $ex){
+ if ( ! $ex) {
return array( 'ex' => false );
}
$ex = unserialize($ex);
@@ -2374,15 +2368,15 @@ SQL
public static function removeCacheExclusion() {
$id = $_POST['id'];
$ex = wfConfig::get('cacheExclusions', false);
- if(! $ex){
+ if ( ! $ex) {
return array( 'ok' => 1 );
}
$ex = unserialize($ex);
$rewriteHtaccess = false;
$removed = false;
- for($i = 0; $i < sizeof($ex); $i++){
- if( (string) $ex[ $i ]['id'] == (string) $id){
- if(wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $ex[ $i ]['pt'])){
+ for ($i = 0; $i < sizeof($ex); $i++) {
+ if ( (string) $ex[ $i ]['id'] == (string) $id) {
+ if (wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $ex[ $i ]['pt'])) {
$rewriteHtaccess = true;
}
array_splice($ex, $i, 1);
@@ -2391,13 +2385,13 @@ SQL
}
}
$return = array( 'ex' => $ex );
- if (!$removed) {
+ if ( ! $removed) {
$return['error'] = 'Not found the cache exclusion.';
return $return;
}
wfConfig::set('cacheExclusions', serialize($ex));
- if($rewriteHtaccess && wfCache::addHtaccessCode('add')){ //rewrites htaccess rules
+ if ($rewriteHtaccess && wfCache::addHtaccessCode('add')) { //rewrites htaccess rules
$return['errorMsg'] = "We removed that rule but could not rewrite your .htaccess file. You're going to have to manually remove this rule from your .htaccess file. Please reload this page now.";
return $return;
}
@@ -2427,17 +2421,17 @@ SQL