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

Apply fixes from CodeFactor
This commit is contained in:
Bogdan Rapaić 2020-03-26 16:33:36 +01:00 committed by GitHub
commit edb1660295
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 1206 additions and 798 deletions

View file

@ -119,7 +119,7 @@ class MainWP_Backup {
// @codingStandardsIgnoreEnd
if ( !is_array( $files ) ) {
$files = array ( $files );
$files = array( $files );
}
if ( null !== $this->archiver ) {

View file

@ -385,7 +385,7 @@ class MainWP_Child_Back_Up_Buddy {
$type = isset($_POST['type']) ? $_POST['type'] : '';
if ($type !== 'general_settings' && $type !== 'advanced_settings' && $type !== 'all' ) {
return array('error' => __('Invalid data. Please check and try again.') );
return array( 'error' => __('Invalid data. Please check and try again.') );
}
$filter_advanced_settings = array(
@ -490,16 +490,16 @@ 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])) {
$save_settings[$field] = $settings[$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])) {
$save_settings[$field] = $settings[$field];
if(isset($settings[ $field ])) {
$save_settings[ $field ] = $settings[ $field ];
}
}
}
@ -509,15 +509,15 @@ class MainWP_Child_Back_Up_Buddy {
$newOptions = pb_backupbuddy::$options;
foreach($newOptions as $key => $val) {
if (isset($save_settings[$key])) {
$newOptions[$key] = $save_settings[$key];
if (isset($save_settings[ $key ])) {
$newOptions[ $key ] = $save_settings[ $key ];
}
}
if (isset($newOptions['profiles']) && isset($newOptions['profiles'][0])) {
foreach ($filter_profile0_values as $field) {
if (isset($settings[$field])) {
$newOptions['profiles'][0][$field] = $settings[$field];
if (isset($settings[ $field ])) {
$newOptions['profiles'][0][ $field ] = $settings[ $field ];
}
}
}
@ -568,7 +568,10 @@ class MainWP_Child_Back_Up_Buddy {
}
function get_notifications() {
return array('result' => 'SUCCESS', 'notifications' => backupbuddy_core::getNotifications() );
return array(
'result' => 'SUCCESS',
'notifications' => backupbuddy_core::getNotifications(),
);
}
function get_schedules_run_time() {
@ -599,7 +602,7 @@ class MainWP_Child_Back_Up_Buddy {
'Last run: ' . $last_run . '<br>' .
'Next run: ' . $next_run;
$schedules_run_time[$schedule_id] = $run_time;
$schedules_run_time[ $schedule_id ] = $run_time;
}
@ -624,16 +627,16 @@ class MainWP_Child_Back_Up_Buddy {
function run_scheduled_backup() {
if ( ! is_main_site() ) { // Only run for main site or standalone. Multisite subsites do not allow schedules.
return array('error' => __('Only run for main site or standalone. Multisite subsites do not allow schedules', 'mainwp-child') );
return array( 'error' => __('Only run for main site or standalone. Multisite subsites do not allow schedules', 'mainwp-child') );
}
$schedule_id = (int) $_POST['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' ));
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' ) );
}
pb_backupbuddy::alert( 'Manually running scheduled backup "' . pb_backupbuddy::$options['schedules'][$schedule_id]['title'] . '" in the background.' . '<br>' .
pb_backupbuddy::alert( 'Manually running scheduled backup "' . pb_backupbuddy::$options['schedules'][ $schedule_id ]['title'] . '" in the background.' . '<br>' .
__( 'Note: If there is no site activity there may be delays between steps in the backup. Access the site or use a 3rd party service, such as a free pinging service, to generate site activity.', 'it-l10n-backupbuddy' ) );
pb_backupbuddy_cron::_run_scheduled_backup( $schedule_id );
@ -648,24 +651,24 @@ class MainWP_Child_Back_Up_Buddy {
$schedule = unserialize(base64_decode($_POST['data']));
if (!is_array($schedule)) {
return array('error' => __( 'Invalid schedule data', 'mainwp-child' ));
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;
pb_backupbuddy::$options['schedules'][ $schedule_id ] = $schedule;
$result = backupbuddy_core::schedule_event( $schedule['first_run'], $schedule['interval'], 'run_scheduled_backup', array( $schedule_id ) );
if ( $result === false ) {
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 {
$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::$options['schedules'][ $schedule_id ] = $schedule;
}
pb_backupbuddy::save();
$information['result'] = 'SUCCESS';
@ -681,10 +684,10 @@ class MainWP_Child_Back_Up_Buddy {
$profile = unserialize(base64_decode($_POST['data']));
if (!is_array($profile)) {
return array('error' => __( 'Invalid profile data', 'mainwp-child' ));
return array( 'error' => __( 'Invalid profile data', 'mainwp-child' ) );
}
pb_backupbuddy::$options['profiles'][$profile_id] = $profile;
pb_backupbuddy::$options['profiles'][ $profile_id ] = $profile;
pb_backupbuddy::save();
$information['result'] = 'SUCCESS';
@ -695,8 +698,8 @@ class MainWP_Child_Back_Up_Buddy {
function delete_profile() {
$profile_id = $_POST['profile_id'];
if (isset(pb_backupbuddy::$options['profiles'][$profile_id])) {
unset(pb_backupbuddy::$options['profiles'][$profile_id]);
if (isset(pb_backupbuddy::$options['profiles'][ $profile_id ])) {
unset(pb_backupbuddy::$options['profiles'][ $profile_id ]);
}
pb_backupbuddy::save();
@ -774,7 +777,7 @@ class MainWP_Child_Back_Up_Buddy {
}
MainWP_Helper::check_classes_exists(array( 'backupbuddy_core', 'backupbuddy_api' ));
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' ) );
$data = array();
@ -823,7 +826,7 @@ class MainWP_Child_Back_Up_Buddy {
$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['backupDirectoryWithinSiteRoot'] = ( false !== stristr( $backup_directory, ABSPATH ) ) ? 'yes' : 'no';
$information['result'] = 'SUCCESS';
return $information;
}
@ -870,7 +873,10 @@ class MainWP_Child_Back_Up_Buddy {
$callback_data = $_POST['callback_data'];
$file = backupbuddy_core::getBackupDirectory() . $callback_data;
if (file_exists($file)) {
return array( 'result' =>'SUCCESS', 'hash' => md5_file( $file ) );
return array(
'result' =>'SUCCESS',
'hash' => md5_file( $file ),
);
} else {
return array( 'error' =>'Not found the file' );
}
@ -882,11 +888,11 @@ 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
$serial = $_POST[ 'serial' ];
$serial = $_POST['serial'];
$alerts = array();
// The fileoptions file that contains the file tree information
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
@ -901,7 +907,7 @@ 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.
@ -928,7 +934,7 @@ class MainWP_Child_Back_Up_Buddy {
// 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
// into the tree)
if ( strlen( $file[ 0 ] ) < $root_len ) {
if ( strlen( $file[0] ) < $root_len ) {
unset( $files[ $key ] );
continue;
@ -939,7 +945,7 @@ class MainWP_Child_Back_Up_Buddy {
// e.g., with root=this/dir/path/
// these will fail: file=this/dir/file; file=this/dir/otherpath/; file=that/dir/path/file
// and these would succeed: file=this/dir/path/; file=this/dir/path/file; file=this/dir/path/otherpath/
if ( substr( $file[ 0 ], 0, $root_len ) != $root ) {
if ( substr( $file[0], 0, $root_len ) != $root ) {
unset( $files[ $key ] );
continue;
@ -949,7 +955,7 @@ class MainWP_Child_Back_Up_Buddy {
// If the file _is_ the root then we don't want to list it
// Don't want to do this on _every_ file as very specific so do it here after we have
// weeded out files for more common reasons
if ( 0 == strcmp( $file[ 0 ], $root ) ) {
if ( 0 == strcmp( $file[0], $root ) ) {
unset( $files[ $key ] );
continue;
@ -958,7 +964,7 @@ class MainWP_Child_Back_Up_Buddy {
// Interesting file, get the path with the root prefix removed
// Note: root may be empty in which case the result will be the original filename
$unrooted_file = substr( $file[ 0 ], $root_len );
$unrooted_file = substr( $file[0], $root_len );
// We must ensure that we list the subdir/ even if subdir/ does not appear
// as a distinct entry in the list but only subdir/file or subdir/subsubdir/ or
@ -977,7 +983,7 @@ class MainWP_Child_Back_Up_Buddy {
$subdirs[] = $subdir;
// Replace the original (rooted) file name
$files[ $key ][ 0 ] = $subdir;
$files[ $key ][0] = $subdir;
} else {
@ -991,13 +997,17 @@ class MainWP_Child_Back_Up_Buddy {
// This is just like file within the root
// Replace the original (rooted) file name
$files[ $key ][ 0 ] = $unrooted_file;
$files[ $key ][0] = $unrooted_file;
}
}
return array('result' => 'SUCCESS', 'files' => $files, 'message' => implode('<br/>', $alerts));
return array(
'result' => 'SUCCESS',
'files' => $files,
'message' => implode('<br/>', $alerts),
);
}
function exclude_tree() {
@ -1058,9 +1068,9 @@ class MainWP_Child_Back_Up_Buddy {
}
$html = ob_get_clean();
return array('result' => $html);
return array( 'result' => $html );
} else {
return array('error' => 'Error #1127555. Unable to read child site root.');
return array( 'error' => 'Error #1127555. Unable to read child site root.' );
}
}
@ -1085,10 +1095,10 @@ class MainWP_Child_Back_Up_Buddy {
if ( true === $display_size ) {
// Fix up row count and average row length for InnoDB engine which returns inaccurate (and changing) values for these.
if ( 'InnoDB' === $result[ 'Engine' ] ) {
if ( 'InnoDB' === $result['Engine'] ) {
if ( false !== ( $rowCount = $wpdb->get_var( "SELECT COUNT(1) as rowCount FROM `{$rs[ 'Name' ]}`", ARRAY_A ) ) ) {
if ( 0 < ( $result[ 'Rows' ] = $rowCount ) ) {
$result[ 'Avg_row_length' ] = ( $result[ 'Data_length' ] / $result[ 'Rows' ] );
if ( 0 < ( $result['Rows'] = $rowCount ) ) {
$result['Avg_row_length'] = ( $result['Data_length'] / $result['Rows'] );
}
}
unset( $rowCount );
@ -1113,8 +1123,8 @@ class MainWP_Child_Back_Up_Buddy {
function restore_file_view() {
$archive_file = $_POST[ 'archive' ]; // archive to extract from.
$file = $_POST[ 'file' ]; // file to extract.
$archive_file = $_POST['archive']; // archive to extract from.
$file = $_POST['file']; // file to extract.
$serial = backupbuddy_core::get_serial_from_file( $archive_file ); // serial of archive.
$temp_file = uniqid(); // temp filename to extract into.
@ -1127,7 +1137,7 @@ class MainWP_Child_Back_Up_Buddy {
if ( ( ( ! file_exists( $destination ) ) && ( false === mkdir( $destination ) ) ) ) {
$error = 'Error #458485945b: Unable to create temporary location.';
pb_backupbuddy::status( 'error', $error );
return array('error' => $error);
return array( 'error' => $error );
}
// If temp directory is within webroot then lock it down.
@ -1165,14 +1175,17 @@ class MainWP_Child_Back_Up_Buddy {
}
}
return array( 'result' => 'SUCCESS', 'file_content' => $file_content );
return array(
'result' => 'SUCCESS',
'file_content' => $file_content,
);
}
function restore_file_restore() {
$files = $_POST[ 'files' ]; // file to extract.
$archive_file = $_POST[ 'archive' ]; // archive to extract from.
$files = $_POST['files']; // file to extract.
$archive_file = $_POST['archive']; // archive to extract from.
$files_array = explode( ',', $files );
$files = array();
@ -1180,7 +1193,7 @@ class MainWP_Child_Back_Up_Buddy {
if ( substr( $file, -1 ) == '/' ) { // If directory then add wildcard.
$file = $file . '*';
}
$files[$file] = $file;
$files[ $file ] = $file;
}
unset( $files_array );
@ -1198,7 +1211,7 @@ class MainWP_Child_Back_Up_Buddy {
$result = backupbuddy_restore_files::restore( backupbuddy_core::getBackupDirectory() . $archive_file, $files, $finalPath = ABSPATH );
$restore_result = ob_get_clean();
pb_backupbuddy::flush();
return array('restore_result' => $restore_result);
return array( 'restore_result' => $restore_result );
}
function get_backup_list( $type = 'default', $subsite_mode = false ) {
@ -1226,7 +1239,7 @@ class MainWP_Child_Back_Up_Buddy {
// Only allow viewing of their own backups.
if ( ! strstr( $file, $backup_prefix ) ) {
unset( $files[$file_id] ); // Remove this backup from the list. This user does not have access to it.
unset( $files[ $file_id ] ); // Remove this backup from the list. This user does not have access to it.
continue; // Skip processing to next file.
}
}
@ -1338,14 +1351,14 @@ class MainWP_Child_Back_Up_Buddy {
$integrity = 'n/a';
}
$backups[basename( $file )] = array(
$backups[ basename( $file ) ] = array(
array( basename( $file ), $main_string . '<br><span class="description" style="color: #AAA; display: inline-block; margin-top: 5px;">' . basename( $file ) . '</span>' ),
$detected_type,
$file_size,
$integrity,
);
$backup_sort_dates[basename( $file)] = $modified_time;
$backup_sort_dates[ basename( $file) ] = $modified_time;
} // End foreach().
@ -1356,8 +1369,8 @@ class MainWP_Child_Back_Up_Buddy {
// Re-arrange backups based on sort dates.
$sorted_backups = array();
foreach( $backup_sort_dates as $backup_file => $backup_sort_date ) {
$sorted_backups[$backup_file] = $backups[$backup_file];
unset( $backups[$backup_file] );
$sorted_backups[ $backup_file ] = $backups[ $backup_file ];
unset( $backups[ $backup_file ] );
}
unset( $backups );
return $sorted_backups;
@ -1476,11 +1489,11 @@ class MainWP_Child_Back_Up_Buddy {
$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;
}
@ -1497,11 +1510,11 @@ class MainWP_Child_Back_Up_Buddy {
$schedule_ids = explode(',', $schedule_ids);
if (empty($schedule_ids)) {
return array('error' => __( 'Empty schedule ids', 'mainwp-child' ));
return array( 'error' => __( 'Empty schedule ids', 'mainwp-child' ) );
}
foreach ($schedule_ids as $sch_id) {
if ( isset( pb_backupbuddy::$options['schedules'][$sch_id] ) ) {
unset( pb_backupbuddy::$options['schedules'][$sch_id] );
if ( isset( pb_backupbuddy::$options['schedules'][ $sch_id ] ) ) {
unset( pb_backupbuddy::$options['schedules'][ $sch_id ] );
}
}
pb_backupbuddy::save();
@ -1510,11 +1523,11 @@ class MainWP_Child_Back_Up_Buddy {
}
function view_log() {
$serial = $_POST[ 'serial' ];
$serial = $_POST['serial'];
$logFile = backupbuddy_core::getLogDirectory() . 'status-' . $serial . '_sum_' . pb_backupbuddy::$options['log_serial'] . '.txt';
if ( ! file_exists( $logFile ) ) {
return array('error' => 'Error #858733: Log file `' . $logFile . '` not found or access denied.' );
return array( 'error' => 'Error #858733: Log file `' . $logFile . '` not found or access denied.' );
}
$lines = file_get_contents( $logFile );
@ -1552,7 +1565,10 @@ class MainWP_Child_Back_Up_Buddy {
<?php
$html = ob_get_clean();
pb_backupbuddy::flush();
return array('result' => 'SUCCESS', 'html_log' => $html);
return array(
'result' => 'SUCCESS',
'html_log' => $html,
);
}
function view_detail() {
@ -1566,7 +1582,7 @@ class MainWP_Child_Back_Up_Buddy {
$optionsFile = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt';
$backup_options = new pb_backupbuddy_fileoptions( $optionsFile, $read_only = true );
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 );
}
ob_start();
$integrity = $backup_options->options['integrity'];
@ -1782,7 +1798,10 @@ class MainWP_Child_Back_Up_Buddy {
$html = ob_get_clean();
pb_backupbuddy::flush();
return array('result' => 'SUCCESS', 'html_detail' => $html);
return array(
'result' => 'SUCCESS',
'html_detail' => $html,
);
}
function reset_integrity() {
@ -1854,7 +1873,7 @@ class MainWP_Child_Back_Up_Buddy {
$requested_profile = $_POST['profile_id'];
if (!isset(pb_backupbuddy::$options['profiles'][ $requested_profile ])) {
return array('error' => 'Invalid Profile. Not found.');
return array( 'error' => 'Invalid Profile. Not found.' );
}
require_once pb_backupbuddy::plugin_path() . '/classes/backup.php';
@ -1874,9 +1893,9 @@ class MainWP_Child_Back_Up_Buddy {
'', // direction
'' // deployDestination
) !== true ) {
return array('error' => __('Fatal Error #4344443: Backup failure. Please see any errors listed in the Status Log for details.', 'it-l10n-backupbuddy' ));
return array( 'error' => __('Fatal Error #4344443: Backup failure. Please see any errors listed in the Status Log for details.', 'it-l10n-backupbuddy' ) );
}
return array('result' => 'SUCCESS');
return array( 'result' => 'SUCCESS' );
}
function start_backup() {
@ -1895,13 +1914,13 @@ class MainWP_Child_Back_Up_Buddy {
$data['direction'],
isset($data['deployDestination']) ? $data['deployDestination'] : ''
) !== true ) {
return array('error' => __('Fatal Error #4344443: Backup failure. Please see any errors listed in the Status Log for details.', 'it-l10n-backupbuddy' ));
return array( 'error' => __('Fatal Error #4344443: Backup failure. Please see any errors listed in the Status Log for details.', 'it-l10n-backupbuddy' ) );
}
} else {
return array('error' => 'Invalid backup request.');
return array( 'error' => 'Invalid backup request.' );
}
return array('ok' => 1);
return array( 'ok' => 1 );
}
function backup_status() {
@ -1912,15 +1931,18 @@ class MainWP_Child_Back_Up_Buddy {
backupbuddy_api::getBackupStatus( $data['serial'], $data['specialAction'], $data['initwaitretrycount'], $data['sqlFile'], $echo = true );
$result = ob_get_clean();
} else {
return array('error' => 'Invalid backup request.');
return array( 'error' => 'Invalid backup request.' );
}
return array('ok' => 1, 'result' => $result);
return array(
'ok' => 1,
'result' => $result,
);
}
function stop_backup() {
$serial = $_POST['serial'];
set_transient( 'pb_backupbuddy_stop_backup-' . $serial, true, ( 60*60*24 ) );
return array('ok' => 1);
return array( 'ok' => 1 );
}
function remote_save() {
@ -1930,7 +1952,7 @@ class MainWP_Child_Back_Up_Buddy {
if (is_array($data) && isset($data['do_not_override'])) {
if (true == $data['do_not_override']) {
if (($data['type'] == 's32' || $data['type'] == 's33')) {
if (( $data['type'] == 's32' || $data['type'] == 's33' )) {
$not_override = array(
'accesskey',
'secretkey',
@ -1938,8 +1960,8 @@ class MainWP_Child_Back_Up_Buddy {
'region',
);
foreach($not_override as $opt) {
if (isset($data[$opt])) {
unset($data[$opt]);
if (isset($data[ $opt ])) {
unset($data[ $opt ]);
}
}
}
@ -1949,16 +1971,16 @@ class MainWP_Child_Back_Up_Buddy {
}
if (is_array($data)) {
if (isset(pb_backupbuddy::$options['remote_destinations'][$destination_id])) { // update
pb_backupbuddy::$options['remote_destinations'][$destination_id] = array_merge( pb_backupbuddy::$options['remote_destinations'][$destination_id], $data );
if (isset(pb_backupbuddy::$options['remote_destinations'][ $destination_id ])) { // update
pb_backupbuddy::$options['remote_destinations'][ $destination_id ] = array_merge( pb_backupbuddy::$options['remote_destinations'][ $destination_id ], $data );
} else { // add new
$data['token'] = pb_backupbuddy::$options['dropboxtemptoken'];
pb_backupbuddy::$options['remote_destinations'][$destination_id] = $data;
pb_backupbuddy::$options['remote_destinations'][ $destination_id ] = $data;
}
pb_backupbuddy::save();
return array('ok' => 1);
return array( 'ok' => 1 );
} else {
return array('error' => 'Invalid request.');
return array( 'error' => 'Invalid request.' );
}
}
@ -1978,12 +2000,12 @@ class MainWP_Child_Back_Up_Buddy {
$delete_response = pb_backupbuddy_destinations::delete_destination( $destination_id, true );
if ( $delete_response !== true ) {
return array('error' => $delete_response);
return array( 'error' => $delete_response );
} else {
return array('ok' => 1);
return array( 'ok' => 1 );
}
} else {
return array('error' => 'Invalid request.');
return array( 'error' => 'Invalid request.' );
}
}
@ -1998,12 +2020,12 @@ class MainWP_Child_Back_Up_Buddy {
if ( ! file_exists( $backup_file ) ) { // Error if file to send did not exist!
$error_message = 'Unable to find file `' . $backup_file . '` to send. File does not appear to exist. You can try again in a moment or turn on full error logging and try again to log for support.';
pb_backupbuddy::status( 'error', $error_message );
return array( 'error' => $error_message);
return array( 'error' => $error_message );
}
if ( is_dir( $backup_file ) ) { // Error if a directory is trying to be sent.
$error_message = 'You are attempting to send a directory, `' . $backup_file . '`. Try again and verify there were no javascript errors.';
pb_backupbuddy::status( 'error', $error_message );
return array( 'error' => $error_message);
return array( 'error' => $error_message );
}
} else {
$backup_file = '';
@ -2025,19 +2047,19 @@ class MainWP_Child_Back_Up_Buddy {
pb_backupbuddy::status( 'details', 'Remote send NOT set to delete after successful send.' );
}
if ( !isset( pb_backupbuddy::$options['remote_destinations'][$destination_id] ) ) {
if ( !isset( pb_backupbuddy::$options['remote_destinations'][ $destination_id ] ) ) {
return array( 'error' => 'Error #833383: Invalid destination ID `' . htmlentities( $destination_id ) . '`.' );
}
// For Stash we will check the quota prior to initiating send.
if ( pb_backupbuddy::$options['remote_destinations'][$destination_id]['type'] == 'stash' ) {
if ( pb_backupbuddy::$options['remote_destinations'][ $destination_id ]['type'] == 'stash' ) {
// Pass off to destination handler.
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
$send_result = pb_backupbuddy_destinations::get_info( 'stash' ); // Used to kick the Stash destination into life.
$stash_quota = pb_backupbuddy_destination_stash::get_quota( pb_backupbuddy::$options['remote_destinations'][$destination_id], true );
$stash_quota = pb_backupbuddy_destination_stash::get_quota( pb_backupbuddy::$options['remote_destinations'][ $destination_id ], true );
if ( isset( $stash_quota['error'] ) ) {
return array( 'error' => ' Error accessing Stash account. Send aborted. Details: `' . implode( ' - ', $stash_quota['error'] ) . '`.');
return array( 'error' => ' Error accessing Stash account. Send aborted. Details: `' . implode( ' - ', $stash_quota['error'] ) . '`.' );
}
if ( $backup_file != '' ) {
@ -2067,7 +2089,7 @@ class MainWP_Child_Back_Up_Buddy {
if ( $schedule_result === false ) {
$error = 'Error scheduling file transfer. Please check your BackupBuddy error log for details. A plugin may have prevented scheduling or the database rejected it.';
pb_backupbuddy::status( 'error', $error );
return array( 'error' => $error);
return array( 'error' => $error );
} else {
pb_backupbuddy::status( 'details', 'Cron to send to remote destination scheduled.' );
}
@ -2075,7 +2097,7 @@ class MainWP_Child_Back_Up_Buddy {
update_option( '_transient_doing_cron', 0 ); // Prevent cron-blocking for next item.
spawn_cron( time() + 150 ); // Adds > 60 seconds to get around once per minute cron running limit.
}
return array( 'ok' => 1);
return array( 'ok' => 1 );
}
function get_main_log() {
@ -2087,7 +2109,7 @@ class MainWP_Child_Back_Up_Buddy {
echo __('Nothing has been logged.', 'it-l10n-backupbuddy' );
}
$result = ob_get_clean();
return array('result' => $result );
return array( 'result' => $result );
}
function settings_other() {
@ -2154,7 +2176,10 @@ class MainWP_Child_Back_Up_Buddy {
$message = 'Marked all timed out or running backups & transfers as officially cancelled (`' . $cancelCount . '` total found).';
}
return array('_error' => $error, '_message' => $message);
return array(
'_error' => $error,
'_message' => $message,
);
}
function malware_scan() {
@ -2217,14 +2242,14 @@ class MainWP_Child_Back_Up_Buddy {
$scan = wp_remote_get(
'http://sitecheck.sucuri.net/scanner/?scan=' . urlencode( $url ) . '&serialized&clear=true',
array(
'method' => 'GET',
'timeout' => 45,
'method' => 'GET',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array(),
'body' => null,
'cookies' => array(),
'blocking' => true,
'headers' => array(),
'body' => null,
'cookies' => array(),
)
);
@ -2266,7 +2291,7 @@ class MainWP_Child_Back_Up_Buddy {
if ( is_array( $array ) ) {
foreach( $array as $array_key => $array_item ) {
if ( is_array( $array_item ) ) {
$array[$array_key] = lined_array( $array_item );
$array[ $array_key ] = lined_array( $array_item );
}
}
//return implode( '<br />', $array );
@ -2450,7 +2475,7 @@ class MainWP_Child_Back_Up_Buddy {
}
$result = ob_get_clean();
return array('result' => $result);
return array( 'result' => $result );
}
@ -2459,10 +2484,10 @@ class MainWP_Child_Back_Up_Buddy {
$errors = array();
$archive_types = array(
'db' => __( 'Database Backup', 'it-l10n-backupbuddy' ),
'full' => __( 'Full Backup', 'it-l10n-backupbuddy' ),
'db' => __( 'Database Backup', 'it-l10n-backupbuddy' ),
'full' => __( 'Full Backup', 'it-l10n-backupbuddy' ),
'plugins' => __( 'Plugins Backup', 'it-l10n-backupbuddy' ),
'themes' => __( 'Themes Backup', 'it-l10n-backupbuddy' ),
'themes' => __( 'Themes Backup', 'it-l10n-backupbuddy' ),
);
$archive_periods = array(
@ -2525,7 +2550,7 @@ class MainWP_Child_Back_Up_Buddy {
foreach( $archive_types as $archive_type => $archive_type_name ) {
foreach( $archive_periods as $archive_period ) {
$settings_name = 'limit_' . $archive_type . '_' . $archive_period;
pb_backupbuddy::$options['remote_destinations'][ $nextDestKey ][ $settings_name ] = $_POST['live_settings'][$settings_name];
pb_backupbuddy::$options['remote_destinations'][ $nextDestKey ][ $settings_name ] = $_POST['live_settings'][ $settings_name ];
}
}
@ -2562,7 +2587,10 @@ class MainWP_Child_Back_Up_Buddy {
if ( 0 == count( $errors ) ) {
pb_backupbuddy::save();
$data = pb_backupbuddy::$options['remote_destinations'][ $destination_id ];
return array( 'destination_id' => $destination_id, 'data' => $data);
return array(
'destination_id' => $destination_id,
'data' => $data,
);
} else {
return array( 'errors' => $errors );
}
@ -2577,7 +2605,7 @@ class MainWP_Child_Back_Up_Buddy {
require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php';
$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;
@ -2588,10 +2616,10 @@ class MainWP_Child_Back_Up_Buddy {
$destination_settings = array_merge( $destination_settings, $data );
$destination_settings['itxapi_username'] = $itxapi_username;
$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) {
unset(pb_backupbuddy::$options['remote_destinations'][$destination_id]);
unset(pb_backupbuddy::$options['remote_destinations'][ $destination_id ]);
}
pb_backupbuddy::save();
@ -2599,11 +2627,11 @@ class MainWP_Child_Back_Up_Buddy {
set_transient( 'backupbuddy_live_jump', array( 'daily_init', array() ), 60*60*48 ); // Tells Live process to restart from the beginning (if mid-process) so new settigns apply.
backupbuddy_live::send_trim_settings();
return array('ok' => 1);
return array( 'ok' => 1 );
} else {
$error = 'Invalid data. Please check and try again.';
}
return array('error' => $error);
return array( 'error' => $error );
}
function live_action_disconnect() {
@ -2662,7 +2690,7 @@ class MainWP_Child_Back_Up_Buddy {
} elseif ( 'pause_periodic' == $action ) {
backupbuddy_api::setLiveStatus( $pause_continuous = '', $pause_periodic = true );
$destination = pb_backupbuddy::$options['remote_destinations'][$destination_id]; // Update local var.
$destination = pb_backupbuddy::$options['remote_destinations'][ $destination_id ]; // Update local var.
//pb_backupbuddy::disalert( '', __( 'Live File Backup paused. It may take a moment for current processes to finish.', 'it-l10n-backupbuddy' ) );
$message = __( 'Live File Backup paused. It may take a moment for current processes to finish.', 'it-l10n-backupbuddy' );
include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats.
@ -2680,13 +2708,13 @@ class MainWP_Child_Back_Up_Buddy {
include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats.
} elseif ( 'pause_continuous' == $action ) {
backupbuddy_api::setLiveStatus( $pause_continuous = true, $pause_periodic = '' );
$destination = pb_backupbuddy::$options['remote_destinations'][$destination_id]; // Update local var.
$destination = pb_backupbuddy::$options['remote_destinations'][ $destination_id ]; // Update local var.
include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats.
//pb_backupbuddy::disalert( '', __( 'Live Database Backup paused.', 'it-l10n-backupbuddy' ) );
$message = __( 'Live Database Backup paused.', 'it-l10n-backupbuddy' );
} elseif ( 'resume_continuous' == $action ) {
backupbuddy_api::setLiveStatus( $pause_continuous = false, $pause_periodic = '' );
$destination = pb_backupbuddy::$options['remote_destinations'][$destination_id]; // Update local var.
$destination = pb_backupbuddy::$options['remote_destinations'][ $destination_id ]; // Update local var.
include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats.
//pb_backupbuddy::disalert( '', __( 'Live Database Backup resumed.', 'it-l10n-backupbuddy' ) );
$message = __( 'Live Database Backup resumed.', 'it-l10n-backupbuddy' );
@ -2694,7 +2722,11 @@ class MainWP_Child_Back_Up_Buddy {
$error = 'Error #1000. Invalid request.';
}
return array( 'ok' => 1, '_error' => $error, '_message' => $message );
return array(
'ok' => 1,
'_error' => $error,
'_message' => $message,
);
}
@ -2704,7 +2736,10 @@ class MainWP_Child_Back_Up_Buddy {
backupbuddy_live_troubleshooting::run();
$output = "**File best viewed with wordwrap OFF**\n\n" . print_r( backupbuddy_live_troubleshooting::get_raw_results(), true );
$backup_prefix = backupbuddy_core::backup_prefix();
return array( 'output' => $output, 'backup_prefix' => $backup_prefix );
return array(
'output' => $output,
'backup_prefix' => $backup_prefix,
);
}
function get_live_backups() {
@ -2747,19 +2782,19 @@ class MainWP_Child_Back_Up_Buddy {
$backup_type = backupbuddy_core::getBackupTypeFromFile( $file['filename'], $quiet = false, $skip_fileoptions = true );
// Generate array of table rows.
while( isset( $backup_list_temp[$last_modified] ) ) { // Avoid collisions.
while( isset( $backup_list_temp[ $last_modified ] ) ) { // Avoid collisions.
$last_modified += 0.1;
}
if ( 'live' == $destination['type'] ) {
$backup_list_temp[$last_modified] = array(
$backup_list_temp[ $last_modified ] = array(
array( base64_encode( $file['url'] ), '<span class="backupbuddy-stash-file-list-title">' . pb_backupbuddy::$format->date( pb_backupbuddy::$format->localize_time( $last_modified ) ) . ' <span class="description">(' . pb_backupbuddy::$format->time_ago( $last_modified ) . ' ago)</span></span><br><span title="' . $file['filename'] . '">' . basename( $file['filename'] ) . '</span>' ),
pb_backupbuddy::$format->date( pb_backupbuddy::$format->localize_time( $last_modified ) ) . '<br /><span class="description">(' . pb_backupbuddy::$format->time_ago( $last_modified ) . ' ago)</span>',
pb_backupbuddy::$format->file_size( $size ),
backupbuddy_core::pretty_backup_type( $backup_type ),
);
} else {
$backup_list_temp[$last_modified] = array(
$backup_list_temp[ $last_modified ] = array(
array( base64_encode( $file['url'] ), '<span title="' . $file['filename'] . '">' . basename( $file['filename'] ) . '</span>' ),
pb_backupbuddy::$format->date( pb_backupbuddy::$format->localize_time( $last_modified ) ) . '<br /><span class="description">(' . pb_backupbuddy::$format->time_ago( $last_modified ) . ' ago)</span>',
pb_backupbuddy::$format->file_size( $size ),
@ -2835,7 +2870,10 @@ class MainWP_Child_Back_Up_Buddy {
$msg = 'Failed to delete one or more files. Details: `' . $response . '`.';
}
return array( 'ok' => 1, 'msg' => $msg );
return array(
'ok' => 1,
'msg' => $msg,
);
}
function get_live_stats() {
@ -2843,11 +2881,11 @@ class MainWP_Child_Back_Up_Buddy {
// Check if running PHP 5.3+.
$php_minimum = 5.3;
if ( version_compare( PHP_VERSION, $php_minimum, '<' ) ) { // Server's PHP is insufficient.
return array('error' => '-1');
return array( 'error' => '-1' );
}
if ( false === ( $stats = backupbuddy_api::getLiveStats() ) ) { // Live is disconnected.
return array('error' => '-1');
return array( 'error' => '-1' );
}
// If there is more to do and too long of time has passed since activity then try to jumpstart the process at the beginning.
@ -2890,14 +2928,14 @@ class MainWP_Child_Back_Up_Buddy {
}
return array('result' => json_encode( $stats ));
return array( 'result' => json_encode( $stats ) );
}
function save_license_settings() {
$settings = $_POST['settings'];
if (is_array($settings) && isset($GLOBALS['ithemes-updater-settings'])) {
$GLOBALS['ithemes-updater-settings']->update_options( $settings );
return array('ok' => 1);
return array( 'ok' => 1 );
}
return false;
}
@ -2917,12 +2955,16 @@ class MainWP_Child_Back_Up_Buddy {
$packages = isset($details['packages']) ? $details['packages'] : array();
if (is_array($packages)) {
foreach ( $packages as $path => $data ) {
$packages_name[$path] = Ithemes_Updater_Functions::get_package_name( $data['package'] );
$packages_name[ $path ] = Ithemes_Updater_Functions::get_package_name( $data['package'] );
}
}
}
return array('ok' => 1, 'packages' => $packages, 'packages_name' => $packages_name);
return array(
'ok' => 1,
'packages' => $packages,
'packages_name' => $packages_name,
);
}
function activate_package() {
@ -2970,9 +3012,9 @@ class MainWP_Child_Back_Up_Buddy {
if ( ! empty( $data['key'] ) ) {
$success[] = $name;
} elseif ( ! empty( $data['status'] ) && ( 'expired' == $data['status'] ) ) {
$warn[$name] = __( 'Your product subscription has expired', 'it-l10n-backupbuddy' );
$warn[ $name ] = __( 'Your product subscription has expired', 'it-l10n-backupbuddy' );
} else {
$fail[$name] = $data['error']['message'];
$fail[ $name ] = $data['error']['message'];
}
}
@ -3044,9 +3086,9 @@ class MainWP_Child_Back_Up_Buddy {
if ( isset( $data['status'] ) && ( 'inactive' == $data['status'] ) ) {
$success[] = $name;
} elseif ( isset( $data['error'] ) && isset( $data['error']['message'] ) ) {
$fail[$name] = $data['error']['message'];
$fail[ $name ] = $data['error']['message'];
} else {
$fail[$name] = __( 'Unknown server error.', 'it-l10n-mainwp-backupbuddy' );
$fail[ $name ] = __( 'Unknown server error.', 'it-l10n-mainwp-backupbuddy' );
}
}

View file

@ -1148,7 +1148,7 @@ class MainWP_Child_Back_Up_Wordpress {
}
}
return array('result' => 'SUCCESS');
return array( 'result' => 'SUCCESS' );
}

View file

@ -247,7 +247,7 @@ class MainWP_Child_Back_WP_Up {
try {
MainWP_Helper::check_classes_exists(array('BackWPup_File', 'BackWPup_Job'));
MainWP_Helper::check_classes_exists(array( 'BackWPup_File', 'BackWPup_Job' ));
MainWP_Helper::check_methods('BackWPup_File', array( 'get_absolute_path' ));
MainWP_Helper::check_methods('BackWPup_Job', array( 'read_logheader' ));
@ -280,23 +280,23 @@ class MainWP_Child_Back_WP_Up {
continue; // do not logging backups have errors
}
$log_items[$mtime] = $meta;
$log_items[$mtime]['file'] = $logfile;
$log_items[ $mtime ] = $meta;
$log_items[ $mtime ]['file'] = $logfile;
}
if ( !empty( $log_items ) ) {
$job_types = array(
'DBDUMP' => __('Database backup', 'mainwp-child'),
'FILE' => __('File backup', 'mainwp-child'),
'WPEXP' => __('WordPress XML export', 'mainwp-child'),
'DBDUMP' => __('Database backup', 'mainwp-child'),
'FILE' => __('File backup', 'mainwp-child'),
'WPEXP' => __('WordPress XML export', 'mainwp-child'),
'WPPLUGIN' => __('Installed plugins list', 'mainwp-child'),
'DBCHECK' => __('Check database tables', 'mainwp-child'),
'DBCHECK' => __('Check database tables', 'mainwp-child'),
);
$new_lasttime_logged = $lasttime_logged;
foreach ($log_items as $log) {
$backup_time = $log[ 'logtime' ];
$backup_time = $log['logtime'];
if ($backup_time < $lasttime_logged) {
// small than last backup time then skip
continue;
@ -304,8 +304,8 @@ class MainWP_Child_Back_WP_Up {
$job_job_types = explode('+', $log['type']);
$backup_type = '';
foreach($job_job_types as $typeid) {
if (isset( $job_types[$typeid] )) {
$backup_type .= ' + ' . $job_types[$typeid];
if (isset( $job_types[ $typeid ] )) {
$backup_type .= ' + ' . $job_types[ $typeid ];
}
}
@ -347,7 +347,7 @@ class MainWP_Child_Back_WP_Up {
}
function get_destinations_list() {
MainWP_Helper::check_classes_exists(array('BackWPup', 'BackWPup_Option'));
MainWP_Helper::check_classes_exists(array( 'BackWPup', 'BackWPup_Option' ));
MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' ));
MainWP_Helper::check_methods('BackWPup_Option', array( 'get_job_ids', 'get' ));
@ -360,7 +360,7 @@ class MainWP_Child_Back_WP_Up {
}
$dests = BackWPup_Option::get( $jobid, 'destinations' );
foreach ( $dests as $dest ) {
if ( ! $destinations[ $dest ][ 'class' ] ) {
if ( ! $destinations[ $dest ]['class'] ) {
continue;
}
@ -368,7 +368,7 @@ class MainWP_Child_Back_WP_Up {
if ($dest_class && method_exists($dest_class, 'file_get_list')) {
$can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest );
if ( ! empty( $can_do_dest ) ) {
$jobdest[ ] = $jobid . '_' . $dest;
$jobdest[] = $jobid . '_' . $dest;
}
}
}
@ -537,7 +537,10 @@ class MainWP_Child_Back_WP_Up {
ob_end_clean();
return array( 'success' => 1, 'response' => $output );
return array(
'success' => 1,
'response' => $output,
);
}
protected function delete_log() {
@ -606,11 +609,17 @@ class MainWP_Child_Back_WP_Up {
if ( is_array( $file ) && $file['file'] == $backupfile ) {
$dest_class->file_delete( $dest, $backupfile );
return array( 'success' => 1, 'response' => 'DELETED' );
return array(
'success' => 1,
'response' => 'DELETED',
);
}
}
return array( 'success' => 1, 'response' => 'Not found' );
return array(
'success' => 1,
'response' => 'Not found',
);
}
protected function view_log() {
@ -640,7 +649,10 @@ class MainWP_Child_Back_WP_Up {
}
}
return array( 'success' => 1, 'response' => $output );
return array(
'success' => 1,
'response' => $output,
);
}
protected function tables() {
@ -666,7 +678,10 @@ class MainWP_Child_Back_WP_Up {
$log_folder = untrailingslashit( $log_folder );
if ( ! is_dir( $log_folder ) ) {
return array( 'success' => 1, 'response' => $array );
return array(
'success' => 1,
'response' => $array,
);
}
update_user_option( get_current_user_id(), 'backwpuplogs_per_page', 99999999 );
$output = new BackWPup_Page_Logs();
@ -697,7 +712,7 @@ class MainWP_Child_Back_WP_Up {
foreach ( $items as $item ) {
$temp_single_item = $item;
$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;
}
}
@ -785,7 +800,10 @@ class MainWP_Child_Back_WP_Up {
}
}
return array( 'success' => 1, 'response' => $array );
return array(
'success' => 1,
'response' => $array,
);
}
public function init_download_backup() {
@ -902,7 +920,10 @@ class MainWP_Child_Back_WP_Up {
ob_end_clean();
return array( 'success' => 1, 'response' => $output );
return array(
'success' => 1,
'response' => $output,
);
}
protected function backup_now() {
@ -938,7 +959,10 @@ class MainWP_Child_Back_WP_Up {
'logfile' => basename( $job_object->logfile ),
);
} else {
return array( 'success' => 1, 'response' => $output['message'] );
return array(
'success' => 1,
'response' => $output['message'],
);
}
}
}
@ -960,7 +984,10 @@ class MainWP_Child_Back_WP_Up {
if ( isset( $output['error'] ) ) {
return array( 'error' => 'Cannot abort: ' . $output['error'] );
} else {
return array( 'success' => 1, 'response' => $output['message'] );
return array(
'success' => 1,
'response' => $output['message'],
);
}
}
@ -993,7 +1020,10 @@ class MainWP_Child_Back_WP_Up {
ob_end_clean();
return array( 'success' => 1, 'response' => $output );
return array(
'success' => 1,
'response' => $output,
);
} else {
return array( 'error' => 'Missing BackWPup_Pro_Wizard_SystemTest' );
}
@ -1092,7 +1122,10 @@ class MainWP_Child_Back_WP_Up {
}
}
return array( 'success' => 1, 'message' => $message );
return array(
'success' => 1,
'message' => $message,
);
}
protected function get_job_files() {
@ -1158,11 +1191,18 @@ class MainWP_Child_Back_WP_Up {
@closedir( $dir );
}
$return[ $key ] = array( 'size' => $main_folder_size, 'name' => $folder, 'folders' => $return_temp );
$return[ $key ] = array(
'size' => $main_folder_size,
'name' => $folder,
'folders' => $return_temp,
);
}
}
return array( 'success' => 1, 'folders' => $return );
return array(
'success' => 1,
'folders' => $return,
);
}
protected function get_child_tables() {
@ -1217,7 +1257,10 @@ class MainWP_Child_Back_WP_Up {
if (isset($settings['job_id'])) {
$return['dbdumpexclude'] = BackWPup_Option::get( $settings['job_id'], 'dbdumpexclude' );
}
return array( 'success' => 1, 'return' => $return );
return array(
'success' => 1,
'return' => $return,
);
}
protected function insert_or_update_jobs_global() {
@ -1298,7 +1341,7 @@ class MainWP_Child_Back_WP_Up {
$to_exclude_parsed = array();
foreach ( $to_exclude as $key => $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 );
BackWPup_Option::update( $id, 'fileexclude', implode( ',', $to_exclude_parsed ) );
@ -1313,7 +1356,7 @@ class MainWP_Child_Back_WP_Up {
$normalized = trailingslashit( wp_normalize_path( trim( $value ) ) );
$normalized and $normalized = filter_var( $normalized, FILTER_SANITIZE_URL );
$realpath = $normalized && $normalized !== '/' ? realpath( $normalized ) : false;
$realpath and $to_include_parsed[$key] = $realpath;
$realpath and $to_include_parsed[ $key ] = $realpath;
}
sort( $to_include_parsed );
BackWPup_Option::update( $id, 'dirinclude', implode( ',', $to_include_parsed ) );
@ -1332,18 +1375,33 @@ class MainWP_Child_Back_WP_Up {
);
foreach( $boolean_fields_def as $key => $value ) {
BackWPup_Option::update( $id, $key, ! empty( $post_data[$key] ) );
BackWPup_Option::update( $id, $key, ! empty( $post_data[ $key ] ) );
}
// Parse and save directories to exclude
$exclude_dirs_def = array(
'backuprootexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
'backuppluginsexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
'backupcontentexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
'backupthemesexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
'backupuploadsexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
'backuprootexcludedirs' => array(
'filter' => FILTER_SANITIZE_URL,
'flags' => FILTER_FORCE_ARRAY,
),
'backuppluginsexcludedirs' => array(
'filter' => FILTER_SANITIZE_URL,
'flags' => FILTER_FORCE_ARRAY,
),
'backupcontentexcludedirs' => array(
'filter' => FILTER_SANITIZE_URL,
'flags' => FILTER_FORCE_ARRAY,
),
'backupthemesexcludedirs' => array(
'filter' => FILTER_SANITIZE_URL,
'flags' => FILTER_FORCE_ARRAY,
),
'backupuploadsexcludedirs' => array(
'filter' => FILTER_SANITIZE_URL,
'flags' => FILTER_FORCE_ARRAY,
),
);
foreach( $exclude_dirs_def as $key => $filter ) {
$value = ! empty( $post_data[$key] ) && is_array( $post_data[$key] ) ? $post_data[$key] : array();
$value = ! empty( $post_data[ $key ] ) && is_array( $post_data[ $key ] ) ? $post_data[ $key ] : array();
BackWPup_Option::update( $id, $key, $value );
}
}
@ -1514,7 +1572,11 @@ class MainWP_Child_Back_WP_Up {
}
}
return array( 'success' => 1, 'changes' => $changes_array, 'message' => $return['message'] );
return array(
'success' => 1,
'changes' => $changes_array,
'message' => $return['message'],
);
}
protected function check_backwpup_messages() {

View file

@ -146,8 +146,8 @@ class MainWP_Child_Branding {
);
foreach($brandingOptions_empty as $opt) {
if (isset($this->child_branding_options[$opt])) {
$this->child_branding_options[$opt] = '';
if (isset($this->child_branding_options[ $opt ])) {
$this->child_branding_options[ $opt ] = '';
}
}
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options );
@ -233,8 +233,8 @@ class MainWP_Child_Branding {
'remove_widget_activity' => $settings['child_remove_widget_activity'],
'remove_widget_quick' => $settings['child_remove_widget_quick'],
'remove_widget_news' => $settings['child_remove_widget_news'],
'login_image_link' => $settings['child_login_image_link'],
'login_image_title' => $settings['child_login_image_title'],
'login_image_link' => $settings['child_login_image_link'],
'login_image_title' => $settings['child_login_image_title'],
'site_generator' => $settings['child_site_generator'],
'generator_link' => $settings['child_generator_link'],
'admin_css' => $settings['child_admin_css'],
@ -268,7 +268,10 @@ class MainWP_Child_Branding {
try {
$upload = $this->uploadImage( $settings['child_login_image_url'] ); //Upload image to WP
if ( null !== $upload ) {
$extra_setting['login_image'] = array( 'path' => $upload['path'], 'url' => $upload['url'] );
$extra_setting['login_image'] = array(
'path' => $upload['path'],
'url' => $upload['url'],
);
if ( isset( $current_extra_setting['login_image']['path'] ) ) {
$old_file = $current_extra_setting['login_image']['path'];
if ( ! empty( $old_file ) && file_exists( $old_file ) ) {
@ -291,7 +294,10 @@ class MainWP_Child_Branding {
try {
$upload = $this->uploadImage( $settings['child_favico_image_url'] ); //Upload image to WP
if ( null !== $upload ) {
$extra_setting['favico_image'] = array( 'path' => $upload['path'], 'url' => $upload['url'] );
$extra_setting['favico_image'] = array(
'path' => $upload['path'],
'url' => $upload['url'],
);
if ( isset( $current_extra_setting['favico_image']['path'] ) ) {
$old_file = $current_extra_setting['favico_image']['path'];
if ( ! empty( $old_file ) && file_exists( $old_file ) ) {
@ -364,7 +370,10 @@ class MainWP_Child_Branding {
$local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
$moved = @rename( $temporary_file, $local_img_path );
if ( $moved ) {
return array( 'path' => $local_img_path, 'url' => $local_img_url );
return array(
'path' => $local_img_path,
'url' => $local_img_url,
);
}
}
if ( file_exists( $temporary_file ) ) {
@ -431,7 +440,7 @@ class MainWP_Child_Branding {
}
add_action( 'admin_head', array( &$this, 'admin_head_hide_elements' ), 15 );
add_action( 'admin_menu', array($this, 'branding_redirect' ), 9);
add_action( 'admin_menu', array( $this, 'branding_redirect' ), 9);
}
// to fix
@ -458,7 +467,7 @@ class MainWP_Child_Branding {
}
if ( isset( $extra_setting['hide_nag'] ) && ! empty( $extra_setting['hide_nag'] ) ) {
add_action( 'admin_init', array($this, 'admin_init'));
add_action( 'admin_init', array( $this, 'admin_init' ));
}
add_action( 'admin_menu', array( &$this, 'remove_default_post_metaboxes' ) );
@ -989,7 +998,7 @@ class MainWP_Child_Branding {
}
public function save_branding_options( $name, $val ) {
$this->child_branding_options[$name] = $val;
$this->child_branding_options[ $name ] = $val;
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options );
}

View file

@ -140,7 +140,7 @@ class MainWP_Child_iThemes_Security {
add_action( 'admin_menu', array( $this, 'remove_menu' ) );
add_action( 'admin_init', array( $this, 'admin_init' ) );
add_action( 'admin_head', array( &$this, 'custom_admin_css' ) );
if ( isset($_GET['page']) && ($_GET['page'] == 'itsec' || $_GET['page'] == 'itsec-security-check') ) {
if ( isset($_GET['page']) && ( $_GET['page'] == 'itsec' || $_GET['page'] == 'itsec-security-check' ) ) {
wp_redirect( get_option( 'siteurl' ) . '/wp-admin/index.php' );
exit();
}
@ -219,7 +219,7 @@ class MainWP_Child_iThemes_Security {
} elseif ($module == 'global') {
$keep_olds = array( 'did_upgrade', 'log_info', 'show_new_dashboard_notice', 'show_security_check', 'nginx_file' );
foreach($keep_olds as $key) {
$settings[$key] = ITSEC_Modules::get_setting( $module, $key ); // not update
$settings[ $key ] = ITSEC_Modules::get_setting( $module, $key ); // not update
}
if (!isset($settings['log_location']) || empty($settings['log_location']) ) {
@ -280,14 +280,14 @@ class MainWP_Child_iThemes_Security {
} elseif ($module == 'notification-center') {
$current_settings = ITSEC_Modules::get_settings( $module );
if (isset($settings['notifications'])) {
$update_fields = array( 'schedule', 'enabled', 'subject');
$update_fields = array( 'schedule', 'enabled', 'subject' );
if (isset($_POST['is_individual']) && $_POST['is_individual']) {
$update_fields = array_merge($update_fields, array('user_list', 'email_list'));
$update_fields = array_merge($update_fields, array( 'user_list', 'email_list' ));
}
foreach ($settings['notifications'] as $key => $val) {
foreach ($update_fields as $field) {
if(isset($val[$field])) {
$current_settings['notifications'][$key][$field] = $val[$field];
if(isset($val[ $field ])) {
$current_settings['notifications'][ $key ][ $field ] = $val[ $field ];
}
}
}
@ -307,7 +307,7 @@ class MainWP_Child_iThemes_Security {
if ( isset( $update_settings['itsec_active_modules'] ) ) {
$current_val = get_site_option( 'itsec_active_modules', array() );
foreach ($update_settings['itsec_active_modules'] as $mod => $val) {
$current_val[$mod] = $val;
$current_val[ $mod ] = $val;
}
update_site_option( 'itsec_active_modules', $current_val );
}
@ -326,10 +326,10 @@ class MainWP_Child_iThemes_Security {
'lockouts_host' => $this->get_lockouts( 'host', true ),
'lockouts_user' => $this->get_lockouts( 'user', true ),
'lockouts_username' => $this->get_lockouts( 'username', true ),
'default_log_location' => ITSEC_Modules::get_default( 'global', 'log_location' ),
'default_location' => ITSEC_Modules::get_default( 'backup', 'location' ),
'excludable_tables' => $this->get_excludable_tables(),
'users_and_roles' => $this->get_available_admin_users_and_roles(),
'default_log_location' => ITSEC_Modules::get_default( 'global', 'log_location' ),
'default_location' => ITSEC_Modules::get_default( 'backup', 'location' ),
'excludable_tables' => $this->get_excludable_tables(),
'users_and_roles' => $this->get_available_admin_users_and_roles(),
);
$return = array(
@ -670,7 +670,7 @@ class MainWP_Child_iThemes_Security {
<br />
<?php
$html = ob_get_clean();
return array('html' => $html);
return array( 'html' => $html );
}
public function file_change() {
@ -867,7 +867,11 @@ class MainWP_Child_iThemes_Security {
'rule' => "define( 'WP_CONTENT_DIR', '" . $new_dir . "' );",
);
$rules_array[] = array( 'type' => 'wpconfig', 'name' => 'Content Directory', 'rules' => $rules );
$rules_array[] = array(
'type' => 'wpconfig',
'name' => 'Content Directory',
'rules' => $rules,
);
return $rules_array;
}
@ -1113,18 +1117,18 @@ class MainWP_Child_iThemes_Security {
$current_val = get_site_option( 'itsec_active_modules', array() );
foreach ($active_modules as $mod => $val) {
$current_val[$mod] = $val;
$current_val[ $mod ] = $val;
}
update_site_option( 'itsec_active_modules', $current_val );
return array('result' => 'success');
return array( 'result' => 'success' );
}
private function reload_backup_exclude() {
return array(
'exclude' => ITSEC_Modules::get_setting( 'backup', 'exclude' ),
'exclude' => ITSEC_Modules::get_setting( 'backup', 'exclude' ),
'excludable_tables' => $this->get_excludable_tables(),
'result' => 'success',
'result' => 'success',
);
}
@ -1161,7 +1165,7 @@ class MainWP_Child_iThemes_Security {
continue;
}
$excludes[$short_table] = $table[0];
$excludes[ $short_table ] = $table[0];
}
return $excludes;
@ -1175,7 +1179,10 @@ class MainWP_Child_iThemes_Security {
ob_start();
ITSEC_Security_Check_Feedback_Renderer::render( $results );
$response = ob_get_clean();
return array('result' => 'success', 'response' => $response);
return array(
'result' => 'success',
'response' => $response,
);
}
// source from itheme plugin
@ -1192,7 +1199,7 @@ class MainWP_Child_iThemes_Security {
foreach ( $roles->roles as $role => $details ) {
if ( isset( $details['capabilities']['manage_options'] ) && ( true === $details['capabilities']['manage_options'] ) ) {
$available_roles["role:$role"] = translate_user_role( $details['name'] );
$available_roles[ "role:$role" ] = translate_user_role( $details['name'] );
$users = get_users( array( 'role' => $role ) );

View file

@ -83,7 +83,7 @@ class MainWP_Child_Links_Checker {
}
MainWP_Helper::write( $information );
} catch(Exception $e) {
MainWP_Helper::write( array('error' => $e->getMessage()) );
MainWP_Helper::write( array( 'error' => $e->getMessage() ) );
}
}
@ -270,9 +270,9 @@ class MainWP_Child_Links_Checker {
if ($offset){
$total_sync = $offset;
}
$total_sync += (is_array($link_data) ? count($link_data) : 0);
$total_sync += ( is_array($link_data) ? count($link_data) : 0 );
$information = array('links_data' => $link_data);
$information = array( 'links_data' => $link_data );
if ($first_sync) {
$information['data'] = $this->get_count_links();
@ -393,7 +393,7 @@ class MainWP_Child_Links_Checker {
if ( ! empty( $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();
$extra_info['count_instance'] = count( $instances );
@ -657,7 +657,7 @@ class MainWP_Child_Links_Checker {
$image = 'font-awesome/font-awesome-comment-alt.png';
}
if (true !== MainWP_Helper::check_methods($container, array( 'get_wrapped_object'), true )) {
if (true !== MainWP_Helper::check_methods($container, array( 'get_wrapped_object' ), true )) {
return false;
}

View file

@ -82,7 +82,7 @@ class MainWP_Child_Pagespeed {
if ( get_option( 'mainwp_pagespeed_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'hide_plugin' ) );
add_action('admin_menu', array($this, 'hide_menu'), 999);
add_action('admin_menu', array( $this, 'hide_menu' ), 999);
}
$this->init_cron();
}
@ -130,7 +130,7 @@ class MainWP_Child_Pagespeed {
if (isset($submenu['tools.php'])) {
foreach($submenu['tools.php'] as $key => $menu) {
if ($menu[2] == 'google-pagespeed-insights') {
unset($submenu['tools.php'][$key]);
unset($submenu['tools.php'][ $key ]);
break;
}
}
@ -483,7 +483,7 @@ class MainWP_Child_Pagespeed {
if($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) {
if($post_type == $restrict_type) {
$typestocheck[] = 'type = %s';
$types[1][] = $custom_post_types[$post_type];
$types[1][] = $custom_post_types[ $post_type ];
}
}
}
@ -492,7 +492,7 @@ class MainWP_Child_Pagespeed {
{
if($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) {
$typestocheck[] = 'type = %s';
$types[1][] = $custom_post_types[$post_type];
$types[1][] = $custom_post_types[ $post_type ];
}
}
}

View file

@ -1056,10 +1056,10 @@ class MainWP_Child_Server_Information {
<td><?php echo( self::filesize_compare( $currentVersion, $pVersion, $pCompare ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::getWarningHTML( $errorType ) ); ?></td>
<?php } elseif ( $whatType == 'curlssl' ) { ?>
<td><?php echo( self::curlssl_compare( $pVersion, $pCompare ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::getWarningHTML( $errorType ) ); ?></td>
<?php } elseif (($pGetter == 'getMaxInputTime' || $pGetter == 'getMaxExecutionTime') && $currentVersion == -1) { ?>
<?php } elseif (( $pGetter == 'getMaxInputTime' || $pGetter == 'getMaxExecutionTime' ) && $currentVersion == -1) { ?>
<td><?php echo '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>'; ?></td>
<?php } else { ?>
<td><?php echo (version_compare($currentVersion, $pVersion, $pCompare) || (($pExtraCompare != null) && version_compare($currentVersion, $pExtraVersion, $pExtraCompare)) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::getWarningHTML( $errorType )); ?></td>
<td><?php echo ( version_compare($currentVersion, $pVersion, $pCompare) || ( ( $pExtraCompare != null ) && version_compare($currentVersion, $pExtraVersion, $pExtraCompare) ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::getWarningHTML( $errorType ) ); ?></td>
<?php } ?>
</tr>
<?php
@ -1329,11 +1329,12 @@ class MainWP_Child_Server_Information {
protected static function serverSelfConnect() {
$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 );
$args = array( 'blocking' => true,
'sslverify' => apply_filters( 'https_local_ssl_verify', true ),
'timeout' => 15,
$args = array(
'blocking' => true,
'sslverify' => apply_filters( 'https_local_ssl_verify', true ),
'timeout' => 15,
);
$response = wp_remote_post( $url, $args );
$test_result = '';
@ -1637,32 +1638,32 @@ class MainWP_Child_Server_Information {
'siteurl' => array(
'title' => __('Site URL', 'mainwp-child'),
'value' => get_bloginfo( 'url' ),
'desc' => get_bloginfo( 'url' ),
'desc' => get_bloginfo( 'url' ),
),
'adminuser' => array(
'title' => __('Administrator name', 'mainwp-child'),
'value' => $current_user->user_login,
'desc' => __('This is your Administrator username, however, you can use any existing Administrator username.', 'mainwp-child'),
'desc' => __('This is your Administrator username, however, you can use any existing Administrator username.', 'mainwp-child'),
),
'friendly_name' => array(
'title' => __('Friendly site name', 'mainwp-child'),
'value' => get_bloginfo( 'name' ),
'desc' => __('For the friendly site name, you can use any name, this is just a suggestion.', 'mainwp-child'),
'desc' => __('For the friendly site name, you can use any name, this is just a suggestion.', 'mainwp-child'),
),
'uniqueid' => array(
'title' => __('Child unique security id', 'mainwp-child'),
'value' => !empty($uniqueId) ? $uniqueId : __('Leave the field blank', 'mainwp-child'),
'desc' => sprintf(__('Child unique security id is not required, however, since you have enabled it, you need to add it to your %s dashboard.', 'mainwp-child'), stripslashes( $branding_title ) ),
'desc' => sprintf(__('Child unique security id is not required, however, since you have enabled it, you need to add it to your %s dashboard.', 'mainwp-child'), stripslashes( $branding_title ) ),
),
'verify_ssl' => array(
'title' => __('Verify certificate', 'mainwp-child'),
'value' => __('Yes', 'mainwp-child'),
'desc' => __('If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child'),
'desc' => __('If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child'),
),
'ssl_version' => array(
'title' => __('SSL version', 'mainwp-child'),
'value' => __('Auto Detect', 'mainwp-child'),
'desc' => __('Auto Detect', 'mainwp-child'),
'desc' => __('Auto Detect', 'mainwp-child'),
),
);

View file

@ -19,7 +19,7 @@ class MainWP_Child_Skeleton_Key {
error_reporting( 0 );
function mainwp_skeleton_key_handle_fatal_error() {
$error = error_get_last();
if ( isset( $error['type'] ) && in_array($error['type'], array(1, 4, 16, 64, 256) ) && isset( $error['message'] ) ) {
if ( isset( $error['type'] ) && in_array($error['type'], array( 1, 4, 16, 64, 256 ) ) && isset( $error['message'] ) ) {
MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
}
// to fix issue double <mainwp></mainwp> header in response
@ -84,8 +84,14 @@ class MainWP_Child_Skeleton_Key {
$post_args['redirection'] = 5;
$post_args['decompress'] = false; // For gzinflate() data error bug
$post_args['cookies'] = array(
new WP_Http_Cookie( array( 'name' => $auth_cookie_name, 'value' => $auth_cookie ) ),
new WP_Http_Cookie( array( 'name' => LOGGED_IN_COOKIE, 'value' => $logged_in_cookie ) ),
new WP_Http_Cookie( array(
'name' => $auth_cookie_name,
'value' => $auth_cookie,
) ),
new WP_Http_Cookie( array(
'name' => LOGGED_IN_COOKIE,
'value' => $logged_in_cookie,
) ),
);
if ( isset( $args['get'] ) ) {
@ -190,7 +196,7 @@ class MainWP_Child_Skeleton_Key {
$settings = isset($_POST['settings']) ? $_POST['settings'] : array();
if (!is_array($settings) || empty($settings)) {
return array('error' => 'Invalid data. Please check and try again.');
return array( 'error' => 'Invalid data. Please check and try again.' );
}
$whitelist_options = array(
@ -211,7 +217,7 @@ class MainWP_Child_Skeleton_Key {
}
//$whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
$whitelist_general = $whitelist_options[ 'general' ];
$whitelist_general = $whitelist_options['general'];
// Handle translation install.
if ( ! empty( $settings['WPLANG'] ) ) {
@ -240,7 +246,7 @@ class MainWP_Child_Skeleton_Key {
return false;
}
return array('result' => 'ok');
return array( 'result' => 'ok' );
}
}

View file

@ -78,7 +78,7 @@ class MainWP_Child_Staging {
public function action() {
if (!$this->is_plugin_installed) {
MainWP_Helper::write( array('error' => 'Please install WP Staging plugin on child website') );
MainWP_Helper::write( array( 'error' => 'Please install WP Staging plugin on child website' ) );
}
if (!class_exists( 'WPStaging\WPStaging' )){
@ -177,12 +177,12 @@ class MainWP_Child_Staging {
$save_fields = array();
foreach($filters as $field) {
if (isset($settings[$field])) {
$save_fields[$field] = $settings[$field];
if (isset($settings[ $field ])) {
$save_fields[ $field ] = $settings[ $field ];
}
}
update_option('wpstg_settings', $save_fields );
return array('result' => 'success');
return array( 'result' => 'success' );
}
public function get_overview() {
@ -201,9 +201,9 @@ class MainWP_Child_Staging {
$options = $scan->getOptions();
$return = array(
'options' => serialize($options),
'options' => serialize($options),
'directoryListing' => $scan->directoryListing(),
'prefix' => WPStaging\WPStaging::getTablePrefix(),
'prefix' => WPStaging\WPStaging::getTablePrefix(),
);
return $return;
}
@ -217,17 +217,17 @@ class MainWP_Child_Staging {
// Check clone name length
if( $cloneNameLength < 1 || $cloneNameLength > 16 ) {
echo array(
'status' => 'failed',
'status' => 'failed',
'message' => 'Clone name must be between 1 - 16 characters',
);
} elseif( array_key_exists( $cloneName, $clones ) ) {
return array(
'status' => 'failed',
'status' => 'failed',
'message' => 'Clone name is already in use, please choose an another clone name',
);
}
return array('status' => 'success');
return array( 'status' => 'success' );
}
public function ajaxStartClone() {
@ -302,7 +302,7 @@ class MainWP_Child_Staging {
$delete->setData();
$clone = $delete->getClone();
$result = array(
'clone' => $clone,
'clone' => $clone,
'deleteTables' => $delete->getTables(),
);
return $result;
@ -384,13 +384,13 @@ class MainWP_Child_Staging {
return '';
}
$units = array('B', 'KB', 'MB', 'GB', 'TB');
$units = array( 'B', 'KB', 'MB', 'GB', 'TB' );
$bytes = (float) $bytes;
$base = log($bytes) / log(1000); // 1024 would be for MiB KiB etc
$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

@ -234,7 +234,13 @@ class MainWP_Child_Themes_Check {
$url = set_url_scheme( $url, 'https' );
}
$args = array( 'slug' => $theme, 'fields' => array( 'sections' => false, 'tags' => false ) );
$args = array(
'slug' => $theme,
'fields' => array(
'sections' => false,
'tags' => false,
),
);
$args = (object) $args;
$http_args = array(

View file

@ -61,14 +61,14 @@ class MainWP_Child_Timecapsule {
public function action() {
if (!$this->is_plugin_installed) {
MainWP_Helper::write( array('error' => 'Please install WP Time Capsule plugin on child website') );
MainWP_Helper::write( array( 'error' => 'Please install WP Time Capsule plugin on child website' ) );
}
try {
$this->require_files();
} catch ( Exception $e) {
$error = $e->getMessage();
MainWP_Helper::write( array('error' => $error) );
MainWP_Helper::write( array( 'error' => $error ) );
}
$information = array();
@ -84,9 +84,9 @@ class MainWP_Child_Timecapsule {
$_POST['mwp_action'] == 'save_settings' ||
$_POST['mwp_action'] == 'get_staging_details_wptc' ||
$_POST['mwp_action'] == 'progress_wptc'
) && (!$is_user_logged_in || !$privileges_wptc )
) && ( !$is_user_logged_in || !$privileges_wptc )
) {
MainWP_Helper::write( array('error' => 'You are not login to your WP Time Capsule account.') );
MainWP_Helper::write( array( 'error' => 'You are not login to your WP Time Capsule account.' ) );
}
switch ( $_POST['mwp_action'] ) {
@ -254,7 +254,7 @@ class MainWP_Child_Timecapsule {
public function get_sync_data() {
try {
$this->require_files();
MainWP_Helper::check_classes_exists(array('Wptc_Options_Helper', 'WPTC_Base_Factory', 'WPTC_Factory'));
MainWP_Helper::check_classes_exists(array( 'Wptc_Options_Helper', 'WPTC_Base_Factory', 'WPTC_Factory' ));
$config = WPTC_Factory::get('config');
MainWP_Helper::check_methods($config, 'get_option');
@ -265,8 +265,8 @@ class MainWP_Child_Timecapsule {
$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($wptc_settings, array( 'get_connected_cloud_info'));
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' ));
$all_backups = $this->getBackups();
$backups_count = 0;
@ -274,19 +274,19 @@ class MainWP_Child_Timecapsule {
$formatted_backups = array();
foreach ($all_backups as $key => $value) {
$value_array = (array) $value;
$formatted_backups[$value_array['backupID']][] = $value_array;
$formatted_backups[ $value_array['backupID'] ][] = $value_array;
}
$backups_count = count($formatted_backups);
}
$return = array(
'main_account_email' => $main_account_email_var,
'signed_in_repos' => $wptc_settings->get_connected_cloud_info(),
'plan_name' => $options_helper->get_plan_interval_from_subs_info(),
'plan_interval' => $options_helper->get_plan_interval_from_subs_info(),
'lastbackup_time' => !empty($last_backup_time) ? $last_backup_time : 0,
'is_user_logged_in' => $options_helper->get_is_user_logged_in(),
'backups_count' => $backups_count,
'signed_in_repos' => $wptc_settings->get_connected_cloud_info(),
'plan_name' => $options_helper->get_plan_interval_from_subs_info(),
'plan_interval' => $options_helper->get_plan_interval_from_subs_info(),
'lastbackup_time' => !empty($last_backup_time) ? $last_backup_time : 0,
'is_user_logged_in' => $options_helper->get_is_user_logged_in(),
'backups_count' => $backups_count,
);
return $return;
} catch ( Exception $e) {
@ -319,7 +319,7 @@ class MainWP_Child_Timecapsule {
public function exclude_file_list() {
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'];
$exclude_class_obj = new Wptc_ExcludeOption($category);
@ -397,7 +397,7 @@ class MainWP_Child_Timecapsule {
$status['cron_url'] = $cron_status['cron_url'];
$status['ips'] = $cron_status['ips'];
}
return array('result' => $status);
return array( 'result' => $status );
}
return false;
}
@ -505,13 +505,14 @@ function get_sibling_files_callback_wptc() {
$totalpages = ceil($totalitems / $perpage); //Total number of pages
//adjust the query to take pagination into account
if (!empty($paged) && !empty($perpage)) {
$offset = ($paged - 1) * $perpage;
$offset = ( $paged - 1 ) * $perpage;
$query .= ' LIMIT ' . (int) $offset . ',' . (int) $perpage;
}
return array( 'items' => $wpdb->get_results($query),
'totalitems' => $totalitems,
'perpage' => $perpage,
return array(
'items' => $wpdb->get_results($query),
'totalitems' => $totalitems,
'perpage' => $perpage,
);
}
@ -551,7 +552,7 @@ function get_sibling_files_callback_wptc() {
$detailed .= '<tr><td></td><td><a style="cursor:pointer; position:relative" class="wptc_activity_log_load_more" action_id="' . esc_attr( $action_id ) . '" limit="' . esc_attr( $to_limit ) . '">Load more</a></td><td></td></tr>';
}
return array( 'result' => $detailed);
return array( 'result' => $detailed );
//die($detailed);
}
@ -605,13 +606,13 @@ function get_sibling_files_callback_wptc() {
// $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);
$msg = '';
if (!(strpos($rec->type, 'backup') === false)) {
if (!( strpos($rec->type, 'backup') === false )) {
//Backup process
$msg = 'Backup Process';
} elseif (!(strpos($rec->type, 'restore') === false)) {
} elseif (!( strpos($rec->type, 'restore') === false )) {
//Restore Process
$msg = 'Restore Process';
} elseif (!(strpos($rec->type, 'staging') === false)) {
} elseif (!( strpos($rec->type, 'staging') === false )) {
//Restore Process
$msg = 'Staging Process';
} else {
@ -636,7 +637,7 @@ function get_sibling_files_callback_wptc() {
//Close the line
$html .= '</tr>';
$display_rows[$key] = $html;
$display_rows[ $key ] = $html;
}
}
@ -667,7 +668,7 @@ function get_sibling_files_callback_wptc() {
} else {
$result = 'no';
}
return array('result' => $result);
return array( 'result' => $result );
}
function stop_fresh_backup_tc_callback_wptc() {
@ -675,7 +676,7 @@ function get_sibling_files_callback_wptc() {
$deactivated_plugin = null;
$backup = new WPTC_BackupController();
$backup->stop($deactivated_plugin);
return array('result' => 'ok');
return array( 'result' => 'ok' );
}
@ -689,7 +690,7 @@ function get_sibling_files_callback_wptc() {
public function exclude_table_list() {
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'];
$exclude_class_obj = new Wptc_ExcludeOption($category);
@ -716,7 +717,7 @@ function get_sibling_files_callback_wptc() {
}
try {
MainWP_Helper::check_classes_exists(array( 'WPTC_Factory'));
MainWP_Helper::check_classes_exists(array( 'WPTC_Factory' ));
$config = WPTC_Factory::get('config');
@ -740,7 +741,7 @@ function get_sibling_files_callback_wptc() {
$formatted_backups = array();
foreach ($all_last_backups as $key => $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';
$backup_type = 'WP Time Capsule backup';
@ -759,7 +760,7 @@ function get_sibling_files_callback_wptc() {
public function include_table_list() {
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'];
$exclude_class_obj = new Wptc_ExcludeOption($category);
@ -770,7 +771,7 @@ function get_sibling_files_callback_wptc() {
public function include_table_structure_only() {
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'];
@ -782,7 +783,7 @@ function get_sibling_files_callback_wptc() {
public function include_file_list() {
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'];
$exclude_class_obj = new Wptc_ExcludeOption($category);
@ -803,7 +804,7 @@ function get_sibling_files_callback_wptc() {
if($options_helper->get_is_user_logged_in()){
return array(
'result' => 'is_user_logged_in',
'result' => 'is_user_logged_in',
'sync_data' => $this->get_sync_data(),
);
}
@ -812,7 +813,7 @@ function get_sibling_files_callback_wptc() {
$pwd = $_POST['acc_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');
@ -836,9 +837,12 @@ function get_sibling_files_callback_wptc() {
$is_user_logged_in = $options->get_option('is_user_logged_in');
if (!$is_user_logged_in) {
return array('error' => 'Login failed.');
return array( 'error' => 'Login failed.' );
}
return array('result' => 'ok', 'sync_data' => $this->get_sync_data());
return array(
'result' => 'ok',
'sync_data' => $this->get_sync_data(),
);
}
function get_installed_plugins() {
@ -847,9 +851,9 @@ function get_sibling_files_callback_wptc() {
$plugins = $backup_before_auto_update_settings->get_installed_plugins();
if ($plugins) {
return array('results' =>$plugins );
return array( 'results' =>$plugins );
}
return array( 'results' => array());
return array( 'results' => array() );
}
function get_installed_themes() {
@ -858,9 +862,9 @@ function get_sibling_files_callback_wptc() {
$plugins = $backup_before_auto_update_settings->get_installed_themes();
if ($plugins) {
return array('results' =>$plugins );
return array( 'results' =>$plugins );
}
return array('results' => array() );
return array( 'results' => array() );
}
function is_staging_need_request() {
@ -880,7 +884,10 @@ function get_sibling_files_callback_wptc() {
$staging = WPTC_Pro_Factory::get('Wptc_Staging');
if (empty($_POST['path'])) {
wptc_die_with_json_encode( array('status' => 'error', 'msg' => 'path is missing') );
wptc_die_with_json_encode( array(
'status' => 'error',
'msg' => 'path is missing',
) );
}
$staging->choose_action($_POST['path'], $reqeust_type = 'fresh');
@ -941,7 +948,7 @@ function get_sibling_files_callback_wptc() {
public function init_restore() {
if (empty($_POST)) {
return ( array('error' => 'Backup id is empty !') );
return ( array( 'error' => 'Backup id is empty !' ) );
}
$restore_to_staging = WPTC_Base_Factory::get('Wptc_Restore_To_Staging');
$restore_to_staging->init_restore($_POST);
@ -956,7 +963,7 @@ function get_sibling_files_callback_wptc() {
if( !$options_helper->get_is_user_logged_in() ){
return array(
'sync_data' => $this->get_sync_data(),
'error' => 'Login to your WP Time Capsule account first',
'error' => 'Login to your WP Time Capsule account first',
);
}
@ -1087,10 +1094,10 @@ function get_sibling_files_callback_wptc() {
}
if ( ! $saved ) {
return array('error' => 'Error: Not saved settings');
return array( 'error' => 'Error: Not saved settings' );
}
return array('result' => 'ok');
return array( 'result' => 'ok' );
}
private function filter_plugins( $included_plugins) {
@ -1125,14 +1132,14 @@ function get_sibling_files_callback_wptc() {
$plugins = $vulns_obj->get_enabled_plugins();
$plugins = WPTC_Base_Factory::get('Wptc_App_Functions')->fancytree_format($plugins, 'plugins');
return array('results' => $plugins);
return array( 'results' => $plugins );
}
public function get_enabled_themes() {
$vulns_obj = WPTC_Base_Factory::get('Wptc_Vulns');
$themes = $vulns_obj->get_enabled_themes();
$themes = WPTC_Base_Factory::get('Wptc_App_Functions')->fancytree_format($themes, 'themes');
return array('results' => $themes);
return array( 'results' => $themes );
}
public function get_system_info() {
@ -1160,15 +1167,15 @@ function get_sibling_files_callback_wptc() {
if ( function_exists( 'curl_version' ) ) {
$curlversion = curl_version();
echo '<tr title=""><td>' . __( 'cURL version', 'wp-time-capsule' ) . '</td><td>' . esc_html( $curlversion[ 'version' ] ) . '</td></tr>';
echo '<tr title=""><td>' . __( 'cURL SSL version', 'wp-time-capsule' ) . '</td><td>' . esc_html( $curlversion[ 'ssl_version' ] ) . '</td></tr>';
echo '<tr title=""><td>' . __( 'cURL version', 'wp-time-capsule' ) . '</td><td>' . esc_html( $curlversion['version'] ) . '</td></tr>';
echo '<tr title=""><td>' . __( 'cURL SSL version', 'wp-time-capsule' ) . '</td><td>' . esc_html( $curlversion['ssl_version'] ) . '</td></tr>';
}
else {
echo '<tr title=""><td>' . __( 'cURL version', 'wp-time-capsule' ) . '</td><td>' . __( 'unavailable', 'wp-time-capsule' ) . '</td></tr>';
}
echo '</td></tr>';
echo '<tr title=""><td>' . __( 'Server', 'wp-time-capsule' ) . '</td><td>' . esc_html( $_SERVER[ 'SERVER_SOFTWARE' ] ) . '</td></tr>';
echo '<tr title=""><td>' . __( 'Server', 'wp-time-capsule' ) . '</td><td>' . esc_html( $_SERVER['SERVER_SOFTWARE'] ) . '</td></tr>';
echo '<tr title=""><td>' . __( 'Operating System', 'wp-time-capsule' ) . '</td><td>' . esc_html( PHP_OS ) . '</td></tr>';
echo '<tr title=""><td>' . __( 'PHP SAPI', 'wp-time-capsule' ) . '</td><td>' . esc_html( PHP_SAPI ) . '</td></tr>';
@ -1187,7 +1194,7 @@ function get_sibling_files_callback_wptc() {
}
$now = localtime( time(), true );
echo '<tr title=""><td>' . __( 'Server Time', 'wp-time-capsule' ) . '</td><td>' . esc_html( $now[ 'tm_hour' ] . ':' . $now[ 'tm_min' ] ) . '</td></tr>';
echo '<tr title=""><td>' . __( 'Server Time', 'wp-time-capsule' ) . '</td><td>' . esc_html( $now['tm_hour'] . ':' . $now['tm_min'] ) . '</td></tr>';
echo '<tr title=""><td>' . __( 'Blog Time', 'wp-time-capsule' ) . '</td><td>' . date( 'H:i', current_time( 'timestamp' ) ) . '</td></tr>';
echo '<tr title="WPLANG"><td>' . __( 'Blog language', 'wp-time-capsule' ) . '</td><td>' . get_bloginfo( 'language' ) . '</td></tr>';
echo '<tr title="utf8"><td>' . __( 'MySQL Client encoding', 'wp-time-capsule' ) . '</td><td>';
@ -1217,7 +1224,7 @@ function get_sibling_files_callback_wptc() {
echo '</table>';
$html = ob_get_clean();
return array( 'result' => $html);
return array( 'result' => $html );
}
@ -1233,7 +1240,7 @@ function get_sibling_files_callback_wptc() {
function start_fresh_backup_tc_callback_wptc() {
start_fresh_backup_tc_callback_wptc($type = '', $args = null, $test_connection = true, $ajax_check = false);
return array('result' => 'success');
return array( 'result' => 'success' );
}
public function save_manual_backup_name_wptc() {

View file

@ -163,7 +163,7 @@ class MainWP_Child_Updraft_Plus_Backups {
break;
}
} catch(Exception $e) {
$information = array('error' => $e->getMessage());
$information = array( 'error' => $e->getMessage() );
}
}
MainWP_Helper::write( $information );
@ -245,12 +245,18 @@ class MainWP_Child_Updraft_Plus_Backups {
private function do_vault_connect() {
$vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' );
if ( is_array( $vault_settings ) && !empty( $vault_settings['token'] ) && !empty( $vault_settings['email'] ) ) {
return array( 'connected' => true, 'html' => $this->connected_html() );
return array(
'connected' => true,
'html' => $this->connected_html(),
);
}
$connect = $this->vault_connect( $_REQUEST['email'], $_REQUEST['passwd'] );
if ( true === $connect ) {
$response = array( 'connected' => true, 'html' => $this->connected_html() );
$response = array(
'connected' => true,
'html' => $this->connected_html(),
);
} else {
$response = array(
'e' => __( 'An unknown error occurred when trying to connect to UpdraftPlus.Com', 'updraftplus' ),
@ -303,11 +309,11 @@ class MainWP_Child_Updraft_Plus_Backups {
$result = wp_remote_post( $vault_mothership . '/?udm_action=vault_connect',
array(
'timeout' => 20,
'body' => array(
'e' => $email,
'p' => base64_encode( $password ),
'body' => array(
'e' => $email,
'p' => base64_encode( $password ),
'sid' => $updraftplus->siteid(),
'su' => base64_encode( home_url() ),
'su' => base64_encode( home_url() ),
),
)
);
@ -376,16 +382,18 @@ class MainWP_Child_Updraft_Plus_Backups {
delete_transient( 'udvault_last_config' );
delete_transient( 'updraftvault_quota_text' );
MainWP_Helper::close_connection( array( 'disconnected' => 1,
'html' => $this->connected_html(), )
MainWP_Helper::close_connection( array(
'disconnected' => 1,
'html' => $this->connected_html(),
)
);
// If $_POST['reset_hash'] is set, then we were alerted by updraftplus.com - no need to notify back
if ( is_array( $vault_settings ) && isset( $vault_settings['email'] ) && empty( $_POST['reset_hash'] ) ) {
$post_body = array(
'e' => (string) $vault_settings['email'],
'e' => (string) $vault_settings['email'],
'sid' => $updraftplus->siteid(),
'su' => base64_encode( home_url() ),
'su' => base64_encode( home_url() ),
);
if ( !empty( $vault_settings['token'] ) ) { $post_body['token'] = (string) $vault_settings['token'];
@ -394,7 +402,7 @@ class MainWP_Child_Updraft_Plus_Backups {
// Use SSL to prevent snooping
wp_remote_post( $vault_mothership . '/?udm_action=vault_disconnect', array(
'timeout' => 20,
'body' => $post_body,
'body' => $post_body,
));
}
}
@ -430,11 +438,11 @@ class MainWP_Child_Updraft_Plus_Backups {
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
if (isset($settings['is_general']) && !empty($settings['is_general'])){
$opts['settings'][$settings_key]['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
$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']);
$opts['settings'][ $settings_key ]['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
}
} else {
if (isset($settings['is_general']) && !empty($settings['is_general'])){
@ -517,15 +525,15 @@ class MainWP_Child_Updraft_Plus_Backups {
}
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
$opts['settings'][$settings_key]['accesskey'] = $settings[ $key ]['accesskey'];
$opts['settings'][$settings_key]['secretkey'] = $settings[ $key ]['secretkey'];
$opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']);
if (!empty($opts['settings'][$settings_key]['path']) && '/' == substr($opts['settings'][$settings_key]['path'], 0, 1)) {
$opts['settings'][$settings_key]['path'] = substr($opts['settings'][$settings_key]['path'], 1);
$opts['settings'][ $settings_key ]['accesskey'] = $settings[ $key ]['accesskey'];
$opts['settings'][ $settings_key ]['secretkey'] = $settings[ $key ]['secretkey'];
$opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']);
if (!empty($opts['settings'][ $settings_key ]['path']) && '/' == substr($opts['settings'][ $settings_key ]['path'], 0, 1)) {
$opts['settings'][ $settings_key ]['path'] = substr($opts['settings'][ $settings_key ]['path'], 1);
}
if (isset($settings[ $key ]['rrs'])) { // premium settings
$opts['settings'][$settings_key]['rrs'] = $settings[ $key ]['rrs'];
$opts['settings'][$settings_key]['server_side_encryption'] = $settings[ $key ]['server_side_encryption'];
$opts['settings'][ $settings_key ]['rrs'] = $settings[ $key ]['rrs'];
$opts['settings'][ $settings_key ]['server_side_encryption'] = $settings[ $key ]['server_side_encryption'];
}
} else {
$opts['accesskey'] = $settings[ $key ]['accesskey'];
@ -548,10 +556,10 @@ class MainWP_Child_Updraft_Plus_Backups {
}
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
$opts['settings'][$settings_key]['endpoint'] = $settings[ $key ]['endpoint'];
$opts['settings'][$settings_key]['accesskey'] = $settings[ $key ]['accesskey'];
$opts['settings'][$settings_key]['secretkey'] = $settings[ $key ]['secretkey'];
$opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']);
$opts['settings'][ $settings_key ]['endpoint'] = $settings[ $key ]['endpoint'];
$opts['settings'][ $settings_key ]['accesskey'] = $settings[ $key ]['accesskey'];
$opts['settings'][ $settings_key ]['secretkey'] = $settings[ $key ]['secretkey'];
$opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']);
} else {
$opts['endpoint'] = $settings[ $key ]['endpoint'];
$opts['accesskey'] = $settings[ $key ]['accesskey'];
@ -567,8 +575,8 @@ class MainWP_Child_Updraft_Plus_Backups {
}
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'];
$opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']);
$opts['settings'][ $settings_key ]['endpoint'] = $settings[ $key ]['endpoint'];
} else {
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
$opts['endpoint'] = $settings[ $key ]['endpoint'];
@ -582,11 +590,11 @@ class MainWP_Child_Updraft_Plus_Backups {
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
if ( isset( $settings[ $key ]['path'] ) ) {
$opts['settings'][$settings_key]['host'] = $settings[ $key ]['host'];
$opts['settings'][$settings_key]['user'] = $settings[ $key ]['user'];
$opts['settings'][$settings_key]['pass'] = $settings[ $key ]['pass'];
$opts['settings'][$settings_key]['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
$opts['settings'][$settings_key]['passive'] = isset($settings[ $key ]['passive']) ? $settings[ $key ]['passive'] : 0;
$opts['settings'][ $settings_key ]['host'] = $settings[ $key ]['host'];
$opts['settings'][ $settings_key ]['user'] = $settings[ $key ]['user'];
$opts['settings'][ $settings_key ]['pass'] = $settings[ $key ]['pass'];
$opts['settings'][ $settings_key ]['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
$opts['settings'][ $settings_key ]['passive'] = isset($settings[ $key ]['passive']) ? $settings[ $key ]['passive'] : 0;
}
} else {
if ( isset( $settings[ $key ]['path'] ) ) {
@ -607,13 +615,13 @@ class MainWP_Child_Updraft_Plus_Backups {
if(is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
if ( isset( $settings[ $key ]['path'] ) ) {
$opts['settings'][$settings_key]['host'] = $settings[ $key ]['host'];
$opts['settings'][$settings_key]['port'] = $settings[ $key ]['port'];
$opts['settings'][$settings_key]['user'] = $settings[ $key ]['user'];
$opts['settings'][$settings_key]['pass'] = $settings[ $key ]['pass'];
$opts['settings'][$settings_key]['key'] = $settings[ $key ]['key'];
$opts['settings'][$settings_key]['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
$opts['settings'][$settings_key]['scp'] = isset($settings[ $key ]['scp']) ? $settings[ $key ]['scp'] : 0;
$opts['settings'][ $settings_key ]['host'] = $settings[ $key ]['host'];
$opts['settings'][ $settings_key ]['port'] = $settings[ $key ]['port'];
$opts['settings'][ $settings_key ]['user'] = $settings[ $key ]['user'];
$opts['settings'][ $settings_key ]['pass'] = $settings[ $key ]['pass'];
$opts['settings'][ $settings_key ]['key'] = $settings[ $key ]['key'];
$opts['settings'][ $settings_key ]['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
$opts['settings'][ $settings_key ]['scp'] = isset($settings[ $key ]['scp']) ? $settings[ $key ]['scp'] : 0;
}
} else {
if ( isset( $settings[ $key ]['path'] ) ) {
@ -635,7 +643,7 @@ class MainWP_Child_Updraft_Plus_Backups {
if(is_array($opts) && isset($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 );
}
@ -646,16 +654,16 @@ class MainWP_Child_Updraft_Plus_Backups {
}
if (is_array($opts) && isset($opts['settings'])) {
$settings_key = key($opts['settings']);
$opts['settings'][$settings_key]['account_id'] = $settings[ $key ]['account_id'];
$opts['settings'][$settings_key]['key'] = $settings[ $key ]['key'];
$opts['settings'][ $settings_key ]['account_id'] = $settings[ $key ]['account_id'];
$opts['settings'][ $settings_key ]['key'] = $settings[ $key ]['key'];
$bname = $this->replace_tokens( $settings[ $key ]['bucket_name'] );
$bpath = $this->replace_tokens( $settings[ $key ]['backup_path'] );
$bname = str_replace('.', '-', $bname);
$bpath = str_replace('.', '-', $bpath);
$bname = str_replace('_', '', $bname); // to fix strange character
$bpath = str_replace('_', '', $bpath);
$opts['settings'][$settings_key]['bucket_name'] = $bname;
$opts['settings'][$settings_key]['backup_path'] = $bpath;
$opts['settings'][ $settings_key ]['bucket_name'] = $bname;
$opts['settings'][ $settings_key ]['backup_path'] = $bpath;
UpdraftPlus_Options::update_updraft_option( $key, $opts );
}
} else {
@ -822,7 +830,10 @@ class MainWP_Child_Updraft_Plus_Backups {
}
if ( ! class_exists( 'UpdraftPlus_WPDB_OtherDB_Test' ) ) {
return array( 'r' => $_POST['row'], 'm' => 'Error: Require premium UpdraftPlus plugin.' );
return array(
'r' => $_POST['row'],
'm' => 'Error: Require premium UpdraftPlus plugin.',
);
}
if ( empty( $_POST['user_db'] ) ) {
@ -882,7 +893,7 @@ class MainWP_Child_Updraft_Plus_Backups {
if ( ! $failed ) {
$all_tables = $wpdb_obj->get_results( 'SHOW TABLES', ARRAY_N );
//$all_tables = array_map( create_function( '$a', 'return $a[0];' ), $all_tables );
$all_tables = array_map(array($this, 'cb_get_name_base_type'), $all_tables);
$all_tables = array_map(array( $this, 'cb_get_name_base_type' ), $all_tables);
if ( empty( $_POST['prefix'] ) ) {
$ret_info .= sprintf( __( '%s table(s) found.', 'updraftplus' ), count( $all_tables ) );
@ -920,7 +931,10 @@ class MainWP_Child_Updraft_Plus_Backups {
restore_error_handler();
return array( 'r' => $_POST['row'], 'm' => $ret . $ret_after );
return array(
'r' => $_POST['row'],
'm' => $ret . $ret_after,
);
}
private function cb_get_name_base_type( $a) {
@ -944,7 +958,10 @@ class MainWP_Child_Updraft_Plus_Backups {
// unfix for tic#22678
$this->close_browser_connection( $msg );
$options = array( 'nocloud' => $backupnow_nocloud, 'use_nonce' => $nonce );
$options = array(
'nocloud' => $backupnow_nocloud,
'use_nonce' => $nonce,
);
if ( ! empty( $_REQUEST['onlythisfileentity'] ) && is_string( $_REQUEST['onlythisfileentity'] ) ) {
// Something to see in the 'last log' field when it first appears, before the backup actually starts
$updraftplus->log( __( 'Start backup', 'updraftplus' ) );
@ -1073,7 +1090,10 @@ class MainWP_Child_Updraft_Plus_Backups {
$last_backup_text = '<span style="color:blue;">' . __( 'No backup has been completed.', 'updraftplus' ) . '</span>';
}
return array( 'b' => $last_backup_text, 'lasttime_gmt' => $backup_time );
return array(
'b' => $last_backup_text,
'lasttime_gmt' => $backup_time,
);
}
private function get_updraft_data( $with_hist = true ) {
@ -1119,7 +1139,7 @@ class MainWP_Child_Updraft_Plus_Backups {
}
$updraft_dir = $updraftplus->backups_dir_location();
$backup_disabled = (UpdraftPlus_Filesystem_Functions::really_is_writable($updraft_dir)) ? 0 : 1;
$backup_disabled = ( UpdraftPlus_Filesystem_Functions::really_is_writable($updraft_dir) ) ? 0 : 1;
$current_timegmt = time();
$current_time = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $current_timegmt ), 'D, F j, Y H:i' );
@ -1221,7 +1241,7 @@ class MainWP_Child_Updraft_Plus_Backups {
MainWP_Helper::check_methods('UpdraftPlus_Filesystem_Functions', 'really_is_writable');
$updraft_dir = $updraftplus->backups_dir_location();
$backup_disabled = (UpdraftPlus_Filesystem_Functions::really_is_writable($updraft_dir)) ? 0 : 1;
$backup_disabled = ( UpdraftPlus_Filesystem_Functions::really_is_writable($updraft_dir) ) ? 0 : 1;
$out = array(
'n' => $html,
@ -1396,7 +1416,10 @@ class MainWP_Child_Updraft_Plus_Backups {
$output = $noutput . $output;
}
return array( 'h' => $output, 'c' => count( $backup_history ) );
return array(
'h' => $output,
'c' => count( $backup_history ),
);
}
public function historystatus( $remotescan = null, $rescan = null ) {
@ -1641,7 +1664,11 @@ class MainWP_Child_Updraft_Plus_Backups {
$timestamp = (int) $_POST['timestamp'];
if ( ! isset( $backups[ $timestamp ] ) ) {
return array( 'm' => '', 'w' => '', 'e' => __( 'No such backup set exists', 'updraftplus' ) );
return array(
'm' => '',
'w' => '',
'e' => __( 'No such backup set exists', 'updraftplus' ),
);
}
@ -2237,7 +2264,10 @@ class MainWP_Child_Updraft_Plus_Backups {
$output = ob_get_clean();
return array( 'o' => $output, 'd' => $deleted );
return array(
'o' => $output,
'd' => $deleted,
);
}
//deletes the -old directories that are created when a backup is restored.
@ -2579,13 +2609,13 @@ 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];
$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
@ -2599,7 +2629,7 @@ class MainWP_Child_Updraft_Plus_Backups {
} else {
$err[] = sprintf(__('Error: %s', 'updraftplus'), __('Decryption failed. The database file is encrypted.', 'updraftplus'));
}
return array($mess, $warn, $err, $info);
return array( $mess, $warn, $err, $info );
}
$decrypted_file = UpdraftPlus_Encryption::decrypt($db_file, $encryption);
@ -2608,22 +2638,22 @@ class MainWP_Child_Updraft_Plus_Backups {
$db_file = $decrypted_file['fullpath'];
} else {
$err[] = __('Decryption failed. The most likely cause is that you used the wrong key.', 'updraftplus');
return array($mess, $warn, $err, $info);
return array( $mess, $warn, $err, $info );
}
}
// 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));
return array($mess, $warn, $err, $info);
return array( $mess, $warn, $err, $info );
}
$is_plain = ('.gz' == substr($db_file, -3, 3)) ? false : true;
$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);
$dbhandle = ( $is_plain ) ? fopen($db_file, 'r') : $this->gzopen_for_read($db_file, $warn, $err);
if (!is_resource($dbhandle)) {
$err[] = __('Failed to open database file.', 'updraftplus');
return array($mess, $warn, $err, $info);
return array( $mess, $warn, $err, $info );
}
$info['timestamp'] = $timestamp;
@ -2644,7 +2674,7 @@ class MainWP_Child_Updraft_Plus_Backups {
// 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
$wanted_tables = array('terms', 'term_taxonomy', 'term_relationships', 'commentmeta', 'comments', 'links', 'options', 'postmeta', 'posts', 'users', 'usermeta');
$wanted_tables = array( 'terms', 'term_taxonomy', 'term_relationships', 'commentmeta', 'comments', 'links', 'options', 'postmeta', 'posts', 'users', 'usermeta' );
$migration_warning = false;
$processing_create = false;
@ -2653,32 +2683,32 @@ class MainWP_Child_Updraft_Plus_Backups {
// 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.
// "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;
$dbscan_timeout = (defined('UPDRAFTPLUS_DBSCAN_TIMEOUT') && is_numeric(UPDRAFTPLUS_DBSCAN_TIMEOUT)) ? UPDRAFTPLUS_DBSCAN_TIMEOUT : $default_dbscan_timeout;
$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;
@set_time_limit($dbscan_timeout);
// 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);
$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_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_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));
$buffer = ( $is_plain ) ? rtrim(fgets($dbhandle, 1048576)) : rtrim(gzgets($dbhandle, 1048576));
// Comments are what we are interested in
if (substr($buffer, 0, 1) == '#') {
$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) {
@ -2690,12 +2720,12 @@ class MainWP_Child_Updraft_Plus_Backups {
$info['same_url'] = false;
$old_siteurl_parsed = parse_url($old_siteurl);
$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()) . ' ';
} else {
$powarn = '';
}
if (('https' == $old_siteurl_parsed['scheme'] && 'http' == $actual_siteurl_parsed['scheme']) || ('http' == $old_siteurl_parsed['scheme'] && 'https' == $actual_siteurl_parsed['scheme'])) {
if (( 'https' == $old_siteurl_parsed['scheme'] && 'http' == $actual_siteurl_parsed['scheme'] ) || ( 'http' == $old_siteurl_parsed['scheme'] && 'https' == $actual_siteurl_parsed['scheme'] )) {
$powarn .= sprintf(__('This backup set is of this site, but at the time of the backup you were using %1$s, whereas the site now uses %2$s.', 'updraftplus'), $old_siteurl_parsed['scheme'], $actual_siteurl_parsed['scheme']);
if ('https' == $old_siteurl_parsed['scheme']) {
$powarn .= ' ' . apply_filters('updraftplus_https_to_http_additional_warning', sprintf(__('This restoration will work if you still have an SSL certificate (i.e. can use https) to access the site. Otherwise, you will want to use %s to search/replace the site address so that the site can be visited without https.', 'updraftplus'), '<a href="https://updraftplus.com/shop/migrator/">' . __('the migrator add-on', 'updraftplus') . '</a>'));
@ -2751,7 +2781,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$warn[] = sprintf(__('The site in this backup was running on a webserver with version %1$s of %2$s. ', 'updraftplus'), $old_php_version, 'PHP') . ' ' . sprintf(__('This is significantly newer than the server which you are now restoring onto (version %s).', 'updraftplus'), PHP_VERSION) . ' ' . sprintf(__('You should only proceed if you cannot update the current server and are confident (or willing to risk) that your plugins/themes/etc. are compatible with the older %s version.', 'updraftplus'), 'PHP') . ' ' . sprintf(__('Any support requests to do with %s should be raised with your web hosting company.', 'updraftplus'), 'PHP');
}
}
} elseif ('' == $old_table_prefix && (preg_match('/^\# Table prefix: (\S+)$/', $buffer, $matches) || preg_match('/^-- Table prefix: (\S+)$/i', $buffer, $matches))) {
} elseif ('' == $old_table_prefix && ( preg_match('/^\# Table prefix: (\S+)$/', $buffer, $matches) || preg_match('/^-- Table prefix: (\S+)$/i', $buffer, $matches) )) {
$old_table_prefix = $matches[1];
// echo '<strong>'.__('Old table prefix:', 'updraftplus').'</strong> '.htmlspecialchars($old_table_prefix).'<br>';
} elseif (empty($info['label']) && preg_match('/^\# Label: (.*)$/', $buffer, $matches)) {
@ -2772,7 +2802,7 @@ class MainWP_Child_Updraft_Plus_Backups {
// Got the needed code?
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);
return array( $mess, $warn, $err, $info );
}
} 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') . ' <a href="https://codex.wordpress.org/Create_A_Network">' . __('If you want to restore a multisite backup, you should first set up your WordPress installation as a multisite.', 'updraftplus') . '</a>';
@ -2785,7 +2815,7 @@ class MainWP_Child_Updraft_Plus_Backups {
if ($val) { $mess[] = '<strong>' . __('Site information:', 'updraftplus') . '</strong> ' . 'backup is of a WordPress Network';
}
}
$old_siteinfo[$key] = $val;
$old_siteinfo[ $key ] = $val;
}
} elseif (preg_match('/^\# Skipped tables: (.*)$/', $buffer, $matches)) {
$skipped_tables = explode(',', $matches[1]);
@ -2798,7 +2828,7 @@ class MainWP_Child_Updraft_Plus_Backups {
// Remove prefix
$table = UpdraftPlus_Manipulation_Functions::str_replace_once($old_table_prefix, '', $table);
if (in_array($table, $wanted_tables)) {
$wanted_tables = array_diff($wanted_tables, array($table));
$wanted_tables = array_diff($wanted_tables, array( $table ));
}
}
if (';' != substr($buffer, -1, 1)) {
@ -2809,19 +2839,19 @@ class MainWP_Child_Updraft_Plus_Backups {
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;
}
}
@ -2855,7 +2885,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$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;
}
@ -2867,7 +2897,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$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)) {
$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])) {
$similar_type_charset = $db_supported_character_sets[0];
@ -2890,7 +2920,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$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;
}
@ -2938,9 +2968,9 @@ class MainWP_Child_Updraft_Plus_Backups {
if ($db_charset_forbidden) {
$collate_change_on_charset_selection_data = array(
'db_supported_collations' => $db_supported_collations,
'db_supported_collations' => $db_supported_collations,
'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)) . '">';
}
@ -2979,7 +3009,7 @@ class MainWP_Child_Updraft_Plus_Backups {
foreach ($missing_tables as $key => $value) {
if (in_array($old_table_prefix . $value, $skipped_tables)) {
unset($missing_tables[$key]);
unset($missing_tables[ $key ]);
}
}
@ -3000,7 +3030,7 @@ class MainWP_Child_Updraft_Plus_Backups {
// $db_file = $decrypted_file['fullpath'].'.crypt';
// unlink($decrypted_file['fullpath']);
return array($mess, $warn, $err, $info);
return array( $mess, $warn, $err, $info );
}
@ -3158,15 +3188,15 @@ class MainWP_Child_Updraft_Plus_Backups {
$service_title = '';
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))) {
if ('none' === $service || '' === $service || ( is_array($service) && ( empty($service) || array( 'none' ) === $service || array( '' ) === $service ) )) {
// Do nothing
} else {
// $image_url = file_exists($image_folder.$service.'.png') ? $image_folder_url.$service.'.png' : $image_folder_url.'folder.png';
$remote_storage = ('remotesend' === $service) ? __('remote site', 'updraftplus') : $updraftplus->backup_methods[$service];
$remote_storage = ( 'remotesend' === $service ) ? __('remote site', 'updraftplus') : $updraftplus->backup_methods[ $service ];
$service_title = '<br>' . esc_attr(sprintf(__('Remote storage: %s', 'updraftplus'), $remote_storage));
}
@ -3859,7 +3889,10 @@ ENDHERE;
$args = $cron[ $time ]['updraft_backup_resume'][ $hook ]['args'];
wp_unschedule_event( $time, 'updraft_backup_resume', $args );
if ( ! $found_it ) {
return array( 'ok' => 'Y', 'm' => __( 'Job deleted', 'updraftplus' ) );
return array(
'ok' => 'Y',
'm' => __( 'Job deleted', 'updraftplus' ),
);
}
$found_it = 1;
}

View file

@ -51,11 +51,14 @@ 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);
$information = array( 'result' => $result, 'ok' => 1);
$information = array(
'result' => $result,
'ok' => 1,
);
return $information;
}
@ -90,15 +93,15 @@ class MainWP_Child_Vulnerability_Checker {
}
if(count($plug_vulner_data) == 0) {
unset($plug_vuln_filter[$slug]);
unset($plug_vuln_filter[ $slug ]);
} else {
$plug_vuln_filter[$slug]['vulnerabilities'] = $plug_vulner_data;
$plug_vuln_filter[$slug]['detected_version'] = $plugin_version;
$plug_vuln_filter[$slug]['plugin_slug'] = $plug;
$plug_vuln_filter[ $slug ]['vulnerabilities'] = $plug_vulner_data;
$plug_vuln_filter[ $slug ]['detected_version'] = $plugin_version;
$plug_vuln_filter[ $slug ]['plugin_slug'] = $plug;
}
} else {
unset($plug_vuln_filter[$slug]);
unset($plug_vuln_filter[ $slug ]);
}
}
@ -111,7 +114,7 @@ class MainWP_Child_Vulnerability_Checker {
} else {
continue;
}
$result[$plug] = $plug_vuln;
$result[ $plug ] = $plug_vuln;
}
}
return $result;
@ -168,12 +171,12 @@ class MainWP_Child_Vulnerability_Checker {
}
if(count($th_vulner_data) == 0) {
unset($th_vuln_filter[$slug]);
unset($th_vuln_filter[ $slug ]);
} else {
$th_vuln_filter[$slug]['vulnerabilities'] = $th_vulner_data;
$th_vuln_filter[ $slug ]['vulnerabilities'] = $th_vulner_data;
}
} else {
unset($th_vuln_filter[$slug]);
unset($th_vuln_filter[ $slug ]);
}
}
@ -186,10 +189,10 @@ class MainWP_Child_Vulnerability_Checker {
continue;
}
$result[$th['id']]['vulner_data'] = $th_vuln;
$result[$th['id']]['name'] = $th['name'];
$result[$th['id']]['author'] = $th['author'];
$result[$th['id']]['detected_version'] = $th['version'];
$result[ $th['id'] ]['vulner_data'] = $th_vuln;
$result[ $th['id'] ]['name'] = $th['name'];
$result[ $th['id'] ]['author'] = $th['author'];
$result[ $th['id'] ]['detected_version'] = $th['version'];
}
}
}
@ -203,7 +206,7 @@ class MainWP_Child_Vulnerability_Checker {
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Token token=' . $this->wpvulndb_token));
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Authorization: Token token=' . $this->wpvulndb_token ));
curl_setopt($ch, CURLOPT_USERAGENT, $this->get_random_user_agent());
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@ -220,7 +223,7 @@ class MainWP_Child_Vulnerability_Checker {
function get_random_user_agent () {
$someUA = array (
$someUA = array(
'Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.1b1) Gecko/20081007 Firefox/3.1b1',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.0',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.4.154.18 Safari/525.19',
@ -236,7 +239,7 @@ class MainWP_Child_Vulnerability_Checker {
srand( (float) microtime()*1000000);
return $someUA[rand(0, count($someUA)-1)];
return $someUA[ rand(0, count($someUA)-1) ];
}

View file

@ -465,7 +465,7 @@ class MainWP_Child_WooCommerce_Status {
$background_updater->save()->dispatch();
}
return array('result' => 'success');
return array( 'result' => 'success' );
}
}

View file

@ -693,7 +693,7 @@ class MainWP_Child_Wordfence {
$scan_time = array();
if ( $rows ) {
while ( $row = MainWP_Child_DB::fetch_array( $rows ) ) {
$scan_time[$row['ctime']] = $row['msg'];
$scan_time[ $row['ctime'] ] = $row['msg'];
}
}
@ -795,17 +795,17 @@ class MainWP_Child_Wordfence {
$counts = $i->getIssueCounts();
return array(
'issuesLists' => $iss,
'issueCounts' => $counts,
'lastScanCompleted' => wfConfig::get( 'lastScanCompleted' ),
'apiKey' => wfConfig::get( 'apiKey' ),
'isPaid' => wfConfig::get('isPaid'),
'issuesLists' => $iss,
'issueCounts' => $counts,
'lastScanCompleted' => wfConfig::get( 'lastScanCompleted' ),
'apiKey' => wfConfig::get( 'apiKey' ),
'isPaid' => wfConfig::get('isPaid'),
'lastscan_timestamp' => $this->get_lastscan(),
'isNginx' => wfUtils::isNginx() ? 1 : 0,
'todayAttBlocked' => $this->count_attacks_blocked(1),
'weekAttBlocked' => $this->count_attacks_blocked(7),
'monthAttBlocked' => $this->count_attacks_blocked(30),
'wafData' => $this->_getWAFData(),
'isNginx' => wfUtils::isNginx() ? 1 : 0,
'todayAttBlocked' => $this->count_attacks_blocked(1),
'weekAttBlocked' => $this->count_attacks_blocked(7),
'monthAttBlocked' => $this->count_attacks_blocked(30),
'wafData' => $this->_getWAFData(),
);
}
@ -817,16 +817,16 @@ class MainWP_Child_Wordfence {
$iss = $i->getIssues($offset, $limit);
$counts = $i->getIssueCounts();
$return = array(
'issuesLists' => $iss,
'issueCounts' => $counts,
'lastScanCompleted' => wfConfig::get('lastScanCompleted'),
'apiKey' => wfConfig::get( 'apiKey' ),
'isPaid' => wfConfig::get('isPaid'),
'issuesLists' => $iss,
'issueCounts' => $counts,
'lastScanCompleted' => wfConfig::get('lastScanCompleted'),
'apiKey' => wfConfig::get( 'apiKey' ),
'isPaid' => wfConfig::get('isPaid'),
'lastscan_timestamp' => self::Instance()->get_lastscan(),
'todayAttBlocked' => self::Instance()->count_attacks_blocked(1),
'weekAttBlocked' => self::Instance()->count_attacks_blocked(7),
'monthAttBlocked' => self::Instance()->count_attacks_blocked(30),
'issueCount' => $i->getIssueCount(),
'todayAttBlocked' => self::Instance()->count_attacks_blocked(1),
'weekAttBlocked' => self::Instance()->count_attacks_blocked(7),
'monthAttBlocked' => self::Instance()->count_attacks_blocked(30),
'issueCount' => $i->getIssueCount(),
);
return $return;
}
@ -834,8 +834,8 @@ class MainWP_Child_Wordfence {
public function load_wafData() {
$return = array(
'wafData' => $this->_getWAFData(),
'ip' => wfUtils::getIP(),
'wafData' => $this->_getWAFData(),
'ip' => wfUtils::getIP(),
'ajaxWatcherDisabled_front' => (bool) wfConfig::get('ajaxWatcherDisabled_front'),
'ajaxWatcherDisabled_admin' => (bool) wfConfig::get('ajaxWatcherDisabled_admin'),
);
@ -888,14 +888,14 @@ SQL
$status = $_POST['status'];
$issueID = $_POST['id'];
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.' );
}
$wfIssues->updateIssue($issueID, $status);
wfScanEngine::refreshScanNotification($wfIssues);
$counts = $wfIssues->getIssueCounts();
return array(
'ok' => 1,
'ok' => 1,
'issueCounts' => $counts,
);
}
@ -1004,7 +1004,11 @@ SQL
$bodyMsg = "We didn't $verb2 anything and no errors were found.";
}
return array( 'ok' => 1, 'bulkHeading' => $headMsg, 'bulkBody' => $bodyMsg );
return array(
'ok' => 1,
'bulkHeading' => $headMsg,
'bulkBody' => $bodyMsg,
);
} else {
return array( 'errorMsg' => 'Invalid bulk operation selected' );
}
@ -1101,10 +1105,10 @@ SQL
for( $i = 0; $i < strlen($string); $i++){
$c = ord(substr($string, $i));
if($action == 'encrypt'){
$c += ord(substr($key, (($i + 1) % strlen($key))));
$c += ord(substr($key, ( ( $i + 1 ) % strlen($key) )));
$res .= chr($c & 0xFF);
}else{
$c -= ord(substr($key, (($i + 1) % strlen($key))));
$c -= ord(substr($key, ( ( $i + 1 ) % strlen($key) )));
$res .= chr(abs($c) & 0xFF);
}
}
@ -1313,7 +1317,7 @@ SQL
} elseif ( !empty( $apiKey ) && $existingAPIKey != $apiKey ) {
$api = new wfAPI( $apiKey, wfUtils::getWPVersion() );
try {
$res = $api->call('check_api_key', array(), array('previousLicense' => $existingAPIKey));
$res = $api->call('check_api_key', array(), array( 'previousLicense' => $existingAPIKey ));
if ( $res['ok'] && isset( $res['isPaid'] ) ) {
// wfConfig::set( 'apiKey', $apiKey );
@ -1357,7 +1361,10 @@ SQL
$api = new wfAPI($apiKey, wfUtils::getWPVersion());
try {
$keyType = wfAPI::KEY_TYPE_FREE;
$keyData = $api->call('ping_api_key', array(), array('supportHash' => wfConfig::get('supportHash', ''), 'whitelistHash' => wfConfig::get('whitelistHash', '')));
$keyData = $api->call('ping_api_key', array(), array(
'supportHash' => wfConfig::get('supportHash', ''),
'whitelistHash' => wfConfig::get('whitelistHash', ''),
));
if (isset($keyData['_isPaidKey'])) {
$keyType = wfConfig::get('keyType');
}
@ -1577,7 +1584,7 @@ SQL
//Basic Options
$keys = wfConfig::getExportableOptionsKeys();
foreach ($keys as $key) {
$export[$key] = wfConfig::get($key, '');
$export[ $key ] = wfConfig::get($key, '');
}
//Serialized Options
@ -1589,22 +1596,22 @@ SQL
//Make the API call
try {
$api = new wfAPI(wfConfig::get('apiKey'), wfUtils::getWPVersion());
$res = $api->call('export_options', array(), array('export' => json_encode($export)));
$res = $api->call('export_options', array(), array( 'export' => json_encode($export) ));
if ($res['ok'] && $res['token']) {
return array(
'ok' => 1,
'ok' => 1,
'token' => $res['token'],
);
}
elseif ($res['err']) {
return array('errorExport' => __('An error occurred: ', 'wordfence') . $res['err']);
return array( 'errorExport' => __('An error occurred: ', 'wordfence') . $res['err'] );
}
else {
throw new Exception(__('Invalid response: ', 'wordfence') . var_export($res, true));
}
}
catch (Exception $e) {
return array('errorExport' => __('An error occurred: ', 'wordfence') . $e->getMessage());
return array( 'errorExport' => __('An error occurred: ', 'wordfence') . $e->getMessage() );
}
}
@ -1612,20 +1619,20 @@ SQL
$token = $_POST['token'];
try {
$api = new wfAPI(wfConfig::get('apiKey'), wfUtils::getWPVersion());
$res = $api->call('import_options', array(), array('token' => $token));
$res = $api->call('import_options', array(), array( 'token' => $token ));
if ($res['ok'] && $res['export']) {
$totalSet = 0;
$import = @json_decode($res['export'], true);
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
$keys = wfConfig::getExportableOptionsKeys();
$toSet = array();
foreach ($keys as $key) {
if (isset($import[$key])) {
$toSet[$key] = $import[$key];
if (isset($import[ $key ])) {
$toSet[ $key ] = $import[ $key ];
}
}
@ -1634,8 +1641,8 @@ SQL
$skipped = array();
if ($validation !== true) {
foreach ($validation as $error) {
$skipped[$error['option']] = $error['error'];
unset($toSet[$error['option']]);
$skipped[ $error['option'] ] = $error['error'];
unset($toSet[ $error['option'] ]);
}
}
@ -1657,20 +1664,20 @@ SQL
}
return array(
'ok' => 1,
'ok' => 1,
'totalSet' => $totalSet,
'settings' => $this->get_settings(),
);
}
elseif ($res['err']) {
return array('errorImport' => 'An error occurred: ' . $res['err']);
return array( 'errorImport' => 'An error occurred: ' . $res['err'] );
}
else {
throw new Exception('Invalid response: ' . var_export($res, true));
}
}
catch (Exception $e) {
return array('errorImport' => 'An error occurred: ' . $e->getMessage());
return array( 'errorImport' => 'An error occurred: ' . $e->getMessage() );
}
}
@ -1678,7 +1685,7 @@ SQL
$keys = wfConfig::getExportableOptionsKeys();
$settings = array();
foreach($keys as $key){
$settings[$key] = wfConfig::get($key, '');
$settings[ $key ] = wfConfig::get($key, '');
}
$settings['apiKey'] = wfConfig::get('apiKey'); //get more apiKey
$settings['isPaid'] = wfConfig::get('isPaid');
@ -1693,9 +1700,9 @@ SQL
$table_wfStatus = wfDB::networkTable('wfStatus');
$jsonData = array(
'serverTime' => $serverTime,
'serverTime' => $serverTime,
'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();
@ -1845,7 +1852,7 @@ SQL
$data['rules'] = wfWAF::getInstance()->getRules();
/** @var wfWAFRule $rule */
foreach ($data['rules'] as $ruleID => $rule) {
$data['rules'][$ruleID] = $rule->toArray();
$data['rules'][ $ruleID ] = $rule->toArray();
}
$whitelistedURLParams = wfWAF::getInstance()->getStorageEngine()->getConfig('whitelistedURLParams', array());
@ -1899,12 +1906,15 @@ SQL
$res[ $ip ] = wfUtils::reverseLookup( $ip );
}
return array( 'ok' => 1, 'ips' => $res );
return array(
'ok' => 1,
'ips' => $res,
);
}
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();
@ -1945,7 +1955,7 @@ SQL
}
wfConfig::save($changes);
return array('success' => true);
return array( 'success' => true );
}
catch (wfWAFStorageFileException $e) {
return array(
@ -2002,7 +2012,7 @@ SQL
public static function saveCountryBlocking() {
if(! wfConfig::get('isPaid')){
return array('error' => 'Sorry but this feature is only available for paid customers.');
return array( 'error' => 'Sorry but this feature is only available for paid customers.' );
}
$settings = $_POST['settings'];
wfConfig::set('cbl_action', $settings['blockAction']);
@ -2014,7 +2024,7 @@ SQL
wfConfig::set('cbl_bypassRedirURL', $settings['bypassRedirURL']);
wfConfig::set('cbl_bypassRedirDest', $settings['bypassRedirDest']);
wfConfig::set('cbl_bypassViewURL', $settings['bypassViewURL']);
return array('ok' => 1);
return array( 'ok' => 1 );
}
public function load_static_panel() {
@ -2030,7 +2040,10 @@ SQL
$results = $wfLog->getThrottledIPs();
}
return array( 'ok' => 1, 'results' => $results );
return array(
'ok' => 1,
'results' => $results,
);
}
public function downgrade_license() {
@ -2089,16 +2102,16 @@ SQL
}
}
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.');
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)){
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");
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', '')){
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.');
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;
@ -2112,7 +2125,11 @@ SQL
if($cacheType == 'php' || $cacheType == 'falcon'){
$err = wfCache::cacheDirectoryTest();
if($err){
return array('ok' => 1, 'heading' => 'Could not write to cache directory', 'body' => "To enable caching, Wordfence needs to be able to create and write to the /wp-content/wfcache/ directory. We did some tests that indicate this is not possible. You need to manually create the /wp-content/wfcache/ directory and make it writable by Wordfence. The error we encountered was during our tests was: $err");
return array(
'ok' => 1,
'heading' => 'Could not write to cache directory',
'body' => "To enable caching, Wordfence needs to be able to create and write to the /wp-content/wfcache/ directory. We did some tests that indicate this is not possible. You need to manually create the /wp-content/wfcache/ directory and make it writable by Wordfence. The error we encountered was during our tests was: $err",
);
}
}
@ -2126,55 +2143,80 @@ SQL
}
if($cacheType == 'disable'){
wfConfig::set('cacheType', false);
return array('ok' => 1, 'heading' => 'Caching successfully disabled.', 'body' => "{$htMsg}Caching has been disabled on your system.<br /><br /><center><input type='button' name='wfReload' value='Click here now to refresh this page' onclick='window.location.reload(true);' /></center>");
return array(
'ok' => 1,
'heading' => 'Caching successfully disabled.',
'body' => "{$htMsg}Caching has been disabled on your system.<br /><br /><center><input type='button' name='wfReload' value='Click here now to refresh this page' onclick='window.location.reload(true);' /></center>",
);
} 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.<br /><br /><center><input type='button' name='wfReload' value='Click here now to refresh this page' onclick='window.location.reload(true);' /></center>");
return array(
'ok' => 1,
'heading' => 'Wordfence Basic Caching Enabled',
'body' => "{$htMsg}Wordfence basic caching has been enabled on your system.<br /><br /><center><input type='button' name='wfReload' value='Click here now to refresh this page' onclick='window.location.reload(true);' /></center>",
);
} elseif($cacheType == 'falcon'){
if($noEditHtaccess != '1'){
$err = wfCache::addHtaccessCode('add');
if($err){
return array('ok' => 1, 'heading' => 'Wordfence could not edit .htaccess', 'body' => 'Wordfence could not edit your .htaccess code. The error was: ' . $err);
return array(
'ok' => 1,
'heading' => 'Wordfence could not edit .htaccess',
'body' => 'Wordfence could not edit your .htaccess code. The error was: ' . $err,
);
}
}
wfConfig::set('cacheType', 'falcon');
wfCache::scheduleUpdateBlockedIPs(); //Runs every 5 mins until we change cachetype
return array('ok' => 1, 'heading' => 'Wordfence Falcon Engine Activated!', 'body' => "Wordfence Falcon Engine has been activated on your system. You will see this icon appear on the Wordfence admin pages as long as Falcon is active indicating your site is running in high performance mode:<div class='wfFalconImage'></div><center><input type='button' name='wfReload' value='Click here now to refresh this page' onclick='window.location.reload(true);' /></center>");
return array(
'ok' => 1,
'heading' => 'Wordfence Falcon Engine Activated!',
'body' => "Wordfence Falcon Engine has been activated on your system. You will see this icon appear on the Wordfence admin pages as long as Falcon is active indicating your site is running in high performance mode:<div class='wfFalconImage'></div><center><input type='button' name='wfReload' value='Click here now to refresh this page' onclick='window.location.reload(true);' /></center>",
);
}
return array('errorMsg' => 'An error occurred.');
return array( 'errorMsg' => 'An error occurred.' );
}
public static function checkFalconHtaccess() {
if(wfUtils::isNginx()){
return array('nginx' => 1);
return array( 'nginx' => 1 );
}
$file = wfCache::getHtaccessPath();
if(! $file){
return array('err' => 'We could not find your .htaccess file to modify it.', 'code' => wfCache::getHtaccessCode() );
return array(
'err' => 'We could not find your .htaccess file to modify it.',
'code' => wfCache::getHtaccessCode(),
);
}
$fh = @fopen($file, 'r+');
if(! $fh){
$err = error_get_last();
return array('err' => 'We found your .htaccess file but could not open it for writing: ' . $err['message'], 'code' => wfCache::getHtaccessCode() );
return array(
'err' => 'We found your .htaccess file but could not open it for writing: ' . $err['message'],
'code' => wfCache::getHtaccessCode(),
);
}
$download_url = admin_url( 'admin-ajax.php' ) . '?action=mainwp_wordfence_download_htaccess&_wpnonce=' . MainWP_Helper::create_nonce_without_session( 'mainwp_download_htaccess' );
return array( 'ok' => 1, 'download_url' => $download_url );
return array(
'ok' => 1,
'download_url' => $download_url,
);
}
public static function checkHtaccess() {
if(wfUtils::isNginx()){
return array('nginx' => 1);
return array( 'nginx' => 1 );
}
$file = wfCache::getHtaccessPath();
if(! $file){
return array('err' => 'We could not find your .htaccess file to modify it.');
return array( 'err' => 'We could not find your .htaccess file to modify it.' );
}
$fh = @fopen($file, 'r+');
if(! $fh){
$err = error_get_last();
return array('err' => 'We found your .htaccess file but could not open it for writing: ' . $err['message']);
return array( 'err' => 'We found your .htaccess file but could not open it for writing: ' . $err['message'] );
}
return array('ok' => 1);
return array( 'ok' => 1 );
}
public static function downloadHtaccess() {
@ -2209,30 +2251,45 @@ SQL
if($changed && wfConfig::get('cacheType', false) == 'falcon'){
$err = wfCache::addHtaccessCode('add');
if($err){
return array('updateErr' => 'Wordfence could not edit your .htaccess file. The error was: ' . $err, 'code' => wfCache::getHtaccessCode() );
return array(
'updateErr' => 'Wordfence could not edit your .htaccess file. The error was: ' . $err,
'code' => wfCache::getHtaccessCode(),
);
}
}
wfCache::scheduleCacheClear();
return array('ok' => 1);
return array( 'ok' => 1 );
}
public static function clearPageCache() {
$stats = wfCache::clearPageCache();
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, 'heading' => 'Error occurred while clearing cache', 'body' => $body );
return array(
'ok' => 1,
'heading' => 'Error occurred while clearing cache',
'body' => $body,
);
}
$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/';
}
return array('ok' => 1, 'heading' => 'Page Cache Cleared', 'body' => $body );
return array(
'ok' => 1,
'heading' => 'Page Cache Cleared',
'body' => $body,
);
}
public static function getCacheStats() {
$s = wfCache::getCacheStats();
if($s['files'] == 0){
return array('ok' => 1, 'heading' => 'Cache Stats', 'body' => 'The cache is currently empty. It may be disabled or it may have been recently cleared.');
return array(
'ok' => 1,
'heading' => 'Cache Stats',
'body' => 'The cache is currently empty. It may be disabled or it may have been recently cleared.',
);
}
$body = 'Total files in cache: ' . $s['files'] .
'<br />Total directories in cache: ' . $s['dirs'] .
@ -2249,7 +2306,7 @@ SQL
if($s['oldestFile'] !== false){
$body .= '<br />Oldest file in cache created ';
if(time() - $s['oldestFile'] < 300){
$body .= (time() - $s['oldestFile']) . ' seconds ago';
$body .= ( time() - $s['oldestFile'] ) . ' seconds ago';
} else {
$body .= human_time_diff($s['oldestFile']) . ' ago.';
}
@ -2257,13 +2314,17 @@ SQL
if($s['newestFile'] !== false){
$body .= '<br />Newest file in cache created ';
if(time() - $s['newestFile'] < 300){
$body .= (time() - $s['newestFile']) . ' seconds ago';
$body .= ( time() - $s['newestFile'] ) . ' seconds ago';
} else {
$body .= human_time_diff($s['newestFile']) . ' ago.';
}
}
return array('ok' => 1, 'heading' => 'Cache Stats', 'body' => $body);
return array(
'ok' => 1,
'heading' => 'Cache Stats',
'body' => $body,
);
}
public static function addCacheExclusion() {
@ -2278,7 +2339,7 @@ SQL
} else {
$ex[] = array(
'pt' => $_POST['patternType'],
'p' => $_POST['pattern'],
'p' => $_POST['pattern'],
'id' => $_POST['id'],
);
}
@ -2286,33 +2347,42 @@ SQL
wfCache::scheduleCacheClear();
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);
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,
);
}
}
return array('ok' => 1, 'ex' => $ex);
return array(
'ok' => 1,
'ex' => $ex,
);
}
public static function loadCacheExclusions() {
$ex = wfConfig::get('cacheExclusions', false);
if(! $ex){
return array('ex' => false);
return array( 'ex' => false );
}
$ex = unserialize($ex);
return array('ok' => 1, 'ex' => $ex);
return array(
'ok' => 1,
'ex' => $ex,
);
}
public static function removeCacheExclusion() {
$id = $_POST['id'];
$ex = wfConfig::get('cacheExclusions', false);
if(! $ex){
return array('ok' => 1);
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'])){
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);
@ -2320,7 +2390,7 @@ SQL
$removed = true;
}
}
$return = array('ex' => $ex);
$return = array( 'ex' => $ex );
if (!$removed) {
$return['error'] = 'Not found the cache exclusion.';
return $return;
@ -2385,7 +2455,7 @@ SQL
'code' => array(),
'strong' => array(),
'em' => array(),
'a' => array('href' => true),
'a' => array( 'href' => true ),
))
?>
</td>
@ -2403,8 +2473,8 @@ SQL
<?php else: ?>
<div class="wf-block
<?php
echo (wfPersistenceController::shared()->isActive($key) ? ' wf-active' : '') .
($hasFailingTest ? ' wf-diagnostic-fail' : '')
echo ( wfPersistenceController::shared()->isActive($key) ? ' wf-active' : '' ) .
( $hasFailingTest ? ' wf-diagnostic-fail' : '' )
?>
" data-persistence-key="<?php echo esc_attr($key); ?>">
<div class="wf-block-header">
@ -2429,7 +2499,7 @@ SQL
'code' => array(),
'strong' => array(),
'em' => array(),
'a' => array('href' => true),
'a' => array( 'href' => true ),
))
?>
</div>
@ -2456,13 +2526,13 @@ SQL
'HTTP_X_REAL_IP' => 'X-Real-IP',
'HTTP_X_FORWARDED_FOR' => 'X-Forwarded-For',
) as $variable => $label) {
if (!($currentServerVarForIP && $currentServerVarForIP === $variable) && $howGet === $variable) {
if (!( $currentServerVarForIP && $currentServerVarForIP === $variable ) && $howGet === $variable) {
$howGetHasErrors = true;
break;
}
}
?>
<div class="wf-block<?php echo ($howGetHasErrors ? ' wf-diagnostic-fail' : '') . (wfPersistenceController::shared()->isActive('wf-diagnostics-client-ip') ? ' wf-active' : ''); ?>" data-persistence-key="<?php echo esc_attr('wf-diagnostics-client-ip'); ?>">
<div class="wf-block<?php echo ( $howGetHasErrors ? ' wf-diagnostic-fail' : '' ) . ( wfPersistenceController::shared()->isActive('wf-diagnostics-client-ip') ? ' wf-active' : '' ); ?>" data-persistence-key="<?php echo esc_attr('wf-diagnostics-client-ip'); ?>">
<div class="wf-block-header">
<div class="wf-block-header-content">
<div class="wf-block-title">
@ -2502,9 +2572,9 @@ SQL
if (!array_key_exists($variable, $_SERVER)) {
echo '(not set)';
} else {
if (strpos($_SERVER[$variable], ',') !== false) {
if (strpos($_SERVER[ $variable ], ',') !== false) {
$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);
$output = '';
$markedSelectedAddress = false;
@ -2528,7 +2598,7 @@ SQL
echo substr($output, 0, -2);
} else {
echo esc_html($_SERVER[$variable]);
echo esc_html($_SERVER[ $variable ]);
}
}
?>
@ -2548,7 +2618,7 @@ SQL
</div>
</div>
<div class="wf-block<?php echo(wfPersistenceController::shared()->isActive('wf-diagnostics-wordpress-constants') ? ' wf-active' : ''); ?>" data-persistence-key="<?php echo esc_attr('wf-diagnostics-wordpress-constants'); ?>">
<div class="wf-block<?php echo( wfPersistenceController::shared()->isActive('wf-diagnostics-wordpress-constants') ? ' wf-active' : '' ); ?>" data-persistence-key="<?php echo esc_attr('wf-diagnostics-wordpress-constants'); ?>">
<div class="wf-block-header">
<div class="wf-block-header-content">
<div class="wf-block-title">
@ -2565,58 +2635,154 @@ SQL
<tbody>
<?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(
'WordPress Version' => array('description' => '', 'value' => $wp_version),
'WP_DEBUG' => array('description' => 'WordPress debug mode', 'value' => (defined('WP_DEBUG') && WP_DEBUG ? 'On' : 'Off')),
'WP_DEBUG_LOG' => array('description' => 'WordPress error logging override', 'value' => defined('WP_DEBUG_LOG') ? (WP_DEBUG_LOG ? 'Enabled' : 'Disabled') : '(not set)'),
'WP_DEBUG_DISPLAY' => array('description' => 'WordPress error display override', 'value' => defined('WP_DEBUG_DISPLAY') ? (WP_DEBUG_LOG ? 'Enabled' : 'Disabled') : '(not set)'),
'SCRIPT_DEBUG' => array('description' => 'WordPress script debug mode', 'value' => (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? 'On' : 'Off')),
'SAVEQUERIES' => array('description' => 'WordPress query debug mode', 'value' => (defined('SAVEQUERIES') && SAVEQUERIES ? 'On' : 'Off')),
'WordPress Version' => array(
'description' => '',
'value' => $wp_version,
),
'WP_DEBUG' => array(
'description' => 'WordPress debug mode',
'value' => ( defined('WP_DEBUG') && WP_DEBUG ? 'On' : 'Off' ),
),
'WP_DEBUG_LOG' => array(
'description' => 'WordPress error logging override',
'value' => defined('WP_DEBUG_LOG') ? ( WP_DEBUG_LOG ? 'Enabled' : 'Disabled' ) : '(not set)',
),
'WP_DEBUG_DISPLAY' => array(
'description' => 'WordPress error display override',
'value' => defined('WP_DEBUG_DISPLAY') ? ( WP_DEBUG_LOG ? 'Enabled' : 'Disabled' ) : '(not set)',
),
'SCRIPT_DEBUG' => array(
'description' => 'WordPress script debug mode',
'value' => ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? 'On' : 'Off' ),
),
'SAVEQUERIES' => array(
'description' => 'WordPress query debug mode',
'value' => ( defined('SAVEQUERIES') && SAVEQUERIES ? 'On' : 'Off' ),
),
'DB_CHARSET' => 'Database character set',
'DB_COLLATE' => 'Database collation',
'WP_SITEURL' => 'Explicitly set site URL',
'WP_HOME' => 'Explicitly set blog URL',
'WP_CONTENT_DIR' => array('description' => '"wp-content" folder is in default location', 'value' => (realpath(WP_CONTENT_DIR) === realpath(ABSPATH . 'wp-content') ? 'Yes' : 'No')),
'WP_CONTENT_DIR' => array(
'description' => '"wp-content" folder is in default location',
'value' => ( realpath(WP_CONTENT_DIR) === realpath(ABSPATH . 'wp-content') ? 'Yes' : 'No' ),
),
'WP_CONTENT_URL' => 'URL to the "wp-content" folder',
'WP_PLUGIN_DIR' => array('description' => '"plugins" folder is in default location', 'value' => (realpath(WP_PLUGIN_DIR) === realpath(ABSPATH . 'wp-content/plugins') ? 'Yes' : 'No')),
'WP_LANG_DIR' => array('description' => '"languages" folder is in default location', 'value' => (realpath(WP_LANG_DIR) === realpath(ABSPATH . 'wp-content/languages') ? 'Yes' : 'No')),
'WP_PLUGIN_DIR' => array(
'description' => '"plugins" folder is in default location',
'value' => ( realpath(WP_PLUGIN_DIR) === realpath(ABSPATH . 'wp-content/plugins') ? 'Yes' : 'No' ),
),
'WP_LANG_DIR' => array(
'description' => '"languages" folder is in default location',
'value' => ( realpath(WP_LANG_DIR) === realpath(ABSPATH . 'wp-content/languages') ? 'Yes' : 'No' ),
),
'WPLANG' => 'Language choice',
'UPLOADS' => 'Custom upload folder location',
'TEMPLATEPATH' => array('description' => 'Theme template folder override', 'value' => (defined('TEMPLATEPATH') && realpath(get_template_directory()) !== realpath(TEMPLATEPATH) ? 'Overridden' : '(not set)')),
'STYLESHEETPATH' => array('description' => 'Theme stylesheet folder override', 'value' => (defined('STYLESHEETPATH') && realpath(get_stylesheet_directory()) !== realpath(STYLESHEETPATH) ? 'Overridden' : '(not set)')),
'TEMPLATEPATH' => array(
'description' => 'Theme template folder override',
'value' => ( defined('TEMPLATEPATH') && realpath(get_template_directory()) !== realpath(TEMPLATEPATH) ? 'Overridden' : '(not set)' ),
),
'STYLESHEETPATH' => array(
'description' => 'Theme stylesheet folder override',
'value' => ( defined('STYLESHEETPATH') && realpath(get_stylesheet_directory()) !== realpath(STYLESHEETPATH) ? 'Overridden' : '(not set)' ),
),
'AUTOSAVE_INTERVAL' => 'Post editing automatic saving interval',
'WP_POST_REVISIONS' => array('description' => 'Post revisions saved by WordPress', 'value' => is_numeric($postRevisions) ? $postRevisions : ($postRevisions ? 'Unlimited' : 'None')),
'WP_POST_REVISIONS' => array(
'description' => 'Post revisions saved by WordPress',
'value' => is_numeric($postRevisions) ? $postRevisions : ( $postRevisions ? 'Unlimited' : 'None' ),
),
'COOKIE_DOMAIN' => 'WordPress cookie domain',
'COOKIEPATH' => 'WordPress cookie path',
'SITECOOKIEPATH' => 'WordPress site cookie path',
'ADMIN_COOKIE_PATH' => 'WordPress admin cookie path',
'PLUGINS_COOKIE_PATH' => 'WordPress plugins cookie path',
'WP_ALLOW_MULTISITE' => array('description' => 'Multisite/network ability enabled', 'value' => (defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ? 'Yes' : 'No')),
'WP_ALLOW_MULTISITE' => array(
'description' => 'Multisite/network ability enabled',
'value' => ( defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ? 'Yes' : 'No' ),
),
'NOBLOGREDIRECT' => 'URL redirected to if the visitor tries to access a nonexistent blog',
'CONCATENATE_SCRIPTS' => array('description' => 'Concatenate JavaScript files', 'value' => (defined('CONCATENATE_SCRIPTS') && CONCATENATE_SCRIPTS ? 'Yes' : 'No')),
'CONCATENATE_SCRIPTS' => array(
'description' => 'Concatenate JavaScript files',
'value' => ( defined('CONCATENATE_SCRIPTS') && CONCATENATE_SCRIPTS ? 'Yes' : 'No' ),
),
'WP_MEMORY_LIMIT' => 'WordPress memory limit',
'WP_MAX_MEMORY_LIMIT' => 'Administrative memory limit',
'WP_CACHE' => array('description' => 'Built-in caching', 'value' => (defined('WP_CACHE') && WP_CACHE ? 'Enabled' : 'Disabled')),
'CUSTOM_USER_TABLE' => array('description' => 'Custom "users" table', 'value' => (defined('CUSTOM_USER_TABLE') ? 'Set' : '(not set)')),
'CUSTOM_USER_META_TABLE' => array('description' => 'Custom "usermeta" table', 'value' => (defined('CUSTOM_USER_META_TABLE') ? 'Set' : '(not set)')),
'FS_CHMOD_DIR' => array('description' => 'Overridden permissions for a new folder', 'value' => defined('FS_CHMOD_DIR') ? decoct(FS_CHMOD_DIR) : '(not set)'),
'FS_CHMOD_FILE' => array('description' => 'Overridden permissions for a new file', 'value' => defined('FS_CHMOD_FILE') ? decoct(FS_CHMOD_FILE) : '(not set)'),
'ALTERNATE_WP_CRON' => array('description' => 'Alternate WP cron', 'value' => (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON ? 'Enabled' : 'Disabled')),
'DISABLE_WP_CRON' => array('description' => 'WP cron status', 'value' => (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ? 'Disabled' : 'Enabled')),
'WP_CACHE' => array(
'description' => 'Built-in caching',
'value' => ( defined('WP_CACHE') && WP_CACHE ? 'Enabled' : 'Disabled' ),
),
'CUSTOM_USER_TABLE' => array(
'description' => 'Custom "users" table',
'value' => ( defined('CUSTOM_USER_TABLE') ? 'Set' : '(not set)' ),
),
'CUSTOM_USER_META_TABLE' => array(
'description' => 'Custom "usermeta" table',
'value' => ( defined('CUSTOM_USER_META_TABLE') ? 'Set' : '(not set)' ),
),
'FS_CHMOD_DIR' => array(
'description' => 'Overridden permissions for a new folder',
'value' => defined('FS_CHMOD_DIR') ? decoct(FS_CHMOD_DIR) : '(not set)',
),
'FS_CHMOD_FILE' => array(
'description' => 'Overridden permissions for a new file',
'value' => defined('FS_CHMOD_FILE') ? decoct(FS_CHMOD_FILE) : '(not set)',
),
'ALTERNATE_WP_CRON' => array(
'description' => 'Alternate WP cron',
'value' => ( defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON ? 'Enabled' : 'Disabled' ),
),
'DISABLE_WP_CRON' => array(
'description' => 'WP cron status',
'value' => ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ? 'Disabled' : 'Enabled' ),
),
'WP_CRON_LOCK_TIMEOUT' => 'Cron running frequency lock',
'EMPTY_TRASH_DAYS' => array('description' => 'Interval the trash is automatically emptied at in days', 'value' => (EMPTY_TRASH_DAYS > 0 ? EMPTY_TRASH_DAYS : 'Never')),
'WP_ALLOW_REPAIR' => array('description' => 'Automatic database repair', 'value' => (defined('WP_ALLOW_REPAIR') && WP_ALLOW_REPAIR ? 'Enabled' : 'Disabled')),
'DO_NOT_UPGRADE_GLOBAL_TABLES' => array('description' => 'Do not upgrade global tables', 'value' => (defined('DO_NOT_UPGRADE_GLOBAL_TABLES') && DO_NOT_UPGRADE_GLOBAL_TABLES ? 'Yes' : 'No')),
'DISALLOW_FILE_EDIT' => array('description' => 'Disallow plugin/theme editing', 'value' => (defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT ? 'Yes' : 'No')),
'DISALLOW_FILE_MODS' => array('description' => 'Disallow plugin/theme update and installation', 'value' => (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS ? 'Yes' : 'No')),
'IMAGE_EDIT_OVERWRITE' => array('description' => 'Overwrite image edits when restoring the original', 'value' => (defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ? 'Yes' : 'No')),
'FORCE_SSL_ADMIN' => array('description' => 'Force SSL for administrative logins', 'value' => (defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'Yes' : 'No')),
'WP_HTTP_BLOCK_EXTERNAL' => array('description' => 'Block external URL requests', 'value' => (defined('WP_HTTP_BLOCK_EXTERNAL') && WP_HTTP_BLOCK_EXTERNAL ? 'Yes' : 'No')),
'EMPTY_TRASH_DAYS' => array(
'description' => 'Interval the trash is automatically emptied at in days',
'value' => ( EMPTY_TRASH_DAYS > 0 ? EMPTY_TRASH_DAYS : 'Never' ),
),
'WP_ALLOW_REPAIR' => array(
'description' => 'Automatic database repair',
'value' => ( defined('WP_ALLOW_REPAIR') && WP_ALLOW_REPAIR ? 'Enabled' : 'Disabled' ),
),
'DO_NOT_UPGRADE_GLOBAL_TABLES' => array(
'description' => 'Do not upgrade global tables',
'value' => ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') && DO_NOT_UPGRADE_GLOBAL_TABLES ? 'Yes' : 'No' ),
),
'DISALLOW_FILE_EDIT' => array(
'description' => 'Disallow plugin/theme editing',
'value' => ( defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT ? 'Yes' : 'No' ),
),
'DISALLOW_FILE_MODS' => array(
'description' => 'Disallow plugin/theme update and installation',
'value' => ( defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS ? 'Yes' : 'No' ),
),
'IMAGE_EDIT_OVERWRITE' => array(
'description' => 'Overwrite image edits when restoring the original',
'value' => ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ? 'Yes' : 'No' ),
),
'FORCE_SSL_ADMIN' => array(
'description' => 'Force SSL for administrative logins',
'value' => ( defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'Yes' : 'No' ),
),
'WP_HTTP_BLOCK_EXTERNAL' => array(
'description' => 'Block external URL requests',
'value' => ( defined('WP_HTTP_BLOCK_EXTERNAL') && WP_HTTP_BLOCK_EXTERNAL ? 'Yes' : 'No' ),
),
'WP_ACCESSIBLE_HOSTS' => 'Whitelisted hosts',
'WP_AUTO_UPDATE_CORE' => array('description' => 'Automatic WP Core updates', 'value' => defined('WP_AUTO_UPDATE_CORE') ? (is_bool(WP_AUTO_UPDATE_CORE) ? (WP_AUTO_UPDATE_CORE ? 'Everything' : 'None') : WP_AUTO_UPDATE_CORE) : 'Default'),
'WP_PROXY_HOST' => array('description' => 'Hostname for a proxy server', 'value' => defined('WP_PROXY_HOST') ? WP_PROXY_HOST : '(not set)'),
'WP_PROXY_PORT' => array('description' => 'Port for a proxy server', 'value' => defined('WP_PROXY_PORT') ? WP_PROXY_PORT : '(not set)'),
'WP_AUTO_UPDATE_CORE' => array(
'description' => 'Automatic WP Core updates',
'value' => defined('WP_AUTO_UPDATE_CORE') ? ( is_bool(WP_AUTO_UPDATE_CORE) ? ( WP_AUTO_UPDATE_CORE ? 'Everything' : 'None' ) : WP_AUTO_UPDATE_CORE ) : 'Default',
),
'WP_PROXY_HOST' => array(
'description' => 'Hostname for a proxy server',
'value' => defined('WP_PROXY_HOST') ? WP_PROXY_HOST : '(not set)',
),
'WP_PROXY_PORT' => array(
'description' => 'Port for a proxy server',
'value' => defined('WP_PROXY_PORT') ? WP_PROXY_PORT : '(not set)',
),
);
foreach ($wordPressValues as $settingName => $settingData):
@ -2646,7 +2812,7 @@ SQL
</div>
</div>
<div class="wf-block<?php echo(wfPersistenceController::shared()->isActive('wf-diagnostics-wordpress-plugins') ? ' wf-active' : ''); ?>" data-persistence-key="<?php echo esc_attr('wf-diagnostics-wordpress-plugins'); ?>">
<div class="wf-block<?php echo( wfPersistenceController::shared()->isActive('wf-diagnostics-wordpress-plugins') ? ' wf-active' : '' ); ?>" data-persistence-key="<?php echo esc_attr('wf-diagnostics-wordpress-plugins'); ?>">
<div class="wf-block-header">
<div class="wf-block-header-content">
<div class="wf-block-title">
@ -2682,7 +2848,7 @@ SQL
</table>
</div>
</div>
<div class="wf-block<?php echo(wfPersistenceController::shared()->isActive('wf-diagnostics-mu-wordpress-plugins') ? ' wf-active' : ''); ?>" data-persistence-key="<?php echo esc_attr('wf-diagnostics-mu-wordpress-plugins'); ?>">
<div class="wf-block<?php echo( wfPersistenceController::shared()->isActive('wf-diagnostics-mu-wordpress-plugins') ? ' wf-active' : '' ); ?>" data-persistence-key="<?php echo esc_attr('wf-diagnostics-mu-wordpress-plugins'); ?>">
<div class="wf-block-header">
<div class="wf-block-header-content">
<div class="wf-block-title">
@ -2721,7 +2887,7 @@ SQL
</table>
</div>
</div>
<div class="wf-block<?php echo(wfPersistenceController::shared()->isActive('wf-diagnostics-wordpress-themes') ? ' wf-active' : ''); ?>" data-persistence-key="<?php echo esc_attr('wf-diagnostics-wordpress-themes'); ?>">
<div class="wf-block<?php echo( wfPersistenceController::shared()->isActive('wf-diagnostics-wordpress-themes') ? ' wf-active' : '' ); ?>" data-persistence-key="<?php echo esc_attr('wf-diagnostics-wordpress-themes'); ?>">
<div class="wf-block-header">
<div class="wf-block-header-content">
<div class="wf-block-title">
@ -2761,7 +2927,7 @@ SQL
</table>
</div>
</div>
<div class="wf-block<?php echo(wfPersistenceController::shared()->isActive('wf-diagnostics-wordpress-cron-jobs') ? ' wf-active' : ''); ?>" data-persistence-key="<?php echo esc_attr('wf-diagnostics-wordpress-cron-jobs'); ?>">
<div class="wf-block<?php echo( wfPersistenceController::shared()->isActive('wf-diagnostics-wordpress-cron-jobs') ? ' wf-active' : '' ); ?>" data-persistence-key="<?php echo esc_attr('wf-diagnostics-wordpress-cron-jobs'); ?>">
<div class="wf-block-header">
<div class="wf-block-header-content">
<div class="wf-block-title">
@ -2813,7 +2979,7 @@ SQL
if ($q):
$databaseCols = count($q[0]);
?>
<div class="wf-block<?php echo(wfPersistenceController::shared()->isActive('wf-diagnostics-database-tables') ? ' wf-active' : ''); ?>" data-persistence-key="<?php echo esc_attr('wf-diagnostics-database-tables'); ?>">
<div class="wf-block<?php echo( wfPersistenceController::shared()->isActive('wf-diagnostics-database-tables') ? ' wf-active' : '' ); ?>" data-persistence-key="<?php echo esc_attr('wf-diagnostics-database-tables'); ?>">
<div class="wf-block-header">
<div class="wf-block-header-content">
<div class="wf-block-title">
@ -2868,7 +3034,7 @@ SQL
</div>
</div>
<?php endif ?>
<div class="wf-block<?php echo(wfPersistenceController::shared()->isActive('wf-diagnostics-log-files') ? ' wf-active' : ''); ?>" data-persistence-key="<?php echo esc_attr('wf-diagnostics-log-files'); ?>">
<div class="wf-block<?php echo( wfPersistenceController::shared()->isActive('wf-diagnostics-log-files') ? ' wf-active' : '' ); ?>" data-persistence-key="<?php echo esc_attr('wf-diagnostics-log-files'); ?>">
<div class="wf-block-header">
<div class="wf-block-header-content">
<div class="wf-block-title">
@ -2903,7 +3069,7 @@ SQL
?>
<tr>
<td style="width: 100%"><?php echo esc_html($log) . ' (' . wfUtils::formatBytes(filesize($log)) . ')'; ?></td>
<td style="white-space: nowrap; text-align: right;"><?php echo($readable ? '<a href="#" data-logfile="' . esc_html($log) . '" class="downloadLogFile" target="_blank" rel="noopener noreferrer">Download</a>' : '<em>Requires downloading from the server directly</em>'); ?></td>
<td style="white-space: nowrap; text-align: right;"><?php echo( $readable ? '<a href="#" data-logfile="' . esc_html($log) . '" class="downloadLogFile" target="_blank" rel="noopener noreferrer">Download</a>' : '<em>Requires downloading from the server directly</em>' ); ?></td>
</tr>
<?php
endforeach;
@ -2959,7 +3125,10 @@ SQL
<?php
$html = ob_get_clean();
return array('ok' => 1, 'html' => $html);
return array(
'ok' => 1,
'html' => $html,
);
}
public static function updateWAFRules() {
@ -2968,7 +3137,10 @@ SQL
$event->fire();
$isPaid = (bool) wfConfig::get('isPaid', 0);
//return self::_getWAFData();
return array('ok' => 1, 'isPaid' => $isPaid );
return array(
'ok' => 1,
'isPaid' => $isPaid,
);
}
public static function updateWAFRules_New() {
@ -2982,10 +3154,10 @@ SQL
public static function save_debugging_config() {
$settings = $_POST['settings'];
foreach (self::$diagnosticParams as $param) {
if (isset($settings[$param])) {
wfConfig::set( $param, $settings[$param] );
if (isset($settings[ $param ])) {
wfConfig::set( $param, $settings[ $param ] );
}
}
return array('ok' => 1 );
return array( 'ok' => 1 );
}
}

View file

@ -56,81 +56,81 @@ class MainWP_Child_WP_Rocket {
function get_rocket_default_options() {
return array(
'cache_mobile' => 1,
'do_caching_mobile_files' => 0,
'cache_logged_user' => 0,
'cache_ssl' => 0,
'emoji' => 0,
'embeds' => 1,
'control_heartbeat' => 0,
'heartbeat_site_behavior' => 'reduce_periodicity',
'heartbeat_admin_behavior' => 'reduce_periodicity',
'heartbeat_editor_behavior' => 'reduce_periodicity',
'varnish_auto_purge' => 0,
'manual_preload' => 0,
'automatic_preload' => 0,
'sitemap_preload' => 0,
'sitemap_preload_url_crawl' => 500000,
'sitemaps' => array(),
'database_revisions' => 0,
'database_auto_drafts' => 0,
'database_trashed_posts' => 0,
'database_spam_comments' => 0,
'database_trashed_comments' => 0,
'database_expired_transients' => 0,
'database_all_transients' => 0,
'database_optimize_tables' => 0,
'schedule_automatic_cleanup' => 0,
'automatic_cleanup_frequency' => '',
'cache_reject_uri' => array(),
'cache_reject_cookies' => array(),
'cache_reject_ua' => array(),
'cache_query_strings' => array(),
'cache_purge_pages' => array(),
'purge_cron_interval' => 10,
'purge_cron_unit' => 'HOUR_IN_SECONDS',
'exclude_css' => array(),
'exclude_js' => array(),
'exclude_inline_js' => array(),
'async_css' => 0,
'defer_all_js' => 0,
'defer_all_js_safe' => 1,
'critical_css' => '',
'deferred_js_files' => array(),
'lazyload' => 0,
'lazyload_iframes' => 0,
'lazyload_youtube' =>0,
'minify_css' => 0,
'cache_mobile' => 1,
'do_caching_mobile_files' => 0,
'cache_logged_user' => 0,
'cache_ssl' => 0,
'emoji' => 0,
'embeds' => 1,
'control_heartbeat' => 0,
'heartbeat_site_behavior' => 'reduce_periodicity',
'heartbeat_admin_behavior' => 'reduce_periodicity',
'heartbeat_editor_behavior' => 'reduce_periodicity',
'varnish_auto_purge' => 0,
'manual_preload' => 0,
'automatic_preload' => 0,
'sitemap_preload' => 0,
'sitemap_preload_url_crawl' => 500000,
'sitemaps' => array(),
'database_revisions' => 0,
'database_auto_drafts' => 0,
'database_trashed_posts' => 0,
'database_spam_comments' => 0,
'database_trashed_comments' => 0,
'database_expired_transients' => 0,
'database_all_transients' => 0,
'database_optimize_tables' => 0,
'schedule_automatic_cleanup' => 0,
'automatic_cleanup_frequency' => '',
'cache_reject_uri' => array(),
'cache_reject_cookies' => array(),
'cache_reject_ua' => array(),
'cache_query_strings' => array(),
'cache_purge_pages' => array(),
'purge_cron_interval' => 10,
'purge_cron_unit' => 'HOUR_IN_SECONDS',
'exclude_css' => array(),
'exclude_js' => array(),
'exclude_inline_js' => array(),
'async_css' => 0,
'defer_all_js' => 0,
'defer_all_js_safe' => 1,
'critical_css' => '',
'deferred_js_files' => array(),
'lazyload' => 0,
'lazyload_iframes' => 0,
'lazyload_youtube' =>0,
'minify_css' => 0,
// 'minify_css_key' => $minify_css_key,
'minify_concatenate_css' => 0,
'minify_concatenate_css' => 0,
//'minify_css_combine_all' => 0,
'minify_css_legacy' => 0,
'minify_js' => 0,
'minify_css_legacy' => 0,
'minify_js' => 0,
// 'minify_js_key' => $minify_js_key,
'minify_js_in_footer' => array(),
'minify_concatenate_js' => 0,
'minify_js_combine_all' => 0,
'minify_js_in_footer' => array(),
'minify_concatenate_js' => 0,
'minify_js_combine_all' => 0,
//'minify_js_legacy' => 0,
'minify_google_fonts' => 0,
'minify_html' => 0,
'remove_query_strings' => 0,
'dns_prefetch' => 0,
'cdn' => 0,
'cdn_cnames' => array(),
'cdn_zone' => array(),
'minify_google_fonts' => 0,
'minify_html' => 0,
'remove_query_strings' => 0,
'dns_prefetch' => 0,
'cdn' => 0,
'cdn_cnames' => array(),
'cdn_zone' => array(),
//'cdn_ssl' => 0,
'cdn_reject_files' => array(),
'do_cloudflare' => 0,
'cloudflare_email' => '',
'cloudflare_api_key' => '',
'cloudflare_domain' => '',
'cdn_reject_files' => array(),
'do_cloudflare' => 0,
'cloudflare_email' => '',
'cloudflare_api_key' => '',
'cloudflare_domain' => '',
//'cloudflare_zone_id' => '',
'cloudflare_devmode' => 0,
'cloudflare_protocol_rewrite' => 0,
'cloudflare_auto_settings' => 0,
'cloudflare_old_settings' => 0,
'do_beta' => 0,
'analytics_enabled' => 1,
'cloudflare_devmode' => 0,
'cloudflare_protocol_rewrite' => 0,
'cloudflare_auto_settings' => 0,
'cloudflare_old_settings' => 0,
'do_beta' => 0,
'analytics_enabled' => 1,
);
}
@ -138,7 +138,7 @@ class MainWP_Child_WP_Rocket {
public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncWPRocketData'] ) && ( 'yes' === $data['syncWPRocketData'] ) ) {
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;
} catch(Exception $e) {
}
@ -305,9 +305,9 @@ class MainWP_Child_WP_Rocket {
if ( function_exists( 'opcache_reset' ) ) {
@opcache_reset();
} else {
return array('error' => 'The host do not support the function reset opcache.');
return array( 'error' => 'The host do not support the function reset opcache.' );
}
return array('result' => 'SUCCESS');
return array( 'result' => 'SUCCESS' );
}
function purge_cloudflare() {
@ -361,7 +361,7 @@ class MainWP_Child_WP_Rocket {
MainWP_Helper::check_classes_exists('WP_Rocket\Preload\Full_Process');
$preload_process = new WP_Rocket\Preload\Full_Process();
MainWP_Helper::check_methods($preload_process, array( 'is_process_running'));
MainWP_Helper::check_methods($preload_process, array( 'is_process_running' ));
if ( $preload_process->is_process_running() ) {
return array( 'result' => 'RUNNING' );
@ -374,11 +374,12 @@ class MainWP_Child_WP_Rocket {
}
function generate_critical_css() {
MainWP_Helper::check_classes_exists( array( 'WP_Rocket\Subscriber\Optimization\Critical_CSS_Subscriber',
'WP_Rocket\Optimization\CSS\Critical_CSS',
'WP_Rocket\Optimization\CSS\Critical_CSS_Generation',
'WP_Rocket\Admin\Options',
'WP_Rocket\Admin\Options_Data',
MainWP_Helper::check_classes_exists( array(
'WP_Rocket\Subscriber\Optimization\Critical_CSS_Subscriber',
'WP_Rocket\Optimization\CSS\Critical_CSS',
'WP_Rocket\Optimization\CSS\Critical_CSS_Generation',
'WP_Rocket\Admin\Options',
'WP_Rocket\Admin\Options_Data',
));
$critical_css = new WP_Rocket\Optimization\CSS\Critical_CSS( new WP_Rocket\Optimization\CSS\Critical_CSS_Generation() );
@ -421,10 +422,11 @@ class MainWP_Child_WP_Rocket {
function optimize_database() {
MainWP_Helper::check_classes_exists( array( 'WP_Rocket\Admin\Database\Optimization',
'WP_Rocket\Admin\Database\Optimization_Process',
'WP_Rocket\Admin\Options',
'WP_Rocket\Admin\Options_Data',
MainWP_Helper::check_classes_exists( array(
'WP_Rocket\Admin\Database\Optimization',
'WP_Rocket\Admin\Database\Optimization_Process',
'WP_Rocket\Admin\Options',
'WP_Rocket\Admin\Options_Data',
));
$process = new WP_Rocket\Admin\Database\Optimization_Process();
@ -446,8 +448,9 @@ class MainWP_Child_WP_Rocket {
function get_optimize_info() {
MainWP_Helper::check_classes_exists( array( 'WP_Rocket\Admin\Database\Optimization',
'WP_Rocket\Admin\Database\Optimization_Process',
MainWP_Helper::check_classes_exists( array(
'WP_Rocket\Admin\Database\Optimization',
'WP_Rocket\Admin\Database\Optimization_Process',
));
$process = new WP_Rocket\Admin\Database\Optimization_Process();
@ -455,10 +458,10 @@ class MainWP_Child_WP_Rocket {
MainWP_Helper::check_methods($optimization, 'count_cleanup_items');
$information['optimize_info'] = array(
'total_revisions' => $optimization->count_cleanup_items( 'database_revisions' ),
'total_revisions' => $optimization->count_cleanup_items( 'database_revisions' ),
'total_auto_draft' => $optimization->count_cleanup_items( 'database_auto_drafts' ),
'total_trashed_posts' => $optimization->count_cleanup_items( 'database_trashed_posts' ),
'total_spam_comments' => $optimization->count_cleanup_items( 'database_spam_comments' ),
'total_spam_comments' => $optimization->count_cleanup_items( 'database_spam_comments' ),
'total_trashed_comments' => $optimization->count_cleanup_items( 'database_trashed_comments' ),
'total_expired_transients' => $optimization->count_cleanup_items( 'database_expired_transients' ),
'total_all_transients' => $optimization->count_cleanup_items( 'database_all_transients' ),
@ -471,7 +474,10 @@ class MainWP_Child_WP_Rocket {
function load_existing_settings() {
$options = get_option( WP_ROCKET_SLUG );
return array('result' => 'SUCCESS', 'options' => $options);
return array(
'result' => 'SUCCESS',
'options' => $options,
);
}
}

View file

@ -129,7 +129,7 @@ class MainWP_Child_WPvivid_BackupRestore {
break;
}
} catch (Exception $e) {
$information = array('error' => $e->getMessage());
$information = array( 'error' => $e->getMessage() );
}
MainWP_Helper::write($information);

View file

@ -63,7 +63,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
// To fix verify nonce conflict #1
// this is fake post field to fix some conflict of wp_verify_nonce()
// just return false to unverify nonce, does not exit
if ( isset($_POST[$action]) && ($_POST[$action] == 'mainwp-bsm-unverify-nonce')) {
if ( isset($_POST[ $action ]) && ( $_POST[ $action ] == 'mainwp-bsm-unverify-nonce' )) {
return false;
}
@ -71,7 +71,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
@ob_start();
@debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$stackTrace = "\n" . @ob_get_clean();
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'You dont send nonce: ' . $action . '<br/>Trace: ' . $stackTrace) ) ) . '</mainwp>' );
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'You dont send nonce: ' . $action . '<br/>Trace: ' . $stackTrace ) ) ) . '</mainwp>' );
}
// To fix verify nonce conflict #2
@ -99,7 +99,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
// To fix verify nonce conflict #3
// this is fake post field to fix some conflict of wp_verify_nonce()
// just return false to unverify nonce, does not exit
if ( isset($_POST[$action]) && ($_POST[$action] == 'mainwp-bsm-unverify-nonce')) {
if ( isset($_POST[ $action ]) && ( $_POST[ $action ] == 'mainwp-bsm-unverify-nonce' )) {
return false;
}
@ -108,7 +108,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
$stackTrace = "\n" . @ob_get_clean();
// Invalid nonce
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'Invalid nonce! Try to use: ' . $action . '<br/>Trace: ' . $stackTrace) ) ) . '</mainwp>' );
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'Invalid nonce! Try to use: ' . $action . '<br/>Trace: ' . $stackTrace ) ) ) . '</mainwp>' );
}
endif;
}
@ -177,7 +177,7 @@ class MainWP_Child {
'wp_rocket' => 'wp_rocket',
'settings_tools' => 'settings_tools',
'skeleton_key' => 'skeleton_key',
'custom_post_type' => 'custom_post_type',
'custom_post_type' => 'custom_post_type',
'backup_buddy' => 'backup_buddy',
'get_site_icon' => 'get_site_icon',
'vulner_checker' => 'vulner_checker',
@ -185,8 +185,8 @@ class MainWP_Child {
'disconnect' => 'disconnect',
'time_capsule' => 'time_capsule',
'extra_excution' => 'extra_execution', // deprecated
'extra_execution' => 'extra_execution',
'wpvivid_backuprestore'=>'wpvivid_backuprestore',
'extra_execution' => 'extra_execution',
'wpvivid_backuprestore' =>'wpvivid_backuprestore',
);
private $FTP_ERROR = 'Failed! Please, add FTP details for automatic updates.';
@ -259,7 +259,7 @@ class MainWP_Child {
//WP-Cron
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
if ( isset($_GET[ 'mainwp_child_run' ]) && ! empty( $_GET[ 'mainwp_child_run' ] ) ) {
if ( isset($_GET['mainwp_child_run']) && ! empty( $_GET['mainwp_child_run'] ) ) {
add_action( 'init', array( $this, 'cron_active' ), PHP_INT_MAX );
}
}
@ -333,7 +333,7 @@ class MainWP_Child {
if ( is_array( $alloptions_db ) ) {
foreach ( (array) $alloptions_db as $o ) {
$alloptions[ $o->option_name ] = $o->option_value;
unset($options[array_search($o->option_name, $options)]);
unset($options[ array_search($o->option_name, $options) ]);
}
foreach ($options as $option ) {
$notoptions[ $option ] = true;
@ -479,30 +479,30 @@ class MainWP_Child {
if ( ! is_array( get_option( 'mainwp_child_branding_settings' ) ) ) {
// to fix: reduce number of options
$brandingOptions = array(
'hide' => 'mainwp_branding_child_hide',
'extra_settings' => 'mainwp_branding_extra_settings',
'branding_disconnected' => 'mainwp_child_branding_disconnected',
'preserve_branding' => 'mainwp_branding_preserve_branding',
'branding_header' => 'mainwp_branding_plugin_header',
'support_email' => 'mainwp_branding_support_email',
'support_message' => 'mainwp_branding_support_message',
'remove_restore' => 'mainwp_branding_remove_restore',
'remove_setting' => 'mainwp_branding_remove_setting',
'remove_server_info' => 'mainwp_branding_remove_server_info',
'remove_connection_detail' => 'mainwp_branding_remove_connection_detail',
'remove_wp_tools' => 'mainwp_branding_remove_wp_tools',
'remove_wp_setting' => 'mainwp_branding_remove_wp_setting',
'remove_permalink' => 'mainwp_branding_remove_permalink',
'contact_label' => 'mainwp_branding_button_contact_label',
'email_message' => 'mainwp_branding_send_email_message',
'message_return_sender' => 'mainwp_branding_message_return_sender',
'hide' => 'mainwp_branding_child_hide',
'extra_settings' => 'mainwp_branding_extra_settings',
'branding_disconnected' => 'mainwp_child_branding_disconnected',
'preserve_branding' => 'mainwp_branding_preserve_branding',
'branding_header' => 'mainwp_branding_plugin_header',
'support_email' => 'mainwp_branding_support_email',
'support_message' => 'mainwp_branding_support_message',
'remove_restore' => 'mainwp_branding_remove_restore',
'remove_setting' => 'mainwp_branding_remove_setting',
'remove_server_info' => 'mainwp_branding_remove_server_info',
'remove_connection_detail' => 'mainwp_branding_remove_connection_detail',
'remove_wp_tools' => 'mainwp_branding_remove_wp_tools',
'remove_wp_setting' => 'mainwp_branding_remove_wp_setting',
'remove_permalink' => 'mainwp_branding_remove_permalink',
'contact_label' => 'mainwp_branding_button_contact_label',
'email_message' => 'mainwp_branding_send_email_message',
'message_return_sender' => 'mainwp_branding_message_return_sender',
'submit_button_title' => 'mainwp_branding_submit_button_title',
'disable_wp_branding' => 'mainwp_branding_disable_wp_branding',
'show_support' => 'mainwp_branding_show_support',
'disable_change' => 'mainwp_branding_disable_change',
'disable_switching_theme' => 'mainwp_branding_disable_switching_theme',
'show_support' => 'mainwp_branding_show_support',
'disable_change' => 'mainwp_branding_disable_change',
'disable_switching_theme' => 'mainwp_branding_disable_switching_theme',
//'hide_child_reports' => 'mainwp_creport_branding_stream_hide',
'branding_ext_enabled' => 'mainwp_branding_ext_enabled',
'branding_ext_enabled' => 'mainwp_branding_ext_enabled',
);
$convertBranding = array();
@ -522,7 +522,7 @@ class MainWP_Child {
if ( ! defined( 'DOING_CRON' ) || ! DOING_CRON ) {
return;
}
if ( empty( $_GET[ 'mainwp_child_run' ] ) || 'test' !== $_GET[ 'mainwp_child_run' ] ) {
if ( empty( $_GET['mainwp_child_run'] ) || 'test' !== $_GET['mainwp_child_run'] ) {
return;
}
@session_write_close();
@ -530,7 +530,7 @@ class MainWP_Child {
@header( 'X-Robots-Tag: noindex, nofollow', true );
@header( 'X-MainWP-Child-Version: ' . self::$version, true );
nocache_headers();
if ( $_GET[ 'mainwp_child_run' ] == 'test' ) {
if ( $_GET['mainwp_child_run'] == 'test' ) {
die( 'MainWP Test' );
}
die( '' );
@ -720,8 +720,8 @@ class MainWP_Child {
add_action( 'admin_print_scripts-' . $settingsPage, array( 'MainWP_Clone', 'print_scripts' ) );
$subpageargs = array(
'child_slug' => 'options-general.php', // to backwards compatible
'branding' => (self::$brandingTitle === null) ? 'MainWP' : self::$brandingTitle,
'child_slug' => 'options-general.php', // to backwards compatible
'branding' => ( self::$brandingTitle === null ) ? 'MainWP' : self::$brandingTitle,
'parent_menu' => $settingsPage,
);
do_action( 'mainwp-child-subpages', $subpageargs ); // to compatible
@ -801,7 +801,7 @@ class MainWP_Child {
self::render_header($shownPage, false);
?>
<?php if (!$hide_settings ) { ?>
<div class="mainwp-child-setting-tab settings" <?php echo ('settings' !== $shownPage) ? $hide_style : ''; ?>>
<div class="mainwp-child-setting-tab settings" <?php echo ( 'settings' !== $shownPage ) ? $hide_style : ''; ?>>
<?php $this->settings(); ?>
</div>
<?php } ?>
@ -828,13 +828,13 @@ class MainWP_Child {
<?php } ?>
<?php if ( !$hide_server_info ) { ?>
<div class="mainwp-child-setting-tab server-info" <?php echo ('server-info' !== $shownPage) ? $hide_style : ''; ?>>
<div class="mainwp-child-setting-tab server-info" <?php echo ( 'server-info' !== $shownPage ) ? $hide_style : ''; ?>>
<?php MainWP_Child_Server_Information::renderPage(); ?>
</div>
<?php } ?>
<?php if ( !$hide_connection_detail ) { ?>
<div class="mainwp-child-setting-tab connection-detail" <?php echo ('connection-detail' !== $shownPage) ? $hide_style : ''; ?>>
<div class="mainwp-child-setting-tab connection-detail" <?php echo ( 'connection-detail' !== $shownPage ) ? $hide_style : ''; ?>>
<?php MainWP_Child_Server_Information::renderConnectionDetails(); ?>
</div>
<?php } ?>
@ -1746,7 +1746,10 @@ class MainWP_Child {
remove_filter( 'http_request_args', array( &$this, 'noSSLFilterFunction' ), 99 );
}
$args = array( 'success' => 1, 'action' => 'install' );
$args = array(
'success' => 1,
'action' => 'install',
);
if ( 'plugin' === $_POST['type'] ) {
$path = $result['destination'];
$fileName = '';
@ -1935,10 +1938,10 @@ class MainWP_Child {
$result = count( $language_updates ) == 0 ? false : $upgrader->bulk_upgrade( $language_updates );
if ( ! empty( $result ) ) {
for ( $i = 0; $i < count( $result ); $i++ ) {
if ( empty( $result[$i] ) || is_wp_error( $result[$i] ) ) {
$information['upgrades'][ $language_updates[$i]->slug ] = false;
if ( empty( $result[ $i ] ) || is_wp_error( $result[ $i ] ) ) {
$information['upgrades'][ $language_updates[ $i ]->slug ] = false;
} else {
$information['upgrades'][ $language_updates[$i]->slug ] = true;
$information['upgrades'][ $language_updates[ $i ]->slug ] = true;
}
}
} else {
@ -2061,7 +2064,7 @@ class MainWP_Child {
if ( !is_wp_error( $api ) && !empty($api)) {
if ( isset($api->download_link) ) {
$res = $upgrader->install($api->download_link);
if ( !is_wp_error( $res ) && !(is_null( $res )) ) {
if ( !is_wp_error( $res ) && !( is_null( $res ) ) ) {
$information['upgrades'][ $plugin ] = true;
}
}
@ -2508,13 +2511,17 @@ class MainWP_Child {
} else {
if ( 'future' == $post_current->post_status ) {
wp_publish_post( $postId ); // to fix: fail when publish future page
wp_update_post(array('ID' => $postId,
'post_date' => current_time( 'mysql', false ),
'post_date_gmt' => current_time( 'mysql', true ),
wp_update_post(array(
'ID' => $postId,
'post_date' => current_time( 'mysql', false ),
'post_date_gmt' => current_time( 'mysql', true ),
));
} else {
// to fix error post slug
wp_update_post(array('ID' => $postId, 'post_status' => 'publish' ));
wp_update_post(array(
'ID' => $postId,
'post_status' => 'publish',
));
}
}
} elseif ( 'update' === $action ) {
@ -2601,12 +2608,12 @@ class MainWP_Child {
$attachment = get_post( $attachment_id );
if ( $attachment ) {
$post_gallery_images[] = array(
'id' => $attachment_id,
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
'caption' => $attachment->post_excerpt,
'id' => $attachment_id,
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
'caption' => $attachment->post_excerpt,
'description' => $attachment->post_content,
'src' => $attachment->guid,
'title' => $attachment->post_title,
'src' => $attachment->guid,
'title' => $attachment->post_title,
);
}
}
@ -2644,7 +2651,7 @@ class MainWP_Child {
'post_category' => base64_encode( $post_category ),
'post_featured_image' => base64_encode( $post_featured_image ),
'post_gallery_images' => base64_encode( serialize( $post_gallery_images ) ),
'child_upload_dir' => base64_encode( serialize( $child_upload_dir ) ),
'child_upload_dir' => base64_encode( serialize( $child_upload_dir ) ),
);
return $post_data;
@ -2663,16 +2670,16 @@ class MainWP_Child {
$new_post = array(
'edit_id' => $id,
'post_title' => $post->post_title,
'post_content' => $post->post_content,
'post_status' => $post->post_status,
'post_date' => $post->post_date,
'post_date_gmt' => $post->post_date_gmt,
'post_type' => 'page',
'post_name' => $post->post_name,
'post_excerpt' => $post->post_excerpt,
'post_title' => $post->post_title,
'post_content' => $post->post_content,
'post_status' => $post->post_status,
'post_date' => $post->post_date,
'post_date_gmt' => $post->post_date_gmt,
'post_type' => 'page',
'post_name' => $post->post_name,
'post_excerpt' => $post->post_excerpt,
'comment_status' => $post->comment_status,
'ping_status' => $post->ping_status,
'ping_status' => $post->ping_status,
);
if ( $post_featured_image != null ) { //Featured image is set, retrieve URL
@ -2689,12 +2696,12 @@ class MainWP_Child {
$attachment = get_post( $attachment_id );
if ( $attachment ) {
$post_gallery_images[] = array(
'id' => $attachment_id,
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
'caption' => $attachment->post_excerpt,
'id' => $attachment_id,
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
'caption' => $attachment->post_excerpt,
'description' => $attachment->post_content,
'src' => $attachment->guid,
'title' => $attachment->post_title,
'src' => $attachment->guid,
'title' => $attachment->post_title,
);
}
}
@ -2704,11 +2711,11 @@ class MainWP_Child {
wp_set_post_lock($id);
$post_data = array(
'new_post' => base64_encode( serialize( $new_post ) ),
'post_custom' => base64_encode( serialize( $post_custom ) ),
'new_post' => base64_encode( serialize( $new_post ) ),
'post_custom' => base64_encode( serialize( $post_custom ) ),
'post_featured_image' => base64_encode( $post_featured_image ),
'post_gallery_images' => base64_encode( serialize( $post_gallery_images ) ),
'child_upload_dir' => base64_encode( serialize( $child_upload_dir ) ),
'child_upload_dir' => base64_encode( serialize( $child_upload_dir ) ),
);
return $post_data;
}
@ -2751,8 +2758,8 @@ class MainWP_Child {
$my_user = $_POST['extra'];
if (is_array($my_user)) {
foreach($my_user as $idx => $val) {
if ($val === 'donotupdate' || (empty($val) && $idx !== 'role')) {
unset($my_user[$idx]);
if ($val === 'donotupdate' || ( empty($val) && $idx !== 'role' )) {
unset($my_user[ $idx ]);
}
}
$result = $this->edit_user( $userId, $my_user );
@ -2791,7 +2798,7 @@ class MainWP_Child {
$userdata = get_userdata( $user_id );
$user->user_login = wp_slash( $userdata->user_login );
} else {
return array('error' => 'ERROR: Empty user id.');
return array( 'error' => 'ERROR: Empty user id.' );
}
$pass1 = $pass2 = '';
@ -2804,17 +2811,17 @@ class MainWP_Child {
if ( isset( $data['role'] ) && current_user_can( 'edit_users' ) ) {
$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.
// Multisite super admins can freely edit their blog roles -- they possess all caps.
if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ($potential_role && $potential_role->has_cap( 'edit_users' ) ) ) {
if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ( $potential_role && $potential_role->has_cap( 'edit_users' ) ) ) {
$user->role = $new_role;
}
// If the new role isn't editable by the logged-in user die with error
$editable_roles = get_editable_roles();
if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) ) {
return array('error' => 'You can&#8217;t give users that role.');
if ( ! empty( $new_role ) && empty( $editable_roles[ $new_role ] ) ) {
return array( 'error' => 'You can&#8217;t give users that role.' );
}
}
@ -2963,7 +2970,7 @@ class MainWP_Child {
$edit_data['user_email'] = $profileuser->user_email;
$edit_data['user_url'] = $profileuser->user_url;
foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) {
$edit_data['contact_methods'][$name] = $profileuser->$name;
$edit_data['contact_methods'][ $name ] = $profileuser->$name;
}
$edit_data['description'] = $profileuser->description;
}
@ -3039,7 +3046,10 @@ class MainWP_Child {
$user = get_user_by( 'login', $_POST['user'] );
require_once ABSPATH . WPINC . '/registration.php';
$id = wp_update_user( array( 'ID' => $user->ID, 'user_pass' => $new_password['user_pass'] ) );
$id = wp_update_user( array(
'ID' => $user->ID,
'user_pass' => $new_password['user_pass'],
) );
if ( $id !== $user->ID ) {
if ( is_wp_error( $id ) ) {
MainWP_Helper::error( $id->get_error_message() );
@ -3660,14 +3670,14 @@ class MainWP_Child {
$information['wpe'] = MainWP_Helper::is_wp_engine() ? 1 : 0;
$theme_name = wp_get_theme()->get( 'Name' );
$information['site_info'] = array(
'wpversion' => $wp_version,
'debug_mode' => (defined('WP_DEBUG') && true === WP_DEBUG) ? true : false,
'phpversion' => phpversion(),
'child_version' => self::$version,
'memory_limit' => MainWP_Child_Server_Information::getPHPMemoryLimit(),
'mysql_version' => MainWP_Child_Server_Information::getMySQLVersion(),
'wpversion' => $wp_version,
'debug_mode' => ( defined('WP_DEBUG') && true === WP_DEBUG ) ? true : false,
'phpversion' => phpversion(),
'child_version' => self::$version,
'memory_limit' => MainWP_Child_Server_Information::getPHPMemoryLimit(),
'mysql_version' => MainWP_Child_Server_Information::getMySQLVersion(),
'themeactivated' => $theme_name,
'ip' => $_SERVER['SERVER_ADDR'],
'ip' => $_SERVER['SERVER_ADDR'],
);
//Try to switch to SSL if SSL is enabled in between!
@ -3876,10 +3886,12 @@ class MainWP_Child {
$information['translation_updates'] = array();
foreach ($translation_updates as $translation_update)
{
$new_translation_update = array('type' => $translation_update->type,
'slug' => $translation_update->slug,
'language' => $translation_update->language,
'version' => $translation_update->version, );
$new_translation_update = array(
'type' => $translation_update->type,
'slug' => $translation_update->slug,
'language' => $translation_update->language,
'version' => $translation_update->version,
);
if ( 'plugin' === $translation_update->type ) {
$all_plugins = get_plugins();
foreach ( $all_plugins as $file => $plugin ) {
@ -3965,7 +3977,11 @@ class MainWP_Child {
//Directory listings!
$information['directories'] = $this->scanDir( ABSPATH, 3 );
$cats = get_categories( array( 'hide_empty' => 0, 'hierarchical' => true, 'number' => 300 ) );
$cats = get_categories( array(
'hide_empty' => 0,
'hierarchical' => true,
'number' => 300,
) );
$categories = array();
foreach ( $cats as $cat ) {
$categories[] = $cat->name;
@ -4324,9 +4340,9 @@ class MainWP_Child {
if ($wp_seo_enabled) {
$post_id = $post->ID;
$outPost['seo_data'] = array(
'count_seo_links' => $link_count->get( $post_id, 'internal_link_count' ),
'count_seo_linked' => $link_count->get( $post_id, 'incoming_link_count' ),
'seo_score' => MainWP_Wordpress_SEO::Instance()->parse_column_score($post_id),
'count_seo_links' => $link_count->get( $post_id, 'internal_link_count' ),
'count_seo_linked' => $link_count->get( $post_id, 'incoming_link_count' ),
'seo_score' => MainWP_Wordpress_SEO::Instance()->parse_column_score($post_id),
'readability_score' => MainWP_Wordpress_SEO::Instance()->parse_column_score_readability($post_id),
);
}
@ -4345,7 +4361,7 @@ class MainWP_Child {
}
function get_all_posts() {
$post_type = (isset($_POST['post_type']) ? $_POST['post_type'] : 'post');
$post_type = ( isset($_POST['post_type']) ? $_POST['post_type'] : 'post' );
$this->get_all_posts_by_type( $post_type );
}
@ -4709,7 +4725,10 @@ class MainWP_Child {
if ( null !== $theTheme && '' !== $theTheme ) {
$tmp['theme'] = $theTheme['Template'];
if ( true === $themeUpgrader->delete_old_theme( null, null, null, $tmp ) ) {
$args = array( 'action' => 'delete', 'Name' => $theTheme['Name'] );
$args = array(
'action' => 'delete',
'Name' => $theTheme['Name'],
);
do_action( 'mainwp_child_theme_action', $args );
}
}
@ -4830,7 +4849,10 @@ class MainWP_Child {
}
$tmp['plugin'] = $plugin;
if ( true === $pluginUpgrader->delete_old_plugin( null, null, null, $tmp ) ) {
$args = array( 'action' => 'delete', 'Name' => $all_plugins[ $plugin ]['Name'] );
$args = array(
'action' => 'delete',
'Name' => $all_plugins[ $plugin ]['Name'],
);
do_action( 'mainwp_child_plugin_action', $args );
}
}
@ -4867,7 +4889,7 @@ class MainWP_Child {
foreach ( $plugins as $pluginslug => $plugin ) {
$out = array();
$out['mainwp'] = ($pluginslug == $this->plugin_slug ? 'T' : 'F');
$out['mainwp'] = ( $pluginslug == $this->plugin_slug ? 'T' : 'F' );
$out['name'] = $plugin['Name'];
$out['slug'] = $pluginslug;
$out['description'] = $plugin['Description'];
@ -4889,7 +4911,7 @@ class MainWP_Child {
if ( is_array( $muplugins ) ) {
foreach ( $muplugins as $pluginslug => $plugin ) {
$out = array();
$out['mainwp'] = ($pluginslug == $this->plugin_slug ? 'T' : 'F');
$out['mainwp'] = ( $pluginslug == $this->plugin_slug ? 'T' : 'F' );
$out['name'] = $plugin['Name'];
$out['slug'] = $pluginslug;
$out['description'] = $plugin['Description'];

View file

@ -675,7 +675,7 @@ class MainWP_Clone_Install {
unset( $_tmp );
} elseif (is_serialized_string($data) && is_serialized($data)) {
// TODO: apply solution like phpmyadmin project have!
if ( ($data = @unserialize( $data )) !== false ) {
if ( ( $data = @unserialize( $data ) ) !== false ) {
$data = str_replace( $from, $to, $data );
$data = serialize( $data );
}

View file

@ -1210,11 +1210,11 @@ class MainWP_Clone {
global $wp_version;
$method = ( function_exists( 'gzopen' ) ? 'tar.gz' : 'zip' );
$result = MainWP_Helper::fetchUrl( $url, array(
'cloneFunc' => 'createCloneBackup',
'key' => $key,
'f' => $rand,
'wpversion' => $wp_version,
'zipmethod' => $method,
'cloneFunc' => 'createCloneBackup',
'key' => $key,
'f' => $rand,
'wpversion' => $wp_version,
'zipmethod' => $method,
'json_result' => true,
) );
@ -1226,7 +1226,10 @@ class MainWP_Clone {
MainWP_Helper::update_option( 'mainwp_temp_clone_plugins', $result['plugins'] );
MainWP_Helper::update_option( 'mainwp_temp_clone_themes', $result['themes'] );
$output = array( 'url' => $result['backup'], 'size' => round( $result['size'] / 1024, 0 ) );
$output = array(
'url' => $result['backup'],
'size' => round( $result['size'] / 1024, 0 ),
);
} catch ( Exception $e ) {
$output = array( 'error' => $e->getMessage() );
}
@ -1257,9 +1260,9 @@ class MainWP_Clone {
MainWP_Helper::endSession();
//Send request to the childsite!
$result = MainWP_Helper::fetchUrl( $url, array(
'cloneFunc' => 'createCloneBackupPoll',
'key' => $key,
'f' => $rand,
'cloneFunc' => 'createCloneBackupPoll',
'key' => $key,
'f' => $rand,
'json_result' => true,
) );
@ -1320,7 +1323,11 @@ class MainWP_Clone {
$filename = $backupdir . $filename;
$response = wp_remote_get( $url, array( 'timeout' => 300000, 'stream' => true, 'filename' => $filename ) );
$response = wp_remote_get( $url, array(
'timeout' => 300000,
'stream' => true,
'filename' => $filename,
) );
if ( is_wp_error( $response ) ) {
unlink( $filename );
@ -1345,9 +1352,9 @@ class MainWP_Clone {
$siteToClone = $sitesToClone[ $siteId ];
MainWP_Helper::fetchUrl( $siteToClone['url'], array(
'cloneFunc' => 'deleteCloneBackup',
'key' => $siteToClone['extauth'],
'f' => $_POST['file'],
'cloneFunc' => 'deleteCloneBackup',
'key' => $siteToClone['extauth'],
'f' => $_POST['file'],
'json_result' => true,
) );
}

View file

@ -67,7 +67,7 @@ class MainWP_Custom_Post_Type {
if ( empty( $data ) || ! is_array( $data ) || ! isset( $data['post'] ) ) {
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);
if (isset($return['success']) && $return['success'] == 1) {
if (isset($data['product_variation']) && is_array($data['product_variation'])) {
@ -177,7 +177,7 @@ class MainWP_Custom_Post_Type {
//$data_insert['post_content'] = $this->_search_images( $data_insert['post_content'], $data['extras']['upload_dir'] );
$is_woocomerce = false;
if ( ($data_insert['post_type'] == 'product' || $data_insert['post_type'] == 'product_variation' )&& function_exists( 'wc_product_has_unique_sku' ) ) {
if ( ( $data_insert['post_type'] == 'product' || $data_insert['post_type'] == 'product_variation' )&& function_exists( 'wc_product_has_unique_sku' ) ) {
$is_woocomerce = true;
}
@ -337,6 +337,9 @@ class MainWP_Custom_Post_Type {
}
}
return array( 'success' => 1, 'post_id' => $post_id );
return array(
'success' => 1,
'post_id' => $post_id,
);
}
}

View file

@ -15,7 +15,7 @@ class MainWP_Helper {
public static function utf8ize( $mixed) {
if (is_array($mixed)) {
foreach ($mixed as $key => $value) {
$mixed[$key] = self::utf8ize($value);
$mixed[ $key ] = self::utf8ize($value);
}
} elseif (is_string($mixed)) {
if ( function_exists( 'mb_convert_encoding' )) {
@ -83,24 +83,24 @@ class MainWP_Helper {
$ordered = array();
for($i=0;$i<count($blocks[0]);$i++){
// 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_value = 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 ]);
}
// 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_value = $blocks[0][$i];
$ordered_key = $blocks[0][ $i ];
$ordered_value = $blocks[0][ $i ];
}
else
{
$ordered_key = 'main';
$ordered_value = $blocks[0][$i];
$ordered_value = $blocks[0][ $i ];
}
// Split by parenthesis, ignoring those inside content-quotes
$ordered[$ordered_key] = preg_split('/([^\'"\{\}]*?[\'"].*?(?<!\\\)[\'"][^\'"\{\}]*?)[\{\}]|([^\'"\{\}]*?)[\{\}]/', trim($ordered_value, " \r\n\t"), -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
$ordered[ $ordered_key ] = preg_split('/([^\'"\{\}]*?[\'"].*?(?<!\\\)[\'"][^\'"\{\}]*?)[\{\}]|([^\'"\{\}]*?)[\{\}]/', trim($ordered_value, " \r\n\t"), -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
}
// Beginning to rebuild new slim CSS-Array
@ -108,12 +108,12 @@ class MainWP_Helper {
$new = array();
for($i = 0; $i<count($val); $i++){
// Split selectors and rules and split properties and values
$selector = trim($val[$i], " \r\n\t");
$selector = trim($val[ $i ], " \r\n\t");
if(!empty($selector)){
if(!isset($new[$selector])) { $new[$selector] = array();
if(!isset($new[ $selector ])) { $new[ $selector ] = array();
}
$rules = explode(';', $val[++$i]);
$rules = explode(';', $val[ ++$i ]);
foreach($rules as $rule){
$rule = trim($rule, " \r\n\t");
if(!empty($rule)){
@ -121,14 +121,14 @@ class MainWP_Helper {
$property = trim(array_pop($rule), " \r\n\t");
$value = implode(':', array_reverse($rule));
if(!isset($new[$selector][$property]) || !preg_match('/!important/', $new[$selector][$property])) { $new[$selector][$property] = $value;
} elseif(preg_match('/!important/', $new[$selector][$property]) && preg_match('/!important/', $value)) { $new[$selector][$property] = $value;
if(!isset($new[ $selector ][ $property ]) || !preg_match('/!important/', $new[ $selector ][ $property ])) { $new[ $selector ][ $property ] = $value;
} elseif(preg_match('/!important/', $new[ $selector ][ $property ]) && preg_match('/!important/', $value)) { $new[ $selector ][ $property ] = $value;
}
}
}
}
}
$ordered[$key] = $new;
$ordered[ $key ] = $new;
}
$parsed = $ordered;
@ -188,7 +188,10 @@ class MainWP_Helper {
if ( file_exists( $temporary_file ) ) {
unlink( $temporary_file );
}
return array( 'id' => $attach->ID, 'url' => $local_img_url );
return array(
'id' => $attach->ID,
'url' => $local_img_url,
);
}
}
}
@ -202,12 +205,15 @@ class MainWP_Helper {
$basedir = $upload_dir['basedir'];
$baseurl = $upload_dir['baseurl'];
$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
if ( file_exists( $temporary_file ) ) {
unlink( $temporary_file );
}
return array( 'id' => $attach->ID, 'url' => $attach->guid );
return array(
'id' => $attach->ID,
'url' => $attach->guid,
);
}
}
}
@ -227,9 +233,9 @@ class MainWP_Helper {
'post_mime_type' => $wp_filetype['type'],
'post_title' => isset( $img_data['title'] ) && !empty( $img_data['title'] ) ? $img_data['title'] : preg_replace( '/\.[^.]+$/', '', basename( $img_url ) ),
'post_content' => isset( $img_data['description'] ) && !empty( $img_data['description'] ) ? $img_data['description'] : '',
'post_excerpt' => isset( $img_data['caption'] ) && !empty( $img_data['caption'] ) ? $img_data['caption'] : '',
'post_excerpt' => isset( $img_data['caption'] ) && !empty( $img_data['caption'] ) ? $img_data['caption'] : '',
'post_status' => 'inherit',
'guid' => $local_img_url, // to fix
'guid' => $local_img_url, // to fix
);
// for post attachments, thumbnail
@ -244,7 +250,10 @@ class MainWP_Helper {
if ( isset( $img_data['alt'] ) && !empty( $img_data['alt'] ) ) {
update_post_meta( $attach_id, '_wp_attachment_image_alt', $img_data['alt'] );
}
return array( 'id' => $attach_id, 'url' => $local_img_url );
return array(
'id' => $attach_id,
'url' => $local_img_url,
);
}
}
if ( file_exists( $temporary_file ) ) {
@ -425,7 +434,7 @@ class MainWP_Helper {
if ( $user_id = wp_check_post_lock( $edit_post_id ) ) {
$user = get_userdata( $user_id );
$error = sprintf( __( 'This content is currently locked. %s is currently editing.' ), $user->display_name );
return array( 'error' => $error);
return array( 'error' => $error );
}
}
@ -496,7 +505,7 @@ class MainWP_Helper {
try {
$upload = self::uploadImage( $gallery['src'], $gallery ); //Upload image to WP
if ( null !== $upload ) {
$replaceAttachedIds[$gallery['id']] = $upload['id'];
$replaceAttachedIds[ $gallery['id'] ] = $upload['id'];
}
} catch ( Exception $e ) {
@ -511,8 +520,8 @@ class MainWP_Helper {
$idsToReplaceWith = '';
$originalIds = explode(',', $idsToReplace);
foreach($originalIds as $attached_id) {
if (!empty($originalIds) && isset($replaceAttachedIds[$attached_id])) {
$idsToReplaceWith .= $replaceAttachedIds[$attached_id] . ',';
if (!empty($originalIds) && isset($replaceAttachedIds[ $attached_id ])) {
$idsToReplaceWith .= $replaceAttachedIds[ $attached_id ] . ',';
}
}
$idsToReplaceWith = rtrim($idsToReplaceWith, ',');
@ -587,11 +596,14 @@ class MainWP_Helper {
return $wp_error->get_error_message();
}
if ( empty( $new_post_id ) ) {
return array( 'error' => 'Empty post id');
return array( 'error' => 'Empty post id' );
}
if ( !$edit_post_id ) {
wp_update_post( array( 'ID' => $new_post_id, 'post_status' => $post_status ) );
wp_update_post( array(
'ID' => $new_post_id,
'post_status' => $post_status,
) );
}
if ( ! empty( $terms ) ) {
@ -732,10 +744,11 @@ class MainWP_Helper {
if (isset($others['featured_image_data'])) {
$_image_data = $others['featured_image_data'];
update_post_meta( $upload['id'], '_wp_attachment_image_alt', $_image_data['alt'] );
wp_update_post( array( 'ID' => $upload['id'],
'post_excerpt' => $_image_data['caption'],
'post_content' => $_image_data['description'],
'post_title' => $_image_data['title'],
wp_update_post( array(
'ID' => $upload['id'],
'post_excerpt' => $_image_data['caption'],
'post_content' => $_image_data['description'],
'post_title' => $_image_data['title'],
)
);
}
@ -767,14 +780,20 @@ class MainWP_Helper {
if ( count( $random_post_authors ) > 0 ) {
shuffle( $random_post_authors );
$key = array_rand( $random_post_authors );
wp_update_post( array( 'ID' => $new_post_id, 'post_author' => $random_post_authors[ $key ] ) );
wp_update_post( array(
'ID' => $new_post_id,
'post_author' => $random_post_authors[ $key ],
) );
}
}
$random_category = isset( $post_custom['_saved_draft_random_category'] ) ? $post_custom['_saved_draft_random_category'] : false;
$random_category = is_array( $random_category ) ? current( $random_category ) : null;
if ( ! empty( $random_category ) ) {
$cats = get_categories( array( 'type' => 'post', 'hide_empty' => 0 ) );
$cats = get_categories( array(
'type' => 'post',
'hide_empty' => 0,
) );
$random_cats = array();
if ( is_array( $cats ) ) {
foreach ( $cats as $cat ) {
@ -793,7 +812,10 @@ class MainWP_Helper {
// to support custom post author
$custom_post_author = apply_filters('mainwp_create_post_custom_author', false, $new_post_id);
if ( !empty( $custom_post_author ) ) {
wp_update_post( array( 'ID' => $new_post_id, 'post_author' => $custom_post_author ) );
wp_update_post( array(
'ID' => $new_post_id,
'post_author' => $custom_post_author,
) );
}
// MainWP Robot
@ -1242,7 +1264,7 @@ class MainWP_Helper {
}
static function update_lasttime_backup( $by, $time ) {
$backup_by = array('backupbuddy', 'backupwordpress', 'backwpup', 'updraftplus', 'wptimecapsule');
$backup_by = array( 'backupbuddy', 'backupwordpress', 'backwpup', 'updraftplus', 'wptimecapsule' );
if (!in_array($by, $backup_by)) {
return false;
@ -1707,7 +1729,7 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name =
}
if (isset($_POST['function']) && isset($_POST['mainwpsignature']) &&
(isset($_POST['mwp_action']) || 'wordpress_seo' == $_POST['function']) // wordpress_seo for WordPress SEO
( isset($_POST['mwp_action']) || 'wordpress_seo' == $_POST['function'] ) // wordpress_seo for WordPress SEO
) {
register_shutdown_function( 'handle_shutdown' );
}

View file

@ -344,7 +344,7 @@ class MainWP_Keyword_Links {
$this->link_case_sensitive = $link->case_sensitive;
$keywords = $this->explode_multi( $link->keyword );
//usort( $keywords, create_function( '$a,$b', 'return strlen($a)<strlen($b);' ) );
usort( $keywords, array($this, 'usort_callback_func') );
usort( $keywords, array( $this, 'usort_callback_func' ) );
$replace_cs = $link->case_sensitive ? 's' : 'is';
//print_r($keywords);
foreach ( $keywords as $keyword ) {

View file

@ -181,15 +181,15 @@ class MainWP_Security {
private static function init_permission_checks() {
if ( null === self::$permission_checks ) {
self::$permission_checks = array(
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../' => '0755',
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../' => '0755',
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../wp-includes' => '0755',
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../.htaccess' => '0644',
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'index.php' => '0644',
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'js/' => '0755',
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'themes' => '0755',
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'plugins' => '0755',
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../wp-admin' => '0755',
WP_CONTENT_DIR => '0755',
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../.htaccess' => '0644',
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'index.php' => '0644',
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'js/' => '0755',
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'themes' => '0755',
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'plugins' => '0755',
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../wp-admin' => '0755',
WP_CONTENT_DIR => '0755',
);
}
}
@ -365,7 +365,7 @@ class MainWP_Security {
public static function update_security_option( $key, $value ) {
$security = get_option( 'mainwp_security' );
if ( !empty($key) ) {
$security[$key] = $value;
$security[ $key ] = $value;
}
MainWP_Helper::update_option( 'mainwp_security', $security, 'yes' );
}