[CodeFactor] Apply fixes to commit 6b31a10

[ci skip] [skip ci]
This commit is contained in:
codefactor-io 2020-03-26 20:01:04 +00:00
parent 6b31a10814
commit 908e352467
29 changed files with 1115 additions and 1118 deletions

View file

@ -69,7 +69,7 @@ class MainWP_Backup {
} }
if ( ( false !== $fileSuffix ) && ! empty( $fileSuffix ) ) { if ( ( false !== $fileSuffix ) && ! empty( $fileSuffix ) ) {
//Append already contains extension! // Append already contains extension!
$file = $fileSuffix . ( true === $append ? '' : $ext ); $file = $fileSuffix . ( true === $append ? '' : $ext );
} else { } else {
$file = 'backup-' . $filePrefix . $timestamp . $ext; $file = 'backup-' . $filePrefix . $timestamp . $ext;
@ -157,7 +157,7 @@ class MainWP_Backup {
} }
public function _zipFilePcl( $files, $archive ) { public function _zipFilePcl( $files, $archive ) {
//Zip this backup folder.. // Zip this backup folder..
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
$this->zip = new PclZip( $archive ); $this->zip = new PclZip( $archive );
@ -469,16 +469,16 @@ class MainWP_Backup {
} }
public function createZipPclFullBackup2( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp ) { public function createZipPclFullBackup2( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp ) {
//Create backup folder // Create backup folder
$backupFolder = dirname( $filepath ) . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR; $backupFolder = dirname( $filepath ) . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR;
// @codingStandardsIgnoreStart // @codingStandardsIgnoreStart
@mkdir( $backupFolder ); @mkdir( $backupFolder );
// @codingStandardsIgnoreEnd // @codingStandardsIgnoreEnd
//Create DB backup // Create DB backup
$db_files = $this->createBackupDB( $backupFolder . 'dbBackup' ); $db_files = $this->createBackupDB( $backupFolder . 'dbBackup' );
//Copy installation to backup folder // Copy installation to backup folder
$nodes = glob( ABSPATH . '*' ); $nodes = glob( ABSPATH . '*' );
if ( ! $includeCoreFiles ) { if ( ! $includeCoreFiles ) {
$coreFiles = array( $coreFiles = array(
@ -530,7 +530,7 @@ class MainWP_Backup {
// @codingStandardsIgnoreEnd // @codingStandardsIgnoreEnd
unset( $nodes ); unset( $nodes );
//Zip this backup folder.. // Zip this backup folder..
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
$this->zip = new PclZip( $filepath ); $this->zip = new PclZip( $filepath );
$this->zip->create( $backupFolder, PCLZIP_OPT_REMOVE_PATH, $backupFolder ); $this->zip->create( $backupFolder, PCLZIP_OPT_REMOVE_PATH, $backupFolder );
@ -546,7 +546,7 @@ class MainWP_Backup {
$this->addFileFromStringToPCLZip( 'clone/config.txt', $string, $filepath ); $this->addFileFromStringToPCLZip( 'clone/config.txt', $string, $filepath );
} }
//Remove backup folder // Remove backup folder
MainWP_Helper::delete_dir( $backupFolder ); MainWP_Helper::delete_dir( $backupFolder );
return true; return true;
@ -660,7 +660,7 @@ class MainWP_Backup {
$this->zipArchiveSizeCount += filesize( $path ); $this->zipArchiveSizeCount += filesize( $path );
$this->gcCnt ++; $this->gcCnt ++;
//5 mb limit! // 5 mb limit!
if ( ! $this->loadFilesBeforeZip || ( filesize( $path ) > 5 * 1024 * 1024 ) ) { if ( ! $this->loadFilesBeforeZip || ( filesize( $path ) > 5 * 1024 * 1024 ) ) {
$this->zipArchiveFileCount ++; $this->zipArchiveFileCount ++;
$added = $this->zip->addFile( $path, $zipEntryName ); $added = $this->zip->addFile( $path, $zipEntryName );
@ -686,7 +686,7 @@ class MainWP_Backup {
$this->gcCnt = 0; $this->gcCnt = 0;
} }
//Over limits? // Over limits?
if ( ( ( $this->file_descriptors > 0 ) && ( $this->zipArchiveFileCount > $this->file_descriptors ) ) ) { // || $this->zipArchiveSizeCount >= (31457280 * 2)) if ( ( ( $this->file_descriptors > 0 ) && ( $this->zipArchiveFileCount > $this->file_descriptors ) ) ) { // || $this->zipArchiveSizeCount >= (31457280 * 2))
$this->zip->close(); $this->zip->close();
$this->zip = null; $this->zip = null;
@ -725,7 +725,7 @@ class MainWP_Backup {
global $wpdb; global $wpdb;
$db_files = array(); $db_files = array();
//Get all the tables // Get all the tables
$tables_db = $wpdb->get_results( 'SHOW TABLES FROM `' . DB_NAME . '`', ARRAY_N ); $tables_db = $wpdb->get_results( 'SHOW TABLES FROM `' . DB_NAME . '`', ARRAY_N );
foreach ( $tables_db as $curr_table ) { foreach ( $tables_db as $curr_table ) {
if ( null !== $archiver ) { if ( null !== $archiver ) {
@ -739,11 +739,11 @@ class MainWP_Backup {
if ( file_exists( $currentfile ) ) { if ( file_exists( $currentfile ) ) {
continue; continue;
} }
$fh = fopen( $currentfile . '.tmp', 'w' ); //or error; $fh = fopen( $currentfile . '.tmp', 'w' ); // or error;
fwrite( $fh, "\n\n" . 'DROP TABLE IF EXISTS ' . $table . ';' ); fwrite( $fh, "\n\n" . 'DROP TABLE IF EXISTS ' . $table . ';' );
//todo fix this // todo fix this
//$table_create = $wpdb->get_row( $wpdb->prepare( 'SHOW CREATE TABLE %s', $table ), ARRAY_N ); // $table_create = $wpdb->get_row( $wpdb->prepare( 'SHOW CREATE TABLE %s', $table ), ARRAY_N );
$table_create = $wpdb->get_row( 'SHOW CREATE TABLE ' . $table, ARRAY_N ); $table_create = $wpdb->get_row( 'SHOW CREATE TABLE ' . $table, ARRAY_N );
fwrite( $fh, "\n" . $table_create[1] . ";\n\n" ); fwrite( $fh, "\n" . $table_create[1] . ";\n\n" );
@ -804,7 +804,7 @@ class MainWP_Backup {
@unlink( $db_file ); @unlink( $db_file );
} }
} else { } else {
//todo: throw exception! // todo: throw exception!
} }
} }

View file

@ -29,7 +29,7 @@ class MainWP_Child_Back_Up_Buddy {
public function __construct() { public function __construct() {
// To fix bug run dashboard on local machine // To fix bug run dashboard on local machine
//if ( is_plugin_active( 'backupbuddy/backupbuddy.php' )) { // if ( is_plugin_active( 'backupbuddy/backupbuddy.php' )) {
if ( class_exists('pb_backupbuddy')) { if ( class_exists('pb_backupbuddy')) {
$this->is_backupbuddy_installed = true; $this->is_backupbuddy_installed = true;
} }
@ -822,7 +822,7 @@ class MainWP_Child_Back_Up_Buddy {
$information = array(); $information = array();
$information['backup_list'] = $this->get_backup_list(); $information['backup_list'] = $this->get_backup_list();
$information['recent_backup_list'] = $this->get_recent_backup_list(); $information['recent_backup_list'] = $this->get_recent_backup_list();
//$information['destinations_list'] = pb_backupbuddy_destinations::get_destinations_list(); // $information['destinations_list'] = pb_backupbuddy_destinations::get_destinations_list();
$backup_directory = backupbuddy_core::getBackupDirectory(); $backup_directory = backupbuddy_core::getBackupDirectory();
$backup_directory = str_replace( '\\', '/', $backup_directory ); $backup_directory = str_replace( '\\', '/', $backup_directory );
$backup_directory = rtrim( $backup_directory, '/\\' ) . '/'; $backup_directory = rtrim( $backup_directory, '/\\' ) . '/';
@ -847,7 +847,7 @@ class MainWP_Child_Back_Up_Buddy {
$comment = backupbuddy_core::normalize_comment_data( $old_comment ); $comment = backupbuddy_core::normalize_comment_data( $old_comment );
$comment['note'] = $note; $comment['note'] = $note;
//$new_comment = base64_encode( serialize( $comment ) ); // $new_comment = base64_encode( serialize( $comment ) );
$comment_result = pb_backupbuddy::$classes['zipbuddy']->set_comment( $backup_file, $comment ); $comment_result = pb_backupbuddy::$classes['zipbuddy']->set_comment( $backup_file, $comment );
@ -1149,16 +1149,16 @@ class MainWP_Child_Back_Up_Buddy {
unset( $temp_dir ); unset( $temp_dir );
$message = 'Extracting "' . $file . '" from archive "' . $archive_file . '" into temporary file "' . $destination . '". '; $message = 'Extracting "' . $file . '" from archive "' . $archive_file . '" into temporary file "' . $destination . '". ';
//echo '<!-- '; // echo '<!-- ';
pb_backupbuddy::status( 'details', $message ); pb_backupbuddy::status( 'details', $message );
//echo $message; // echo $message;
$file_content = ''; $file_content = '';
$extractions = array( $file => $temp_file ); $extractions = array( $file => $temp_file );
$extract_result = $zipbuddy->extract( backupbuddy_core::getBackupDirectory() . $archive_file, $destination, $extractions ); $extract_result = $zipbuddy->extract( backupbuddy_core::getBackupDirectory() . $archive_file, $destination, $extractions );
if ( false === $extract_result ) { // failed. if ( false === $extract_result ) { // failed.
//echo ' -->'; // echo ' -->';
$error = 'Error #584984458. Unable to extract.'; $error = 'Error #584984458. Unable to extract.';
pb_backupbuddy::status( 'error', $error ); pb_backupbuddy::status( 'error', $error );
return array( 'error' => $error ); return array( 'error' => $error );
@ -1539,7 +1539,7 @@ class MainWP_Child_Back_Up_Buddy {
<?php <?php
foreach ( (array) $lines as $rawline ) { foreach ( (array) $lines as $rawline ) {
$line = json_decode( $rawline, true ); $line = json_decode( $rawline, true );
//print_r( $line ); // print_r( $line );
if ( is_array( $line ) ) { if ( is_array( $line ) ) {
$u = ''; $u = '';
if ( isset( $line['u'] ) ) { // As off v4.2.15.6. TODO: Remove this in a couple of versions once old logs without this will have cycled out. if ( isset( $line['u'] ) ) { // As off v4.2.15.6. TODO: Remove this in a couple of versions once old logs without this will have cycled out.
@ -1598,7 +1598,7 @@ class MainWP_Child_Back_Up_Buddy {
} }
} }
//***** BEGIN TESTS AND RESULTS. // ***** BEGIN TESTS AND RESULTS.
if ( isset( $integrity['status_details'] ) ) { // $integrity['status_details'] is NOT array (old, pre-3.1.9). if ( isset( $integrity['status_details'] ) ) { // $integrity['status_details'] is NOT array (old, pre-3.1.9).
echo '<h3>Integrity Technical Details</h3>'; echo '<h3>Integrity Technical Details</h3>';
echo '<textarea style="width: 100%; height: 175px;" wrap="off">'; echo '<textarea style="width: 100%; height: 175px;" wrap="off">';
@ -1662,7 +1662,7 @@ class MainWP_Child_Back_Up_Buddy {
} // end $integrity['status_details'] is an array. } // end $integrity['status_details'] is an array.
echo '<br><br>'; echo '<br><br>';
//***** END TESTS AND RESULTS. // ***** END TESTS AND RESULTS.
// Output meta info table (if any). // Output meta info table (if any).
$metaInfo = array(); $metaInfo = array();
@ -1679,7 +1679,7 @@ class MainWP_Child_Back_Up_Buddy {
} }
echo '<br><br>'; echo '<br><br>';
//***** BEGIN STEPS. // ***** BEGIN STEPS.
$steps = array(); $steps = array();
$steps[] = array( 'Start Time', $start_time, '' ); $steps[] = array( 'Start Time', $start_time, '' );
if ( isset( $backup_options->options['steps'] ) ) { if ( isset( $backup_options->options['steps'] ) ) {
@ -1776,7 +1776,7 @@ class MainWP_Child_Back_Up_Buddy {
); );
} }
echo '<br><br>'; echo '<br><br>';
//***** END STEPS. // ***** END STEPS.
if ( isset( $backup_options->options['trigger'] ) ) { if ( isset( $backup_options->options['trigger'] ) ) {
$trigger = $backup_options->options['trigger']; $trigger = $backup_options->options['trigger'];
@ -2229,7 +2229,7 @@ class MainWP_Child_Back_Up_Buddy {
delete_transient( 'pb_backupbuddy_malwarescan' ); delete_transient( 'pb_backupbuddy_malwarescan' );
} }
//echo '<br />Scanning `' . $url . '`.<br /><br />'; // echo '<br />Scanning `' . $url . '`.<br /><br />';
if ( ! defined( 'pluginbuddy_importbuddy' ) ) { if ( ! defined( 'pluginbuddy_importbuddy' ) ) {
$scan = get_transient( 'pb_backupbuddy_malwarescan' ); $scan = get_transient( 'pb_backupbuddy_malwarescan' );
} else { } else {
@ -2272,9 +2272,9 @@ class MainWP_Child_Back_Up_Buddy {
$continue_2 = false; $continue_2 = false;
} else { } else {
$scan = maybe_unserialize( $scan ); $scan = maybe_unserialize( $scan );
//echo '<pre>'; // echo '<pre>';
//print_r( $scan ); // print_r( $scan );
//echo '</pre>'; // echo '</pre>';
} }
} }
@ -2294,7 +2294,7 @@ class MainWP_Child_Back_Up_Buddy {
$array[ $array_key ] = lined_array( $array_item ); $array[ $array_key ] = lined_array( $array_item );
} }
} }
//return implode( '<br />', $array ); // return implode( '<br />', $array );
$return = ''; $return = '';
foreach ( $array as $array_item ) { foreach ( $array as $array_item ) {
$return .= $array_item . '<br />'; $return .= $array_item . '<br />';
@ -2653,7 +2653,7 @@ class MainWP_Child_Back_Up_Buddy {
} }
pb_backupbuddy::save(); pb_backupbuddy::save();
//pb_backupbuddy::alert( __( 'Settings saved. Restarting Live process so they take immediate effect.', 'it-l10n-backupbuddy' ) ); // pb_backupbuddy::alert( __( 'Settings saved. Restarting Live process so they take immediate effect.', 'it-l10n-backupbuddy' ) );
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. 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(); backupbuddy_live::send_trim_settings();
@ -2713,7 +2713,7 @@ class MainWP_Child_Back_Up_Buddy {
} elseif ( 'create_snapshot' == $action ) { // < 100% backed up _OR_ ( we are on a step other than daily_init and the last_activity is more recent than the php runtime ) } elseif ( 'create_snapshot' == $action ) { // < 100% backed up _OR_ ( we are on a step other than daily_init and the last_activity is more recent than the php runtime )
if ( true === backupbuddy_api::runLiveSnapshot() ) { if ( true === backupbuddy_api::runLiveSnapshot() ) {
//pb_backupbuddy::alert( '<h3>' . __( 'Verifying everything is up to date before Snapshot', 'it-l10n-backupbuddy' ) . '</h3><p class="description" style="max-width: 700px; display: inline-block;">' . __( 'Please wait while we verify your backup is completely up to date before we create the Snapshot. This may take a few minutes...', 'it-l10n-backupbuddy' ) . '</p>', false, '', 'backupbuddy_live_snapshot_verify_uptodate' ); // pb_backupbuddy::alert( '<h3>' . __( 'Verifying everything is up to date before Snapshot', 'it-l10n-backupbuddy' ) . '</h3><p class="description" style="max-width: 700px; display: inline-block;">' . __( 'Please wait while we verify your backup is completely up to date before we create the Snapshot. This may take a few minutes...', 'it-l10n-backupbuddy' ) . '</p>', false, '', 'backupbuddy_live_snapshot_verify_uptodate' );
$message = '<h3>' . __( 'Verifying everything is up to date before Snapshot', 'it-l10n-backupbuddy' ) . '</h3><p class="description" style="max-width: 700px; display: inline-block;">' . __( 'Please wait while we verify your backup is completely up to date before we create the Snapshot. This may take a few minutes...', 'it-l10n-backupbuddy' ) . '</p>'; $message = '<h3>' . __( 'Verifying everything is up to date before Snapshot', 'it-l10n-backupbuddy' ) . '</h3><p class="description" style="max-width: 700px; display: inline-block;">' . __( 'Please wait while we verify your backup is completely up to date before we create the Snapshot. This may take a few minutes...', 'it-l10n-backupbuddy' ) . '</p>';
require pb_backupbuddy::plugin_path() . '/destinations/live/_manual_snapshot.php'; require pb_backupbuddy::plugin_path() . '/destinations/live/_manual_snapshot.php';
} }
@ -2721,7 +2721,7 @@ class MainWP_Child_Back_Up_Buddy {
} elseif ( 'pause_periodic' == $action ) { } elseif ( 'pause_periodic' == $action ) {
backupbuddy_api::setLiveStatus( $pause_continuous = '', $pause_periodic = true ); 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' ) ); // 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' ); $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. include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats.
} elseif ( 'resume_periodic' == $action ) { } elseif ( 'resume_periodic' == $action ) {
@ -2733,20 +2733,20 @@ class MainWP_Child_Back_Up_Buddy {
} }
backupbuddy_api::setLiveStatus( $pause_continuous = '', $pause_periodic = false, $start_run ); backupbuddy_api::setLiveStatus( $pause_continuous = '', $pause_periodic = false, $start_run );
//pb_backupbuddy::disalert( '', __( 'Live File Backup has resumed.', 'it-l10n-backupbuddy' ) . $launchNowText ); // pb_backupbuddy::disalert( '', __( 'Live File Backup has resumed.', 'it-l10n-backupbuddy' ) . $launchNowText );
$message = __( 'Live File Backup has resumed.', 'it-l10n-backupbuddy' ) . $launchNowText; $message = __( 'Live File Backup has resumed.', 'it-l10n-backupbuddy' ) . $launchNowText;
include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats.
} elseif ( 'pause_continuous' == $action ) { } elseif ( 'pause_continuous' == $action ) {
backupbuddy_api::setLiveStatus( $pause_continuous = true, $pause_periodic = '' ); 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. include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats.
//pb_backupbuddy::disalert( '', __( 'Live Database Backup paused.', 'it-l10n-backupbuddy' ) ); // pb_backupbuddy::disalert( '', __( 'Live Database Backup paused.', 'it-l10n-backupbuddy' ) );
$message = __( 'Live Database Backup paused.', 'it-l10n-backupbuddy' ); $message = __( 'Live Database Backup paused.', 'it-l10n-backupbuddy' );
} elseif ( 'resume_continuous' == $action ) { } elseif ( 'resume_continuous' == $action ) {
backupbuddy_api::setLiveStatus( $pause_continuous = false, $pause_periodic = '' ); 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. include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats.
//pb_backupbuddy::disalert( '', __( 'Live Database Backup resumed.', 'it-l10n-backupbuddy' ) ); // pb_backupbuddy::disalert( '', __( 'Live Database Backup resumed.', 'it-l10n-backupbuddy' ) );
$message = __( 'Live Database Backup resumed.', 'it-l10n-backupbuddy' ); $message = __( 'Live Database Backup resumed.', 'it-l10n-backupbuddy' );
} else { } else {
$error = 'Error #1000. Invalid request.'; $error = 'Error #1000. Invalid request.';
@ -2795,7 +2795,7 @@ class MainWP_Child_Back_Up_Buddy {
$site_only = true; $site_only = true;
} }
$files = pb_backupbuddy_destination_stash2::listFiles( $settings, '', $site_only ); //2nd param was $remotePath. $files = pb_backupbuddy_destination_stash2::listFiles( $settings, '', $site_only ); // 2nd param was $remotePath.
if ( ! is_array( $files ) ) { if ( ! is_array( $files ) ) {
return array( 'error' => 'Error #892329c: ' . $files ); return array( 'error' => 'Error #892329c: ' . $files );
} }

View file

@ -586,7 +586,7 @@ class MainWP_Child_Back_Up_Wordpress {
?> ?>
<div class="hmbkp-exclude-settings"> <div class="hmbkp-exclude-settings">
<?php //if ( $schedule->get_excludes() ) : ?> <?php // if ( $schedule->get_excludes() ) : ?>
<h3> <h3>
<?php esc_html_e( 'Currently Excluded', 'backupwordpress' ); ?> <?php esc_html_e( 'Currently Excluded', 'backupwordpress' ); ?>
@ -658,7 +658,7 @@ class MainWP_Child_Back_Up_Wordpress {
</table> </table>
<?php //endif; ?> <?php // endif; ?>
<h3 id="directory-listing"><?php esc_html_e( 'Your Site', 'backupwordpress' ); ?></h3> <h3 id="directory-listing"><?php esc_html_e( 'Your Site', 'backupwordpress' ); ?></h3>
@ -889,7 +889,7 @@ class MainWP_Child_Back_Up_Wordpress {
<?php <?php
} elseif ( $file->isDir() ) { } elseif ( $file->isDir() ) {
//echo add_query_arg( 'hmbkp_directory_browse', urlencode( $file->getPathname() ) ); // echo add_query_arg( 'hmbkp_directory_browse', urlencode( $file->getPathname() ) );
?> ?>
<code title="<?php echo esc_attr( $file->getRealPath() ); ?>"><a <code title="<?php echo esc_attr( $file->getRealPath() ); ?>"><a
href="#" href="#"
@ -1163,11 +1163,11 @@ class MainWP_Child_Back_Up_Wordpress {
return array( 'error' => 'Error: Schedule data' ); return array( 'error' => 'Error: Schedule data' );
} }
// $current_value = get_option( 'hmbkp_schedule_' . $sch_id ); // $current_value = get_option( 'hmbkp_schedule_' . $sch_id );
// if ( is_array( $current_value ) && isset( $current_value['excludes'] ) ) { // if ( is_array( $current_value ) && isset( $current_value['excludes'] ) ) {
// // do not update 'excludes' value // do not update 'excludes' value
// $options['excludes'] = $current_value['excludes']; // $options['excludes'] = $current_value['excludes'];
// } // }
$filter_opts = array( $filter_opts = array(
'type', 'type',

View file

@ -96,7 +96,7 @@ class MainWP_Child_Back_WP_Up {
MainWP_Helper::check_methods('get_instance'); MainWP_Helper::check_methods('get_instance');
BackWPup::get_instance(); BackWPup::get_instance();
//add_action( 'wp_ajax_mainwp_backwpup_download_backup', array( $this, 'download_backup' ) ); // add_action( 'wp_ajax_mainwp_backwpup_download_backup', array( $this, 'download_backup' ) );
add_action( 'admin_init', array( $this, 'init_download_backup' ) ); add_action( 'admin_init', array( $this, 'init_download_backup' ) );
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
} }
@ -258,7 +258,7 @@ class MainWP_Child_Back_WP_Up {
$log_folder = BackWPup_File::get_absolute_path( $log_folder ); $log_folder = BackWPup_File::get_absolute_path( $log_folder );
$log_folder = untrailingslashit( $log_folder ); $log_folder = untrailingslashit( $log_folder );
//load logs // load logs
$logfiles = array(); $logfiles = array();
if ( is_readable( $log_folder ) && $dir = opendir( $log_folder ) ) { if ( is_readable( $log_folder ) && $dir = opendir( $log_folder ) ) {
while ( ( $file = readdir( $dir ) ) !== false ) { while ( ( $file = readdir( $dir ) ) !== false ) {
@ -518,7 +518,7 @@ class MainWP_Child_Back_WP_Up {
echo '<tr title="WP_MEMORY_LIMIT"><td>' . __( 'WP memory limit', 'backwpup' ) . '</td><td>' . esc_html( WP_MEMORY_LIMIT ) . '</td></tr>'; echo '<tr title="WP_MEMORY_LIMIT"><td>' . __( 'WP memory limit', 'backwpup' ) . '</td><td>' . esc_html( WP_MEMORY_LIMIT ) . '</td></tr>';
echo '<tr title="WP_MAX_MEMORY_LIMIT"><td>' . __( 'WP maximum memory limit', 'backwpup' ) . '</td><td>' . esc_html( WP_MAX_MEMORY_LIMIT ) . '</td></tr>'; echo '<tr title="WP_MAX_MEMORY_LIMIT"><td>' . __( 'WP maximum memory limit', 'backwpup' ) . '</td><td>' . esc_html( WP_MAX_MEMORY_LIMIT ) . '</td></tr>';
echo '<tr title=""><td>' . __( 'Memory in use', 'backwpup' ) . '</td><td>' . esc_html( size_format( @memory_get_usage( true ), 2 ) ) . '</td></tr>'; echo '<tr title=""><td>' . __( 'Memory in use', 'backwpup' ) . '</td><td>' . esc_html( size_format( @memory_get_usage( true ), 2 ) ) . '</td></tr>';
//disabled PHP functions // disabled PHP functions
$disabled = ini_get( 'disable_functions' ); $disabled = ini_get( 'disable_functions' );
if ( ! empty( $disabled ) ) { if ( ! empty( $disabled ) ) {
$disabledarry = explode( ',', $disabled ); $disabledarry = explode( ',', $disabled );
@ -526,7 +526,7 @@ class MainWP_Child_Back_WP_Up {
echo esc_html( implode( ', ', $disabledarry ) ); echo esc_html( implode( ', ', $disabledarry ) );
echo '</td></tr>'; echo '</td></tr>';
} }
//Loaded PHP Extensions // Loaded PHP Extensions
echo '<tr title=""><td>' . __( 'Loaded PHP Extensions:', 'backwpup' ) . '</td><td>'; echo '<tr title=""><td>' . __( 'Loaded PHP Extensions:', 'backwpup' ) . '</td><td>';
$extensions = get_loaded_extensions(); $extensions = get_loaded_extensions();
sort( $extensions ); sort( $extensions );
@ -1049,7 +1049,7 @@ class MainWP_Child_Back_WP_Up {
// From BackWPup_Destination_Email::edit_ajax // From BackWPup_Destination_Email::edit_ajax
if ( $emailmethod ) { if ( $emailmethod ) {
//do so if i'm the wp_mail to get the settings // do so if i'm the wp_mail to get the settings
global $phpmailer; global $phpmailer;
// (Re)create it, if it's gone missing // (Re)create it, if it's gone missing
if ( ! is_object( $phpmailer ) || ! $phpmailer instanceof PHPMailer ) { if ( ! is_object( $phpmailer ) || ! $phpmailer instanceof PHPMailer ) {
@ -1057,10 +1057,10 @@ class MainWP_Child_Back_WP_Up {
require_once ABSPATH . WPINC . '/class-smtp.php'; require_once ABSPATH . WPINC . '/class-smtp.php';
$phpmailer = new PHPMailer( true ); $phpmailer = new PHPMailer( true );
} }
//only if PHPMailer really used // only if PHPMailer really used
if ( is_object( $phpmailer ) ) { if ( is_object( $phpmailer ) ) {
do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) ); do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
//get settings from PHPMailer // get settings from PHPMailer
$emailmethod = $phpmailer->Mailer; $emailmethod = $phpmailer->Mailer;
$emailsendmail = $phpmailer->Sendmail; $emailsendmail = $phpmailer->Sendmail;
$emailhost = $phpmailer->Host; $emailhost = $phpmailer->Host;
@ -1071,7 +1071,7 @@ class MainWP_Child_Back_WP_Up {
} }
} }
//Generate mail with Swift Mailer // Generate mail with Swift Mailer
if ( ! class_exists( 'Swift', false ) ) { if ( ! class_exists( 'Swift', false ) ) {
require BackWPup::get_plugin_data( 'plugindir' ) . '/vendor/SwiftMailer/swift_required.php'; require BackWPup::get_plugin_data( 'plugindir' ) . '/vendor/SwiftMailer/swift_required.php';
} }
@ -1430,7 +1430,7 @@ class MainWP_Child_Back_WP_Up {
if ( $settings['job_id'] > 0 ) { if ( $settings['job_id'] > 0 ) {
$job_id = intval( $settings['job_id'] ); $job_id = intval( $settings['job_id'] );
} else { } else {
//generate jobid if not exists // generate jobid if not exists
$newjobid = BackWPup_Option::get_job_ids(); $newjobid = BackWPup_Option::get_job_ids();
sort( $newjobid ); sort( $newjobid );
$job_id = end( $newjobid ) + 1; $job_id = end( $newjobid ) + 1;
@ -1452,7 +1452,7 @@ class MainWP_Child_Back_WP_Up {
if ($settings['tab'] == 'jobtype-FILE') { if ($settings['tab'] == 'jobtype-FILE') {
// to fix // to fix
$this->edit_form_post_save($settings['value'], $job_id); $this->edit_form_post_save($settings['value'], $job_id);
//saved message // saved message
$messages = BackWPup_Admin::get_messages(); $messages = BackWPup_Admin::get_messages();
if ( empty( $messages['error'] ) ) { if ( empty( $messages['error'] ) ) {
$url = BackWPup_Job::get_jobrun_url( 'runnowlink', $job_id ); $url = BackWPup_Job::get_jobrun_url( 'runnowlink', $job_id );

View file

@ -110,7 +110,7 @@ class MainWP_Child_Branding {
'mainwp_branding_remove_wp_tools', 'mainwp_branding_remove_wp_tools',
'mainwp_branding_remove_wp_setting', 'mainwp_branding_remove_wp_setting',
'mainwp_branding_remove_permalink', 'mainwp_branding_remove_permalink',
//'mainwp_branding_plugin_header', // don't remove header // 'mainwp_branding_plugin_header', // don't remove header
'mainwp_branding_button_contact_label', 'mainwp_branding_button_contact_label',
'mainwp_branding_send_email_message', 'mainwp_branding_send_email_message',
'mainwp_branding_message_return_sender', 'mainwp_branding_message_return_sender',
@ -136,7 +136,7 @@ class MainWP_Child_Branding {
'remove_wp_tools', 'remove_wp_tools',
'remove_wp_setting', 'remove_wp_setting',
'remove_permalink', 'remove_permalink',
//'branding_header', // don't remove header // 'branding_header', // don't remove header
'contact_label', 'contact_label',
'email_message', 'email_message',
'message_return_sender', 'message_return_sender',
@ -174,7 +174,7 @@ class MainWP_Child_Branding {
$current_settings = $this->child_branding_options; $current_settings = $this->child_branding_options;
$current_extra_setting = $this->child_branding_options['extra_settings']; $current_extra_setting = $this->child_branding_options['extra_settings'];
//MainWP_Helper::update_option( 'mainwp_branding_ext_enabled', 'Y' ); // MainWP_Helper::update_option( 'mainwp_branding_ext_enabled', 'Y' );
$current_settings['branding_ext_enabled'] = 'Y'; $current_settings['branding_ext_enabled'] = 'Y';
$header = array( $header = array(
@ -187,22 +187,22 @@ class MainWP_Child_Branding {
MainWP_Helper::update_option( 'mainwp_branding_preserve_branding', $settings['child_preserve_branding'], 'yes' ); // to compatible with old version of child report plugin MainWP_Helper::update_option( 'mainwp_branding_preserve_branding', $settings['child_preserve_branding'], 'yes' ); // to compatible with old version of child report plugin
MainWP_Helper::update_option( 'mainwp_branding_plugin_header', $header, 'yes' ); // to compatible MainWP_Helper::update_option( 'mainwp_branding_plugin_header', $header, 'yes' ); // to compatible
// MainWP_Helper::update_option( 'mainwp_branding_support_email', $settings['child_support_email'] ); // MainWP_Helper::update_option( 'mainwp_branding_support_email', $settings['child_support_email'] );
// MainWP_Helper::update_option( 'mainwp_branding_support_message', $settings['child_support_message'] ); // MainWP_Helper::update_option( 'mainwp_branding_support_message', $settings['child_support_message'] );
// MainWP_Helper::update_option( 'mainwp_branding_remove_restore', $settings['child_remove_restore'] ); // MainWP_Helper::update_option( 'mainwp_branding_remove_restore', $settings['child_remove_restore'] );
// MainWP_Helper::update_option( 'mainwp_branding_remove_setting', $settings['child_remove_setting'], 'yes' ); // MainWP_Helper::update_option( 'mainwp_branding_remove_setting', $settings['child_remove_setting'], 'yes' );
// MainWP_Helper::update_option( 'mainwp_branding_remove_server_info', $settings['child_remove_server_info'] ); // MainWP_Helper::update_option( 'mainwp_branding_remove_server_info', $settings['child_remove_server_info'] );
// MainWP_Helper::update_option( 'mainwp_branding_remove_connection_detail', (isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0) ); // MainWP_Helper::update_option( 'mainwp_branding_remove_connection_detail', (isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0) );
// MainWP_Helper::update_option( 'mainwp_branding_remove_wp_tools', $settings['child_remove_wp_tools'], 'yes' ); // MainWP_Helper::update_option( 'mainwp_branding_remove_wp_tools', $settings['child_remove_wp_tools'], 'yes' );
// MainWP_Helper::update_option( 'mainwp_branding_remove_wp_setting', $settings['child_remove_wp_setting'], 'yes' ); // MainWP_Helper::update_option( 'mainwp_branding_remove_wp_setting', $settings['child_remove_wp_setting'], 'yes' );
// MainWP_Helper::update_option( 'mainwp_branding_remove_permalink', $settings['child_remove_permalink'], 'yes' ); // MainWP_Helper::update_option( 'mainwp_branding_remove_permalink', $settings['child_remove_permalink'], 'yes' );
// MainWP_Helper::update_option( 'mainwp_branding_button_contact_label', $settings['child_button_contact_label'], 'yes' ); // MainWP_Helper::update_option( 'mainwp_branding_button_contact_label', $settings['child_button_contact_label'], 'yes' );
// MainWP_Helper::update_option( 'mainwp_branding_send_email_message', $settings['child_send_email_message'] ); // MainWP_Helper::update_option( 'mainwp_branding_send_email_message', $settings['child_send_email_message'] );
// MainWP_Helper::update_option( 'mainwp_branding_message_return_sender', $settings['child_message_return_sender'] ); // MainWP_Helper::update_option( 'mainwp_branding_message_return_sender', $settings['child_message_return_sender'] );
// MainWP_Helper::update_option( 'mainwp_branding_submit_button_title', $settings['child_submit_button_title'] ); // MainWP_Helper::update_option( 'mainwp_branding_submit_button_title', $settings['child_submit_button_title'] );
// if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) { // if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) {
// MainWP_Helper::update_option( 'mainwp_branding_disable_wp_branding', $settings['child_disable_wp_branding'] ); // MainWP_Helper::update_option( 'mainwp_branding_disable_wp_branding', $settings['child_disable_wp_branding'] );
// } // }
$current_settings['preserve_branding'] = $settings['child_preserve_branding']; $current_settings['preserve_branding'] = $settings['child_preserve_branding'];
$current_settings['branding_header'] = $header; $current_settings['branding_header'] = $header;
@ -266,7 +266,7 @@ class MainWP_Child_Branding {
$extra_setting['login_image'] = array(); $extra_setting['login_image'] = array();
} else { } else {
try { try {
$upload = $this->uploadImage( $settings['child_login_image_url'] ); //Upload image to WP $upload = $this->uploadImage( $settings['child_login_image_url'] ); // Upload image to WP
if ( null !== $upload ) { if ( null !== $upload ) {
$extra_setting['login_image'] = array( $extra_setting['login_image'] = array(
'path' => $upload['path'], 'path' => $upload['path'],
@ -292,7 +292,7 @@ class MainWP_Child_Branding {
$extra_setting['favico_image'] = array(); $extra_setting['favico_image'] = array();
} else { } else {
try { try {
$upload = $this->uploadImage( $settings['child_favico_image_url'] ); //Upload image to WP $upload = $this->uploadImage( $settings['child_favico_image_url'] ); // Upload image to WP
if ( null !== $upload ) { if ( null !== $upload ) {
$extra_setting['favico_image'] = array( $extra_setting['favico_image'] = array(
'path' => $upload['path'], 'path' => $upload['path'],
@ -313,7 +313,7 @@ class MainWP_Child_Branding {
$extra_setting['favico_image'] = $current_extra_setting['favico_image']; $extra_setting['favico_image'] = $current_extra_setting['favico_image'];
} }
//MainWP_Helper::update_option( 'mainwp_branding_extra_settings', $extra_setting, 'yes' ); // MainWP_Helper::update_option( 'mainwp_branding_extra_settings', $extra_setting, 'yes' );
$current_settings['extra_settings'] = $extra_setting; $current_settings['extra_settings'] = $extra_setting;
// keep it to compatible with old version of child reports plugin // keep it to compatible with old version of child reports plugin
@ -323,23 +323,23 @@ class MainWP_Child_Branding {
MainWP_Helper::update_option( 'mainwp_branding_child_hide', '' ); MainWP_Helper::update_option( 'mainwp_branding_child_hide', '' );
} }
// //
// if ( $settings['child_show_support_button'] && ! empty( $settings['child_support_email'] ) ) { // if ( $settings['child_show_support_button'] && ! empty( $settings['child_support_email'] ) ) {
// MainWP_Helper::update_option( 'mainwp_branding_show_support', 'T' ); // MainWP_Helper::update_option( 'mainwp_branding_show_support', 'T' );
// } else { // } else {
// MainWP_Helper::update_option( 'mainwp_branding_show_support', '' ); // MainWP_Helper::update_option( 'mainwp_branding_show_support', '' );
// } // }
// if ( $settings['child_disable_change'] ) { // if ( $settings['child_disable_change'] ) {
// MainWP_Helper::update_option( 'mainwp_branding_disable_change', 'T' ); // MainWP_Helper::update_option( 'mainwp_branding_disable_change', 'T' );
// } else { // } else {
// MainWP_Helper::update_option( 'mainwp_branding_disable_change', '' ); // MainWP_Helper::update_option( 'mainwp_branding_disable_change', '' );
// } // }
// if ( $settings['child_disable_switching_theme'] ) { // if ( $settings['child_disable_switching_theme'] ) {
// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', 'T' ); // MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', 'T' );
// } else { // } else {
// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', '' ); // MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', '' );
// } // }
$current_settings['hide'] = $settings['child_plugin_hide'] ? 'T' : ''; $current_settings['hide'] = $settings['child_plugin_hide'] ? 'T' : '';
$current_settings['show_support'] = ( $settings['child_show_support_button'] && ! empty($settings['child_support_email']) ) ? 'T' : ''; $current_settings['show_support'] = ( $settings['child_show_support_button'] && ! empty($settings['child_support_email']) ) ? 'T' : '';
@ -354,10 +354,10 @@ class MainWP_Child_Branding {
} }
static function uploadImage( $img_url ) { static function uploadImage( $img_url ) {
include_once ABSPATH . 'wp-admin/includes/file.php'; //Contains download_url include_once ABSPATH . 'wp-admin/includes/file.php'; // Contains download_url
global $mainWPChild; global $mainWPChild;
add_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 ); add_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
//Download $img_url // Download $img_url
$temporary_file = download_url( $img_url ); $temporary_file = download_url( $img_url );
remove_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 ); remove_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
@ -365,7 +365,7 @@ class MainWP_Child_Branding {
throw new Exception( 'Error: ' . $temporary_file->get_error_message() ); throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
} else { } else {
$upload_dir = wp_upload_dir(); $upload_dir = wp_upload_dir();
$local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . basename( $img_url ); //Local name $local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . basename( $img_url ); // Local name
$local_img_path = dirname( $local_img_path ) . '/' . wp_unique_filename( dirname( $local_img_path ), basename( $local_img_path ) ); $local_img_path = dirname( $local_img_path ) . '/' . wp_unique_filename( dirname( $local_img_path ), basename( $local_img_path ) );
$local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path ); $local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
$moved = @rename( $temporary_file, $local_img_path ); $moved = @rename( $temporary_file, $local_img_path );
@ -444,8 +444,7 @@ class MainWP_Child_Branding {
} }
// to fix // to fix
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );// add_action( 'admin_menu', array( &$this, 'admin_menu' ) ); if ( ! isset($opts['disable_wp_branding']) || $opts['disable_wp_branding'] !== 'Y' ) {
if ( ! isset($opts['disable_wp_branding']) || $opts['disable_wp_branding'] !== 'Y' ) {
add_filter( 'wp_footer', array( &$this, 'branding_global_footer' ), 15 ); add_filter( 'wp_footer', array( &$this, 'branding_global_footer' ), 15 );
add_action( 'wp_dashboard_setup', array( &$this, 'custom_dashboard_widgets' ), 999 ); add_action( 'wp_dashboard_setup', array( &$this, 'custom_dashboard_widgets' ), 999 );
// branding site generator // branding site generator
@ -461,7 +460,7 @@ class MainWP_Child_Branding {
add_filter( 'login_headertext', array( &$this, 'custom_login_headertitle' ) ); add_filter( 'login_headertext', array( &$this, 'custom_login_headertitle' ) );
add_action( 'wp_head', array( &$this, 'custom_favicon_frontend' ) ); add_action( 'wp_head', array( &$this, 'custom_favicon_frontend' ) );
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) { if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
//remove_filter( 'update_footer', 'core_update_footer' ); // remove_filter( 'update_footer', 'core_update_footer' );
add_filter( 'update_footer', array( &$this, 'core_update_footer' ), 14 ); add_filter( 'update_footer', array( &$this, 'core_update_footer' ), 14 );
add_filter( 'admin_footer_text', array( &$this, 'admin_footer_text' ), 14 ); add_filter( 'admin_footer_text', array( &$this, 'admin_footer_text' ), 14 );
} }

View file

@ -1,7 +1,7 @@
<?php <?php
class MainWP_Child_DB { class MainWP_Child_DB {
//Support old & new versions of WordPress (3.9+) // Support old & new versions of WordPress (3.9+)
public static function use_mysqli() { public static function use_mysqli() {
/** @var $wpdb wpdb */ /** @var $wpdb wpdb */
if ( ! function_exists( 'mysqli_connect' ) ) { if ( ! function_exists( 'mysqli_connect' ) ) {

View file

@ -194,14 +194,14 @@ class MainWP_Child_iThemes_Security {
'404-detection', '404-detection',
'network-brute-force', 'network-brute-force',
'ssl', 'ssl',
//'strong-passwords', // 'strong-passwords',
'password-requirements', 'password-requirements',
'system-tweaks', 'system-tweaks',
'wordpress-tweaks', 'wordpress-tweaks',
'multisite-tweaks', 'multisite-tweaks',
'notification-center', 'notification-center',
//'salts', // 'salts',
//'content-directory', // 'content-directory',
); );
$require_permalinks = false; $require_permalinks = false;
@ -369,7 +369,7 @@ class MainWP_Child_iThemes_Security {
} elseif ( $results['saved'] ) { } elseif ( $results['saved'] ) {
ITSEC_Modules::activate( 'network-brute-force' ); ITSEC_Modules::activate( 'network-brute-force' );
$nbf_settings = ITSEC_Modules::get_settings( 'network-brute-force' ); $nbf_settings = ITSEC_Modules::get_settings( 'network-brute-force' );
// ITSEC_Response::set_response( '<p>' . __( 'Your site is now using Network Brute Force Protection.', 'better-wp-security' ) . '</p>' ); // ITSEC_Response::set_response( '<p>' . __( 'Your site is now using Network Brute Force Protection.', 'better-wp-security' ) . '</p>' );
} }
} }
if ($nbf_settings !== null) { if ($nbf_settings !== null) {
@ -409,15 +409,15 @@ class MainWP_Child_iThemes_Security {
$key = ITSEC_Network_Brute_Force_Utilities::get_api_key( $settings['email'], $settings['updates_optin'] ); $key = ITSEC_Network_Brute_Force_Utilities::get_api_key( $settings['email'], $settings['updates_optin'] );
if ( is_wp_error( $key ) ) { if ( is_wp_error( $key ) ) {
return false; return false;
// $this->set_can_save( false ); // $this->set_can_save( false );
// $this->add_error( $key ); // $this->add_error( $key );
} else { } else {
$secret = ITSEC_Network_Brute_Force_Utilities::activate_api_key( $key ); $secret = ITSEC_Network_Brute_Force_Utilities::activate_api_key( $key );
if ( is_wp_error( $secret ) ) { if ( is_wp_error( $secret ) ) {
return false; return false;
// $this->set_can_save( false ); // $this->set_can_save( false );
// $this->add_error( $secret ); // $this->add_error( $secret );
} else { } else {
$settings['api_key'] = $key; $settings['api_key'] = $key;
$settings['api_secret'] = $secret; $settings['api_secret'] = $secret;
@ -697,7 +697,7 @@ class MainWP_Child_iThemes_Security {
$new_username = isset( $settings['new_username'] ) ? $settings['new_username'] : ''; $new_username = isset( $settings['new_username'] ) ? $settings['new_username'] : '';
$change_id = isset( $settings['change_id'] ) && $settings['change_id'] ? true : false; $change_id = isset( $settings['change_id'] ) && $settings['change_id'] ? true : false;
//load utility functions // load utility functions
if ( ! class_exists( 'ITSEC_Lib' ) ) { if ( ! class_exists( 'ITSEC_Lib' ) ) {
global $itsec_globals; global $itsec_globals;
require ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php'; require ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php';
@ -723,13 +723,13 @@ class MainWP_Child_iThemes_Security {
$msg .= __( 'Admin user ID already changes.', 'mainwp-child' ); $msg .= __( 'Admin user ID already changes.', 'mainwp-child' );
} }
// if ( $change_id ) { // if ( $change_id ) {
// $user = get_user_by( 'login', $new_username ); // $user = get_user_by( 'login', $new_username );
// if ( $user && 1 === (int) $user->ID ) { // if ( $user && 1 === (int) $user->ID ) {
// $return['result'] = 'CHILD_ADMIN'; // $return['result'] = 'CHILD_ADMIN';
// return $return; // return $return;
// } // }
// } // }
$admin_success = true; $admin_success = true;
$return = array(); $return = array();
@ -755,26 +755,26 @@ class MainWP_Child_iThemes_Security {
$itsec_files = ITSEC_Core::get_itsec_files(); $itsec_files = ITSEC_Core::get_itsec_files();
// do not need to check this // do not need to check this
//if ( $itsec_files->get_file_lock( 'admin_user' ) ) { //make sure it isn't already running // if ( $itsec_files->get_file_lock( 'admin_user' ) ) { //make sure it isn't already running
//sanitize the username // sanitize the username
$new_user = sanitize_text_field( $username ); $new_user = sanitize_text_field( $username );
//Get the full user object // Get the full user object
$user_object = get_user_by( 'id', '1' ); $user_object = get_user_by( 'id', '1' );
if ( null !== $username && validate_username( $new_user ) && false === username_exists( $new_user ) ) { //there is a valid username to change if ( null !== $username && validate_username( $new_user ) && false === username_exists( $new_user ) ) { // there is a valid username to change
if ( true === $id ) { //we're changing the id too so we'll set the username if ( true === $id ) { // we're changing the id too so we'll set the username
$user_login = $new_user; $user_login = $new_user;
} else { // we're only changing the username } else { // we're only changing the username
//query main user table // query main user table
$wpdb->query( 'UPDATE `' . $wpdb->users . "` SET user_login = '" . esc_sql( $new_user ) . "' WHERE user_login='admin';" ); $wpdb->query( 'UPDATE `' . $wpdb->users . "` SET user_login = '" . esc_sql( $new_user ) . "' WHERE user_login='admin';" );
if ( is_multisite() ) { //process sitemeta if we're in a multi-site situation if ( is_multisite() ) { // process sitemeta if we're in a multi-site situation
$oldAdmins = $wpdb->get_var( 'SELECT meta_value FROM `' . $wpdb->sitemeta . "` WHERE meta_key = 'site_admins'" ); $oldAdmins = $wpdb->get_var( 'SELECT meta_value FROM `' . $wpdb->sitemeta . "` WHERE meta_key = 'site_admins'" );
$newAdmins = str_replace( '5:"admin"', strlen( $new_user ) . ':"' . esc_sql( $new_user ) . '"', $oldAdmins ); $newAdmins = str_replace( '5:"admin"', strlen( $new_user ) . ':"' . esc_sql( $new_user ) . '"', $oldAdmins );
@ -787,19 +787,19 @@ class MainWP_Child_iThemes_Security {
return true; return true;
} }
} elseif ( null !== $username ) { //username didn't validate } elseif ( null !== $username ) { // username didn't validate
$itsec_files->release_file_lock( 'admin_user' ); $itsec_files->release_file_lock( 'admin_user' );
return false; return false;
} else { //only changing the id } else { // only changing the id
$user_login = $user_object->user_login; $user_login = $user_object->user_login;
} }
if ( true === $id ) { //change the user id if ( true === $id ) { // change the user id
$wpdb->query( 'DELETE FROM `' . $wpdb->users . '` WHERE ID = 1;' ); $wpdb->query( 'DELETE FROM `' . $wpdb->users . '` WHERE ID = 1;' );
@ -815,7 +815,7 @@ class MainWP_Child_iThemes_Security {
'display_name' => $user_object->display_name, 'display_name' => $user_object->display_name,
) ); ) );
if ( is_multisite() && null !== $username && validate_username( $new_user ) ) { //process sitemeta if we're in a multi-site situation if ( is_multisite() && null !== $username && validate_username( $new_user ) ) { // process sitemeta if we're in a multi-site situation
$oldAdmins = $wpdb->get_var( 'SELECT meta_value FROM `' . $wpdb->sitemeta . "` WHERE meta_key = 'site_admins'" ); $oldAdmins = $wpdb->get_var( 'SELECT meta_value FROM `' . $wpdb->sitemeta . "` WHERE meta_key = 'site_admins'" );
$newAdmins = str_replace( '5:"admin"', strlen( $new_user ) . ':"' . esc_sql( $new_user ) . '"', $oldAdmins ); $newAdmins = str_replace( '5:"admin"', strlen( $new_user ) . ':"' . esc_sql( $new_user ) . '"', $oldAdmins );
@ -836,13 +836,13 @@ class MainWP_Child_iThemes_Security {
return true; return true;
} }
//} // }
return false; return false;
} }
public function build_wpconfig_rules( $rules_array, $input = null ) { public function build_wpconfig_rules( $rules_array, $input = null ) {
//Get the rules from the database if input wasn't sent // Get the rules from the database if input wasn't sent
if ( null === $input ) { if ( null === $input ) {
return $rules_array; return $rules_array;
} }

View file

@ -137,13 +137,13 @@ class MainWP_Child_Links_Checker {
global $wpdb; global $wpdb;
/** @var wpdb $wpdb */ /** @var wpdb $wpdb */
//Delete all discovered instances // Delete all discovered instances
$wpdb->query( "TRUNCATE {$wpdb->prefix}blc_instances" ); $wpdb->query( "TRUNCATE {$wpdb->prefix}blc_instances" );
//Delete all discovered links // Delete all discovered links
$wpdb->query( "TRUNCATE {$wpdb->prefix}blc_links" ); $wpdb->query( "TRUNCATE {$wpdb->prefix}blc_links" );
//Mark all posts, custom fields and bookmarks for processing. // Mark all posts, custom fields and bookmarks for processing.
blc_resynch( true ); blc_resynch( true );
} }
@ -158,18 +158,18 @@ class MainWP_Child_Links_Checker {
} }
blc_init(); blc_init();
//Get the container type matching the type of the deleted post // Get the container type matching the type of the deleted post
$post = get_post( $post_id ); $post = get_post( $post_id );
if ( ! $post ) { if ( ! $post ) {
return; return;
} }
//Get the associated container object // Get the associated container object
$post_container = blcContainerHelper::get_container( array( $post->post_type, intval( $post_id ) ) ); $post_container = blcContainerHelper::get_container( array( $post->post_type, intval( $post_id ) ) );
if ( $post_container ) { if ( $post_container ) {
//Delete it // Delete it
$post_container->delete(); $post_container->delete();
//Clean up any dangling links // Clean up any dangling links
blc_cleanup_links(); blc_cleanup_links();
} }
} }
@ -345,7 +345,7 @@ class MainWP_Child_Links_Checker {
'last_success', 'last_success',
'may_recheck', 'may_recheck',
'false_positive', 'false_positive',
//'result_hash', // 'result_hash',
'dismissed', 'dismissed',
'status_text', 'status_text',
'status_code', 'status_code',
@ -374,7 +374,7 @@ class MainWP_Child_Links_Checker {
$days_broken = 0; $days_broken = 0;
if ( $link->broken ) { if ( $link->broken ) {
//Add a highlight to broken links that appear to be permanently broken // Add a highlight to broken links that appear to be permanently broken
$days_broken = intval( ( time() - $link->first_failure ) / ( 3600 * 24 ) ); $days_broken = intval( ( time() - $link->first_failure ) / ( 3600 * 24 ) );
if ( $days_broken >= $blc_option['failure_duration_threshold'] ) { if ( $days_broken >= $blc_option['failure_duration_threshold'] ) {
$extra_info['permanently_broken'] = 1; $extra_info['permanently_broken'] = 1;
@ -433,7 +433,7 @@ class MainWP_Child_Links_Checker {
$link_texts = $can_edit_text ? $editable_link_texts : $non_editable_link_texts; $link_texts = $can_edit_text ? $editable_link_texts : $non_editable_link_texts;
$data_link_text = ''; $data_link_text = '';
if ( count( $link_texts ) === 1 ) { if ( count( $link_texts ) === 1 ) {
//All instances have the same text - use it. // All instances have the same text - use it.
$link_text = key( $link_texts ); $link_text = key( $link_texts );
$data_link_text = esc_attr( $link_text ); $data_link_text = esc_attr( $link_text );
} }
@ -462,14 +462,14 @@ class MainWP_Child_Links_Checker {
return $information; return $information;
} }
//Load the link // Load the link
$link = new blcLink( intval( $_POST['link_id'] ) ); $link = new blcLink( intval( $_POST['link_id'] ) );
if ( ! $link->valid() ) { if ( ! $link->valid() ) {
$information['error'] = 'NOTFOUNDLINK'; // Oops, I can't find the link $information['error'] = 'NOTFOUNDLINK'; // Oops, I can't find the link
return $information; return $information;
} }
//Validate the new URL. // Validate the new URL.
$new_url = stripslashes( $_POST['new_url'] ); $new_url = stripslashes( $_POST['new_url'] );
$parsed = @parse_url( $new_url ); $parsed = @parse_url( $new_url );
if ( ! $parsed ) { if ( ! $parsed ) {
@ -482,7 +482,7 @@ class MainWP_Child_Links_Checker {
$new_text = null; $new_text = null;
} }
if ( ! empty( $new_text ) && ! current_user_can( 'unfiltered_html' ) ) { if ( ! empty( $new_text ) && ! current_user_can( 'unfiltered_html' ) ) {
$new_text = stripslashes( wp_filter_post_kses( addslashes( $new_text ) ) ); //wp_filter_post_kses expects slashed data. $new_text = stripslashes( wp_filter_post_kses( addslashes( $new_text ) ) ); // wp_filter_post_kses expects slashed data.
} }
$rez = $link->edit( $new_url, $new_text ); $rez = $link->edit( $new_url, $new_text );
@ -515,7 +515,7 @@ class MainWP_Child_Links_Checker {
'ui_link_text' => isset( $new_text ) ? $ui_link_text : null, 'ui_link_text' => isset( $new_text ) ? $ui_link_text : null,
'errors' => array(), 'errors' => array(),
); );
//url, status text, status code, link text, editable link text // url, status text, status code, link text, editable link text
foreach ( $rez['errors'] as $error ) { foreach ( $rez['errors'] as $error ) {
/** @var $error WP_Error */ /** @var $error WP_Error */
@ -535,7 +535,7 @@ class MainWP_Child_Links_Checker {
} }
if ( isset( $_POST['link_id'] ) ) { if ( isset( $_POST['link_id'] ) ) {
//Load the link // Load the link
$link = new blcLink( intval( $_POST['link_id'] ) ); $link = new blcLink( intval( $_POST['link_id'] ) );
if ( ! $link->valid() ) { if ( ! $link->valid() ) {
@ -543,7 +543,7 @@ class MainWP_Child_Links_Checker {
return $information; return $information;
} }
//Try and unlink it // Try and unlink it
$rez = $link->unlink(); $rez = $link->unlink();
if ( false === $rez ) { if ( false === $rez ) {
@ -580,7 +580,7 @@ class MainWP_Child_Links_Checker {
} }
if ( isset( $_POST['link_id'] ) ) { if ( isset( $_POST['link_id'] ) ) {
//Load the link // Load the link
$link = new blcLink( intval( $_POST['link_id'] ) ); $link = new blcLink( intval( $_POST['link_id'] ) );
if ( ! $link->valid() ) { if ( ! $link->valid() ) {
@ -590,7 +590,7 @@ class MainWP_Child_Links_Checker {
$link->dismissed = $dismiss; $link->dismissed = $dismiss;
//Save the changes // Save the changes
if ( $link->save() ) { if ( $link->save() ) {
$information = 'OK'; $information = 'OK';
} else { } else {
@ -613,7 +613,7 @@ class MainWP_Child_Links_Checker {
return $information; return $information;
} }
if ( isset( $_POST['link_id'] ) ) { if ( isset( $_POST['link_id'] ) ) {
//Load the link // Load the link
$link = new blcLink( intval( $_POST['link_id'] ) ); $link = new blcLink( intval( $_POST['link_id'] ) );
if ( ! $link->valid() ) { if ( ! $link->valid() ) {
@ -621,13 +621,13 @@ class MainWP_Child_Links_Checker {
return $information; return $information;
} }
//Make it appear "not broken" // Make it appear "not broken"
$link->broken = false; $link->broken = false;
$link->false_positive = true; $link->false_positive = true;
$link->last_check_attempt = time(); $link->last_check_attempt = time();
$link->log = __( 'This link was manually marked as working by the user.', 'mainwp-child' ); $link->log = __( 'This link was manually marked as working by the user.', 'mainwp-child' );
//Save the changes // Save the changes
if ( $link->save() ) { if ( $link->save() ) {
$information['status'] = 'OK'; $information['status'] = 'OK';
$information['last_check_attempt'] = $link->last_check_attempt; $information['last_check_attempt'] = $link->last_check_attempt;
@ -652,7 +652,7 @@ class MainWP_Child_Links_Checker {
} }
function ui_get_source_comment( $container, $container_field = '' ) { function ui_get_source_comment( $container, $container_field = '' ) {
//Display a comment icon. // Display a comment icon.
if ( 'comment_author_url' === $container_field ) { if ( 'comment_author_url' === $container_field ) {
$image = 'font-awesome/font-awesome-user.png'; $image = 'font-awesome/font-awesome-user.png';
} else { } else {
@ -665,7 +665,7 @@ class MainWP_Child_Links_Checker {
$comment = $container->get_wrapped_object(); $comment = $container->get_wrapped_object();
//Display a small text sample from the comment // Display a small text sample from the comment
$text_sample = strip_tags( $comment->comment_content ); $text_sample = strip_tags( $comment->comment_content );
$text_sample = blcUtility::truncate( $text_sample, 65 ); $text_sample = blcUtility::truncate( $text_sample, 65 );

View file

@ -240,17 +240,17 @@ class MainWP_Child_Pagespeed {
$result = $this->get_sync_data( $strategy ); $result = $this->get_sync_data( $strategy );
// if ( isset( $_POST['doaction'] ) && ( 'check_new_pages' === $_POST['doaction'] || 'recheck_all_pages' === $_POST['doaction'] ) ) { // if ( isset( $_POST['doaction'] ) && ( 'check_new_pages' === $_POST['doaction'] || 'recheck_all_pages' === $_POST['doaction'] ) ) {
// if ( 'recheck_all_pages' === $_POST['doaction'] ) { // if ( 'recheck_all_pages' === $_POST['doaction'] ) {
// $recheck = true; // $recheck = true;
// } else { // } else {
// $recheck = false; // $recheck = false;
// } // }
// //
// //
// if ($this->do_check_pages($recheck)) // if ($this->do_check_pages($recheck))
// $information['checked_pages'] = 1; // $information['checked_pages'] = 1;
// } // }
$information['data'] = $result['data']; $information['data'] = $result['data'];
return $information; return $information;
} }
@ -276,7 +276,7 @@ class MainWP_Child_Pagespeed {
if ( $checkstatus ) { if ( $checkstatus ) {
$information['error'] = __( 'The API is busy checking other pages, please try again later.', 'gpagespeedi' ); $information['error'] = __( 'The API is busy checking other pages, please try again later.', 'gpagespeedi' );
} else { } else {
//do_action( 'googlepagespeedinsightsworker', array(), $forceRecheck ); // do_action( 'googlepagespeedinsightsworker', array(), $forceRecheck );
do_action( 'run_gpi', $forceRecheck ); // to fix do_action( 'run_gpi', $forceRecheck ); // to fix
$information['checked_pages'] = 1; $information['checked_pages'] = 1;
} }
@ -343,7 +343,7 @@ class MainWP_Child_Pagespeed {
} }
$score_column = $strategy . '_score'; $score_column = $strategy . '_score';
//$page_stats_column = $strategy . '_page_stats'; // $page_stats_column = $strategy . '_page_stats';
$data_typestocheck = self::get_filter_options( 'all' ); $data_typestocheck = self::get_filter_options( 'all' );
@ -400,9 +400,9 @@ class MainWP_Child_Pagespeed {
// Not Null check for Report List scores // Not Null check for Report List scores
switch ( $strategy ) { switch ( $strategy ) {
// case 'both': // case 'both':
// $nullcheck = 'desktop_score IS NOT NULL AND mobile_score IS NOT NULL'; // $nullcheck = 'desktop_score IS NOT NULL AND mobile_score IS NOT NULL';
// break; // break;
case 'mobile': case 'mobile':
$nullcheck = 'mobile_score IS NOT NULL'; $nullcheck = 'mobile_score IS NOT NULL';

View file

@ -45,7 +45,7 @@ class MainWP_Child_Plugins_Check {
add_action( $this->cron_name_watcher, array( $this, 'perform_watchdog' ) ); add_action( $this->cron_name_watcher, array( $this, 'perform_watchdog' ) );
//add_filter( 'plugin_row_meta', array( $this, 'change_plugin_row_meta' ), 10, 4 ); // add_filter( 'plugin_row_meta', array( $this, 'change_plugin_row_meta' ), 10, 4 );
add_filter( 'plugins_api_args', array( $this, 'modify_plugin_api_search_query' ), 10, 2 ); add_filter( 'plugins_api_args', array( $this, 'modify_plugin_api_search_query' ), 10, 2 );
@ -97,7 +97,7 @@ class MainWP_Child_Plugins_Check {
$last_run = new \DateTime( '@' . $last_run ); $last_run = new \DateTime( '@' . $last_run );
} }
//Get now // Get now
$now = new \DateTime(); $now = new \DateTime();
if ( false === $last_run || (int) $now->diff( $last_run )->format( '%h' ) >= 24 ) { if ( false === $last_run || (int) $now->diff( $last_run )->format( '%h' ) >= 24 ) {
@ -112,10 +112,10 @@ class MainWP_Child_Plugins_Check {
} }
public function schedule_watchdog() { public function schedule_watchdog() {
//For testing // For testing
//$this->cleanup_deactivation(); // $this->cleanup_deactivation();
//Schedule a global watching cron just in case both other crons get killed // Schedule a global watching cron just in case both other crons get killed
if ( ! wp_next_scheduled( $this->cron_name_watcher ) ) { if ( ! wp_next_scheduled( $this->cron_name_watcher ) ) {
wp_schedule_event( time(), 'hourly', $this->cron_name_watcher ); wp_schedule_event( time(), 'hourly', $this->cron_name_watcher );
} }
@ -146,31 +146,31 @@ class MainWP_Child_Plugins_Check {
// for testing // for testing
public function change_plugin_row_meta( $plugin_meta, $plugin_file, $plugin_data, $status ) { public function change_plugin_row_meta( $plugin_meta, $plugin_file, $plugin_data, $status ) {
//Grab our previously stored array of known last modified dates // Grab our previously stored array of known last modified dates
//Requires WP 2.8.0 // Requires WP 2.8.0
$plugin_info = get_transient( $this->tran_name_plugin_timestamps ); $plugin_info = get_transient( $this->tran_name_plugin_timestamps );
//Sanity check the response // Sanity check the response
if ( false === $plugin_info || ! is_array( $plugin_info ) && 0 === count( $plugin_info ) ) { if ( false === $plugin_info || ! is_array( $plugin_info ) && 0 === count( $plugin_info ) ) {
return $plugin_meta; return $plugin_meta;
} }
//See if this specific plugin is in the known list // See if this specific plugin is in the known list
if ( array_key_exists( $plugin_file, $plugin_info ) ) { if ( array_key_exists( $plugin_file, $plugin_info ) ) {
//Get now // Get now
$now = new \DateTime(); $now = new \DateTime();
$last_updated = $plugin_info[ $plugin_file ]['last_updated']; $last_updated = $plugin_info[ $plugin_file ]['last_updated'];
//Last updated is stored as timestamp, get a real date // Last updated is stored as timestamp, get a real date
$plugin_last_updated_date = new \DateTime( '@' . $last_updated ); $plugin_last_updated_date = new \DateTime( '@' . $last_updated );
//Compute days between now and plugin last updated // Compute days between now and plugin last updated
$diff_in_days = $now->diff( $plugin_last_updated_date )->format( '%a' ); $diff_in_days = $now->diff( $plugin_last_updated_date )->format( '%a' );
//Customizable number of days for tolerance // Customizable number of days for tolerance
$tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 ); $tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 );
//If we're outside the window for tolerance show a message // If we're outside the window for tolerance show a message
if ( $diff_in_days > $tolerance_in_days ) { if ( $diff_in_days > $tolerance_in_days ) {
$plugin_meta[] = sprintf( '<strong style="color: #f00;">This plugin has not been updated by the author in %1$d days!</strong>', $diff_in_days ); $plugin_meta[] = sprintf( '<strong style="color: #f00;">This plugin has not been updated by the author in %1$d days!</strong>', $diff_in_days );
} else { } else {
@ -186,17 +186,17 @@ class MainWP_Child_Plugins_Check {
require_once ABSPATH . '/wp-admin/includes/plugin.php'; require_once ABSPATH . '/wp-admin/includes/plugin.php';
} }
//Get our previous results // Get our previous results
$responses = get_transient( $this->tran_name_plugin_timestamps ); $responses = get_transient( $this->tran_name_plugin_timestamps );
if ( false === $responses || ! is_array( $responses ) ) { if ( false === $responses || ! is_array( $responses ) ) {
$responses = array(); $responses = array();
} }
//Get our previous cache of plugins for batching // Get our previous cache of plugins for batching
$all_plugins = get_transient( $this->tran_name_plugins_to_batch ); $all_plugins = get_transient( $this->tran_name_plugins_to_batch );
//If there wasn't a previous cache // If there wasn't a previous cache
if ( false === $all_plugins || ! is_array( $all_plugins ) ) { if ( false === $all_plugins || ! is_array( $all_plugins ) ) {
$plugins = get_plugins(); $plugins = get_plugins();
if ( is_array( $plugins ) ) { if ( is_array( $plugins ) ) {
@ -215,29 +215,29 @@ class MainWP_Child_Plugins_Check {
} }
$avoid_plugins = array( 'sitepress-multilingual-cms/sitepress.php' ); $avoid_plugins = array( 'sitepress-multilingual-cms/sitepress.php' );
//Grab a small number of plugins to scan // Grab a small number of plugins to scan
$plugins_to_scan = array_splice( $all_plugins, 0, apply_filters( 'mainwp_child_plugin_health_check_max_plugins_to_batch', 10 ) ); $plugins_to_scan = array_splice( $all_plugins, 0, apply_filters( 'mainwp_child_plugin_health_check_max_plugins_to_batch', 10 ) );
$tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 ); $tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 );
//Loop through each known plugin // Loop through each known plugin
foreach ( $plugins_to_scan as $slug => $v ) { foreach ( $plugins_to_scan as $slug => $v ) {
if ( in_array( $slug, $avoid_plugins ) ) { if ( in_array( $slug, $avoid_plugins ) ) {
continue; continue;
} }
//Try to get the raw information for this plugin // Try to get the raw information for this plugin
$body = $this->try_get_response_body( $slug, false ); $body = $this->try_get_response_body( $slug, false );
//We couldn't get any information, skip this plugin // We couldn't get any information, skip this plugin
if ( false === $body ) { if ( false === $body ) {
continue; continue;
} }
//Deserialize the response // Deserialize the response
$obj = maybe_unserialize( $body ); $obj = maybe_unserialize( $body );
$now = new \DateTime(); $now = new \DateTime();
//Sanity check that deserialization worked and that our property exists // Sanity check that deserialization worked and that our property exists
if ( false !== $obj && is_object( $obj ) && property_exists( $obj, 'last_updated' ) ) { if ( false !== $obj && is_object( $obj ) && property_exists( $obj, 'last_updated' ) ) {
if ( version_compare( $v['Version'], $obj->version, '>' ) ) { if ( version_compare( $v['Version'], $obj->version, '>' ) ) {
continue; continue;
@ -259,7 +259,7 @@ class MainWP_Child_Plugins_Check {
define( 'DAY_IN_SECONDS', 24 * 60 * 60 ); define( 'DAY_IN_SECONDS', 24 * 60 * 60 );
} }
//Store the master response for usage in the plugin table // Store the master response for usage in the plugin table
set_transient( $this->tran_name_plugin_timestamps, $responses, DAY_IN_SECONDS ); set_transient( $this->tran_name_plugin_timestamps, $responses, DAY_IN_SECONDS );
if ( 0 === count( $all_plugins ) ) { if ( 0 === count( $all_plugins ) ) {
@ -271,26 +271,26 @@ class MainWP_Child_Plugins_Check {
} }
private function try_get_response_body( $plugin, $second_pass ) { private function try_get_response_body( $plugin, $second_pass ) {
//Some of this code is lifted from class-wp-upgrader // Some of this code is lifted from class-wp-upgrader
//Get the WordPress current version to be polite in the API call // Get the WordPress current version to be polite in the API call
include ABSPATH . WPINC . '/version.php'; include ABSPATH . WPINC . '/version.php';
global $wp_version; global $wp_version;
//General options to be passed to wp_remote_get // General options to be passed to wp_remote_get
$options = array( $options = array(
'timeout' => 60 * 60, //HOUR_IN_SECONDS 'timeout' => 60 * 60, // HOUR_IN_SECONDS
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ), 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
); );
//The URL for the endpoint // The URL for the endpoint
$url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/'; $url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/';
//If we support SSL // If we support SSL
//Requires WP 3.2.0 // Requires WP 3.2.0
if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
//Requires WP 3.4.0 // Requires WP 3.4.0
$url = set_url_scheme( $url, 'https' ); $url = set_url_scheme( $url, 'https' );
} }
@ -299,27 +299,27 @@ class MainWP_Child_Plugins_Check {
$plugin_dir = dirname( $plugin ); $plugin_dir = dirname( $plugin );
} }
//Try to get the response (usually the SSL version) // Try to get the response (usually the SSL version)
//Requires WP 2.7.0 // Requires WP 2.7.0
$raw_response = wp_remote_get( $url . $plugin_dir, $options ); $raw_response = wp_remote_get( $url . $plugin_dir, $options );
//If we don't have an error and we received a valid response code // If we don't have an error and we received a valid response code
//Requires WP 2.7.0 // Requires WP 2.7.0
if ( ! is_wp_error( $raw_response ) && 200 === (int) wp_remote_retrieve_response_code( $raw_response ) ) { if ( ! is_wp_error( $raw_response ) && 200 === (int) wp_remote_retrieve_response_code( $raw_response ) ) {
//Get the actual body // Get the actual body
//Requires WP 2.7.0 // Requires WP 2.7.0
$body = wp_remote_retrieve_body( $raw_response ); $body = wp_remote_retrieve_body( $raw_response );
//Make sure that it isn't empty and also not an empty serialized object // Make sure that it isn't empty and also not an empty serialized object
if ( '' !== $body && 'N;' !== $body ) { if ( '' !== $body && 'N;' !== $body ) {
//If valid, return that // If valid, return that
return $body; return $body;
} }
} }
//The above valid // The above valid
//If we previously tried an SSL version try without SSL // If we previously tried an SSL version try without SSL
//Code below same as above block // Code below same as above block
if ( $ssl ) { if ( $ssl ) {
$raw_response = wp_remote_get( $http_url . $plugin, $options ); $raw_response = wp_remote_get( $http_url . $plugin, $options );
if ( ! is_wp_error( $raw_response ) && 200 === (int) wp_remote_retrieve_response_code( $raw_response ) ) { if ( ! is_wp_error( $raw_response ) && 200 === (int) wp_remote_retrieve_response_code( $raw_response ) ) {
@ -330,22 +330,22 @@ class MainWP_Child_Plugins_Check {
} }
} }
//The above failed // The above failed
//If we're on a second pass already then there's nothing left to do but bail // If we're on a second pass already then there's nothing left to do but bail
if ( true === $second_pass ) { if ( true === $second_pass ) {
return false; return false;
} }
//We're still on the first pass, try to get just the name of the directory of the plugin // We're still on the first pass, try to get just the name of the directory of the plugin
$parts = explode( '/', $plugin ); $parts = explode( '/', $plugin );
//Sanity check that we have two parts, a directory and a file name // Sanity check that we have two parts, a directory and a file name
if ( 2 === count( $parts ) ) { if ( 2 === count( $parts ) ) {
//Try this entire function using just the directory name // Try this entire function using just the directory name
return $this->try_get_response_body( $parts[0], true ); return $this->try_get_response_body( $parts[0], true );
} }
//Everything above failed, bail // Everything above failed, bail
return false; return false;
} }
} }

View file

@ -515,7 +515,7 @@ class MainWP_Child_Server_Information {
if ( ! self::check( '>=', '10000', 'getOutputBufferSize' ) ) { if ( ! self::check( '>=', '10000', 'getOutputBufferSize' ) ) {
$i ++; $i ++;
} }
// if (!self::check('=', true, 'getSSLSupport')) $i++; // if (!self::check('=', true, 'getSSLSupport')) $i++;
if ( ! self::checkDirectoryMainWPDirectory( false ) ) { if ( ! self::checkDirectoryMainWPDirectory( false ) ) {
$i ++; $i ++;
@ -879,7 +879,7 @@ class MainWP_Child_Server_Information {
} }
public static function mainwpRequiredFunctions() { public static function mainwpRequiredFunctions() {
//error_reporting(E_ALL); // error_reporting(E_ALL);
$disabled_functions = ini_get( 'disable_functions' ); $disabled_functions = ini_get( 'disable_functions' );
if ( '' !== $disabled_functions ) { if ( '' !== $disabled_functions ) {
$arr = explode( ',', $disabled_functions ); $arr = explode( ',', $disabled_functions );

View file

@ -23,9 +23,9 @@ class MainWP_Child_Skeleton_Key {
MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) ); MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
} }
// to fix issue double <mainwp></mainwp> header in response // to fix issue double <mainwp></mainwp> header in response
// else { // else {
// MainWP_Helper::write( MainWP_Child_Skeleton_Key::$information ); // MainWP_Helper::write( MainWP_Child_Skeleton_Key::$information );
// } // }
} }
register_shutdown_function( 'mainwp_skeleton_key_handle_fatal_error' ); register_shutdown_function( 'mainwp_skeleton_key_handle_fatal_error' );
@ -42,7 +42,7 @@ class MainWP_Child_Skeleton_Key {
} }
MainWP_Helper::write( $information ); MainWP_Helper::write( $information );
//MainWP_Child_Skeleton_Key::$information = $information; // MainWP_Child_Skeleton_Key::$information = $information;
exit(); exit();
} }
@ -216,7 +216,7 @@ class MainWP_Child_Skeleton_Key {
$whitelist_options['general'][] = 'default_role'; $whitelist_options['general'][] = 'default_role';
} }
//$whitelist_options = apply_filters( 'whitelist_options', $whitelist_options ); // $whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
$whitelist_general = $whitelist_options['general']; $whitelist_general = $whitelist_options['general'];
// Handle translation install. // Handle translation install.

View file

@ -167,12 +167,12 @@ class MainWP_Child_Staging {
'disableAdminLogin', 'disableAdminLogin',
'querySRLimit', 'querySRLimit',
'maxFileSize', 'maxFileSize',
//'wpSubDirectory', // removed // 'wpSubDirectory', // removed
'debugMode', 'debugMode',
'unInstallOnDelete', 'unInstallOnDelete',
'checkDirectorySize', 'checkDirectorySize',
'optimizer', 'optimizer',
//'loginSlug' // removed // 'loginSlug' // removed
); );
$save_fields = array(); $save_fields = array();

View file

@ -95,7 +95,7 @@ class MainWP_Child_Themes_Check {
$last_run = new \DateTime( '@' . $last_run ); $last_run = new \DateTime( '@' . $last_run );
} }
//Get now // Get now
$now = new \DateTime(); $now = new \DateTime();
if ( false === $last_run || (int) $now->diff( $last_run )->format( '%h' ) >= 24 ) { if ( false === $last_run || (int) $now->diff( $last_run )->format( '%h' ) >= 24 ) {
@ -110,10 +110,10 @@ class MainWP_Child_Themes_Check {
} }
public function schedule_watchdog() { public function schedule_watchdog() {
//For testing // For testing
//$this->cleanup_deactivation(); // $this->cleanup_deactivation();
//Schedule a global watching cron just in case both other crons get killed // Schedule a global watching cron just in case both other crons get killed
if ( ! wp_next_scheduled( $this->cron_name_watcher ) ) { if ( ! wp_next_scheduled( $this->cron_name_watcher ) ) {
wp_schedule_event( time(), 'hourly', $this->cron_name_watcher ); wp_schedule_event( time(), 'hourly', $this->cron_name_watcher );
} }
@ -147,7 +147,7 @@ class MainWP_Child_Themes_Check {
require_once ABSPATH . '/wp-admin/includes/theme.php'; require_once ABSPATH . '/wp-admin/includes/theme.php';
} }
//Get our previous results // Get our previous results
$responses = get_transient( $this->tran_name_theme_timestamps ); $responses = get_transient( $this->tran_name_theme_timestamps );
if ( false === $responses || ! is_array( $responses ) ) { if ( false === $responses || ! is_array( $responses ) ) {
@ -155,7 +155,7 @@ class MainWP_Child_Themes_Check {
} }
$all_themes = get_transient( $this->tran_name_themes_to_batch ); $all_themes = get_transient( $this->tran_name_themes_to_batch );
//If there wasn't a previous cache // If there wasn't a previous cache
if ( false === $all_themes || ! is_array( $all_themes ) ) { if ( false === $all_themes || ! is_array( $all_themes ) ) {
$all_themes = array(); $all_themes = array();
$themes = wp_get_themes(); $themes = wp_get_themes();
@ -187,12 +187,12 @@ class MainWP_Child_Themes_Check {
continue; continue;
} }
//Deserialize the response // Deserialize the response
$obj = maybe_unserialize( $body ); $obj = maybe_unserialize( $body );
$now = new \DateTime(); $now = new \DateTime();
//Sanity check that deserialization worked and that our property exists // Sanity check that deserialization worked and that our property exists
if ( false !== $obj && is_object( $obj ) && property_exists( $obj, 'last_updated' ) ) { if ( false !== $obj && is_object( $obj ) && property_exists( $obj, 'last_updated' ) ) {
$last_updated = strtotime( $obj->last_updated ); $last_updated = strtotime( $obj->last_updated );
$theme_last_updated_date = new \DateTime( '@' . $last_updated ); $theme_last_updated_date = new \DateTime( '@' . $last_updated );
@ -213,7 +213,7 @@ class MainWP_Child_Themes_Check {
define( 'DAY_IN_SECONDS', 24 * 60 * 60 ); define( 'DAY_IN_SECONDS', 24 * 60 * 60 );
} }
//Store the master response for usage in the plugin table // Store the master response for usage in the plugin table
set_transient( $this->tran_name_theme_timestamps, $responses, DAY_IN_SECONDS ); set_transient( $this->tran_name_theme_timestamps, $responses, DAY_IN_SECONDS );
if ( 0 === count( $all_themes ) ) { if ( 0 === count( $all_themes ) ) {
@ -227,7 +227,7 @@ class MainWP_Child_Themes_Check {
private function try_get_response_body( $theme ) { private function try_get_response_body( $theme ) {
//Get the WordPress current version to be polite in the API call // Get the WordPress current version to be polite in the API call
include ABSPATH . WPINC . '/version.php'; include ABSPATH . WPINC . '/version.php';
$url = $http_url = 'http://api.wordpress.org/themes/info/1.0/'; $url = $http_url = 'http://api.wordpress.org/themes/info/1.0/';
@ -254,20 +254,20 @@ class MainWP_Child_Themes_Check {
$raw_response = wp_remote_post( $url, $http_args ); $raw_response = wp_remote_post( $url, $http_args );
if ( ! is_wp_error( $raw_response ) && 200 === (int) wp_remote_retrieve_response_code( $raw_response ) ) { if ( ! is_wp_error( $raw_response ) && 200 === (int) wp_remote_retrieve_response_code( $raw_response ) ) {
//Get the actual body // Get the actual body
//Requires WP 2.7.0 // Requires WP 2.7.0
$body = wp_remote_retrieve_body( $raw_response ); $body = wp_remote_retrieve_body( $raw_response );
//Make sure that it isn't empty and also not an empty serialized object // Make sure that it isn't empty and also not an empty serialized object
if ( '' !== $body && 'N;' !== $body ) { if ( '' !== $body && 'N;' !== $body ) {
//If valid, return that // If valid, return that
return $body; return $body;
} }
} }
//The above valid // The above valid
//If we previously tried an SSL version try without SSL // If we previously tried an SSL version try without SSL
//Code below same as above block // Code below same as above block
if ( $ssl ) { if ( $ssl ) {
$raw_response = wp_remote_post( $http_url, $http_args ); $raw_response = wp_remote_post( $http_url, $http_args );
@ -279,7 +279,7 @@ class MainWP_Child_Themes_Check {
} }
} }
//Everything above failed, bail // Everything above failed, bail
return false; return false;
} }
} }

View file

@ -428,7 +428,7 @@ class MainWP_Child_Timecapsule {
} }
function get_sibling_files_callback_wptc() { function get_sibling_files_callback_wptc() {
//note that we are getting the ajax function data via $_POST. // note that we are getting the ajax function data via $_POST.
$file_name = $_POST['data']['file_name']; $file_name = $_POST['data']['file_name'];
$file_name = wp_normalize_path($file_name); $file_name = wp_normalize_path($file_name);
$backup_id = $_POST['data']['backup_id']; $backup_id = $_POST['data']['backup_id'];
@ -487,7 +487,7 @@ class MainWP_Child_Timecapsule {
/* /*
-- Ordering parameters -- */ -- Ordering parameters -- */
//Parameters that are going to be used to order the result // Parameters that are going to be used to order the result
$orderby = ! empty($_POST['orderby']) ? mysql_real_escape_string($_POST['orderby']) : 'id'; $orderby = ! empty($_POST['orderby']) ? mysql_real_escape_string($_POST['orderby']) : 'id';
$order = ! empty($_POST['order']) ? mysql_real_escape_string($_POST['order']) : 'DESC'; $order = ! empty($_POST['order']) ? mysql_real_escape_string($_POST['order']) : 'DESC';
if ( ! empty($orderby) & ! empty($order)) { if ( ! empty($orderby) & ! empty($order)) {
@ -495,17 +495,17 @@ class MainWP_Child_Timecapsule {
/* /*
-- Pagination parameters -- */ -- Pagination parameters -- */
//Number of elements in your table? // Number of elements in your table?
$totalitems = $wpdb->query($query); //return the total number of affected rows $totalitems = $wpdb->query($query); // return the total number of affected rows
//How many to display per page? // How many to display per page?
$perpage = 20; $perpage = 20;
//Which page is this? // Which page is this?
$paged = ! empty($_POST['paged']) ? $_POST['paged'] : ''; $paged = ! empty($_POST['paged']) ? $_POST['paged'] : '';
if (empty($paged) || ! is_numeric($paged) || $paged <= 0) { if (empty($paged) || ! is_numeric($paged) || $paged <= 0) {
$paged = 1;} //Page Number $paged = 1;} //Page Number
//How many pages do we have in total? // How many pages do we have in total?
$totalpages = ceil($totalitems / $perpage); //Total number of pages $totalpages = ceil($totalitems / $perpage); // Total number of pages
//adjust the query to take pagination into account // adjust the query to take pagination into account
if ( ! empty($paged) && ! empty($perpage)) { if ( ! empty($paged) && ! empty($perpage)) {
$offset = ( $paged - 1 ) * $perpage; $offset = ( $paged - 1 ) * $perpage;
$query .= ' LIMIT ' . (int) $offset . ',' . (int) $perpage; $query .= ' LIMIT ' . (int) $offset . ',' . (int) $perpage;
@ -556,20 +556,20 @@ class MainWP_Child_Timecapsule {
return array( 'result' => $detailed ); return array( 'result' => $detailed );
//die($detailed); // die($detailed);
} }
function get_display_rows( $records) { function get_display_rows( $records) {
global $wpdb; global $wpdb;
//Get the records registered in the prepare_items method // Get the records registered in the prepare_items method
if ( ! is_array($records)) { if ( ! is_array($records)) {
return ''; return '';
} }
$i = 0; $i = 0;
$limit = WPTC_Factory::get('config')->get_option('activity_log_lazy_load_limit'); $limit = WPTC_Factory::get('config')->get_option('activity_log_lazy_load_limit');
//Get the columns registered in the get_columns and get_sortable_columns methods // Get the columns registered in the get_columns and get_sortable_columns methods
// $columns = $this->get_columns(); // $columns = $this->get_columns();
$timezone = WPTC_Factory::get('config')->get_option('wptc_timezone'); $timezone = WPTC_Factory::get('config')->get_option('wptc_timezone');
if (count($records) > 0) { if (count($records) > 0) {
@ -598,7 +598,7 @@ class MainWP_Child_Timecapsule {
} }
} }
//Open the line // Open the line
$html .= '<tr class="act-tr">'; $html .= '<tr class="act-tr">';
$Ldata = unserialize($rec->log_data); $Ldata = unserialize($rec->log_data);
$user_time = WPTC_Factory::get('config')->cnvt_UTC_to_usrTime($Ldata['log_time']); $user_time = WPTC_Factory::get('config')->cnvt_UTC_to_usrTime($Ldata['log_time']);
@ -609,13 +609,13 @@ class MainWP_Child_Timecapsule {
$user_tz_now = date('M d, Y @ g:i:s a', $user_time); $user_tz_now = date('M d, Y @ g:i:s a', $user_time);
$msg = ''; $msg = '';
if ( ! ( strpos($rec->type, 'backup') === false )) { if ( ! ( strpos($rec->type, 'backup') === false )) {
//Backup process // Backup process
$msg = 'Backup Process'; $msg = 'Backup Process';
} elseif ( ! ( strpos($rec->type, 'restore') === false )) { } elseif ( ! ( strpos($rec->type, 'restore') === false )) {
//Restore Process // Restore Process
$msg = 'Restore Process'; $msg = 'Restore Process';
} elseif ( ! ( strpos($rec->type, 'staging') === false )) { } elseif ( ! ( strpos($rec->type, 'staging') === false )) {
//Restore Process // Restore Process
$msg = 'Staging Process'; $msg = 'Staging Process';
} else { } else {
if ($row_count < 2) { if ($row_count < 2) {
@ -636,7 +636,7 @@ class MainWP_Child_Timecapsule {
} else { } else {
$html .= '</td>'; $html .= '</td>';
} }
//Close the line // Close the line
$html .= '</tr>'; $html .= '</tr>';
$display_rows[ $key ] = $html; $display_rows[ $key ] = $html;
@ -674,7 +674,7 @@ class MainWP_Child_Timecapsule {
} }
function stop_fresh_backup_tc_callback_wptc() { function stop_fresh_backup_tc_callback_wptc() {
//for backup during update // for backup during update
$deactivated_plugin = null; $deactivated_plugin = null;
$backup = new WPTC_BackupController(); $backup = new WPTC_BackupController();
$backup->stop($deactivated_plugin); $backup->stop($deactivated_plugin);
@ -1208,7 +1208,7 @@ class MainWP_Child_Timecapsule {
echo '<tr title="WP_MAX_MEMORY_LIMIT"><td>' . __( 'WP maximum memory limit', 'wp-time-capsule' ) . '</td><td>' . esc_html( WP_MAX_MEMORY_LIMIT ) . '</td></tr>'; echo '<tr title="WP_MAX_MEMORY_LIMIT"><td>' . __( 'WP maximum memory limit', 'wp-time-capsule' ) . '</td><td>' . esc_html( WP_MAX_MEMORY_LIMIT ) . '</td></tr>';
echo '<tr title=""><td>' . __( 'Memory in use', 'wp-time-capsule' ) . '</td><td>' . size_format( @memory_get_usage( true ), 2 ) . '</td></tr>'; echo '<tr title=""><td>' . __( 'Memory in use', 'wp-time-capsule' ) . '</td><td>' . size_format( @memory_get_usage( true ), 2 ) . '</td></tr>';
//disabled PHP functions // disabled PHP functions
$disabled = esc_html( ini_get( 'disable_functions' ) ); $disabled = esc_html( ini_get( 'disable_functions' ) );
if ( ! empty( $disabled ) ) { if ( ! empty( $disabled ) ) {
$disabledarry = explode( ',', $disabled ); $disabledarry = explode( ',', $disabled );
@ -1217,7 +1217,7 @@ class MainWP_Child_Timecapsule {
echo '</td></tr>'; echo '</td></tr>';
} }
//Loaded PHP Extensions // Loaded PHP Extensions
echo '<tr title=""><td>' . __( 'Loaded PHP Extensions:', 'wp-time-capsule' ) . '</td><td>'; echo '<tr title=""><td>' . __( 'Loaded PHP Extensions:', 'wp-time-capsule' ) . '</td><td>';
$extensions = get_loaded_extensions(); $extensions = get_loaded_extensions();
sort( $extensions ); sort( $extensions );

View file

@ -188,7 +188,7 @@ class MainWP_Child_Updraft_Plus_Backups {
'updraft_retain', 'updraft_retain',
'updraft_retain_db', 'updraft_retain_db',
'updraft_encryptionphrase', 'updraft_encryptionphrase',
//'updraft_service', // will check override to save // 'updraft_service', // will check override to save
'updraft_dir', 'updraft_dir',
'updraft_email', 'updraft_email',
'updraft_delete_local', 'updraft_delete_local',
@ -215,7 +215,7 @@ class MainWP_Child_Updraft_Plus_Backups {
'updraft_disable_ping', 'updraft_disable_ping',
'updraft_openstack', 'updraft_openstack',
'updraft_bitcasa', 'updraft_bitcasa',
//'updraft_cloudfiles', // 'updraft_cloudfiles',
'updraft_ssl_useservercerts', 'updraft_ssl_useservercerts',
'updraft_ssl_disableverify', 'updraft_ssl_disableverify',
'updraft_report_warningsonly', 'updraft_report_warningsonly',
@ -233,10 +233,10 @@ class MainWP_Child_Updraft_Plus_Backups {
'updraft_sftp_settings', 'updraft_sftp_settings',
'updraft_webdav_settings', 'updraft_webdav_settings',
'updraft_dreamobjects', 'updraft_dreamobjects',
//'updraft_onedrive', // disalbed // 'updraft_onedrive', // disalbed
//'updraft_azure', // disabled // 'updraft_azure', // disabled
'updraft_googlecloud', 'updraft_googlecloud',
//'updraft_updraftvault', // 'updraft_updraftvault',
'updraft_retain_extrarules', 'updraft_retain_extrarules',
'updraft_backblaze', 'updraft_backblaze',
); );
@ -444,75 +444,75 @@ class MainWP_Child_Updraft_Plus_Backups {
if (isset($settings['is_general']) && ! empty($settings['is_general'])) { if (isset($settings['is_general']) && ! empty($settings['is_general'])) {
$opts['settings'][ $settings_key ]['folder'] = $this->replace_tokens($settings[ $key ]['folder']); $opts['settings'][ $settings_key ]['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
} else { } else {
// $opts['settings'][$settings_key]['appkey'] = $settings[ $key ]['appkey']; // $opts['settings'][$settings_key]['appkey'] = $settings[ $key ]['appkey'];
// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret']; // $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 { } else {
if (isset($settings['is_general']) && ! empty($settings['is_general'])) { if (isset($settings['is_general']) && ! empty($settings['is_general'])) {
$opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']); $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
} else { } else {
// $opts['appkey'] = $settings[ $key ]['appkey']; // $opts['appkey'] = $settings[ $key ]['appkey'];
// $opts['secret'] = $settings[ $key ]['secret']; // $opts['secret'] = $settings[ $key ]['secret'];
$opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']); $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
} }
} }
UpdraftPlus_Options::update_updraft_option( $key, $opts ); UpdraftPlus_Options::update_updraft_option( $key, $opts );
} elseif ( 'updraft_googledrive' === $key ) { } elseif ( 'updraft_googledrive' === $key ) {
// do not saving from dashboard // do not saving from dashboard
// $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_googledrive' ); // $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_googledrive' );
// if (!is_array($opts)) // if (!is_array($opts))
// $opts = array(); // $opts = array();
// if(is_array($opts) && isset($opts['settings'])) { // if(is_array($opts) && isset($opts['settings'])) {
// $settings_key = key($opts['settings']); // $settings_key = key($opts['settings']);
//// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid']; // $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
//// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret']; // $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 { // } else {
//// $opts['clientid'] = $settings[ $key ]['clientid']; // $opts['clientid'] = $settings[ $key ]['clientid'];
//// $opts['secret'] = $settings[ $key ]['secret']; // $opts['secret'] = $settings[ $key ]['secret'];
// $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']); // $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
// } // }
// UpdraftPlus_Options::update_updraft_option( $key, $opts ); // UpdraftPlus_Options::update_updraft_option( $key, $opts );
} elseif ( 'updraft_googlecloud' === $key ) { } elseif ( 'updraft_googlecloud' === $key ) {
// do not saving from dashboard // do not saving from dashboard
// $opts = UpdraftPlus_Options::get_updraft_option( $key ); // $opts = UpdraftPlus_Options::get_updraft_option( $key );
// if (!is_array($opts)) // if (!is_array($opts))
// $opts = array(); // $opts = array();
// if(is_array($opts) && isset($opts['settings'])) { // if(is_array($opts) && isset($opts['settings'])) {
// $settings_key = key($opts['settings']); // $settings_key = key($opts['settings']);
//// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid']; // $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
//// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret']; // $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret'];
//// $opts['settings'][$settings_key]['project_id'] = $settings[ $key ]['project_id']; // $opts['settings'][$settings_key]['project_id'] = $settings[ $key ]['project_id'];
//// $opts['settings'][$settings_key]['bucket_path'] = $settings[ $key ]['bucket_path']; // $opts['settings'][$settings_key]['bucket_path'] = $settings[ $key ]['bucket_path'];
// $opts['settings'][$settings_key]['storage_class'] = $settings[ $key ]['storage_class']; // $opts['settings'][$settings_key]['storage_class'] = $settings[ $key ]['storage_class'];
// $opts['settings'][$settings_key]['bucket_location'] = $settings[ $key ]['bucket_location']; // $opts['settings'][$settings_key]['bucket_location'] = $settings[ $key ]['bucket_location'];
// } else { // } else {
//// $opts['clientid'] = $settings[ $key ]['clientid']; // $opts['clientid'] = $settings[ $key ]['clientid'];
//// $opts['secret'] = $settings[ $key ]['secret']; // $opts['secret'] = $settings[ $key ]['secret'];
//// $opts['project_id'] = $settings[ $key ]['project_id']; // $opts['project_id'] = $settings[ $key ]['project_id'];
//// $opts['bucket_path'] = $settings[ $key ]['bucket_path']; // $opts['bucket_path'] = $settings[ $key ]['bucket_path'];
// $opts['storage_class'] = $settings[ $key ]['storage_class']; // $opts['storage_class'] = $settings[ $key ]['storage_class'];
// $opts['bucket_location'] = $settings[ $key ]['bucket_location']; // $opts['bucket_location'] = $settings[ $key ]['bucket_location'];
// } // }
// UpdraftPlus_Options::update_updraft_option( $key, $opts ); // UpdraftPlus_Options::update_updraft_option( $key, $opts );
} elseif ( 'updraft_onedrive' === $key ) { } elseif ( 'updraft_onedrive' === $key ) {
// do not saving from dashboard // do not saving from dashboard
// $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_onedrive' ); // $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_onedrive' );
// if (!is_array($opts)) // if (!is_array($opts))
// $opts = array(); // $opts = array();
// if(is_array($opts) && isset($opts['settings'])) { // if(is_array($opts) && isset($opts['settings'])) {
// $settings_key = key($opts['settings']); // $settings_key = key($opts['settings']);
//// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid']; // $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
//// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret']; // $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 { // } else {
//// $opts['clientid'] = $settings[ $key ]['clientid']; // $opts['clientid'] = $settings[ $key ]['clientid'];
//// $opts['secret'] = $settings[ $key ]['secret']; // $opts['secret'] = $settings[ $key ]['secret'];
// $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']); // $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
// } // }
// //
// UpdraftPlus_Options::update_updraft_option( $key, $opts ); // UpdraftPlus_Options::update_updraft_option( $key, $opts );
} elseif ( 'updraft_email' === $key ) { } elseif ( 'updraft_email' === $key ) {
$value = $settings[ $key ]; $value = $settings[ $key ];
// free version // free version
@ -773,7 +773,7 @@ class MainWP_Child_Updraft_Plus_Backups {
// Funnelling through here a) allows for future flexibility and b) allows us to migrate elegantly from the previous non-MU-friendly setup // Funnelling through here a) allows for future flexibility and b) allows us to migrate elegantly from the previous non-MU-friendly setup
public function addons2_get_option( $option ) { public function addons2_get_option( $option ) {
$val = get_site_option( $option ); $val = get_site_option( $option );
# On multisite, migrate options into the site options // On multisite, migrate options into the site options
if ( false === $val && is_multisite() ) { if ( false === $val && is_multisite() ) {
$blog_id = get_current_blog_id(); $blog_id = get_current_blog_id();
if ( $blog_id > 1 ) { if ( $blog_id > 1 ) {
@ -785,7 +785,7 @@ class MainWP_Child_Updraft_Plus_Backups {
return $val; return $val;
} }
} }
# $val is still false // $val is still false
switch_to_blog( 1 ); switch_to_blog( 1 );
$val = get_option( $option ); $val = get_option( $option );
if ( false !== $val ) { if ( false !== $val ) {
@ -803,7 +803,7 @@ class MainWP_Child_Updraft_Plus_Backups {
} }
public function options_validate( $input ) { public function options_validate( $input ) {
# See: http://codex.wordpress.org/Function_Reference/add_settings_error // See: http://codex.wordpress.org/Function_Reference/add_settings_error
// When the options are re-saved, clear any previous cache of the connection status // When the options are re-saved, clear any previous cache of the connection status
$ehash = substr( md5( $input['email'] ), 0, 23 ); $ehash = substr( md5( $input['email'] ), 0, 23 );
@ -897,7 +897,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$ret_info = ''; $ret_info = '';
if ( ! $failed ) { if ( ! $failed ) {
$all_tables = $wpdb_obj->get_results( 'SHOW TABLES', ARRAY_N ); $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( 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'] ) ) { if ( empty( $_POST['prefix'] ) ) {
@ -975,24 +975,24 @@ class MainWP_Child_Updraft_Plus_Backups {
do_action( $event, apply_filters( 'updraft_backupnow_options', $options, array() ) ); do_action( $event, apply_filters( 'updraft_backupnow_options', $options, array() ) );
//return $msg; // return $msg;
// Control returns when the backup finished; but, the browser connection should have been closed before // Control returns when the backup finished; but, the browser connection should have been closed before
die; die;
// not used anymore // not used anymore
// if (wp_schedule_single_event(time()+5, $event, array($backupnow_nocloud)) === false) { // if (wp_schedule_single_event(time()+5, $event, array($backupnow_nocloud)) === false) {
// $updraftplus->log("A backup run failed to schedule"); // $updraftplus->log("A backup run failed to schedule");
// //echo __("Failed.", 'updraftplus')."</div>"; // echo __("Failed.", 'updraftplus')."</div>";
// $result = 'FAILED'; // $result = 'FAILED';
// } else { // } else {
// $result = 'OK'; // $result = 'OK';
// //echo htmlspecialchars(__('OK. You should soon see activity in the "Last log message" field below.','updraftplus'))." <a href=\"http://updraftplus.com/faqs/my-scheduled-backups-and-pressing-backup-now-does-nothing-however-pressing-debug-backup-does-produce-a-backup/\"><br>".__('Nothing happening? Follow this link for help.','updraftplus')."</a></div>"; // echo htmlspecialchars(__('OK. You should soon see activity in the "Last log message" field below.','updraftplus'))." <a href=\"http://updraftplus.com/faqs/my-scheduled-backups-and-pressing-backup-now-does-nothing-however-pressing-debug-backup-does-produce-a-backup/\"><br>".__('Nothing happening? Follow this link for help.','updraftplus')."</a></div>";
// $updraftplus->log("A backup run has been scheduled"); // $updraftplus->log("A backup run has been scheduled");
// } // }
// $out = array( 'result' => 'OK' ); // $out = array( 'result' => 'OK' );
// //
// return $out; // return $out;
} }
function activejobs_list() { function activejobs_list() {
@ -1000,7 +1000,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$download_status = array(); $download_status = array();
if ( ! empty( $_REQUEST['downloaders'] ) ) { if ( ! empty( $_REQUEST['downloaders'] ) ) {
foreach ( explode( ':', $_REQUEST['downloaders'] ) as $downloader ) { foreach ( explode( ':', $_REQUEST['downloaders'] ) as $downloader ) {
# prefix, timestamp, entity, index // prefix, timestamp, entity, index
if ( preg_match( '/^([^,]+),(\d+),([-a-z]+|db[0-9]+),(\d+)$/', $downloader, $matches ) ) { if ( preg_match( '/^([^,]+),(\d+),([-a-z]+|db[0-9]+),(\d+)$/', $downloader, $matches ) ) {
$updraftplus->nonce = $matches[2]; $updraftplus->nonce = $matches[2];
$status = $this->download_status( $matches[2], $matches[3], $matches[4] ); $status = $this->download_status( $matches[2], $matches[3], $matches[4] );
@ -1194,7 +1194,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$next_scheduled_backup_gmt = gmdate('Y-m-d H:i:s', $next_scheduled_backup); $next_scheduled_backup_gmt = gmdate('Y-m-d H:i:s', $next_scheduled_backup);
// Convert to blog time zone // Convert to blog time zone
$next_scheduled_backup = get_date_from_gmt($next_scheduled_backup_gmt, 'D, F j, Y H:i'); $next_scheduled_backup = get_date_from_gmt($next_scheduled_backup_gmt, 'D, F j, Y H:i');
// $next_scheduled_backup = date_i18n('D, F j, Y H:i', $next_scheduled_backup); // $next_scheduled_backup = date_i18n('D, F j, Y H:i', $next_scheduled_backup);
} else { } else {
$next_scheduled_backup = __('Nothing currently scheduled', 'updraftplus'); $next_scheduled_backup = __('Nothing currently scheduled', 'updraftplus');
$files_not_scheduled = true; $files_not_scheduled = true;
@ -1215,7 +1215,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$next_scheduled_backup_database_gmt = gmdate('Y-m-d H:i:s', $next_scheduled_backup_database); $next_scheduled_backup_database_gmt = gmdate('Y-m-d H:i:s', $next_scheduled_backup_database);
// Convert to blog time zone // Convert to blog time zone
$next_scheduled_backup_database = get_date_from_gmt($next_scheduled_backup_database_gmt, 'D, F j, Y H:i'); $next_scheduled_backup_database = get_date_from_gmt($next_scheduled_backup_database_gmt, 'D, F j, Y H:i');
// $next_scheduled_backup_database = date_i18n('D, F j, Y H:i', $next_scheduled_backup_database); // $next_scheduled_backup_database = date_i18n('D, F j, Y H:i', $next_scheduled_backup_database);
} else { } else {
$next_scheduled_backup_database = __('Nothing currently scheduled', 'updraftplus'); $next_scheduled_backup_database = __('Nothing currently scheduled', 'updraftplus');
$database_not_scheduled = true; $database_not_scheduled = true;
@ -1345,7 +1345,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$remote_deleted = 0; $remote_deleted = 0;
add_action( 'http_request_args', array( $updraftplus, 'modify_http_options' ) ); add_action( 'http_request_args', array( $updraftplus, 'modify_http_options' ) );
foreach ( $files_to_delete as $key => $files ) { foreach ( $files_to_delete as $key => $files ) {
# Local deletion // Local deletion
if ( is_string( $files ) ) { if ( is_string( $files ) ) {
$files = array( $files ); $files = array( $files );
} }
@ -1367,12 +1367,12 @@ class MainWP_Child_Updraft_Plus_Backups {
$objname = 'UpdraftPlus_BackupModule_' . $service; $objname = 'UpdraftPlus_BackupModule_' . $service;
$deleted = - 1; $deleted = - 1;
if ( class_exists( $objname ) ) { if ( class_exists( $objname ) ) {
# TODO: Re-use the object (i.e. prevent repeated connection setup/teardown) // TODO: Re-use the object (i.e. prevent repeated connection setup/teardown)
$remote_obj = new $objname(); $remote_obj = new $objname();
$deleted = $remote_obj->delete( $files ); $deleted = $remote_obj->delete( $files );
} }
if ( $deleted === - 1 ) { if ( $deleted === - 1 ) {
//echo __('Did not know how to delete from this cloud service.', 'updraftplus'); // echo __('Did not know how to delete from this cloud service.', 'updraftplus');
} elseif ( $deleted !== false ) { } elseif ( $deleted !== false ) {
$remote_deleted = $remote_deleted + count( $files ); $remote_deleted = $remote_deleted + count( $files );
} else { } else {
@ -1554,7 +1554,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$needs_downloading = false; $needs_downloading = false;
if ( ! file_exists( $fullpath ) ) { if ( ! file_exists( $fullpath ) ) {
//if the file doesn't exist and they're using one of the cloud options, fetch it down from the cloud. // if the file doesn't exist and they're using one of the cloud options, fetch it down from the cloud.
$needs_downloading = true; $needs_downloading = true;
$updraftplus->log( 'File does not yet exist locally - needs downloading' ); $updraftplus->log( 'File does not yet exist locally - needs downloading' );
} elseif ( $known_size > 0 && filesize( $fullpath ) < $known_size ) { } elseif ( $known_size > 0 && filesize( $fullpath ) < $known_size ) {
@ -1616,7 +1616,7 @@ class MainWP_Child_Updraft_Plus_Backups {
return array( 'result' => 'OK' ); return array( 'result' => 'OK' );
} }
# Pass only a single service, as a string, into this function // Pass only a single service, as a string, into this function
private function download_file( $file, $service ) { private function download_file( $file, $service ) {
global $updraftplus; global $updraftplus;
@ -1728,7 +1728,7 @@ class MainWP_Child_Updraft_Plus_Backups {
if ( ! is_array( $foreign_known ) || empty( $foreign_known[ $backups[ $timestamp ]['meta_foreign'] ] ) ) { if ( ! is_array( $foreign_known ) || empty( $foreign_known[ $backups[ $timestamp ]['meta_foreign'] ] ) ) {
$err[] = sprintf( __( 'Backup created by unknown source (%s) - cannot be restored.', 'updraftplus' ), $backups[ $timestamp ]['meta_foreign'] ); $err[] = sprintf( __( 'Backup created by unknown source (%s) - cannot be restored.', 'updraftplus' ), $backups[ $timestamp ]['meta_foreign'] );
} else { } else {
# For some reason, on PHP 5.5 passing by reference in a single array stopped working with apply_filters_ref_array (though not with do_action_ref_array). // For some reason, on PHP 5.5 passing by reference in a single array stopped working with apply_filters_ref_array (though not with do_action_ref_array).
$backupable_plus_db = apply_filters_ref_array( 'updraftplus_importforeign_backupable_plus_db', array( $backupable_plus_db = apply_filters_ref_array( 'updraftplus_importforeign_backupable_plus_db', array(
$backupable_plus_db, $backupable_plus_db,
array( $foreign_known[ $backups[ $timestamp ]['meta_foreign'] ], &$mess, &$warn, &$err ), array( $foreign_known[ $backups[ $timestamp ]['meta_foreign'] ], &$mess, &$warn, &$err ),
@ -1776,7 +1776,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$expected_index ++; $expected_index ++;
} }
do_action_ref_array( "updraftplus_checkzip_end_$type", array( &$mess, &$warn, &$err ) ); do_action_ref_array( "updraftplus_checkzip_end_$type", array( &$mess, &$warn, &$err ) );
# Detect missing archives where they are missing from the end of the set // Detect missing archives where they are missing from the end of the set
if ( $outof > 0 && $expected_index < $outof ) { if ( $outof > 0 && $expected_index < $outof ) {
for ( $j = $expected_index; $j < $outof; $j ++ ) { for ( $j = $expected_index; $j < $outof; $j ++ ) {
$missing .= ( '' === $missing ) ? ( 1 + $j ) : ',' . ( 1 + $j ); $missing .= ( '' === $missing ) ? ( 1 + $j ) : ',' . ( 1 + $j );
@ -1835,7 +1835,7 @@ class MainWP_Child_Updraft_Plus_Backups {
} }
} }
$pval = ( $updraftplus->have_addons ) ? 1 : 0; $pval = ( $updraftplus->have_addons ) ? 1 : 0;
//echo '<strong>'.__('Actions','updraftplus').':</strong> <a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus&updraft_restore_success='.$s_val.'&pval='.$pval.'">'.__('Return to UpdraftPlus Configuration','updraftplus').'</a>'; // echo '<strong>'.__('Actions','updraftplus').':</strong> <a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus&updraft_restore_success='.$s_val.'&pval='.$pval.'">'.__('Return to UpdraftPlus Configuration','updraftplus').'</a>';
} elseif ( is_wp_error( $backup_success ) ) { } elseif ( is_wp_error( $backup_success ) ) {
echo '<p>'; echo '<p>';
@ -1844,10 +1844,10 @@ class MainWP_Child_Updraft_Plus_Backups {
$updraftplus->log_wp_error( $backup_success ); $updraftplus->log_wp_error( $backup_success );
$updraftplus->log( 'Restore failed' ); $updraftplus->log( 'Restore failed' );
$updraftplus->list_errors(); $updraftplus->list_errors();
//echo '<strong>'.__('Actions','updraftplus').':</strong> <a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus">'.__('Return to UpdraftPlus Configuration','updraftplus').'</a>'; // echo '<strong>'.__('Actions','updraftplus').':</strong> <a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus">'.__('Return to UpdraftPlus Configuration','updraftplus').'</a>';
} elseif ( false === $backup_success ) { } elseif ( false === $backup_success ) {
# This means, "not yet - but stay on the page because we may be able to do it later, e.g. if the user types in the requested information" // This means, "not yet - but stay on the page because we may be able to do it later, e.g. if the user types in the requested information"
} }
@ -1863,7 +1863,7 @@ class MainWP_Child_Updraft_Plus_Backups {
@set_time_limit( 900 ); @set_time_limit( 900 );
global $wp_filesystem, $updraftplus; global $wp_filesystem, $updraftplus;
// $backup_history = UpdraftPlus_Options::get_updraft_option( 'updraft_backup_history' ); // $backup_history = UpdraftPlus_Options::get_updraft_option( 'updraft_backup_history' );
$backup_history = UpdraftPlus_Backup_History::get_history(); $backup_history = UpdraftPlus_Backup_History::get_history();
if ( ! is_array( $backup_history[ $timestamp ] ) ) { if ( ! is_array( $backup_history[ $timestamp ] ) ) {
echo wp_kses_post( '<p>' . esc_html__( 'This backup does not exist in the backup history - restoration aborted. Timestamp:', 'updraftplus' ) . " $timestamp</p><br/>" ); echo wp_kses_post( '<p>' . esc_html__( 'This backup does not exist in the backup history - restoration aborted. Timestamp:', 'updraftplus' ) . " $timestamp</p><br/>" );
@ -1897,20 +1897,20 @@ class MainWP_Child_Updraft_Plus_Backups {
exit; exit;
} }
# Set up logging // Set up logging
$updraftplus->backup_time_nonce(); $updraftplus->backup_time_nonce();
$updraftplus->jobdata_set( 'job_type', 'restore' ); $updraftplus->jobdata_set( 'job_type', 'restore' );
$updraftplus->jobdata_set( 'job_time_ms', $updraftplus->job_time_ms ); $updraftplus->jobdata_set( 'job_time_ms', $updraftplus->job_time_ms );
$updraftplus->logfile_open( $updraftplus->nonce ); $updraftplus->logfile_open( $updraftplus->nonce );
# Provide download link for the log file // Provide download link for the log file
#echo '<p><a target="_new" href="?action=downloadlog&page=updraftplus&updraftplus_backup_nonce='.htmlspecialchars($updraftplus->nonce).'">'.__('Follow this link to download the log file for this restoration.', 'updraftplus').'</a></p>'; // echo '<p><a target="_new" href="?action=downloadlog&page=updraftplus&updraftplus_backup_nonce='.htmlspecialchars($updraftplus->nonce).'">'.__('Follow this link to download the log file for this restoration.', 'updraftplus').'</a></p>';
# TODO: Automatic purging of old log files // TODO: Automatic purging of old log files
# TODO: Provide option to auto-email the log file // TODO: Provide option to auto-email the log file
//if we make it this far then WP_Filesystem has been instantiated and is functional (tested with ftpext, what about suPHP and other situations where direct may work?) // if we make it this far then WP_Filesystem has been instantiated and is functional (tested with ftpext, what about suPHP and other situations where direct may work?)
echo '<h1>' . esc_html__( 'UpdraftPlus Restoration: Progress', 'updraftplus' ) . '</h1><div id="updraft-restore-progress">'; echo '<h1>' . esc_html__( 'UpdraftPlus Restoration: Progress', 'updraftplus' ) . '</h1><div id="updraft-restore-progress">';
$this->show_admin_warning( '<a href="#" onclick="event.preventDefault(); mainwp_updraft_popuplog(\'' . htmlspecialchars( $updraftplus->nonce ) . '\', this);" >' . __( 'Follow this link to download the log file for this restoration (needed for any support requests).', 'updraftplus' ) . '</a>' ); $this->show_admin_warning( '<a href="#" onclick="event.preventDefault(); mainwp_updraft_popuplog(\'' . htmlspecialchars( $updraftplus->nonce ) . '\', this);" >' . __( 'Follow this link to download the log file for this restoration (needed for any support requests).', 'updraftplus' ) . '</a>' );
@ -2023,8 +2023,8 @@ class MainWP_Child_Updraft_Plus_Backups {
if ( 'wpcore' === $type && is_multisite() && 0 === $updraftplus_restorer->ud_backup_is_multisite ) { if ( 'wpcore' === $type && is_multisite() && 0 === $updraftplus_restorer->ud_backup_is_multisite ) {
echo wp_kses_post( "<p>$type: <strong>" ); echo wp_kses_post( "<p>$type: <strong>" );
esc_html_e( 'Skipping restoration of WordPress core when importing a single site into a multisite installation. If you had anything necessary in your WordPress directory then you will need to re-add it manually from the zip file.', 'updraftplus' ); esc_html_e( 'Skipping restoration of WordPress core when importing a single site into a multisite installation. If you had anything necessary in your WordPress directory then you will need to re-add it manually from the zip file.', 'updraftplus' );
#TODO // TODO
#$updraftplus->log_e('Skipping restoration of WordPress core when importing a single site into a multisite installation. If you had anything necessary in your WordPress directory then you will need to re-add it manually from the zip file.'); // $updraftplus->log_e('Skipping restoration of WordPress core when importing a single site into a multisite installation. If you had anything necessary in your WordPress directory then you will need to re-add it manually from the zip file.');
echo '</strong></p>'; echo '</strong></p>';
continue; continue;
} }
@ -2101,12 +2101,12 @@ class MainWP_Child_Updraft_Plus_Backups {
$this->print_delete_old_dirs_form(); $this->print_delete_old_dirs_form();
} }
} }
echo '</div>'; //close the updraft_restore_progress div even if we error echo '</div>'; // close the updraft_restore_progress div even if we error
restore_error_handler(); restore_error_handler();
return $val; return $val;
} elseif ( false === $val ) { } elseif ( false === $val ) {
echo '</div>'; //close the updraft_restore_progress div even if we error echo '</div>'; // close the updraft_restore_progress div even if we error
restore_error_handler(); restore_error_handler();
return false; return false;
@ -2135,7 +2135,7 @@ class MainWP_Child_Updraft_Plus_Backups {
// Second loop: now actually do the restoration // Second loop: now actually do the restoration
uksort( $second_loop, array( $this, 'sort_restoration_entities' ) ); uksort( $second_loop, array( $this, 'sort_restoration_entities' ) );
foreach ( $second_loop as $type => $files ) { foreach ( $second_loop as $type => $files ) {
# Types: uploads, themes, plugins, others, db // Types: uploads, themes, plugins, others, db
$info = ( isset( $backupable_entities[ $type ] ) ) ? $backupable_entities[ $type ] : array(); $info = ( isset( $backupable_entities[ $type ] ) ) ? $backupable_entities[ $type ] : array();
echo ( 'db' === $type ) ? '<h2>' . esc_html__( 'Database', 'updraftplus' ) . '</h2>' : '<h2>' . esc_html( $info['description'] ) . '</h2>'; echo ( 'db' === $type ) ? '<h2>' . esc_html__( 'Database', 'updraftplus' ) . '</h2>' : '<h2>' . esc_html( $info['description'] ) . '</h2>';
@ -2167,12 +2167,12 @@ class MainWP_Child_Updraft_Plus_Backups {
} }
} }
} }
echo '</div>'; //close the updraft_restore_progress div even if we error echo '</div>'; // close the updraft_restore_progress div even if we error
restore_error_handler(); restore_error_handler();
return $val; return $val;
} elseif ( false === $val ) { } elseif ( false === $val ) {
echo '</div>'; //close the updraft_restore_progress div even if we error echo '</div>'; // close the updraft_restore_progress div even if we error
restore_error_handler(); restore_error_handler();
return false; return false;
@ -2186,14 +2186,14 @@ class MainWP_Child_Updraft_Plus_Backups {
add_filter( 'pre_option_' . $opt, array( $this, 'option_filter_' . $opt ) ); add_filter( 'pre_option_' . $opt, array( $this, 'option_filter_' . $opt ) );
} }
# Clear any cached pages after the restore // Clear any cached pages after the restore
$updraftplus_restorer->clear_cache(); $updraftplus_restorer->clear_cache();
if ( ! function_exists( 'validate_current_theme' ) ) { if ( ! function_exists( 'validate_current_theme' ) ) {
require_once ABSPATH . WPINC . '/themes'; require_once ABSPATH . WPINC . '/themes';
} }
# Have seen a case where the current theme in the DB began with a capital, but not on disk - and this breaks migrating from Windows to a case-sensitive system // Have seen a case where the current theme in the DB began with a capital, but not on disk - and this breaks migrating from Windows to a case-sensitive system
$template = get_option( 'template' ); $template = get_option( 'template' );
echo esc_html( $template ); echo esc_html( $template );
if ( ! empty( $template ) && WP_DEFAULT_THEME !== $template && strtolower( $template ) !== $template ) { if ( ! empty( $template ) && WP_DEFAULT_THEME !== $template && strtolower( $template ) !== $template ) {
@ -2213,11 +2213,11 @@ class MainWP_Child_Updraft_Plus_Backups {
$updraftplus->log_e( 'The current theme was not found; to prevent this stopping the site from loading, your theme has been reverted to the default theme' ); $updraftplus->log_e( 'The current theme was not found; to prevent this stopping the site from loading, your theme has been reverted to the default theme' );
echo '</strong>'; echo '</strong>';
} }
#foreach (array('template', 'stylesheet', 'template_root', 'stylesheet_root') as $opt) { // foreach (array('template', 'stylesheet', 'template_root', 'stylesheet_root') as $opt) {
# remove_filter('pre_option_'.$opt, array($this, 'option_filter_'.$opt)); // remove_filter('pre_option_'.$opt, array($this, 'option_filter_'.$opt));
#} // }
echo '</div>'; //close the updraft_restore_progress div echo '</div>'; // close the updraft_restore_progress div
restore_error_handler(); restore_error_handler();
@ -2265,7 +2265,7 @@ class MainWP_Child_Updraft_Plus_Backups {
} else { } else {
echo '<p>', esc_html__( 'Old directory removal failed for some reason. You may want to do this manually.', 'updraftplus' ) . '</p><br/>'; echo '<p>', esc_html__( 'Old directory removal failed for some reason. You may want to do this manually.', 'updraftplus' ) . '</p><br/>';
} }
//if ($show_return) echo '<b>'.__('Actions','updraftplus').':</b> <a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus">'.__('Return to UpdraftPlus Configuration','updraftplus').'</a>'; // if ($show_return) echo '<b>'.__('Actions','updraftplus').':</b> <a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus">'.__('Return to UpdraftPlus Configuration','updraftplus').'</a>';
$output = ob_get_clean(); $output = ob_get_clean();
@ -2275,7 +2275,7 @@ class MainWP_Child_Updraft_Plus_Backups {
); );
} }
//deletes the -old directories that are created when a backup is restored. // deletes the -old directories that are created when a backup is restored.
private function delete_old_dirs() { private function delete_old_dirs() {
global $wp_filesystem, $updraftplus; global $wp_filesystem, $updraftplus;
$credentials = request_filesystem_credentials( wp_nonce_url( UpdraftPlus_Options::admin_page_url() . '?page=updraftplus&action=updraft_delete_old_dirs', 'updraftplus-credentialtest-nonce' ) ); $credentials = request_filesystem_credentials( wp_nonce_url( UpdraftPlus_Options::admin_page_url() . '?page=updraftplus&action=updraft_delete_old_dirs', 'updraftplus-credentialtest-nonce' ) );
@ -2296,7 +2296,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$ret4 = true; $ret4 = true;
} }
// $ret2 = $this->delete_old_dirs_dir($wp_filesystem->abspath()); // $ret2 = $this->delete_old_dirs_dir($wp_filesystem->abspath());
$plugs = untrailingslashit( $wp_filesystem->wp_plugins_dir() ); $plugs = untrailingslashit( $wp_filesystem->wp_plugins_dir() );
if ( $wp_filesystem->is_dir( $plugs . '-old' ) ) { if ( $wp_filesystem->is_dir( $plugs . '-old' ) ) {
print '<strong>' . esc_html__( 'Delete', 'updraftplus' ) . ': </strong>plugins-old: '; print '<strong>' . esc_html__( 'Delete', 'updraftplus' ) . ': </strong>plugins-old: ';
@ -2333,7 +2333,7 @@ class MainWP_Child_Updraft_Plus_Backups {
foreach ( $list as $item ) { foreach ( $list as $item ) {
$name = ( is_array( $item ) ) ? $item['name'] : $item; $name = ( is_array( $item ) ) ? $item['name'] : $item;
if ( '-old' == substr( $name, - 4, 4 ) ) { if ( '-old' == substr( $name, - 4, 4 ) ) {
//recursively delete // recursively delete
print '<strong>' . esc_html__( 'Delete', 'updraftplus' ) . ': </strong>' . htmlspecialchars( $name ) . ': '; print '<strong>' . esc_html__( 'Delete', 'updraftplus' ) . ': </strong>' . htmlspecialchars( $name ) . ': ';
if ( $wpfs ) { if ( $wpfs ) {
@ -2375,7 +2375,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$updraft_dir = $updraftplus->backups_dir_location(); $updraft_dir = $updraftplus->backups_dir_location();
if ( false === $db_file ) { if ( false === $db_file ) {
# This attempts to raise the maximum packet size. This can't be done within the session, only globally. Therefore, it has to be done before the session starts; in our case, during the pre-analysis. // This attempts to raise the maximum packet size. This can't be done within the session, only globally. Therefore, it has to be done before the session starts; in our case, during the pre-analysis.
$updraftplus->get_max_packet_size(); $updraftplus->get_max_packet_size();
if (method_exists($updraftplus, 'get_backup_history')) { if (method_exists($updraftplus, 'get_backup_history')) {
@ -2427,7 +2427,7 @@ class MainWP_Child_Updraft_Plus_Backups {
} }
} }
# Even the empty schema when gzipped comes to 1565 bytes; a blank WP 3.6 install at 5158. But we go low, in case someone wants to share single tables. // 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 ) { if ( filesize( $db_file ) < 1000 ) {
$err[] = sprintf( __( 'The database is too small to be a valid WordPress database (size: %s Kb).', 'updraftplus' ), round( filesize( $db_file ) / 1024, 1 ) ); $err[] = sprintf( __( 'The database is too small to be a valid WordPress database (size: %s Kb).', 'updraftplus' ), round( filesize( $db_file ) / 1024, 1 ) );
@ -2443,7 +2443,7 @@ class MainWP_Child_Updraft_Plus_Backups {
return array( $mess, $warn, $err, $info ); return array( $mess, $warn, $err, $info );
} }
# Analyse the file, print the results. // Analyse the file, print the results.
$line = 0; $line = 0;
$old_siteurl = ''; $old_siteurl = '';
@ -2474,7 +2474,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$migration_warning = false; $migration_warning = false;
# Don't set too high - we want a timely response returned to the browser // Don't set too high - we want a timely response returned to the browser
@set_time_limit( 90 ); @set_time_limit( 90 );
while ( ( ( $is_plain && ! feof( $dbhandle ) ) || ( ! $is_plain && ! gzeof( $dbhandle ) ) ) && ( $line < 100 || ( ! $header_only && count( $wanted_tables ) > 0 ) ) ) { while ( ( ( $is_plain && ! feof( $dbhandle ) ) || ( ! $is_plain && ! gzeof( $dbhandle ) ) ) && ( $line < 100 || ( ! $header_only && count( $wanted_tables ) > 0 ) ) ) {
@ -2510,20 +2510,20 @@ class MainWP_Child_Updraft_Plus_Backups {
$old_wp_version .= substr( $matches[3], 0, strlen( $matches[3] ) - 1 ); $old_wp_version .= substr( $matches[3], 0, strlen( $matches[3] ) - 1 );
} }
if ( version_compare( $old_wp_version, $wp_version, '>' ) ) { if ( version_compare( $old_wp_version, $wp_version, '>' ) ) {
//$mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version); // $mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version);
$warn[] = sprintf( __( 'You are importing from a newer version of WordPress (%1$s) into an older one (%2$s). There are no guarantees that WordPress can handle this.', 'updraftplus' ), $old_wp_version, $wp_version ); $warn[] = sprintf( __( 'You are importing from a newer version of WordPress (%1$s) into an older one (%2$s). There are no guarantees that WordPress can handle this.', 'updraftplus' ), $old_wp_version, $wp_version );
} }
if ( preg_match( '/running on PHP ([0-9]+\.[0-9]+)(\s|\.)/', $matches[4], $nmatches ) && preg_match( '/^([0-9]+\.[0-9]+)(\s|\.)/', PHP_VERSION, $cmatches ) ) { if ( preg_match( '/running on PHP ([0-9]+\.[0-9]+)(\s|\.)/', $matches[4], $nmatches ) && preg_match( '/^([0-9]+\.[0-9]+)(\s|\.)/', PHP_VERSION, $cmatches ) ) {
$old_php_version = $nmatches[1]; $old_php_version = $nmatches[1];
$current_php_version = $cmatches[1]; $current_php_version = $cmatches[1];
if ( version_compare( $old_php_version, $current_php_version, '>' ) ) { if ( version_compare( $old_php_version, $current_php_version, '>' ) ) {
//$mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version); // $mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version);
$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' ); $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]; $old_table_prefix = $matches[1];
// echo '<strong>'.__('Old table prefix:', 'updraftplus').'</strong> '.htmlspecialchars($old_table_prefix).'<br>'; // echo '<strong>'.__('Old table prefix:', 'updraftplus').'</strong> '.htmlspecialchars($old_table_prefix).'<br>';
} elseif ( empty( $info['label'] ) && preg_match( '/^\# Label: (.*)$/', $buffer, $matches ) ) { } elseif ( empty( $info['label'] ) && preg_match( '/^\# Label: (.*)$/', $buffer, $matches ) ) {
$info['label'] = $matches[1]; $info['label'] = $matches[1];
$mess[] = __( 'Backup label:', 'updraftplus' ) . ' ' . htmlspecialchars( $info['label'] ); $mess[] = __( 'Backup label:', 'updraftplus' ) . ' ' . htmlspecialchars( $info['label'] );
@ -3070,7 +3070,7 @@ class MainWP_Child_Updraft_Plus_Backups {
if ( false === ( $bytes = gzread( $dbhandle, 3 ) ) ) { if ( false === ( $bytes = gzread( $dbhandle, 3 ) ) ) {
return false; return false;
} }
# Double-gzipped? // Double-gzipped?
if ( 'H4sI' !== base64_encode( $bytes ) ) { if ( 'H4sI' !== base64_encode( $bytes ) ) {
if ( 0 === gzseek( $dbhandle, 0 ) ) { if ( 0 === gzseek( $dbhandle, 0 ) ) {
return $dbhandle; return $dbhandle;
@ -3080,7 +3080,7 @@ class MainWP_Child_Updraft_Plus_Backups {
return gzopen( $file, 'r' ); return gzopen( $file, 'r' );
} }
} }
# Yes, it's double-gzipped // Yes, it's double-gzipped
$what_to_return = false; $what_to_return = false;
$mess = __( 'The database file appears to have been compressed twice - probably the website you downloaded it from had a mis-configured webserver.', 'updraftplus' ); $mess = __( 'The database file appears to have been compressed twice - probably the website you downloaded it from had a mis-configured webserver.', 'updraftplus' );
@ -3112,7 +3112,7 @@ class MainWP_Child_Updraft_Plus_Backups {
gzclose( $dbhandle ); gzclose( $dbhandle );
fclose( $fnew ); fclose( $fnew );
# On some systems (all Windows?) you can't rename a gz file whilst it's gzopened // On some systems (all Windows?) you can't rename a gz file whilst it's gzopened
if ( ! rename( $file . '.tmp', $file ) ) { if ( ! rename( $file . '.tmp', $file ) ) {
$err_msg = __( 'The attempt to undo the double-compression failed.', 'updraftplus' ); $err_msg = __( 'The attempt to undo the double-compression failed.', 'updraftplus' );
} else { } else {
@ -3168,10 +3168,10 @@ class MainWP_Child_Updraft_Plus_Backups {
krsort( $backup_history ); krsort( $backup_history );
foreach ( $backup_history as $key => $backup ) { foreach ( $backup_history as $key => $backup ) {
# https://core.trac.wordpress.org/ticket/25331 explains why the following line is wrong // https://core.trac.wordpress.org/ticket/25331 explains why the following line is wrong
# $pretty_date = date_i18n('Y-m-d G:i',$key); // $pretty_date = date_i18n('Y-m-d G:i',$key);
// Convert to blog time zone // Convert to blog time zone
// $pretty_date = get_date_from_gmt(gmdate('Y-m-d H:i:s', (int)$key), 'Y-m-d G:i'); // $pretty_date = get_date_from_gmt(gmdate('Y-m-d H:i:s', (int)$key), 'Y-m-d G:i');
$pretty_date = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', (int) $key ), 'M d, Y G:i' ); $pretty_date = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', (int) $key ), 'M d, Y G:i' );
$esc_pretty_date = esc_attr( $pretty_date ); $esc_pretty_date = esc_attr( $pretty_date );
@ -3179,17 +3179,17 @@ class MainWP_Child_Updraft_Plus_Backups {
$non = $backup['nonce']; $non = $backup['nonce'];
// $rawbackup = "<h2>$esc_pretty_date ($key)</h2><pre><p>" . esc_attr( print_r( $backup, true ) ); // $rawbackup = "<h2>$esc_pretty_date ($key)</h2><pre><p>" . esc_attr( print_r( $backup, true ) );
// if ( ! empty( $non ) ) { // if ( ! empty( $non ) ) {
// $jd = $updraftplus->jobdata_getarray( $non ); // $jd = $updraftplus->jobdata_getarray( $non );
// if ( ! empty( $jd ) && is_array( $jd ) ) { // if ( ! empty( $jd ) && is_array( $jd ) ) {
// $rawbackup .= '</p><p>' . esc_attr( print_r( $jd, true ) ); // $rawbackup .= '</p><p>' . esc_attr( print_r( $jd, true ) );
// } // }
// } // }
// $rawbackup .= '</p></pre>'; // $rawbackup .= '</p></pre>';
// to fix // to fix
$rawbackup = ''; //$updraftplus_admin->raw_backup_info($backup_history, $key, $non); $rawbackup = ''; // $updraftplus_admin->raw_backup_info($backup_history, $key, $non);
$jobdata = $updraftplus->jobdata_getarray( $non ); $jobdata = $updraftplus->jobdata_getarray( $non );
@ -3208,7 +3208,7 @@ class MainWP_Child_Updraft_Plus_Backups {
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 // Do nothing
} else { } else {
// $image_url = file_exists($image_folder.$service.'.png') ? $image_folder_url.$service.'.png' : $image_folder_url.'folder.png'; // $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 ];
@ -3245,7 +3245,7 @@ ENDHERE;
$ret .= $this->download_db_button( 'db', $key, $esc_pretty_date, $nonce_field, $backup, $accept ); $ret .= $this->download_db_button( 'db', $key, $esc_pretty_date, $nonce_field, $backup, $accept );
} }
# External databases // External databases
foreach ( $backup as $bkey => $binfo ) { foreach ( $backup as $bkey => $binfo ) {
if ( 'db' === $bkey || 'db' !== substr( $bkey, 0, 2 ) || '-size' === substr( $bkey, - 5, 5 ) ) { if ( 'db' === $bkey || 'db' !== substr( $bkey, 0, 2 ) || '-size' === substr( $bkey, - 5, 5 ) ) {
continue; continue;
@ -3253,7 +3253,7 @@ ENDHERE;
$ret .= $this->download_db_button( $bkey, $key, $esc_pretty_date, $nonce_field, $backup ); $ret .= $this->download_db_button( $bkey, $key, $esc_pretty_date, $nonce_field, $backup );
} }
} else { } else {
# Foreign without separate db // Foreign without separate db
$entities = '/db=0/meta_foreign=1/'; $entities = '/db=0/meta_foreign=1/';
} }
@ -3265,13 +3265,13 @@ ENDHERE;
$ret .= $download_buttons; $ret .= $download_buttons;
// $ret .="</td>"; // $ret .="</td>";
// No logs expected for foreign backups // No logs expected for foreign backups
if ( empty( $backup['meta_foreign'] ) ) { if ( empty( $backup['meta_foreign'] ) ) {
// $ret .= '<td>'; // $ret .= '<td>';
// $ret .= $this->log_button($backup); // $ret .= $this->log_button($backup);
// $ret .= "</td>"; // $ret .= "</td>";
} }
$ret .= '</td>'; $ret .= '</td>';
@ -3305,7 +3305,7 @@ ENDHERE;
if ( isset( $backup['native'] ) && false === $backup['native'] ) { if ( isset( $backup['native'] ) && false === $backup['native'] ) {
$show_data .= ' ' . __( '(backup set imported from remote storage)', 'updraftplus' ); $show_data .= ' ' . __( '(backup set imported from remote storage)', 'updraftplus' );
} }
# jQuery('#updraft_restore_label_wpcore').html('".esc_js($wpcore_restore_descrip)."'); // jQuery('#updraft_restore_label_wpcore').html('".esc_js($wpcore_restore_descrip)."');
$ret .= '<button title="' . __( 'Go to Restore', 'updraftplus' ) . '" type="button" class="ui green button mwp-updraftplus-restore-btn" >' . __( 'Restore', 'updraftplus' ) . '</button>'; $ret .= '<button title="' . __( 'Go to Restore', 'updraftplus' ) . '" type="button" class="ui green button mwp-updraftplus-restore-btn" >' . __( 'Restore', 'updraftplus' ) . '</button>';
} }
$ret .= "</form></div>\n"; $ret .= "</form></div>\n";
@ -3542,7 +3542,7 @@ ENDHERE;
} else { } else {
$backupable_entities = $updraftplus->get_backupable_file_entities( true, false ); $backupable_entities = $updraftplus->get_backupable_file_entities( true, false );
if ( ! empty( $backupable_entities[ $_POST['entity'] ] ) ) { if ( ! empty( $backupable_entities[ $_POST['entity'] ] ) ) {
# Might be an array // Might be an array
$basedir = $backupable_entities[ $_POST['entity'] ]; $basedir = $backupable_entities[ $_POST['entity'] ];
$dirs = apply_filters( 'updraftplus_dirlist_' . $_POST['entity'], $basedir ); $dirs = apply_filters( 'updraftplus_dirlist_' . $_POST['entity'], $basedir );
$out['diskspaceused'] = $this->recursive_directory_size( $dirs, $updraftplus->get_exclude( $_POST['entity'] ), $basedir ); $out['diskspaceused'] = $this->recursive_directory_size( $dirs, $updraftplus->get_exclude( $_POST['entity'] ), $basedir );
@ -3555,7 +3555,7 @@ ENDHERE;
} }
# If $basedirs is passed as an array, then $directorieses must be too // If $basedirs is passed as an array, then $directorieses must be too
private function recursive_directory_size( $directorieses, $exclude = array(), $basedirs = '' ) { private function recursive_directory_size( $directorieses, $exclude = array(), $basedirs = '' ) {
$size = 0; $size = 0;
@ -3627,7 +3627,7 @@ ENDHERE;
$handlesize = $this->recursive_directory_size_raw( $prefix_directory, $exclude, $suffix_directory . ( '' === $suffix_directory ? '' : '/' ) . $file ); $handlesize = $this->recursive_directory_size_raw( $prefix_directory, $exclude, $suffix_directory . ( '' === $suffix_directory ? '' : '/' ) . $file );
if ( $handlesize >= 0 ) { if ( $handlesize >= 0 ) {
$size += $handlesize; $size += $handlesize;
}# else { return -1; } }// else { return -1; }
} }
} }
} }
@ -3666,14 +3666,14 @@ ENDHERE;
// A value for $this_job_only also causes something to always be returned (to allow detection of the job having started on the front-end) // A value for $this_job_only also causes something to always be returned (to allow detection of the job having started on the front-end)
private function print_active_jobs( $this_job_only = false ) { private function print_active_jobs( $this_job_only = false ) {
$cron = $this->get_cron(); $cron = $this->get_cron();
// $found_jobs = 0; // $found_jobs = 0;
$ret = ''; $ret = '';
foreach ( $cron as $time => $job ) { foreach ( $cron as $time => $job ) {
if ( isset( $job['updraft_backup_resume'] ) ) { if ( isset( $job['updraft_backup_resume'] ) ) {
foreach ( $job['updraft_backup_resume'] as $hook => $info ) { foreach ( $job['updraft_backup_resume'] as $hook => $info ) {
if ( isset( $info['args'][1] ) ) { if ( isset( $info['args'][1] ) ) {
// $found_jobs++; // $found_jobs++;
$job_id = $info['args'][1]; $job_id = $info['args'][1];
if ( false === $this_job_only || $job_id === $this_job_only ) { if ( false === $this_job_only || $job_id === $this_job_only ) {
$ret .= $this->print_active_job( $job_id, false, $time, $info['args'][0] ); $ret .= $this->print_active_job( $job_id, false, $time, $info['args'][0] );
@ -3692,7 +3692,7 @@ ENDHERE;
} }
} }
// if (0 == $found_jobs) $ret .= '<p><em>'.__('(None)', 'updraftplus').'</em></p>'; // if (0 == $found_jobs) $ret .= '<p><em>'.__('(None)', 'updraftplus').'</em></p>';
return $ret; return $ret;
} }
@ -3707,7 +3707,7 @@ ENDHERE;
return ''; return '';
} }
#if (!is_array($jobdata)) $jobdata = array(); // if (!is_array($jobdata)) $jobdata = array();
if ( ! isset( $jobdata['backup_time'] ) ) { if ( ! isset( $jobdata['backup_time'] ) ) {
return ''; return '';
} }
@ -3719,11 +3719,11 @@ ENDHERE;
$jobstatus = empty( $jobdata['jobstatus'] ) ? 'unknown' : $jobdata['jobstatus']; $jobstatus = empty( $jobdata['jobstatus'] ) ? 'unknown' : $jobdata['jobstatus'];
$stage = 0; $stage = 0;
switch ( $jobstatus ) { switch ( $jobstatus ) {
# Stage 0 // Stage 0
case 'begun': case 'begun':
$curstage = __( 'Backup begun', 'updraftplus' ); $curstage = __( 'Backup begun', 'updraftplus' );
break; break;
# Stage 1 // Stage 1
case 'filescreating': case 'filescreating':
$stage = 1; $stage = 1;
$curstage = __( 'Creating file backup zips', 'updraftplus' ); $curstage = __( 'Creating file backup zips', 'updraftplus' );
@ -3744,7 +3744,7 @@ ENDHERE;
$curstage = __( 'Created file backup zips', 'updraftplus' ); $curstage = __( 'Created file backup zips', 'updraftplus' );
break; break;
# Stage 4 // Stage 4
case 'clouduploading': case 'clouduploading':
$stage = 4; $stage = 4;
$curstage = __( 'Uploading files to remote storage', 'updraftplus' ); $curstage = __( 'Uploading files to remote storage', 'updraftplus' );
@ -3765,13 +3765,13 @@ ENDHERE;
$stage = - 1; $stage = - 1;
$curstage = __( 'Waiting until scheduled time to retry because of errors', 'updraftplus' ); $curstage = __( 'Waiting until scheduled time to retry because of errors', 'updraftplus' );
break; break;
# Stage 6 // Stage 6
case 'finished': case 'finished':
$stage = 6; $stage = 6;
$curstage = __( 'Backup finished', 'updraftplus' ); $curstage = __( 'Backup finished', 'updraftplus' );
break; break;
default: default:
# Database creation and encryption occupies the space from 2 to 4. Databases are created then encrypted, then the next databae is created/encrypted, etc. // Database creation and encryption occupies the space from 2 to 4. Databases are created then encrypted, then the next databae is created/encrypted, etc.
if ( 'dbcreated' === substr( $jobstatus, 0, 9 ) ) { if ( 'dbcreated' === substr( $jobstatus, 0, 9 ) ) {
$jobstatus = 'dbcreated'; $jobstatus = 'dbcreated';
$whichdb = substr( $jobstatus, 9 ); $whichdb = substr( $jobstatus, 9 );

View file

@ -81,7 +81,7 @@ class MainWP_Child_Wordfence {
'scansEnabled_fileContents', 'scansEnabled_fileContents',
'scansEnabled_fileContentsGSB', 'scansEnabled_fileContentsGSB',
'scan_include_extra', 'scan_include_extra',
//'scansEnabled_heartbleed', // 'scansEnabled_heartbleed',
'scansEnabled_checkHowGetIPs', 'scansEnabled_checkHowGetIPs',
'scansEnabled_highSense', 'scansEnabled_highSense',
'lowResourceScansEnabled', 'lowResourceScansEnabled',
@ -96,7 +96,7 @@ class MainWP_Child_Wordfence {
'scansEnabled_themes', 'scansEnabled_themes',
'scheduledScansEnabled', 'scheduledScansEnabled',
'securityLevel', 'securityLevel',
//'scheduleScan' // NOTE: filtered, not save // 'scheduleScan' // NOTE: filtered, not save
'blockFakeBots', 'blockFakeBots',
'neverBlockBG', 'neverBlockBG',
'maxGlobalRequests', 'maxGlobalRequests',
@ -134,15 +134,15 @@ class MainWP_Child_Wordfence {
'disableCookies', 'disableCookies',
'liveActivityPauseEnabled', 'liveActivityPauseEnabled',
'startScansRemotely', 'startScansRemotely',
//'disableConfigCaching', // 'disableConfigCaching',
//'addCacheComment', // removed // 'addCacheComment', // removed
'disableCodeExecutionUploads', 'disableCodeExecutionUploads',
//'isPaid', // 'isPaid',
'advancedCommentScanning', 'advancedCommentScanning',
'scansEnabled_checkGSB', 'scansEnabled_checkGSB',
'checkSpamIP', 'checkSpamIP',
'spamvertizeCheck', 'spamvertizeCheck',
//'scansEnabled_public', // 'scansEnabled_public',
'email_summary_enabled', 'email_summary_enabled',
'email_summary_dashboard_widget_enabled', 'email_summary_dashboard_widget_enabled',
'ssl_verify', 'ssl_verify',
@ -151,8 +151,8 @@ class MainWP_Child_Wordfence {
'allowed404s', 'allowed404s',
'wafAlertWhitelist', 'wafAlertWhitelist',
'wafAlertOnAttacks', 'wafAlertOnAttacks',
//'ajaxWatcherDisabled_front', // do not update those values when save settings // 'ajaxWatcherDisabled_front', // do not update those values when save settings
//'ajaxWatcherDisabled_admin' // those values saved in the ['changes'] in the saveOptions function // 'ajaxWatcherDisabled_admin' // those values saved in the ['changes'] in the saveOptions function
'howGetIPs_trusted_proxies', 'howGetIPs_trusted_proxies',
'other_bypassLitespeedNoabort', 'other_bypassLitespeedNoabort',
'disableWAFIPBlocking', 'disableWAFIPBlocking',
@ -168,11 +168,11 @@ class MainWP_Child_Wordfence {
// for separated saving this values // for separated saving this values
public static $diagnosticParams = array( public static $diagnosticParams = array(
//'addCacheComment', // 'addCacheComment',
'debugOn', 'debugOn',
'startScansRemotely', 'startScansRemotely',
'ssl_verify', 'ssl_verify',
//'disableConfigCaching', // 'disableConfigCaching',
'betaThreatDefenseFeed', 'betaThreatDefenseFeed',
); );
@ -542,8 +542,8 @@ class MainWP_Child_Wordfence {
); );
$scan_opts = array( $scan_opts = array(
'scansEnabled_checkGSB', //paid 'scansEnabled_checkGSB', // paid
'spamvertizeCheck', //paid 'spamvertizeCheck', // paid
'checkSpamIP', // paid 'checkSpamIP', // paid
'scansEnabled_checkHowGetIPs', 'scansEnabled_checkHowGetIPs',
'scansEnabled_checkReadableConfig', 'scansEnabled_checkReadableConfig',
@ -629,7 +629,7 @@ class MainWP_Child_Wordfence {
private function kill_scan() { private function kill_scan() {
wordfence::status(1, 'info', 'Scan kill request received.'); wordfence::status(1, 'info', 'Scan kill request received.');
wordfence::status(10, 'info', 'SUM_KILLED:A request was received to kill the previous scan.'); wordfence::status(10, 'info', 'SUM_KILLED:A request was received to kill the previous scan.');
wfUtils::clearScanLock(); //Clear the lock now because there may not be a scan running to pick up the kill request and clear the lock wfUtils::clearScanLock(); // Clear the lock now because there may not be a scan running to pick up the kill request and clear the lock
wfScanEngine::requestKill(); wfScanEngine::requestKill();
return array( return array(
'ok' => 1, 'ok' => 1,
@ -1183,40 +1183,40 @@ SQL
} }
} }
// $to_fix_boolean_values = array( // $to_fix_boolean_values = array(
// 'scansEnabled_checkGSB', // 'scansEnabled_checkGSB',
// 'spamvertizeCheck', // 'spamvertizeCheck',
// 'checkSpamIP', // 'checkSpamIP',
// 'scansEnabled_checkHowGetIPs', // 'scansEnabled_checkHowGetIPs',
// 'scansEnabled_checkReadableConfig', // 'scansEnabled_checkReadableConfig',
// 'scansEnabled_suspectedFiles', // 'scansEnabled_suspectedFiles',
// 'scansEnabled_core', // 'scansEnabled_core',
// 'scansEnabled_themes', // 'scansEnabled_themes',
// 'scansEnabled_plugins', // 'scansEnabled_plugins',
// 'scansEnabled_coreUnknown', // 'scansEnabled_coreUnknown',
// 'scansEnabled_malware', // 'scansEnabled_malware',
// 'scansEnabled_fileContents', // 'scansEnabled_fileContents',
// 'scansEnabled_fileContentsGSB', // 'scansEnabled_fileContentsGSB',
// 'scansEnabled_posts', // 'scansEnabled_posts',
// 'scansEnabled_comments', // 'scansEnabled_comments',
// 'scansEnabled_suspiciousOptions', // 'scansEnabled_suspiciousOptions',
// 'scansEnabled_oldVersions', // 'scansEnabled_oldVersions',
// 'scansEnabled_suspiciousAdminUsers', // 'scansEnabled_suspiciousAdminUsers',
// 'scansEnabled_passwds', // 'scansEnabled_passwds',
// 'scansEnabled_diskSpace', // 'scansEnabled_diskSpace',
// 'scansEnabled_dns', // 'scansEnabled_dns',
// 'other_scanOutside', // 'other_scanOutside',
// 'scansEnabled_scanImages', // 'scansEnabled_scanImages',
// 'scansEnabled_highSense', // 'scansEnabled_highSense',
// 'scheduledScansEnabled', // 'scheduledScansEnabled',
// 'lowResourceScansEnabled', // 'lowResourceScansEnabled',
// ); // );
// //
// save the settings // save the settings
foreach ( $opts as $key => $val ) { foreach ( $opts as $key => $val ) {
// check saving section fields // check saving section fields
if ( in_array( $key, $saving_opts ) ) { if ( in_array( $key, $saving_opts ) ) {
if ( 'apiKey' == $key ) { //Don't save API key yet if ( 'apiKey' == $key ) { // Don't save API key yet
continue; continue;
} }
if (in_array( $key, self::$firewall_options_filter ) ) { if (in_array( $key, self::$firewall_options_filter ) ) {
@ -1283,7 +1283,7 @@ SQL
} }
// Finished saving settings // Finished saving settings
///////////////////// //
$result['cacheType'] = wfConfig::get( 'cacheType' ); $result['cacheType'] = wfConfig::get( 'cacheType' );
$result['paidKeyMsg'] = false; $result['paidKeyMsg'] = false;
@ -1323,17 +1323,17 @@ SQL
$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'] ) ) { if ( $res['ok'] && isset( $res['isPaid'] ) ) {
// wfConfig::set( 'apiKey', $apiKey ); // wfConfig::set( 'apiKey', $apiKey );
// wfConfig::set( 'isPaid', $res['isPaid'] ); //res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools. // wfConfig::set( 'isPaid', $res['isPaid'] ); //res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools.
// $result['apiKey'] = $apiKey; // $result['apiKey'] = $apiKey;
// $result['isPaid'] = $res['isPaid']; // $result['isPaid'] = $res['isPaid'];
// if ( $res['isPaid'] ) { // if ( $res['isPaid'] ) {
// $result['paidKeyMsg'] = true; // $result['paidKeyMsg'] = true;
// } // }
$isPaid = wfUtils::truthyToBoolean($res['isPaid']); $isPaid = wfUtils::truthyToBoolean($res['isPaid']);
wfConfig::set('apiKey', $apiKey); wfConfig::set('apiKey', $apiKey);
wfConfig::set('isPaid', $isPaid); //res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools. wfConfig::set('isPaid', $isPaid); // res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools.
wordfence::licenseStatusChanged(); wordfence::licenseStatusChanged();
if ( ! $isPaid) { if ( ! $isPaid) {
wfConfig::set('keyType', wfAPI::KEY_TYPE_FREE); wfConfig::set('keyType', wfAPI::KEY_TYPE_FREE);
@ -1472,7 +1472,7 @@ SQL
foreach ( $opts as $key => $val ) { foreach ( $opts as $key => $val ) {
if ( in_array( $key, self::$options_filter ) ) { if ( in_array( $key, self::$options_filter ) ) {
if ( 'apiKey' !== $key ) { //Don't save API key yet if ( 'apiKey' !== $key ) { // Don't save API key yet
wfConfig::set( $key, $val ); wfConfig::set( $key, $val );
} }
} }
@ -1524,7 +1524,7 @@ SQL
$result['cacheType'] = wfConfig::get( 'cacheType' ); $result['cacheType'] = wfConfig::get( 'cacheType' );
$result['paidKeyMsg'] = false; $result['paidKeyMsg'] = false;
$apiKey = trim( $_POST['apiKey'] ); $apiKey = trim( $_POST['apiKey'] );
if ( ! $apiKey ) { //Empty API key (after trim above), then try to get one. if ( ! $apiKey ) { // Empty API key (after trim above), then try to get one.
$api = new wfAPI( '', wfUtils::getWPVersion() ); $api = new wfAPI( '', wfUtils::getWPVersion() );
try { try {
$keyData = $api->call( 'get_anon_api_key' ); $keyData = $api->call( 'get_anon_api_key' );
@ -1548,7 +1548,7 @@ SQL
$res = $api->call( 'check_api_key', array(), array() ); $res = $api->call( 'check_api_key', array(), array() );
if ( $res['ok'] && isset( $res['isPaid'] ) ) { if ( $res['ok'] && isset( $res['isPaid'] ) ) {
wfConfig::set( 'apiKey', $apiKey ); wfConfig::set( 'apiKey', $apiKey );
wfConfig::set( 'isPaid', $res['isPaid'] ); //res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools. wfConfig::set( 'isPaid', $res['isPaid'] ); // res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools.
$result['apiKey'] = $apiKey; $result['apiKey'] = $apiKey;
$result['isPaid'] = $res['isPaid']; $result['isPaid'] = $res['isPaid'];
if ( $res['isPaid'] ) { if ( $res['isPaid'] ) {
@ -1584,19 +1584,19 @@ SQL
$export = array(); $export = array();
//Basic Options // Basic Options
$keys = wfConfig::getExportableOptionsKeys(); $keys = wfConfig::getExportableOptionsKeys();
foreach ($keys as $key) { foreach ($keys as $key) {
$export[ $key ] = wfConfig::get($key, ''); $export[ $key ] = wfConfig::get($key, '');
} }
//Serialized Options // Serialized Options
$export['scanSched'] = wfConfig::get_ser('scanSched', array()); $export['scanSched'] = wfConfig::get_ser('scanSched', array());
//Table-based Options // Table-based Options
$export['blocks'] = wfBlock::exportBlocks(); $export['blocks'] = wfBlock::exportBlocks();
//Make the API call // Make the API call
try { try {
$api = new wfAPI(wfConfig::get('apiKey'), wfUtils::getWPVersion()); $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) ));
@ -1627,7 +1627,7 @@ SQL
return array( 'errorImport' => __('An error occurred: Invalid options format received.', 'wordfence') ); return array( 'errorImport' => __('An error occurred: Invalid options format received.', 'wordfence') );
} }
//Basic Options // Basic Options
$keys = wfConfig::getExportableOptionsKeys(); $keys = wfConfig::getExportableOptionsKeys();
$toSet = array(); $toSet = array();
foreach ($keys as $key) { foreach ($keys as $key) {
@ -1650,14 +1650,14 @@ SQL
wfConfig::save(wfConfig::clean($toSet)); wfConfig::save(wfConfig::clean($toSet));
} }
//Serialized Options // Serialized Options
if (isset($import['scanSched']) && is_array($import['scanSched'])) { if (isset($import['scanSched']) && is_array($import['scanSched'])) {
wfConfig::set_ser('scanSched', $import['scanSched']); wfConfig::set_ser('scanSched', $import['scanSched']);
wfScanner::shared()->scheduleScans(); wfScanner::shared()->scheduleScans();
$totalSet++; $totalSet++;
} }
//Table-based Options // Table-based Options
if (isset($import['blocks']) && is_array($import['blocks'])) { if (isset($import['blocks']) && is_array($import['blocks'])) {
wfBlock::importBlocks($import['blocks']); wfBlock::importBlocks($import['blocks']);
$totalSet += count($import['blocks']); $totalSet += count($import['blocks']);
@ -1684,7 +1684,7 @@ SQL
foreach ($keys as $key) { foreach ($keys as $key) {
$settings[ $key ] = wfConfig::get($key, ''); $settings[ $key ] = wfConfig::get($key, '');
} }
$settings['apiKey'] = wfConfig::get('apiKey'); //get more apiKey $settings['apiKey'] = wfConfig::get('apiKey'); // get more apiKey
$settings['isPaid'] = wfConfig::get('isPaid'); $settings['isPaid'] = wfConfig::get('isPaid');
return $settings; return $settings;
} }
@ -1726,7 +1726,7 @@ SQL
} }
} }
$jsonData['events'] = $events; $jsonData['events'] = $events;
$jsonData['alsoGet'] = $alsoGet; //send it back so we don't load data if panel has changed $jsonData['alsoGet'] = $alsoGet; // send it back so we don't load data if panel has changed
$jsonData['cacheType'] = wfConfig::get( 'cacheType' ); $jsonData['cacheType'] = wfConfig::get( 'cacheType' );
return $jsonData; return $jsonData;
} }
@ -2050,7 +2050,7 @@ SQL
wfConfig::set( 'isPaid', 0 ); wfConfig::set( 'isPaid', 0 );
$return['apiKey'] = $keyData['apiKey']; $return['apiKey'] = $keyData['apiKey'];
$return['isPaid'] = 0; $return['isPaid'] = 0;
//When downgrading we must disable all two factor authentication because it can lock an admin out if we don't. // When downgrading we must disable all two factor authentication because it can lock an admin out if we don't.
wfConfig::set_ser( 'twoFactorUsers', array() ); wfConfig::set_ser( 'twoFactorUsers', array() );
} else { } else {
throw new Exception( 'Could not understand the response we received from the Wordfence servers when applying for a free API key.' ); throw new Exception( 'Could not understand the response we received from the Wordfence servers when applying for a free API key.' );
@ -2127,7 +2127,7 @@ SQL
} }
} }
//Mainly we clear the cache here so that any footer cache diagnostic comments are rebuilt. We could just leave it intact unless caching is being disabled. // Mainly we clear the cache here so that any footer cache diagnostic comments are rebuilt. We could just leave it intact unless caching is being disabled.
if ($cacheType != wfConfig::get('cacheType', false)) { if ($cacheType != wfConfig::get('cacheType', false)) {
wfCache::scheduleCacheClear(); wfCache::scheduleCacheClear();
} }
@ -2161,7 +2161,7 @@ SQL
} }
} }
wfConfig::set('cacheType', 'falcon'); wfConfig::set('cacheType', 'falcon');
wfCache::scheduleUpdateBlockedIPs(); //Runs every 5 mins until we change cachetype wfCache::scheduleUpdateBlockedIPs(); // Runs every 5 mins until we change cachetype
return array( return array(
'ok' => 1, 'ok' => 1,
'heading' => 'Wordfence Falcon Engine Activated!', 'heading' => 'Wordfence Falcon Engine Activated!',
@ -2240,7 +2240,7 @@ SQL
$changed = true; $changed = true;
} }
wfConfig::set('allowHTTPSCaching', $_POST['allowHTTPSCaching'] == '1' ? 1 : 0); wfConfig::set('allowHTTPSCaching', $_POST['allowHTTPSCaching'] == '1' ? 1 : 0);
//wfConfig::set('addCacheComment', $_POST['addCacheComment'] == 1 ? '1' : 0); // wfConfig::set('addCacheComment', $_POST['addCacheComment'] == 1 ? '1' : 0);
wfConfig::set('clearCacheSched', $_POST['clearCacheSched'] == 1 ? '1' : 0); wfConfig::set('clearCacheSched', $_POST['clearCacheSched'] == 1 ? '1' : 0);
if ($changed && wfConfig::get('cacheType', false) == 'falcon') { if ($changed && wfConfig::get('cacheType', false) == 'falcon') {
$err = wfCache::addHtaccessCode('add'); $err = wfCache::addHtaccessCode('add');
@ -2340,7 +2340,7 @@ SQL
wfConfig::set('cacheExclusions', serialize($ex)); wfConfig::set('cacheExclusions', serialize($ex));
wfCache::scheduleCacheClear(); wfCache::scheduleCacheClear();
if (wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $_POST['patternType'])) { if (wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $_POST['patternType'])) {
if (wfCache::addHtaccessCode('add')) { //rewrites htaccess rules if (wfCache::addHtaccessCode('add')) { // rewrites htaccess rules
return array( 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.', '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, 'ex' => $ex,
@ -2380,7 +2380,7 @@ SQL
$rewriteHtaccess = true; $rewriteHtaccess = true;
} }
array_splice($ex, $i, 1); array_splice($ex, $i, 1);
//Dont break in case of dups // Dont break in case of dups
$removed = true; $removed = true;
} }
} }
@ -2391,7 +2391,7 @@ SQL
} }
wfConfig::set('cacheExclusions', serialize($ex)); wfConfig::set('cacheExclusions', serialize($ex));
if ($rewriteHtaccess && wfCache::addHtaccessCode('add')) { //rewrites htaccess rules if ($rewriteHtaccess && wfCache::addHtaccessCode('add')) { // rewrites htaccess rules
$return['errorMsg'] = "We removed that rule but could not rewrite your .htaccess file. You're going to have to manually remove this rule from your .htaccess file. Please reload this page now."; $return['errorMsg'] = "We removed that rule but could not rewrite your .htaccess file. You're going to have to manually remove this rule from your .htaccess file. Please reload this page now.";
return $return; return $return;
} }
@ -2962,7 +2962,7 @@ SQL
<?php <?php
global $wpdb; global $wpdb;
$wfdb = new wfDB(); $wfdb = new wfDB();
//This must be done this way because MySQL with InnoDB tables does a full regeneration of all metadata if we don't. That takes a long time with a large table count. // This must be done this way because MySQL with InnoDB tables does a full regeneration of all metadata if we don't. That takes a long time with a large table count.
$tables = $wfdb->querySelect('SELECT SQL_CALC_FOUND_ROWS TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE() ORDER BY TABLE_NAME ASC LIMIT 250'); $tables = $wfdb->querySelect('SELECT SQL_CALC_FOUND_ROWS TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE() ORDER BY TABLE_NAME ASC LIMIT 250');
$total = $wfdb->querySingle('SELECT FOUND_ROWS()'); $total = $wfdb->querySingle('SELECT FOUND_ROWS()');
foreach ($tables as &$t) { foreach ($tables as &$t) {
@ -3130,7 +3130,7 @@ SQL
$event->setWaf(wfWAF::getInstance()); $event->setWaf(wfWAF::getInstance());
$event->fire(); $event->fire();
$isPaid = (bool) wfConfig::get('isPaid', 0); $isPaid = (bool) wfConfig::get('isPaid', 0);
//return self::_getWAFData(); // return self::_getWAFData();
return array( return array(
'ok' => 1, 'ok' => 1,
'isPaid' => $isPaid, 'isPaid' => $isPaid,

View file

@ -34,9 +34,9 @@ class MainWP_Child_WP_Rocket {
} }
public function init() { public function init() {
// if ( get_option( 'mainwp_wprocket_ext_enabled' ) !== 'Y' ) { // if ( get_option( 'mainwp_wprocket_ext_enabled' ) !== 'Y' ) {
// return; // return;
// } // }
if ( ! $this->is_plugin_installed ) { if ( ! $this->is_plugin_installed ) {
return; return;
@ -101,16 +101,16 @@ class MainWP_Child_WP_Rocket {
'lazyload_iframes' => 0, 'lazyload_iframes' => 0,
'lazyload_youtube' => 0, 'lazyload_youtube' => 0,
'minify_css' => 0, 'minify_css' => 0,
// 'minify_css_key' => $minify_css_key, // 'minify_css_key' => $minify_css_key,
'minify_concatenate_css' => 0, 'minify_concatenate_css' => 0,
//'minify_css_combine_all' => 0, // 'minify_css_combine_all' => 0,
'minify_css_legacy' => 0, 'minify_css_legacy' => 0,
'minify_js' => 0, 'minify_js' => 0,
// 'minify_js_key' => $minify_js_key, // 'minify_js_key' => $minify_js_key,
'minify_js_in_footer' => array(), 'minify_js_in_footer' => array(),
'minify_concatenate_js' => 0, 'minify_concatenate_js' => 0,
'minify_js_combine_all' => 0, 'minify_js_combine_all' => 0,
//'minify_js_legacy' => 0, // 'minify_js_legacy' => 0,
'minify_google_fonts' => 0, 'minify_google_fonts' => 0,
'minify_html' => 0, 'minify_html' => 0,
'remove_query_strings' => 0, 'remove_query_strings' => 0,
@ -118,13 +118,13 @@ class MainWP_Child_WP_Rocket {
'cdn' => 0, 'cdn' => 0,
'cdn_cnames' => array(), 'cdn_cnames' => array(),
'cdn_zone' => array(), 'cdn_zone' => array(),
//'cdn_ssl' => 0, // 'cdn_ssl' => 0,
'cdn_reject_files' => array(), 'cdn_reject_files' => array(),
'do_cloudflare' => 0, 'do_cloudflare' => 0,
'cloudflare_email' => '', 'cloudflare_email' => '',
'cloudflare_api_key' => '', 'cloudflare_api_key' => '',
'cloudflare_domain' => '', 'cloudflare_domain' => '',
//'cloudflare_zone_id' => '', // 'cloudflare_zone_id' => '',
'cloudflare_devmode' => 0, 'cloudflare_devmode' => 0,
'cloudflare_protocol_rewrite' => 0, 'cloudflare_protocol_rewrite' => 0,
'cloudflare_auto_settings' => 0, 'cloudflare_auto_settings' => 0,
@ -207,9 +207,9 @@ class MainWP_Child_WP_Rocket {
if ( ! $this->is_plugin_installed ) { if ( ! $this->is_plugin_installed ) {
return false; return false;
} }
// if ( ! defined( 'WP_ROCKET_VERSION' ) || ! defined( 'WP_ROCKET_SLUG' ) ) { // if ( ! defined( 'WP_ROCKET_VERSION' ) || ! defined( 'WP_ROCKET_SLUG' ) ) {
// return false; // return false;
// } // }
return true; return true;
} }
@ -252,7 +252,7 @@ class MainWP_Child_WP_Rocket {
$information = array(); $information = array();
if ( isset( $_POST['mwp_action'] ) ) { if ( isset( $_POST['mwp_action'] ) ) {
// MainWP_Helper::update_option( 'mainwp_wprocket_ext_enabled', 'Y' ); // MainWP_Helper::update_option( 'mainwp_wprocket_ext_enabled', 'Y' );
try { try {
switch ( $_POST['mwp_action'] ) { switch ( $_POST['mwp_action'] ) {
case 'set_showhide': case 'set_showhide':

File diff suppressed because it is too large Load diff

View file

@ -41,8 +41,8 @@ class MainWP_Clone_Install {
* @return bool * @return bool
*/ */
public function checkZipConsole() { public function checkZipConsole() {
//todo: implement // todo: implement
// return function_exists('system'); // return function_exists('system');
return false; return false;
} }
@ -59,7 +59,7 @@ class MainWP_Clone_Install {
if ( null !== $this->archiver ) { if ( null !== $this->archiver ) {
} elseif ( $this->checkZipConsole() ) { } elseif ( $this->checkZipConsole() ) {
//todo: implement // todo: implement
} elseif ( $this->checkZipSupport() ) { } elseif ( $this->checkZipSupport() ) {
$zip = new ZipArchive(); $zip = new ZipArchive();
$zipRes = $zip->open( $this->file ); $zipRes = $zip->open( $this->file );
@ -73,7 +73,7 @@ class MainWP_Clone_Install {
return false; return false;
} else { } else {
//use pclzip // use pclzip
$zip = new PclZip( $this->file ); $zip = new PclZip( $this->file );
$list = $zip->delete( PCLZIP_OPT_BY_NAME, 'wp-config.php' ); $list = $zip->delete( PCLZIP_OPT_BY_NAME, 'wp-config.php' );
$list2 = $zip->delete( PCLZIP_OPT_BY_NAME, 'clone' ); $list2 = $zip->delete( PCLZIP_OPT_BY_NAME, 'clone' );
@ -115,7 +115,7 @@ class MainWP_Clone_Install {
return $this->archiver->file_exists( $file ); return $this->archiver->file_exists( $file );
} elseif ( $this->checkZipConsole() ) { } elseif ( $this->checkZipConsole() ) {
//todo: implement // todo: implement
} elseif ( $this->checkZipSupport() ) { } elseif ( $this->checkZipSupport() ) {
$zip = new ZipArchive(); $zip = new ZipArchive();
$zipRes = $zip->open( $this->file ); $zipRes = $zip->open( $this->file );
@ -236,7 +236,7 @@ class MainWP_Clone_Install {
$readline = ''; $readline = '';
while ( ( $line = fgets( $handle, 81920 ) ) !== false ) { while ( ( $line = fgets( $handle, 81920 ) ) !== false ) {
if ( time() - $lastRun > 20 ) { if ( time() - $lastRun > 20 ) {
@set_time_limit( 0 ); //reset timer.. @set_time_limit( 0 ); // reset timer..
$lastRun = time(); $lastRun = time();
} }
@ -373,14 +373,14 @@ class MainWP_Clone_Install {
return $content; return $content;
} else { } else {
if ( $this->checkZipConsole() ) { if ( $this->checkZipConsole() ) {
//todo: implement // todo: implement
} elseif ( $this->checkZipSupport() ) { } elseif ( $this->checkZipSupport() ) {
$zip = new ZipArchive(); $zip = new ZipArchive();
$zipRes = $zip->open( $this->file ); $zipRes = $zip->open( $this->file );
if ( $zipRes ) { if ( $zipRes ) {
$content = $zip->getFromName( 'clone/config.txt' ); $content = $zip->getFromName( 'clone/config.txt' );
// $zip->deleteName('clone/config.txt'); // $zip->deleteName('clone/config.txt');
// $zip->deleteName('clone/'); // $zip->deleteName('clone/');
$zip->close(); $zip->close();
return $content; return $content;
@ -388,7 +388,7 @@ class MainWP_Clone_Install {
return false; return false;
} else { } else {
//use pclzip // use pclzip
$zip = new PclZip( $this->file ); $zip = new PclZip( $this->file );
$content = $zip->extract( PCLZIP_OPT_BY_NAME, 'clone/config.txt', $content = $zip->extract( PCLZIP_OPT_BY_NAME, 'clone/config.txt',
PCLZIP_OPT_EXTRACT_AS_STRING ); PCLZIP_OPT_EXTRACT_AS_STRING );
@ -484,8 +484,8 @@ class MainWP_Clone_Install {
* @return bool * @return bool
*/ */
public function extractZipConsoleBackup() { public function extractZipConsoleBackup() {
//todo implement // todo implement
//system('zip'); // system('zip');
return false; return false;
} }

View file

@ -50,7 +50,7 @@ class MainWP_Clone {
$ajaxPosts = array(); $ajaxPosts = array();
} }
//If already processed, just quit! // If already processed, just quit!
if ( isset( $ajaxPosts[ $action ] ) && ( $ajaxPosts[ $action ] == $_POST['dts'] ) ) { if ( isset( $ajaxPosts[ $action ] ) && ( $ajaxPosts[ $action ] == $_POST['dts'] ) ) {
die( json_encode( array( 'error' => __( 'Double request!', 'mainwp-child' ) ) ) ); die( json_encode( array( 'error' => __( 'Double request!', 'mainwp-child' ) ) ) );
} }
@ -1205,7 +1205,7 @@ class MainWP_Clone {
$key = $siteToClone['extauth']; $key = $siteToClone['extauth'];
MainWP_Helper::endSession(); MainWP_Helper::endSession();
//Send request to the childsite! // Send request to the childsite!
global $wp_version; global $wp_version;
$method = ( function_exists( 'gzopen' ) ? 'tar.gz' : 'zip' ); $method = ( function_exists( 'gzopen' ) ? 'tar.gz' : 'zip' );
$result = MainWP_Helper::fetchUrl( $url, array( $result = MainWP_Helper::fetchUrl( $url, array(
@ -1257,7 +1257,7 @@ class MainWP_Clone {
$key = $siteToClone['extauth']; $key = $siteToClone['extauth'];
MainWP_Helper::endSession(); MainWP_Helper::endSession();
//Send request to the childsite! // Send request to the childsite!
$result = MainWP_Helper::fetchUrl( $url, array( $result = MainWP_Helper::fetchUrl( $url, array(
'cloneFunc' => 'createCloneBackupPoll', 'cloneFunc' => 'createCloneBackupPoll',
'key' => $key, 'key' => $key,
@ -1273,7 +1273,7 @@ class MainWP_Clone {
} catch ( Exception $e ) { } catch ( Exception $e ) {
$output = array( 'error' => $e->getMessage() ); $output = array( 'error' => $e->getMessage() );
} }
//Return size in kb // Return size in kb
die( json_encode( $output ) ); die( json_encode( $output ) );
} }
@ -1284,7 +1284,7 @@ class MainWP_Clone {
if ( ! isset( $_POST['file'] ) ) { if ( ! isset( $_POST['file'] ) ) {
throw new Exception( __( 'No download link given', 'mainwp-child' ) ); throw new Exception( __( 'No download link given', 'mainwp-child' ) );
} }
// if (!isset($_POST['siteId'])) throw new Exception(__('No site given','mainwp-child')); // if (!isset($_POST['siteId'])) throw new Exception(__('No site given','mainwp-child'));
$file = $_POST['file']; $file = $_POST['file'];
if ( isset( $_POST['siteId'] ) ) { if ( isset( $_POST['siteId'] ) ) {
@ -1304,7 +1304,7 @@ class MainWP_Clone {
$url = $file; $url = $file;
} }
MainWP_Helper::endSession(); MainWP_Helper::endSession();
//Send request to the childsite! // Send request to the childsite!
$split = explode( '=', $file ); $split = explode( '=', $file );
$file = urldecode( $split[ count( $split ) - 1 ] ); $file = urldecode( $split[ count( $split ) - 1 ] );
$filename = 'download-' . basename( $file ); $filename = 'download-' . basename( $file );
@ -1342,7 +1342,7 @@ class MainWP_Clone {
$output = array( 'done' => $filename ); $output = array( 'done' => $filename );
//Delete backup on child // Delete backup on child
try { try {
if ( isset( $_POST['siteId'] ) ) { if ( isset( $_POST['siteId'] ) ) {
$siteId = $_POST['siteId']; $siteId = $_POST['siteId'];
@ -1392,7 +1392,7 @@ class MainWP_Clone {
} catch ( Exception $e ) { } catch ( Exception $e ) {
$output = array( 'error' => $e->getMessage() ); $output = array( 'error' => $e->getMessage() );
} }
//return size in kb // return size in kb
die( json_encode( $output ) ); die( json_encode( $output ) );
} }
@ -1429,10 +1429,10 @@ class MainWP_Clone {
} }
$testFull = true; $testFull = true;
} }
//return size in kb // return size in kb
$cloneInstall = new MainWP_Clone_Install( $file ); $cloneInstall = new MainWP_Clone_Install( $file );
//todo: RS: refactor to get those plugins after install (after .18 release) // todo: RS: refactor to get those plugins after install (after .18 release)
$cloneInstall->readConfigurationFile(); $cloneInstall->readConfigurationFile();
$plugins = get_option( 'mainwp_temp_clone_plugins' ); $plugins = get_option( 'mainwp_temp_clone_plugins' );
@ -1454,14 +1454,14 @@ class MainWP_Clone {
$cloneInstall->install(); $cloneInstall->install();
// $cloneInstall->update_option('mainwp_child_pubkey', $pubkey); // $cloneInstall->update_option('mainwp_child_pubkey', $pubkey);
// $cloneInstall->update_option('mainwp_child_uniqueId', $uniqueId); // $cloneInstall->update_option('mainwp_child_uniqueId', $uniqueId);
// $cloneInstall->update_option('mainwp_child_server', $server); // $cloneInstall->update_option('mainwp_child_server', $server);
// $cloneInstall->update_option('mainwp_child_nonce', $nonce); // $cloneInstall->update_option('mainwp_child_nonce', $nonce);
// $cloneInstall->update_option('mainwp_child_nossl', $nossl); // $cloneInstall->update_option('mainwp_child_nossl', $nossl);
// $cloneInstall->update_option('mainwp_child_nossl_key', $nossl_key); // $cloneInstall->update_option('mainwp_child_nossl_key', $nossl_key);
// $cloneInstall->update_option('mainwp_child_clone_sites', $sitesToClone); // $cloneInstall->update_option('mainwp_child_clone_sites', $sitesToClone);
// $cloneInstall->update_option('mainwp_child_clone_permalink', true); // $cloneInstall->update_option('mainwp_child_clone_permalink', true);
// to fix update values // to fix update values
delete_option('mainwp_child_pubkey'); delete_option('mainwp_child_pubkey');
@ -1533,14 +1533,14 @@ class MainWP_Clone {
delete_option( 'mainwp_temp_clone_themes' ); delete_option( 'mainwp_temp_clone_themes' );
} }
$output = array( 'result' => 'ok' ); $output = array( 'result' => 'ok' );
//todo: remove old tables if other prefix? // todo: remove old tables if other prefix?
wp_logout(); wp_logout();
wp_set_current_user( 0 ); wp_set_current_user( 0 );
} catch ( Exception $e ) { } catch ( Exception $e ) {
$output = array( 'error' => $e->getMessage() ); $output = array( 'error' => $e->getMessage() );
} }
//return size in kb // return size in kb
die( json_encode( $output ) ); die( json_encode( $output ) );
} }

View file

@ -20,10 +20,10 @@ class MainWP_Custom_Post_Type {
$error = error_get_last(); $error = error_get_last();
if ( isset( $error['type'] ) && E_ERROR === $error['type'] && isset( $error['message'] ) ) { if ( isset( $error['type'] ) && E_ERROR === $error['type'] && isset( $error['message'] ) ) {
$data = array( 'error' => 'MainWPChild fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ); $data = array( 'error' => 'MainWPChild fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] );
// die( '<mainwp>' . base64_encode( serialize( ) ) . '</mainwp>' ); // die( '<mainwp>' . base64_encode( serialize( ) ) . '</mainwp>' );
} else { } else {
$data = self::$information; $data = self::$information;
// die( '<mainwp>' . base64_encode( serialize( MainWP_Custom_Post_Type::$information ) ) . '</mainwp>' ); // die( '<mainwp>' . base64_encode( serialize( MainWP_Custom_Post_Type::$information ) ) . '</mainwp>' );
} }
if ( isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] ) { if ( isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] ) {
@ -174,7 +174,7 @@ class MainWP_Custom_Post_Type {
return array( 'error' => __( 'Please install', $this->plugin_translate ) . ' ' . $data_insert['post_type'] . ' ' . __( 'on child and try again', $this->plugin_translate ) ); return array( 'error' => __( 'Please install', $this->plugin_translate ) . ' ' . $data_insert['post_type'] . ' ' . __( 'on child and try again', $this->plugin_translate ) );
} }
//$data_insert['post_content'] = $this->_search_images( $data_insert['post_content'], $data['extras']['upload_dir'] ); // $data_insert['post_content'] = $this->_search_images( $data_insert['post_content'], $data['extras']['upload_dir'] );
$is_woocomerce = false; $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' ) ) {
@ -303,7 +303,7 @@ class MainWP_Custom_Post_Type {
} }
} }
//Insert post terms except categories // Insert post terms except categories
if ( ! empty( $data['terms'] ) && is_array( $data['terms'] ) ) { if ( ! empty( $data['terms'] ) && is_array( $data['terms'] ) ) {
foreach ( $data['terms'] as $key ) { foreach ( $data['terms'] as $key ) {
if ( ! taxonomy_exists( $key['taxonomy'] ) ) { if ( ! taxonomy_exists( $key['taxonomy'] ) ) {

View file

@ -13,7 +13,7 @@ class MainWP_Debug {
$start = microtime( true ); $start = microtime( true );
if ( 'fullbackup' == $_GET['mainwpdebug'] ) { if ( 'fullbackup' == $_GET['mainwpdebug'] ) {
//Full backup // Full backup
$_POST['type'] = 'full'; $_POST['type'] = 'full';
$_POST['excludebackup'] = '1'; $_POST['excludebackup'] = '1';
$_POST['excludecache'] = '1'; $_POST['excludecache'] = '1';

View file

@ -161,16 +161,16 @@ class MainWP_Helper {
if ( ! is_array($img_data) ) { if ( ! is_array($img_data) ) {
$img_data = array(); $img_data = array();
} }
include_once ABSPATH . 'wp-admin/includes/file.php'; //Contains download_url include_once ABSPATH . 'wp-admin/includes/file.php'; // Contains download_url
$upload_dir = wp_upload_dir(); $upload_dir = wp_upload_dir();
//Download $img_url // Download $img_url
$temporary_file = download_url( $img_url ); $temporary_file = download_url( $img_url );
if ( is_wp_error( $temporary_file ) ) { if ( is_wp_error( $temporary_file ) ) {
throw new Exception( 'Error: ' . $temporary_file->get_error_message() ); throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
} else { } else {
$filename = basename( $img_url ); $filename = basename( $img_url );
$local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . $filename; //Local name $local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . $filename; // Local name
$local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path ); $local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
$gen_unique_fn = true; $gen_unique_fn = true;
@ -227,7 +227,7 @@ class MainWP_Helper {
$moved = @rename( $temporary_file, $local_img_path ); $moved = @rename( $temporary_file, $local_img_path );
if ( $moved ) { if ( $moved ) {
$wp_filetype = wp_check_filetype( basename( $img_url ), null ); //Get the filetype to set the mimetype $wp_filetype = wp_check_filetype( basename( $img_url ), null ); // Get the filetype to set the mimetype
$attachment = array( $attachment = array(
'post_mime_type' => $wp_filetype['type'], '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_title' => isset( $img_data['title'] ) && ! empty( $img_data['title'] ) ? $img_data['title'] : preg_replace( '/\.[^.]+$/', '', basename( $img_url ) ),
@ -242,10 +242,10 @@ class MainWP_Helper {
$attachment['post_parent'] = $parent_id; $attachment['post_parent'] = $parent_id;
} }
$attach_id = wp_insert_attachment( $attachment, $local_img_path ); //Insert the image in the database $attach_id = wp_insert_attachment( $attachment, $local_img_path ); // Insert the image in the database
require_once ABSPATH . 'wp-admin/includes/image.php'; require_once ABSPATH . 'wp-admin/includes/image.php';
$attach_data = wp_generate_attachment_metadata( $attach_id, $local_img_path ); $attach_data = wp_generate_attachment_metadata( $attach_id, $local_img_path );
wp_update_attachment_metadata( $attach_id, $attach_data ); //Update generated metadata wp_update_attachment_metadata( $attach_id, $attach_data ); // Update generated metadata
if ( isset( $img_data['alt'] ) && ! empty( $img_data['alt'] ) ) { if ( isset( $img_data['alt'] ) && ! empty( $img_data['alt'] ) ) {
update_post_meta( $attach_id, '_wp_attachment_image_alt', $img_data['alt'] ); update_post_meta( $attach_id, '_wp_attachment_image_alt', $img_data['alt'] );
} }
@ -281,7 +281,7 @@ class MainWP_Helper {
$file_name = sanitize_file_name( $file_name ); $file_name = sanitize_file_name( $file_name );
} }
$full_file_name = $path . DIRECTORY_SEPARATOR . $file_name; //Local name $full_file_name = $path . DIRECTORY_SEPARATOR . $file_name; // Local name
$response = wp_remote_get( $file_url, array( $response = wp_remote_get( $file_url, array(
'timeout' => 10 * 60 * 60, 'timeout' => 10 * 60 * 60,
@ -365,9 +365,9 @@ class MainWP_Helper {
// current user may be connected admin or alternative admin // current user may be connected admin or alternative admin
$current_uid = $current_user->ID; $current_uid = $current_user->ID;
//Set up a new post (adding addition information) // Set up a new post (adding addition information)
//$usr = get_user_by( 'login', $_POST['user'] ); // $usr = get_user_by( 'login', $_POST['user'] );
//$new_post['post_author'] = $current_user->ID; // $new_post['post_author'] = $current_user->ID;
$is_robot_post = false; // retirement soon $is_robot_post = false; // retirement soon
if ( isset( $_POST['isMainWPRobot'] ) && ! empty( $_POST['isMainWPRobot'] ) ) { if ( isset( $_POST['isMainWPRobot'] ) && ! empty( $_POST['isMainWPRobot'] ) ) {
@ -411,11 +411,11 @@ class MainWP_Helper {
if ( isset( $new_post['post_date_gmt'] ) && ! empty( $new_post['post_date_gmt'] ) && $new_post['post_date_gmt'] != '0000-00-00 00:00:00' ) { if ( isset( $new_post['post_date_gmt'] ) && ! empty( $new_post['post_date_gmt'] ) && $new_post['post_date_gmt'] != '0000-00-00 00:00:00' ) {
$post_date_timestamp = strtotime( $new_post['post_date_gmt'] ) + get_option( 'gmt_offset' ) * 60 * 60; $post_date_timestamp = strtotime( $new_post['post_date_gmt'] ) + get_option( 'gmt_offset' ) * 60 * 60;
$new_post['post_date'] = date( 'Y-m-d H:i:s', $post_date_timestamp ); $new_post['post_date'] = date( 'Y-m-d H:i:s', $post_date_timestamp );
//$new_post['post_status'] = ( $post_date_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future'; // $new_post['post_status'] = ( $post_date_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future';
} }
// else { // else {
// $new_post['post_status'] = 'publish'; // $new_post['post_status'] = 'publish';
// } // }
} }
$wpr_options = isset( $_POST['wpr_options'] ) ? $_POST['wpr_options'] : array(); $wpr_options = isset( $_POST['wpr_options'] ) ? $_POST['wpr_options'] : array();
@ -442,11 +442,11 @@ class MainWP_Helper {
$check_image_existed = true; // if editing post then will check if image existed $check_image_existed = true; // if editing post then will check if image existed
} }
//Search for all the images added to the new post // Search for all the images added to the new post
//some images have a href tag to click to navigate to the image.. we need to replace this too // some images have a href tag to click to navigate to the image.. we need to replace this too
$foundMatches = preg_match_all( '/(<a[^>]+href=\"(.*?)\"[^>]*>)?(<img[^>\/]*src=\"((.*?)(png|gif|jpg|jpeg))\")/ix', $new_post['post_content'], $matches, PREG_SET_ORDER ); $foundMatches = preg_match_all( '/(<a[^>]+href=\"(.*?)\"[^>]*>)?(<img[^>\/]*src=\"((.*?)(png|gif|jpg|jpeg))\")/ix', $new_post['post_content'], $matches, PREG_SET_ORDER );
if ( ( $foundMatches > 0 || ( $is_robot_post && isset( $wpr_options['wpr_save_images'] ) && 'Yes' === $wpr_options['wpr_save_images'] ) ) && ( ! $is_ezine_post ) ) { if ( ( $foundMatches > 0 || ( $is_robot_post && isset( $wpr_options['wpr_save_images'] ) && 'Yes' === $wpr_options['wpr_save_images'] ) ) && ( ! $is_ezine_post ) ) {
//We found images, now to download them so we can start balbal // We found images, now to download them so we can start balbal
foreach ( $matches as $match ) { foreach ( $matches as $match ) {
$hrefLink = $match[2]; $hrefLink = $match[2];
$imgUrl = $match[4]; $imgUrl = $match[4];
@ -476,12 +476,12 @@ class MainWP_Helper {
$new_post['post_content'] = str_replace( $serverHref, $replaceServerHref, $new_post['post_content'] ); $new_post['post_content'] = str_replace( $serverHref, $replaceServerHref, $new_post['post_content'] );
} }
// To fix bug // To fix bug
// else if ( strpos( $hrefLink, 'http' ) !== false ) { // else if ( strpos( $hrefLink, 'http' ) !== false ) {
// $lnkToReplace = dirname( $hrefLink ); // $lnkToReplace = dirname( $hrefLink );
// if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) { // if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) {
// $new_post['post_content'] = str_replace( $lnkToReplace, $linkToReplaceWith, $new_post['post_content'] ); // $new_post['post_content'] = str_replace( $lnkToReplace, $linkToReplaceWith, $new_post['post_content'] );
// } // }
// } // }
} }
$lnkToReplace = dirname( $imgUrl ); $lnkToReplace = dirname( $imgUrl );
if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) { if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) {
@ -502,7 +502,7 @@ class MainWP_Helper {
foreach ($post_gallery_images as $gallery) { foreach ($post_gallery_images as $gallery) {
if (isset($gallery['src'])) { if (isset($gallery['src'])) {
try { try {
$upload = self::uploadImage( $gallery['src'], $gallery ); //Upload image to WP $upload = self::uploadImage( $gallery['src'], $gallery ); // Upload image to WP
if ( null !== $upload ) { if ( null !== $upload ) {
$replaceAttachedIds[ $gallery['id'] ] = $upload['id']; $replaceAttachedIds[ $gallery['id'] ] = $upload['id'];
} }
@ -563,8 +563,8 @@ class MainWP_Helper {
} }
$random_timestamp = rand( $random_date_from, $random_date_to ); $random_timestamp = rand( $random_date_from, $random_date_to );
// $post_status = ( $random_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future'; // $post_status = ( $random_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future';
// $new_post['post_status'] = $post_status; // $new_post['post_status'] = $post_status;
$new_post['post_date'] = date( 'Y-m-d H:i:s', $random_timestamp ); $new_post['post_date'] = date( 'Y-m-d H:i:s', $random_timestamp );
} }
} }
@ -573,7 +573,7 @@ class MainWP_Helper {
$new_post['tags_input'] = $post_tags; $new_post['tags_input'] = $post_tags;
} }
//Save the post to the wp // Save the post to the wp
remove_filter( 'content_save_pre', 'wp_filter_post_kses' ); // to fix brake scripts or html remove_filter( 'content_save_pre', 'wp_filter_post_kses' ); // to fix brake scripts or html
$post_status = $new_post['post_status']; $post_status = $new_post['post_status'];
$new_post['post_status'] = 'auto-draft'; // child reports: to logging as created post $new_post['post_status'] = 'auto-draft'; // child reports: to logging as created post
@ -590,7 +590,7 @@ class MainWP_Helper {
$new_post_id = wp_insert_post( $new_post, $wp_error ); $new_post_id = wp_insert_post( $new_post, $wp_error );
//Show errors if something went wrong // Show errors if something went wrong
if ( is_wp_error( $wp_error ) ) { if ( is_wp_error( $wp_error ) ) {
return $wp_error->get_error_message(); return $wp_error->get_error_message();
} }
@ -616,7 +616,7 @@ class MainWP_Helper {
$seo_ext_activated = true; $seo_ext_activated = true;
} }
//Set custom fields // Set custom fields
$not_allowed = array( $not_allowed = array(
'_slug', '_slug',
'_tags', '_tags',
@ -700,9 +700,9 @@ class MainWP_Helper {
// upload image if it on the server // upload image if it on the server
if ( ! empty( $_seo_opengraph_image ) && strpos( $_seo_opengraph_image, $_server_domain ) !== false ) { if ( ! empty( $_seo_opengraph_image ) && strpos( $_seo_opengraph_image, $_server_domain ) !== false ) {
try { try {
$upload = self::uploadImage( $_seo_opengraph_image ); //Upload image to WP $upload = self::uploadImage( $_seo_opengraph_image ); // Upload image to WP
if ( null !== $upload ) { if ( null !== $upload ) {
update_post_meta( $new_post_id, WPSEO_Meta::$meta_prefix . 'opengraph-image', $upload['url'] ); //Add the image to the post! update_post_meta( $new_post_id, WPSEO_Meta::$meta_prefix . 'opengraph-image', $upload['url'] ); // Add the image to the post!
} }
} catch ( Exception $e ) { } catch ( Exception $e ) {
@ -711,8 +711,8 @@ class MainWP_Helper {
} }
} }
//If categories exist, create them (second parameter of wp_create_categories adds the categories to the post) // If categories exist, create them (second parameter of wp_create_categories adds the categories to the post)
include_once ABSPATH . 'wp-admin/includes/taxonomy.php'; //Contains wp_create_categories include_once ABSPATH . 'wp-admin/includes/taxonomy.php'; // Contains wp_create_categories
if ( isset( $post_category ) && '' !== $post_category ) { if ( isset( $post_category ) && '' !== $post_category ) {
$categories = explode( ',', $post_category ); $categories = explode( ',', $post_category );
if ( count( $categories ) > 0 ) { if ( count( $categories ) > 0 ) {
@ -733,12 +733,12 @@ class MainWP_Helper {
} }
$featured_image_exist = false; $featured_image_exist = false;
//If featured image exists - set it // If featured image exists - set it
if ( null !== $post_featured_image ) { if ( null !== $post_featured_image ) {
try { try {
$upload = self::uploadImage( $post_featured_image, array(), $check_image_existed, $new_post_id); //Upload image to WP $upload = self::uploadImage( $post_featured_image, array(), $check_image_existed, $new_post_id); // Upload image to WP
if ( null !== $upload ) { if ( null !== $upload ) {
update_post_meta( $new_post_id, '_thumbnail_id', $upload['id'] ); //Add the thumbnail to the post! update_post_meta( $new_post_id, '_thumbnail_id', $upload['id'] ); // Add the thumbnail to the post!
$featured_image_exist = true; $featured_image_exist = true;
if (isset($others['featured_image_data'])) { if (isset($others['featured_image_data'])) {
$_image_data = $others['featured_image_data']; $_image_data = $others['featured_image_data'];
@ -949,9 +949,9 @@ class MainWP_Helper {
if ( empty( $wp_filesystem ) ) { if ( empty( $wp_filesystem ) ) {
ob_start(); ob_start();
// if ( file_exists( ABSPATH . '/wp-admin/includes/deprecated.php' ) ) { // if ( file_exists( ABSPATH . '/wp-admin/includes/deprecated.php' ) ) {
// include_once( ABSPATH . '/wp-admin/includes/deprecated.php' ); // include_once( ABSPATH . '/wp-admin/includes/deprecated.php' );
// } // }
if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) {
include_once ABSPATH . '/wp-admin/includes/screen.php'; include_once ABSPATH . '/wp-admin/includes/screen.php';
} }
@ -1049,7 +1049,7 @@ class MainWP_Helper {
} }
public static function _fetchUrl( $url, $postdata ) { public static function _fetchUrl( $url, $postdata ) {
//$agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'; // $agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)';
$agent = 'Mozilla/5.0 (compatible; MainWP-Child/' . MainWP_Child::$version . '; +http://mainwp.com)'; $agent = 'Mozilla/5.0 (compatible; MainWP-Child/' . MainWP_Child::$version . '; +http://mainwp.com)';
if ( ! is_array( $postdata )) { if ( ! is_array( $postdata )) {
@ -1075,7 +1075,7 @@ class MainWP_Helper {
} elseif ( preg_match( '/<mainwp>(.*)<\/mainwp>/', $data, $results ) > 0 ) { } elseif ( preg_match( '/<mainwp>(.*)<\/mainwp>/', $data, $results ) > 0 ) {
$result = $results[1]; $result = $results[1];
$result_base = base64_decode( $result ); $result_base = base64_decode( $result );
//$information = maybe_unserialize( $result_base ); // $information = maybe_unserialize( $result_base );
$information = json_decode( $result_base, true ); // it is json_encode result $information = json_decode( $result_base, true ); // it is json_encode result
return $information; return $information;

View file

@ -31,7 +31,7 @@ class MainWP_Keyword_Links {
if ( empty( $this->keyword_links ) ) { if ( empty( $this->keyword_links ) ) {
$this->keyword_links = array(); $this->keyword_links = array();
} }
//print_r($this->keyword_links); // print_r($this->keyword_links);
$this->siteurl = get_option( 'home' ); $this->siteurl = get_option( 'home' );
add_action( 'permalink_structure_changed', array( &$this, 'permalinkChanged' ), 10, 2 ); add_action( 'permalink_structure_changed', array( &$this, 'permalinkChanged' ), 10, 2 );
} }
@ -79,7 +79,7 @@ class MainWP_Keyword_Links {
$rules .= "RewriteEngine On\n"; $rules .= "RewriteEngine On\n";
$rules .= "RewriteBase $home_root\n"; $rules .= "RewriteBase $home_root\n";
//add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all) // add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
foreach ( $pRules as $match => $query ) { foreach ( $pRules as $match => $query ) {
// Apache 1.3 does not support the reluctant (non-greedy) modifier. // Apache 1.3 does not support the reluctant (non-greedy) modifier.
$match = str_replace( '.+?', '.+', $match ); $match = str_replace( '.+?', '.+', $match );
@ -131,9 +131,9 @@ class MainWP_Keyword_Links {
if ( empty( $redirection_folder ) ) { if ( empty( $redirection_folder ) ) {
$rules = $this->get_cloak_rules(); $rules = $this->get_cloak_rules();
$rules = $this->mod_rewrite_rules( $rules ); $rules = $this->mod_rewrite_rules( $rules );
//self::clear_htaccess(); // self::clear_htaccess();
} else { } else {
//Create rewrite ruler // Create rewrite ruler
$rules = $this->mod_rewrite_rules( array( $redirection_folder . '/' => 'index.php' ) ); $rules = $this->mod_rewrite_rules( array( $redirection_folder . '/' => 'index.php' ) );
} }
$home_path = ABSPATH; $home_path = ABSPATH;
@ -297,7 +297,7 @@ class MainWP_Keyword_Links {
if ( is_array( $specific_link ) && count( $specific_link ) > 0 ) { if ( is_array( $specific_link ) && count( $specific_link ) > 0 ) {
$specific_link = current( $specific_link ); $specific_link = current( $specific_link );
$specific_link->post_id = $post->ID; $specific_link->post_id = $post->ID;
//update_post_meta($post->ID, '_mainwp_kwl_specific_link_save', array($specific_link->id => $specific_link)); // update_post_meta($post->ID, '_mainwp_kwl_specific_link_save', array($specific_link->id => $specific_link));
update_post_meta( $post->ID, '_mainwp_kwl_specific_link_id', $specific_link->id ); update_post_meta( $post->ID, '_mainwp_kwl_specific_link_id', $specific_link->id );
if ( $this->set_link( $specific_link->id, $specific_link ) ) { if ( $this->set_link( $specific_link->id, $specific_link ) ) {
update_post_meta( $post->ID, '_mainwp_kwl_specific_link', '<saved>' ); update_post_meta( $post->ID, '_mainwp_kwl_specific_link', '<saved>' );
@ -312,11 +312,11 @@ class MainWP_Keyword_Links {
} }
// print_r($this->keyword_links); // print_r($this->keyword_links);
// if ($post->ID == 751) { // if ($post->ID == 751) {
// //print_r($links); // print_r($links);
// $custom = get_post_custom($post->ID); // $custom = get_post_custom($post->ID);
// print_r($custom); // print_r($custom);
// } // }
if ( empty( $links ) ) { if ( empty( $links ) ) {
return $content; return $content;
@ -343,10 +343,10 @@ class MainWP_Keyword_Links {
$this->link_exact_match = $link->exact_match; $this->link_exact_match = $link->exact_match;
$this->link_case_sensitive = $link->case_sensitive; $this->link_case_sensitive = $link->case_sensitive;
$keywords = $this->explode_multi( $link->keyword ); $keywords = $this->explode_multi( $link->keyword );
//usort( $keywords, create_function( '$a,$b', 'return strlen($a)<strlen($b);' ) ); // 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'; $replace_cs = $link->case_sensitive ? 's' : 'is';
//print_r($keywords); // print_r($keywords);
foreach ( $keywords as $keyword ) { foreach ( $keywords as $keyword ) {
$keyword = trim( $keyword ); $keyword = trim( $keyword );
if ( empty( $keyword ) ) { if ( empty( $keyword ) ) {
@ -361,15 +361,15 @@ class MainWP_Keyword_Links {
$keyword = preg_replace( '/([$^\/?+.*\]\[)(}{])/is', '\\\\\1', $keyword ); $keyword = preg_replace( '/([$^\/?+.*\]\[)(}{])/is', '\\\\\1', $keyword );
if ( ( $link->case_sensitive && strpos( $content, $keyword ) !== false ) || ( ! $link->case_sensitive && stripos( $content, $keyword ) !== false ) ) { if ( ( $link->case_sensitive && strpos( $content, $keyword ) !== false ) || ( ! $link->case_sensitive && stripos( $content, $keyword ) !== false ) ) {
//Replace keyword in H tag // Replace keyword in H tag
if ( $this->get_option( 'replace_keyword_in_h_tag' ) ) { if ( $this->get_option( 'replace_keyword_in_h_tag' ) ) {
//$content = preg_replace_callback('/(<a[^>]*>.*?'.$keyword.'.*?<\/a>|<[^>]*'.$keyword.'[^>]*>|\{[^}]*'.$keyword.'[^}]*\}|\w*('.$keyword.')\w*)/is', array(&$this, 'keyword_mark'), $content); // $content = preg_replace_callback('/(<a[^>]*>.*?'.$keyword.'.*?<\/a>|<[^>]*'.$keyword.'[^>]*>|\{[^}]*'.$keyword.'[^}]*\}|\w*('.$keyword.')\w*)/is', array(&$this, 'keyword_mark'), $content);
$content = preg_replace_callback( '/(<a[^>]*>[^<]*?' . $keyword . '[^<]*?<\/a>|<[^>]*' . $keyword . '[^>]*>|\{[^\}]*' . $keyword . '[^\}]*\}|\w*(' . $keyword . ')\w*)/' . $replace_cs, array( $content = preg_replace_callback( '/(<a[^>]*>[^<]*?' . $keyword . '[^<]*?<\/a>|<[^>]*' . $keyword . '[^>]*>|\{[^\}]*' . $keyword . '[^\}]*\}|\w*(' . $keyword . ')\w*)/' . $replace_cs, array(
&$this, &$this,
'keyword_mark', 'keyword_mark',
), $content ); ), $content );
} else { } else {
//$content = preg_replace_callback('/(<h[123456][^>]*>.*?'.$keyword.'.*?<\/h[123456]>|<a[^>]*>.*?'.$keyword.'.*?<\/a>|<[^>]*'.$keyword.'[^>]*>|\{[^}]*'.$keyword.'[^}]*\}|\w*('.$keyword.')\w*)/is', array(&$this, 'keyword_mark'), $content); // $content = preg_replace_callback('/(<h[123456][^>]*>.*?'.$keyword.'.*?<\/h[123456]>|<a[^>]*>.*?'.$keyword.'.*?<\/a>|<[^>]*'.$keyword.'[^>]*>|\{[^}]*'.$keyword.'[^}]*\}|\w*('.$keyword.')\w*)/is', array(&$this, 'keyword_mark'), $content);
$content = preg_replace_callback( '/(<h[123456][^>]*>[^<]*?' . $keyword . '[^<]*?<\/h[123456]>|<a[^>]*>[^<]*?' . $keyword . '[^<]*?<\/a>|<[^>]*' . $keyword . '[^>]*>|\{[^\}]*' . $keyword . '[^\}]*\}|\w*(' . $keyword . ')\w*)/' . $replace_cs, array( $content = preg_replace_callback( '/(<h[123456][^>]*>[^<]*?' . $keyword . '[^<]*?<\/h[123456]>|<a[^>]*>[^<]*?' . $keyword . '[^<]*?<\/a>|<[^>]*' . $keyword . '[^>]*>|\{[^\}]*' . $keyword . '[^\}]*\}|\w*(' . $keyword . ')\w*)/' . $replace_cs, array(
&$this, &$this,
'keyword_mark', 'keyword_mark',
@ -378,7 +378,7 @@ class MainWP_Keyword_Links {
} }
} }
} }
//$content = preg_replace_callback('/\{MAINWP_LINK +HREF="(.*?)" +TARGET="(.*?)" +REL="(.*?)" +LINK-ID="(.*?)" +CLASS="(.*?)" +TEXT="(.*?)" *\}/is', array(&$this, 'keyword_replace'), $content); // $content = preg_replace_callback('/\{MAINWP_LINK +HREF="(.*?)" +TARGET="(.*?)" +REL="(.*?)" +LINK-ID="(.*?)" +CLASS="(.*?)" +TEXT="(.*?)" *\}/is', array(&$this, 'keyword_replace'), $content);
$content = preg_replace_callback( '/\{MAINWP_LINK +HREF="(.*?)" +TARGET="(.*?)" +REL="(.*?)" +LINK-ID="(.*?)" +CLASS="(.*?)" +TEXT="(.*?)" +FULL_TEXT="(.*?)" *\}/is', array( $content = preg_replace_callback( '/\{MAINWP_LINK +HREF="(.*?)" +TARGET="(.*?)" +REL="(.*?)" +LINK-ID="(.*?)" +CLASS="(.*?)" +TEXT="(.*?)" +FULL_TEXT="(.*?)" *\}/is', array(
&$this, &$this,
'keyword_replace', 'keyword_replace',
@ -415,19 +415,19 @@ class MainWP_Keyword_Links {
$this->link_count_each_temp --; $this->link_count_each_temp --;
} }
// if (isset($this->link_temp->type) && $this->link_temp->type == 'post_type') { // if (isset($this->link_temp->type) && $this->link_temp->type == 'post_type') {
//// $post = get_post($this->link_temp->id); // $post = get_post($this->link_temp->id);
//// if ($post) { // if ($post) {
//// $disable_linking = $this->get_option('disable_linking_automatically', array()); // $disable_linking = $this->get_option('disable_linking_automatically', array());
//// if (in_array($post->post_name, $disable_linking[$post->post_type])) // if (in_array($post->post_name, $disable_linking[$post->post_type]))
//// return $matches[1]; // do not link to this post // return $matches[1]; // do not link to this post
//// } // }
// $link_target = get_post_meta($this->link_temp->id, '_mainwp_kl_link_newtab', true); // $link_target = get_post_meta($this->link_temp->id, '_mainwp_kl_link_newtab', true);
// $this->link_temp->link_target = ( $link_target != -1 && $link_target == 1 ? '_blank' : '' ); // $this->link_temp->link_target = ( $link_target != -1 && $link_target == 1 ? '_blank' : '' );
// $link_rel = get_post_meta($this->link_temp->id, '_mainwp_kl_link_nofollow', true); // $link_rel = get_post_meta($this->link_temp->id, '_mainwp_kl_link_nofollow', true);
// $this->link_temp->link_rel = ( $link_rel != -1 && $link_rel == 1 ? 'nofollow' : '' ); // $this->link_temp->link_rel = ( $link_rel != -1 && $link_rel == 1 ? 'nofollow' : '' );
// $this->link_temp->link_class = get_post_meta($this->link_temp->id, '_mainwp_kl_link_class', true); // $this->link_temp->link_class = get_post_meta($this->link_temp->id, '_mainwp_kl_link_class', true);
// } // }
if ( '-1' !== $this->link_temp->link_target ) { if ( '-1' !== $this->link_temp->link_target ) {
$target = $this->link_temp->link_target; $target = $this->link_temp->link_target;
} else { } else {
@ -456,7 +456,7 @@ class MainWP_Keyword_Links {
$class .= ' kwl-regular-link'; $class .= ' kwl-regular-link';
} }
//return '{MAINWP_LINK HREF="' . ( $this->link_temp->cloak_path ? $this->siteurl . $redirection_folder . '/' . $this->link_temp->cloak_path : $this->link_temp->destination_url) . '" TARGET="' . $target . '" REL="' . $rel . '" LINK-ID="' . (isset($this->link_temp->id) ? $this->link_temp->id : 0) . '" CLASS="' . $class . '" TEXT="' . $matches[1] . '"}'; // return '{MAINWP_LINK HREF="' . ( $this->link_temp->cloak_path ? $this->siteurl . $redirection_folder . '/' . $this->link_temp->cloak_path : $this->link_temp->destination_url) . '" TARGET="' . $target . '" REL="' . $rel . '" LINK-ID="' . (isset($this->link_temp->id) ? $this->link_temp->id : 0) . '" CLASS="' . $class . '" TEXT="' . $matches[1] . '"}';
return '{MAINWP_LINK HREF="' . ( $this->link_temp->cloak_path ? $this->siteurl . $redirection_folder . '/' . $this->link_temp->cloak_path : $this->link_temp->destination_url ) . '" TARGET="' . $target . '" REL="' . $rel . '" LINK-ID="' . ( isset( $this->link_temp->id ) ? $this->link_temp->id : 0 ) . '" CLASS="' . $class . '" TEXT="' . $matches[2] . '" FULL_TEXT="' . $matches[1] . '"}'; return '{MAINWP_LINK HREF="' . ( $this->link_temp->cloak_path ? $this->siteurl . $redirection_folder . '/' . $this->link_temp->cloak_path : $this->link_temp->destination_url ) . '" TARGET="' . $target . '" REL="' . $rel . '" LINK-ID="' . ( isset( $this->link_temp->id ) ? $this->link_temp->id : 0 ) . '" CLASS="' . $class . '" TEXT="' . $matches[2] . '" FULL_TEXT="' . $matches[1] . '"}';
} }
@ -483,16 +483,16 @@ class MainWP_Keyword_Links {
$post = get_post( $post_id ); $post = get_post( $post_id );
} }
$links = array(); $links = array();
// $disable_add_links = $this->get_option('disable_add_links_automatically'); // $disable_add_links = $this->get_option('disable_add_links_automatically');
// // if disabled add links automatically in this post, avoid // if disabled add links automatically in this post, avoid
// if (in_array($post->post_name, (array) $disable_add_links[$post->post_type])) { // if (in_array($post->post_name, (array) $disable_add_links[$post->post_type])) {
// return $links; // return $links;
// } // }
// Check if this post was disabled with this function, come back // Check if this post was disabled with this function, come back
// $disable = get_post_meta($post->ID, '_mainwp_kl_disable', true); // $disable = get_post_meta($post->ID, '_mainwp_kl_disable', true);
// if ($disable == 1) // if ($disable == 1)
// return $links; // return $links;
// count replace max and max keyword allowed. // count replace max and max keyword allowed.
$replace_max = intval( $this->get_option( 'replace_max' ) ); $replace_max = intval( $this->get_option( 'replace_max' ) );
$replace_max_keyword = intval( $this->get_option( 'replace_max_keyword' ) ); $replace_max_keyword = intval( $this->get_option( 'replace_max_keyword' ) );
@ -514,7 +514,7 @@ class MainWP_Keyword_Links {
} else { } else {
$links_post_type = (array) $this->get_post_keywords( $post_type ); $links_post_type = (array) $this->get_post_keywords( $post_type );
} }
//print_r($links_post_type); // print_r($links_post_type);
if ( count( $links_post_type ) > 0 ) { if ( count( $links_post_type ) > 0 ) {
$links = array_merge( $links, $links_post_type ); $links = array_merge( $links, $links_post_type );
} }
@ -557,7 +557,7 @@ class MainWP_Keyword_Links {
$join = "JOIN $wpdb->term_relationships tr ON tr.object_id = p.ID"; $join = "JOIN $wpdb->term_relationships tr ON tr.object_id = p.ID";
$where = " AND (tr.term_taxonomy_id = '" . implode( "' OR tr.term_taxonomy_id = '", $cats ) . "')"; $where = " AND (tr.term_taxonomy_id = '" . implode( "' OR tr.term_taxonomy_id = '", $cats ) . "')";
} }
//$results = $wpdb->get_results(sprintf("SELECT * FROM $wpdb->posts as p LEFT JOIN $wpdb->postmeta as pm ON p.ID=pm.post_id $join WHERE p.post_status='publish' AND p.post_type='%s' AND pm.meta_key='_mainwp_kl_post_keyword' $where", $post_type)); // $results = $wpdb->get_results(sprintf("SELECT * FROM $wpdb->posts as p LEFT JOIN $wpdb->postmeta as pm ON p.ID=pm.post_id $join WHERE p.post_status='publish' AND p.post_type='%s' AND pm.meta_key='_mainwp_kl_post_keyword' $where", $post_type));
$results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->posts as p $join WHERE p.post_status='publish' AND p.post_type= %s $where", $post_type ) ); $results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->posts as p $join WHERE p.post_status='publish' AND p.post_type= %s $where", $post_type ) );
$links = array(); $links = array();
if ( ! is_array( $results ) ) { if ( ! is_array( $results ) ) {
@ -573,12 +573,12 @@ class MainWP_Keyword_Links {
} }
$link = new stdClass(); $link = new stdClass();
// This is on-fly link so have not ID // This is on-fly link so have not ID
//$link->id = $result->ID; // $link->id = $result->ID;
$link->name = $result->post_title; $link->name = $result->post_title;
//if ($result->post_type == 'page') // if ($result->post_type == 'page')
// $link->destination_url = get_permalink($result->ID); // $link->destination_url = get_permalink($result->ID);
//else // else
// $link->destination_url = $result->guid; // $link->destination_url = $result->guid;
$link->destination_url = get_permalink( $result->ID ); $link->destination_url = get_permalink( $result->ID );
$link->cloak_path = ''; $link->cloak_path = '';
$link->keyword = ( 1 === (int) $this->get_option( 'post_match_title' ) ? $result->post_title : '' ); $link->keyword = ( 1 === (int) $this->get_option( 'post_match_title' ) ? $result->post_title : '' );
@ -625,7 +625,7 @@ class MainWP_Keyword_Links {
$redirection_folder = $this->get_option( 'redirection_folder', '' ); $redirection_folder = $this->get_option( 'redirection_folder', '' );
if ( ! empty( $redirection_folder ) ) { if ( ! empty( $redirection_folder ) ) {
//if the request doesn't' containt the redirection folder we will return immediately // if the request doesn't' containt the redirection folder we will return immediately
if ( strpos( $filter_request, $redirection_folder . '/' ) === false ) { if ( strpos( $filter_request, $redirection_folder . '/' ) === false ) {
return; return;
} }
@ -677,21 +677,21 @@ class MainWP_Keyword_Links {
} }
} }
// public function get_statistic() { // public function get_statistic() {
// global $wpdb; // global $wpdb;
// $link_id = $_POST['link_id']; // $link_id = $_POST['link_id'];
// if ($link_id) { // if ($link_id) {
// $stat_data = get_option('mainwp_kwl_statistic_data_' . $link_id, array()); // $stat_data = get_option('mainwp_kwl_statistic_data_' . $link_id, array());
// if ($stat_data) { // if ($stat_data) {
// $return['stat_data'] = $stat_data; // $return['stat_data'] = $stat_data;
// //$wpdb->query("UPDATE {$wpdb->prefix}options SET option_name = 'mainwp_kwl_statistic_data_done_" . $link_id . "' WHERE option_name = 'mainwp_kwl_statistic_data_" . $link_id . "'"); // $wpdb->query("UPDATE {$wpdb->prefix}options SET option_name = 'mainwp_kwl_statistic_data_done_" . $link_id . "' WHERE option_name = 'mainwp_kwl_statistic_data_" . $link_id . "'");
// update_option('mainwp_kwl_statistic_data_' . $link_id, ''); // update_option('mainwp_kwl_statistic_data_' . $link_id, '');
// } else // } else
// $return['stat_data'] = 'EMPTY'; // $return['stat_data'] = 'EMPTY';
// $return['status'] = 'SUCCESS'; // $return['status'] = 'SUCCESS';
// } // }
// return $return; // return $return;
// } // }
public function action() { public function action() {
$result = array(); $result = array();

View file

@ -5,9 +5,9 @@ class MainWP_Security {
self::remove_wp_version(); self::remove_wp_version();
self::remove_rsd(); self::remove_rsd();
self::remove_wlw(); self::remove_wlw();
// MainWP_Security::remove_core_update(); // MainWP_Security::remove_core_update();
// MainWP_Security::remove_plugin_update(); // MainWP_Security::remove_plugin_update();
// MainWP_Security::remove_theme_update(); // MainWP_Security::remove_theme_update();
self::remove_php_reporting(); self::remove_php_reporting();
self::remove_registered_versions(); self::remove_registered_versions();
self::remove_generator_version(); self::remove_generator_version();
@ -19,7 +19,7 @@ class MainWP_Security {
add_filter( 'script_loader_src', array( 'MainWP_Security', 'remove_theme_versions' ), PHP_INT_MAX ); add_filter( 'script_loader_src', array( 'MainWP_Security', 'remove_theme_versions' ), PHP_INT_MAX );
} }
//Prevent listing wp-content, wp-content/plugins, wp-content/themes, wp-content/uploads // Prevent listing wp-content, wp-content/plugins, wp-content/themes, wp-content/uploads
private static $listingDirectories = null; private static $listingDirectories = null;
private static function init_listingDirectories() { private static function init_listingDirectories() {
@ -66,7 +66,7 @@ class MainWP_Security {
return ! empty( $security ) && isset( $security[ $option ] ) && ( true === $security[ $option ] ); return ! empty( $security ) && isset( $security[ $option ] ) && ( true === $security[ $option ] );
} }
//Removed wp-version // Removed wp-version
public static function remove_wp_version_ok() { public static function remove_wp_version_ok() {
return ! ( has_action( 'wp_head', 'wp_generator' ) || has_filter( 'wp_head', 'wp_generator' ) ); return ! ( has_action( 'wp_head', 'wp_generator' ) || has_filter( 'wp_head', 'wp_generator' ) );
} }
@ -78,7 +78,7 @@ class MainWP_Security {
} }
} }
//Removed Really Simple Discovery meta tag // Removed Really Simple Discovery meta tag
public static function remove_rsd_ok() { public static function remove_rsd_ok() {
return ( ! has_action( 'wp_head', 'rsd_link' ) ); return ( ! has_action( 'wp_head', 'rsd_link' ) );
} }
@ -89,7 +89,7 @@ class MainWP_Security {
} }
} }
//Removed Windows Live Writer meta tag // Removed Windows Live Writer meta tag
public static function remove_wlw_ok() { public static function remove_wlw_ok() {
return ( ! has_action( 'wp_head', 'wlwmanifest_link' ) ); return ( ! has_action( 'wp_head', 'wlwmanifest_link' ) );
} }
@ -100,82 +100,82 @@ class MainWP_Security {
} }
} }
//Removed core update information for non-admins // Removed core update information for non-admins
// public static function remove_core_update_ok() // public static function remove_core_update_ok()
// { // {
// return self::get_security_option('core_updates'); // return self::get_security_option('core_updates');
// } // }
// public static function remove_core_update($force = false) // public static function remove_core_update($force = false)
// { // {
// if ($force || self::get_security_option('core_updates')) // if ($force || self::get_security_option('core_updates'))
// { // {
// if (!current_user_can('update_plugins')) // if (!current_user_can('update_plugins'))
// { // {
// add_action('admin_init', create_function('$a', "remove_action( 'admin_notices', 'maintenance_nag' );")); // add_action('admin_init', create_function('$a', "remove_action( 'admin_notices', 'maintenance_nag' );"));
// add_action('admin_init', create_function('$a', "remove_action( 'admin_notices', 'update_nag', 3 );")); // add_action('admin_init', create_function('$a', "remove_action( 'admin_notices', 'update_nag', 3 );"));
// add_action('admin_init', create_function('$a', "remove_action( 'admin_init', '_maybe_update_core' );")); // add_action('admin_init', create_function('$a', "remove_action( 'admin_init', '_maybe_update_core' );"));
// add_action('init', create_function('$a', "remove_action( 'init', 'wp_version_check' );")); // add_action('init', create_function('$a', "remove_action( 'init', 'wp_version_check' );"));
// add_filter('pre_option_update_core', create_function('$a', "return null;")); // add_filter('pre_option_update_core', create_function('$a', "return null;"));
// remove_action('wp_version_check', 'wp_version_check'); // remove_action('wp_version_check', 'wp_version_check');
// remove_action('admin_init', '_maybe_update_core'); // remove_action('admin_init', '_maybe_update_core');
// add_filter('pre_transient_update_core', create_function('$a', "return null;")); // add_filter('pre_transient_update_core', create_function('$a', "return null;"));
// add_filter('pre_site_transient_update_core', create_function('$a', "return null;")); // add_filter('pre_site_transient_update_core', create_function('$a', "return null;"));
// } // }
// } // }
// } // }
//Removed plugin-update information for non-admins // Removed plugin-update information for non-admins
// public static function remove_plugin_update_ok() // public static function remove_plugin_update_ok()
// { // {
// return self:get_security_option('plugin_updates'); // return self:get_security_option('plugin_updates');
// } // }
// public static function remove_plugin_update($force = false) // public static function remove_plugin_update($force = false)
// { // {
// if ($force || self::get_security_option('plugin_updates')) // if ($force || self::get_security_option('plugin_updates'))
// { // {
// if (!current_user_can('update_plugins')) // if (!current_user_can('update_plugins'))
// { // {
// add_action('admin_init', create_function('$a', "remove_action( 'admin_init', 'wp_plugin_update_rows' );"), 2); // add_action('admin_init', create_function('$a', "remove_action( 'admin_init', 'wp_plugin_update_rows' );"), 2);
// add_action('admin_init', create_function('$a', "remove_action( 'admin_init', '_maybe_update_plugins' );"), 2); // add_action('admin_init', create_function('$a', "remove_action( 'admin_init', '_maybe_update_plugins' );"), 2);
// add_action('admin_menu', create_function('$a', "remove_action( 'load-plugins.php', 'wp_update_plugins' );")); // add_action('admin_menu', create_function('$a', "remove_action( 'load-plugins.php', 'wp_update_plugins' );"));
// add_action('admin_init', create_function('$a', "remove_action( 'admin_init', 'wp_update_plugins' );"), 2); // add_action('admin_init', create_function('$a', "remove_action( 'admin_init', 'wp_update_plugins' );"), 2);
// add_action('init', create_function('$a', "remove_action( 'init', 'wp_update_plugins' );"), 2); // add_action('init', create_function('$a', "remove_action( 'init', 'wp_update_plugins' );"), 2);
// add_filter('pre_option_update_plugins', create_function('$a', "return null;")); // add_filter('pre_option_update_plugins', create_function('$a', "return null;"));
// remove_action('load-plugins.php', 'wp_update_plugins'); // remove_action('load-plugins.php', 'wp_update_plugins');
// remove_action('load-update.php', 'wp_update_plugins'); // remove_action('load-update.php', 'wp_update_plugins');
// remove_action('admin_init', '_maybe_update_plugins'); // remove_action('admin_init', '_maybe_update_plugins');
// remove_action('wp_update_plugins', 'wp_update_plugins'); // remove_action('wp_update_plugins', 'wp_update_plugins');
// remove_action('load-update-core.php', 'wp_update_plugins'); // remove_action('load-update-core.php', 'wp_update_plugins');
// add_filter('pre_transient_update_plugins', create_function('$a', "return null;")); // add_filter('pre_transient_update_plugins', create_function('$a', "return null;"));
// } // }
// } // }
// } // }
//Removed theme-update information for non-admins // Removed theme-update information for non-admins
// public static function remove_theme_update_ok() // public static function remove_theme_update_ok()
// { // {
// return self::get_security_option('theme_updates'); // return self::get_security_option('theme_updates');
// } // }
// public static function remove_theme_update($force = false) // public static function remove_theme_update($force = false)
// { // {
// if ($force || self::get_security_option('theme_updates')) // if ($force || self::get_security_option('theme_updates'))
// { // {
// if (!current_user_can('edit_themes')) // if (!current_user_can('edit_themes'))
// { // {
// remove_action('load-themes.php', 'wp_update_themes'); // remove_action('load-themes.php', 'wp_update_themes');
// remove_action('load-update.php', 'wp_update_themes'); // remove_action('load-update.php', 'wp_update_themes');
// remove_action('admin_init', '_maybe_update_themes'); // remove_action('admin_init', '_maybe_update_themes');
// remove_action('wp_update_themes', 'wp_update_themes'); // remove_action('wp_update_themes', 'wp_update_themes');
// remove_action('load-update-core.php', 'wp_update_themes'); // remove_action('load-update-core.php', 'wp_update_themes');
// add_filter('pre_transient_update_themes', create_function('$a', "return null;")); // add_filter('pre_transient_update_themes', create_function('$a', "return null;"));
// } // }
// } // }
// } // }
//File permissions not secure // File permissions not secure
private static $permission_checks = null; private static $permission_checks = null;
private static function init_permission_checks() { private static function init_permission_checks() {
@ -194,38 +194,38 @@ class MainWP_Security {
} }
} }
// public static function fix_file_permissions_ok() // public static function fix_file_permissions_ok()
// { // {
// MainWP_Security::init_permission_checks(); // MainWP_Security::init_permission_checks();
// //
// $perms_issues = 0; // $perms_issues = 0;
// //
// foreach (MainWP_Security::$permission_checks as $dir => $needed_perms) // foreach (MainWP_Security::$permission_checks as $dir => $needed_perms)
// { // {
// if (!file_exists($dir)) continue; // if (!file_exists($dir)) continue;
// //
// $perms = substr(sprintf('%o', fileperms($dir)), -4); // $perms = substr(sprintf('%o', fileperms($dir)), -4);
// if ($perms != $needed_perms) // if ($perms != $needed_perms)
// { // {
// $perms_issues++; // $perms_issues++;
// } // }
// } // }
// return ($perms_issues == 0); // return ($perms_issues == 0);
// } // }
// public static function fix_file_permissions() // public static function fix_file_permissions()
// { // {
// MainWP_Security::init_permission_checks(); // MainWP_Security::init_permission_checks();
// $success = true; // $success = true;
// foreach (MainWP_Security::$permission_checks as $dir => $needed_perms) // foreach (MainWP_Security::$permission_checks as $dir => $needed_perms)
// { // {
// if (!file_exists($dir)) continue; // if (!file_exists($dir)) continue;
// $success == $success && chmod($dir, $needed_perms); // $success == $success && chmod($dir, $needed_perms);
// } // }
// return $success; // return $success;
// } // }
//Database error reporting turned on/off // Database error reporting turned on/off
public static function remove_database_reporting_ok() { public static function remove_database_reporting_ok() {
global $wpdb; global $wpdb;
@ -239,7 +239,7 @@ class MainWP_Security {
$wpdb->suppress_errors(); $wpdb->suppress_errors();
} }
//PHP error reporting turned on/off // PHP error reporting turned on/off
public static function remove_php_reporting_ok() { public static function remove_php_reporting_ok() {
return ! ( ( ( 0 != ini_get( 'display_errors' ) ) && ( 'off' != ini_get( 'display_errors' ) ) ) || ( ( 0 != ini_get( 'display_startup_errors' ) ) && ( 'off' != ini_get( 'display_startup_errors' ) ) ) ); return ! ( ( ( 0 != ini_get( 'display_errors' ) ) && ( 'off' != ini_get( 'display_errors' ) ) ) || ( ( 0 != ini_get( 'display_startup_errors' ) ) && ( 'off' != ini_get( 'display_startup_errors' ) ) ) );
} }
@ -252,7 +252,7 @@ class MainWP_Security {
} }
} }
//Removed version information for scripts/stylesheets // Removed version information for scripts/stylesheets
public static function remove_scripts_version_ok() { public static function remove_scripts_version_ok() {
return self::get_security_option( 'scripts_version' ); return self::get_security_option( 'scripts_version' );
} }
@ -349,7 +349,7 @@ class MainWP_Security {
return self::get_security_option( 'styles_version' ); return self::get_security_option( 'styles_version' );
} }
//Admin user name is not admin // Admin user name is not admin
public static function admin_user_ok() { public static function admin_user_ok() {
$user = get_user_by( 'login', 'admin' ); $user = get_user_by( 'login', 'admin' );
if ( ! $user ) { if ( ! $user ) {

View file

@ -58,7 +58,7 @@ class MainWP_Wordpress_SEO {
$file_url = base64_decode( $_POST['file_url'] ); $file_url = base64_decode( $_POST['file_url'] );
$temporary_file = ''; $temporary_file = '';
try { try {
include_once ABSPATH . 'wp-admin/includes/file.php'; //Contains download_url include_once ABSPATH . 'wp-admin/includes/file.php'; // Contains download_url
$temporary_file = download_url( $file_url ); $temporary_file = download_url( $file_url );
if ( is_wp_error( $temporary_file ) ) { if ( is_wp_error( $temporary_file ) ) {

View file

@ -1,6 +1,6 @@
<?php <?php
//todo: BZ2; support fseek! // todo: BZ2; support fseek!
class Tar_Archiver { class Tar_Archiver {
const IDLE = 0; const IDLE = 0;
@ -16,16 +16,16 @@ class Tar_Archiver {
protected $debug; protected $debug;
protected $chunk = ''; //1024 * 1024 * 4 protected $chunk = ''; // 1024 * 1024 * 4
protected $chunkSize = 4194304; //1024 * 1024 * 4 protected $chunkSize = 4194304; // 1024 * 1024 * 4
/** @var $backup MainWP_Backup */ /** @var $backup MainWP_Backup */
protected $backup; protected $backup;
protected $type; protected $type;
protected $pidFile; //filepath of pid file protected $pidFile; // filepath of pid file
protected $pidContent; //content of pid file protected $pidContent; // content of pid file
protected $pidUpdated; //last updated pid file protected $pidUpdated; // last updated pid file
protected $mode = self::IDLE; protected $mode = self::IDLE;
@ -127,19 +127,19 @@ class Tar_Archiver {
} }
public function createFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp, $append = false ) { public function createFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp, $append = false ) {
//$this->logHandle = fopen($filepath . ".log", "a+"); // $this->logHandle = fopen($filepath . ".log", "a+");
$this->createPidFile( $filepath ); $this->createPidFile( $filepath );
$this->excludeZip = $excludezip; $this->excludeZip = $excludezip;
$this->archivePath = $filepath; $this->archivePath = $filepath;
// if (!file_exists($filepath)) // if (!file_exists($filepath))
// { // {
// $this->limit = true; // $this->limit = true;
// } // }
if ( $append && @file_exists( $filepath ) ) { //todo: use wpFS if ( $append && @file_exists( $filepath ) ) { // todo: use wpFS
$this->mode = self::APPEND; $this->mode = self::APPEND;
$this->prepareAppend( $filepath ); $this->prepareAppend( $filepath );
} else { } else {
@ -255,9 +255,9 @@ class Tar_Archiver {
'themes' => $themes, 'themes' => $themes,
) ) ); ) ) );
// $configFile = dirname($filepath) . DIRECTORY_SEPARATOR . time() . 'config.txt'; // $configFile = dirname($filepath) . DIRECTORY_SEPARATOR . time() . 'config.txt';
// $fh = fopen($filepath, 'w'); //or error; // $fh = fopen($filepath, 'w'); //or error;
// dirname($filepath) . DIRECTORY_SEPARATOR // dirname($filepath) . DIRECTORY_SEPARATOR
$this->addEmptyDirectory( 'clone', 0, 0, 0, time() ); $this->addEmptyDirectory( 'clone', 0, 0, 0, time() );
$this->addFileFromString( 'clone/config.txt', $string ); $this->addFileFromString( 'clone/config.txt', $string );
} }
@ -328,11 +328,11 @@ class Tar_Archiver {
} }
if ( 'tar.gz' == $this->type ) { if ( 'tar.gz' == $this->type ) {
//if (@fwrite($this->archive, $data, strlen($data)) === false) // if (@fwrite($this->archive, $data, strlen($data)) === false)
if ( false === @gzwrite( $this->archive, $data, strlen( $data ) ) ) { if ( false === @gzwrite( $this->archive, $data, strlen( $data ) ) ) {
throw new Exception( 'Could not write to archive' ); throw new Exception( 'Could not write to archive' );
} }
//@fflush($this->archive); // @fflush($this->archive);
} elseif ( 'tar.bz2' == $this->type ) { } elseif ( 'tar.bz2' == $this->type ) {
if ( false === @bzwrite( $this->archive, $data, strlen( $data ) ) ) { if ( false === @bzwrite( $this->archive, $data, strlen( $data ) ) ) {
throw new Exception( 'Could not write to archive' ); throw new Exception( 'Could not write to archive' );
@ -351,12 +351,12 @@ class Tar_Archiver {
return; return;
} }
// if ($this->cnt++ > 3) // if ($this->cnt++ > 3)
// { // {
// $this->log('error?'); // $this->log('error?');
// $this->cnt = 0; // $this->cnt = 0;
// throw new Exception('error!'); // throw new Exception('error!');
// } // }
if ( 'tar.gz' == $this->type ) { if ( 'tar.gz' == $this->type ) {
$this->log( 'writing & flushing ' . $len ); $this->log( 'writing & flushing ' . $len );
@ -467,7 +467,7 @@ class Tar_Archiver {
protected $tempContent; protected $tempContent;
protected $gcCnt = 0; protected $gcCnt = 0;
// protected $limit; // protected $limit;
protected $cnt = 0; protected $cnt = 0;
private function addFile( $path, $entryName ) { private function addFile( $path, $entryName ) {
@ -483,12 +483,12 @@ class Tar_Archiver {
$this->log( 'Adding ' . $path ); $this->log( 'Adding ' . $path );
// if ($this->limit) // if ($this->limit)
// { // {
// $this->cnt++; // $this->cnt++;
// //
// if ($this->cnt > 250) throw new Exception('Some error..' . $this->archivePath); // if ($this->cnt > 250) throw new Exception('Some error..' . $this->archivePath);
// } // }
$this->updatePidFile(); $this->updatePidFile();
@ -519,7 +519,7 @@ class Tar_Archiver {
$stat = @stat( $path ); $stat = @stat( $path );
$fp = @fopen( $path, 'rb' ); $fp = @fopen( $path, 'rb' );
if ( ! $fp ) { if ( ! $fp ) {
//todo: add some error feedback! // todo: add some error feedback!
return; return;
} }
@ -616,7 +616,7 @@ class Tar_Archiver {
} }
while ( ! feof( $fp ) ) { while ( ! feof( $fp ) ) {
//0.1MB = 1024 000 // 0.1MB = 1024 000
$this->tempContent = fread( $fp, 1024000 * 5 ); $this->tempContent = fread( $fp, 1024000 * 5 );
$read = strlen( $this->tempContent ); $read = strlen( $this->tempContent );
@ -630,7 +630,7 @@ class Tar_Archiver {
$this->updatePidFile(); $this->updatePidFile();
// if ($this->limit) throw new Exception('Some error..' . $entryName); // if ($this->limit) throw new Exception('Some error..' . $entryName);
} }
@fclose( $fp ); @fclose( $fp );
@ -725,14 +725,14 @@ class Tar_Archiver {
private function checkBeforeAppend( $entryName ) { private function checkBeforeAppend( $entryName ) {
$rslt = $this->isNextFile( $entryName ); $rslt = $this->isNextFile( $entryName );
//Correct file // Correct file
if ( true === $rslt ) { if ( true === $rslt ) {
return true; return true;
} }
$out = false; $out = false;
//close, reopen with append & ftruncate // close, reopen with append & ftruncate
$this->close( false ); $this->close( false );
$this->log( 'Reopen archive to append from here' ); $this->log( 'Reopen archive to append from here' );
$this->append( $this->archivePath ); $this->append( $this->archivePath );
@ -744,7 +744,7 @@ class Tar_Archiver {
} elseif ( 'tar.gz' == $this->type ) { } elseif ( 'tar.gz' == $this->type ) {
$readOffset = $rslt['readOffset']; $readOffset = $rslt['readOffset'];
$bytesRead = $rslt['bytesRead']; $bytesRead = $rslt['bytesRead'];
//@fseek($this->archive, $readOffset + $bytesRead); // @fseek($this->archive, $readOffset + $bytesRead);
$out = array( 'bytesRead' => $bytesRead ); $out = array( 'bytesRead' => $bytesRead );
} }
@ -753,7 +753,7 @@ class Tar_Archiver {
@fseek( $this->archive, 0, SEEK_END ); @fseek( $this->archive, 0, SEEK_END );
} }
} else { } else {
//todo: check for tar.gz & tar! // todo: check for tar.gz & tar!
@fseek( $this->archive, $rslt ); @fseek( $this->archive, $rslt );
@ftruncate( $this->archive, $rslt ); @ftruncate( $this->archive, $rslt );
} }
@ -790,7 +790,7 @@ class Tar_Archiver {
} }
$temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block ); $temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block );
//Check for long file!! // Check for long file!!
if ( 'L' == $temp['type'] ) { if ( 'L' == $temp['type'] ) {
$fname = trim( @fread( $this->archive, 512 ) ); $fname = trim( @fread( $this->archive, 512 ) );
$block = @fread( $this->archive, 512 ); $block = @fread( $this->archive, 512 );
@ -904,7 +904,7 @@ class Tar_Archiver {
} }
if ( 'tar.gz' == $this->type ) { if ( 'tar.gz' == $this->type ) {
//$this->archive = @fopen('compress.zlib://' . $filepath, 'ab'); // $this->archive = @fopen('compress.zlib://' . $filepath, 'ab');
$this->archive = @gzopen( $filepath, 'wb' ); $this->archive = @gzopen( $filepath, 'wb' );
} elseif ( 'tar.bz2' == $this->type ) { } elseif ( 'tar.bz2' == $this->type ) {
$this->archive = @bzopen( $filepath, 'w' ); $this->archive = @bzopen( $filepath, 'w' );
@ -926,7 +926,7 @@ class Tar_Archiver {
} }
if ( 'tar.gz' == $this->type ) { if ( 'tar.gz' == $this->type ) {
//$this->archive = @fopen('compress.zlib://' . $filepath, 'ab'); // $this->archive = @fopen('compress.zlib://' . $filepath, 'ab');
$this->archive = @gzopen( $filepath, 'ab' ); $this->archive = @gzopen( $filepath, 'ab' );
} elseif ( $this->type == 'tar.bz2' ) { } elseif ( $this->type == 'tar.bz2' ) {
$this->archive = @bzopen( $filepath, 'a' ); $this->archive = @bzopen( $filepath, 'a' );
@ -942,9 +942,9 @@ class Tar_Archiver {
function prepareAppend( $filepath ) { function prepareAppend( $filepath ) {
if ( $this->debug ) { if ( $this->debug ) {
if ( 'tar.gz' == substr( $filepath, - 6 ) ) { if ( 'tar.gz' == substr( $filepath, - 6 ) ) {
$text = chr( 31 ) . chr( 139 ) . chr( 8 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ); //magic header!! $text = chr( 31 ) . chr( 139 ) . chr( 8 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ); // magic header!!
//Check if valid, if not, crop to valid! // Check if valid, if not, crop to valid!
$fh = @fopen( $filepath, 'rb' ); $fh = @fopen( $filepath, 'rb' );
$read = ''; $read = '';
$lastCorrect = 0; $lastCorrect = 0;
@ -972,7 +972,7 @@ class Tar_Archiver {
@fclose( $fh ); @fclose( $fh );
} catch ( Exception $e ) { } catch ( Exception $e ) {
@fclose( $fh ); @fclose( $fh );
//reopen & truncate // reopen & truncate
$fh = @fopen( $filepath, 'ab+' ); $fh = @fopen( $filepath, 'ab+' );
@fseek( $fh, $lastCorrect ); @fseek( $fh, $lastCorrect );
@ftruncate( $fh, $lastCorrect ); @ftruncate( $fh, $lastCorrect );
@ -990,7 +990,7 @@ class Tar_Archiver {
if ( 'tar.gz' == substr( $filepath, - 6 ) ) { if ( 'tar.gz' == substr( $filepath, - 6 ) ) {
$this->type = 'tar.gz'; $this->type = 'tar.gz';
// $this->archive = @fopen('compress.zlib://' . $filepath, 'rb'); // $this->archive = @fopen('compress.zlib://' . $filepath, 'rb');
$this->archive = @gzopen( $filepath, 'r' ); $this->archive = @gzopen( $filepath, 'r' );
} elseif ( 'tar.bz2' == substr( $filepath, - 7 ) ) { } elseif ( 'tar.bz2' == substr( $filepath, - 7 ) ) {
$this->type = 'tar.bz2'; $this->type = 'tar.bz2';
@ -1009,7 +1009,7 @@ class Tar_Archiver {
} }
function close( $closeLog = true ) { function close( $closeLog = true ) {
//Write chunk if it's not empty.. // Write chunk if it's not empty..
$this->writeChunk(); $this->writeChunk();
$this->log( 'Closing archive' ); $this->log( 'Closing archive' );
@ -1020,7 +1020,7 @@ class Tar_Archiver {
if ( $this->archive ) { if ( $this->archive ) {
if ( 'tar.gz' == $this->type ) { if ( 'tar.gz' == $this->type ) {
//@fclose($this->archive); // @fclose($this->archive);
@gzclose( $this->archive ); @gzclose( $this->archive );
} elseif ( 'tar.bz2' == $this->type ) { } elseif ( 'tar.bz2' == $this->type ) {
@bzclose( $this->archive ); @bzclose( $this->archive );
@ -1041,7 +1041,7 @@ class Tar_Archiver {
@fseek( $this->archive, 0 ); @fseek( $this->archive, 0 );
while ( $block = @fread( $this->archive, 512 ) ) { while ( $block = @fread( $this->archive, 512 ) ) {
$temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block ); $temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block );
//Check for long file!! // Check for long file!!
if ( 'L' == $temp['type'] ) { if ( 'L' == $temp['type'] ) {
$fname = trim( @fread( $this->archive, 512 ) ); $fname = trim( @fread( $this->archive, 512 ) );
$block = @fread( $this->archive, 512 ); $block = @fread( $this->archive, 512 );
@ -1066,7 +1066,7 @@ class Tar_Archiver {
if ( $file['checksum'] == 0x00000000 ) { if ( $file['checksum'] == 0x00000000 ) {
break; break;
} elseif ( substr( $file['magic'], 0, 5 ) != 'ustar' ) { } elseif ( substr( $file['magic'], 0, 5 ) != 'ustar' ) {
// $this->error[] = "This script does not support extracting this type of tar file."; // $this->error[] = "This script does not support extracting this type of tar file.";
break; break;
} }
@ -1075,8 +1075,8 @@ class Tar_Archiver {
for ( $i = 0; $i < 512; $i ++ ) { for ( $i = 0; $i < 512; $i ++ ) {
$checksum += ord( substr( $block, $i, 1 ) ); $checksum += ord( substr( $block, $i, 1 ) );
} }
// if ($file['checksum'] != $checksum) // if ($file['checksum'] != $checksum)
// $this->error[] = "Could not extract from {$this->options['name']}, it is corrupt."; // $this->error[] = "Could not extract from {$this->options['name']}, it is corrupt.";
if ( 0 == $file['type'] ) { if ( 0 == $file['type'] ) {
if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) { if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) {
@ -1110,7 +1110,7 @@ class Tar_Archiver {
@fseek( $this->archive, 0 ); @fseek( $this->archive, 0 );
while ( $block = @fread( $this->archive, 512 ) ) { while ( $block = @fread( $this->archive, 512 ) ) {
$temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block ); $temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block );
//Check for long file!! // Check for long file!!
if ( 'L' == $temp['type'] ) { if ( 'L' == $temp['type'] ) {
$fname = trim( @fread( $this->archive, 512 ) ); $fname = trim( @fread( $this->archive, 512 ) );
$block = @fread( $this->archive, 512 ); $block = @fread( $this->archive, 512 );
@ -1135,7 +1135,7 @@ class Tar_Archiver {
if ( $file['checksum'] == 0x00000000 ) { if ( $file['checksum'] == 0x00000000 ) {
break; break;
} elseif ( 'ustar' != substr( $file['magic'], 0, 5 ) ) { } elseif ( 'ustar' != substr( $file['magic'], 0, 5 ) ) {
// $this->error[] = "This script does not support extracting this type of tar file."; // $this->error[] = "This script does not support extracting this type of tar file.";
break; break;
} }
@ -1144,8 +1144,8 @@ class Tar_Archiver {
for ( $i = 0; $i < 512; $i ++ ) { for ( $i = 0; $i < 512; $i ++ ) {
$checksum += ord( substr( $block, $i, 1 ) ); $checksum += ord( substr( $block, $i, 1 ) );
} }
// if ($file['checksum'] != $checksum) // if ($file['checksum'] != $checksum)
// $this->error[] = "Could not extract from {$this->options['name']}, it is corrupt."; // $this->error[] = "Could not extract from {$this->options['name']}, it is corrupt.";
if ( 5 == $file['type'] ) { if ( 5 == $file['type'] ) {
if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) { if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) {
@ -1174,7 +1174,7 @@ class Tar_Archiver {
@fseek( $this->archive, 0 ); @fseek( $this->archive, 0 );
while ( $block = fread( $this->archive, 512 ) ) { while ( $block = fread( $this->archive, 512 ) ) {
$temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block ); $temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block );
//Check for long file!! // Check for long file!!
if ( 'L' == $temp['type'] ) { if ( 'L' == $temp['type'] ) {
$fname = trim( @fread( $this->archive, 512 ) ); $fname = trim( @fread( $this->archive, 512 ) );
$block = @fread( $this->archive, 512 ); $block = @fread( $this->archive, 512 );
@ -1199,7 +1199,7 @@ class Tar_Archiver {
if ( $file['checksum'] == 0x00000000 ) { if ( $file['checksum'] == 0x00000000 ) {
break; break;
} elseif ( 'ustar' != substr( $file['magic'], 0, 5 ) ) { } elseif ( 'ustar' != substr( $file['magic'], 0, 5 ) ) {
// $this->error[] = "This script does not support extracting this type of tar file."; // $this->error[] = "This script does not support extracting this type of tar file.";
break; break;
} }
$block = substr_replace( $block, ' ', 148, 8 ); $block = substr_replace( $block, ' ', 148, 8 );
@ -1207,8 +1207,8 @@ class Tar_Archiver {
for ( $i = 0; $i < 512; $i ++ ) { for ( $i = 0; $i < 512; $i ++ ) {
$checksum += ord( substr( $block, $i, 1 ) ); $checksum += ord( substr( $block, $i, 1 ) );
} }
// if ($file['checksum'] != $checksum) // if ($file['checksum'] != $checksum)
// $this->error[] = "Could not extract from {$this->options['name']}, it is corrupt."; // $this->error[] = "Could not extract from {$this->options['name']}, it is corrupt.";
if ( 5 == $file['type'] ) { if ( 5 == $file['type'] ) {
if ( ! is_dir( $to . $file['name'] ) ) { if ( ! is_dir( $to . $file['name'] ) ) {
if ( ! empty( $wp_filesystem ) ) { if ( ! empty( $wp_filesystem ) ) {
@ -1302,7 +1302,7 @@ if ( class_exists( 'SplHeap' ) ) {
$dirnameA = ( is_file( $pathA ) ? dirname( $pathA ) : $pathA ); $dirnameA = ( is_file( $pathA ) ? dirname( $pathA ) : $pathA );
$dirnameB = ( is_file( $pathB ) ? dirname( $pathB ) : $pathB ); $dirnameB = ( is_file( $pathB ) ? dirname( $pathB ) : $pathB );
//if both are in the same folder, first show the files, then the directories // if both are in the same folder, first show the files, then the directories
if ( dirname( $pathA ) == dirname( $pathB ) ) { if ( dirname( $pathA ) == dirname( $pathB ) ) {
if ( is_file( $pathA ) && ! is_file( $pathB ) ) { if ( is_file( $pathA ) && ! is_file( $pathB ) ) {
return - 1; return - 1;

View file

@ -8,7 +8,7 @@
Text Domain: mainwp-child Text Domain: mainwp-child
Version: 4.0.7 Version: 4.0.7
*/ */
require_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php'; //Version information from WordPress require_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php'; // Version information from WordPress
define( 'MAINWP_DEBUG', false ); define( 'MAINWP_DEBUG', false );