Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-file-.../inc
File: backup.php
<?php if (!defined('ABSPATH')) { exit; }
[0] Fix | Delete
$backupDirs = array('uploads.zip','plugins.zip','themes.zip','others.zip','db.sql.gz');
[1] Fix | Delete
$upload_dir = wp_upload_dir();
[2] Fix | Delete
$backup_dirname = $upload_dir['basedir'].'/wp-file-manager-pro/fm_backup/';
[3] Fix | Delete
$backup_baseurl = site_url().'/wp-json/v1/fm/backup/';
[4] Fix | Delete
$backupall_baseurl = site_url().'/wp-json/v1/fm/backupall/';
[5] Fix | Delete
global $wpdb;
[6] Fix | Delete
$fmdb = $wpdb->prefix.'wpfm_backup';
[7] Fix | Delete
$backups = $wpdb->get_results("select * from ".$fmdb." order by id desc");
[8] Fix | Delete
$settings = get_option('wp_file_manager_settings');
[9] Fix | Delete
if(isset($settings['fm_max_packet_allowed'])){
[10] Fix | Delete
$default_packet_value = intval($settings['fm_max_packet_allowed']*1000000);
[11] Fix | Delete
}else{
[12] Fix | Delete
$max_allowed_packet = 'max_allowed_packet';
[13] Fix | Delete
$packet_obj = $wpdb->get_row( $wpdb->prepare( "SHOW SESSION VARIABLES WHERE (variable_name = %s)", $max_allowed_packet ) );
[14] Fix | Delete
$default_packet_value = intval($packet_obj->Value);
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
wp_enqueue_style('fm_backup_css', plugins_url('../css/fm-backup.css', __FILE__), '', $this->ver);
[18] Fix | Delete
wp_register_script( "fm_backup", plugins_url('../js/fm-backup.js', __FILE__ ), array(), rand(0,9999) );
[19] Fix | Delete
wp_localize_script( 'fm_backup', 'fmbackupparams', array(
[20] Fix | Delete
'ajaxurl' => admin_url('admin-ajax.php'),
[21] Fix | Delete
'plugin_url' => plugins_url('lib/', __FILE__),
[22] Fix | Delete
'packet_error_msg' => __('Error: Unable to restore backup because database backup is heavy in size. Please try to increase Maximum allowed size from Preferences settings.','wp-file-manager'),
[23] Fix | Delete
'delete_backup' => __('Select backup(s) to delete!','wp-file-manager'),
[24] Fix | Delete
'confirm_del' => __('Are you sure want to remove selected backup(s)?','wp-file-manager'),
[25] Fix | Delete
'wpfmbackup' => wp_create_nonce( 'wpfmbackup' ),
[26] Fix | Delete
'wpfmbackupremove' => wp_create_nonce( 'wpfmbackupremove' ),
[27] Fix | Delete
'wpfmbackuplogs' => wp_create_nonce( 'wpfmbackuplogs' ),
[28] Fix | Delete
'wpfmbackuprestore' => wp_create_nonce( 'wpfmbackuprestore' ),
[29] Fix | Delete
'backup_running' => __('Backup is running, please wait','wp-file-manager'),
[30] Fix | Delete
'restore_running' => __('Restore is running, please wait','wp-file-manager'),
[31] Fix | Delete
'backup_empty_error' => __('Nothing selected for backup.','wp-file-manager'),
[32] Fix | Delete
'backup_baseurl' => $backup_baseurl,
[33] Fix | Delete
'backupall_baseurl' => $backupall_baseurl,
[34] Fix | Delete
'default_packet_value' => $default_packet_value,
[35] Fix | Delete
)
[36] Fix | Delete
);
[37] Fix | Delete
wp_enqueue_script( 'fm_backup' );
[38] Fix | Delete
[39] Fix | Delete
?>
[40] Fix | Delete
[41] Fix | Delete
<div class="wrap restore-sec">
[42] Fix | Delete
<div class="title">
[43] Fix | Delete
<h3> <?php _e('WP File Manager - Backup/Restore', 'wp-file-manager'); ?></h3>
[44] Fix | Delete
</div>
[45] Fix | Delete
[46] Fix | Delete
<div class="schedule-back">
[47] Fix | Delete
[48] Fix | Delete
<div class="double-col">
[49] Fix | Delete
<h4><?php _e('Backup Options:', 'wp-file-manager'); ?></h4>
[50] Fix | Delete
<div class="inner-col-wrap">
[51] Fix | Delete
<div class="inner-col-half">
[52] Fix | Delete
<div class="colmn-div3">
[53] Fix | Delete
<span class="styledCheckbox mrt10">
[54] Fix | Delete
<input type="checkbox" name="fm_bkp_database" id="fm_bkp_database" value="5" checked="checked"> <span class="fm_checkmark"></span>
[55] Fix | Delete
</span>
[56] Fix | Delete
<span class="chk-label"><?php _e('Database Backup', 'wp-file-manager'); ?></span>
[57] Fix | Delete
</div>
[58] Fix | Delete
<div class="colmn-div3">
[59] Fix | Delete
<span class="styledCheckbox mrt10">
[60] Fix | Delete
<input type="checkbox" class="chk-all-files" name="fm_bkp_files" id="fm_bkp_files" value="files" checked="checked"> <span class="fm_checkmark"></span>
[61] Fix | Delete
</span>
[62] Fix | Delete
<span class="chk-label"><a href="javascript:void(0)" id="fm_open_files_option"><?php _e('Files Backup', 'wp-file-manager'); ?></a></span>
[63] Fix | Delete
<div id="fm_open_files_options" class="fm_open_files_options">
[64] Fix | Delete
<li><span class="styledCheckbox mrt10">
[65] Fix | Delete
<input type="checkbox" class="chk-files" id="fm_bkp_plugins" name="fm_bkp_plugins" value="1" checked="checked"> <span class="fm_checkmark"></span>
[66] Fix | Delete
</span> <span class="chk-label"><?php _e('Plugins', 'wp-file-manager'); ?></span></li>
[67] Fix | Delete
<li><span class="styledCheckbox mrt10">
[68] Fix | Delete
<input type="checkbox" class="chk-files" id="fm_bkp_themes" name="fm_bkp_themes" value="2" checked="checked"> <span class="fm_checkmark"></span>
[69] Fix | Delete
</span> <span class="chk-label"><?php _e('Themes', 'wp-file-manager'); ?></span></li>
[70] Fix | Delete
<li><span class="styledCheckbox mrt10">
[71] Fix | Delete
<input type="checkbox" class="chk-files" id="fm_bkp_uploads" name="fm_bkp_uploads" value="3" checked="checked"> <span class="fm_checkmark"></span>
[72] Fix | Delete
</span> <span class="chk-label"><?php _e('Uploads', 'wp-file-manager'); ?></span></li>
[73] Fix | Delete
<li><span class="styledCheckbox mrt10">
[74] Fix | Delete
<input type="checkbox" class="chk-files" id="fm_bkp_other" name="fm_bkp_other" value="4" checked="checked"> <span class="fm_checkmark"></span>
[75] Fix | Delete
</span> <span class="chk-label"><?php _e('Others (Any other directories found inside wp-content)', 'wp-file-manager'); ?></span></li>
[76] Fix | Delete
</div>
[77] Fix | Delete
</div>
[78] Fix | Delete
<div class="colmn-div3 inner-col-half">
[79] Fix | Delete
<button id="wpfm-backupnow-button" type="button" class="backup_btn"><?php _e('Backup Now', 'wp-file-manager'); ?></button>
[80] Fix | Delete
</div>
[81] Fix | Delete
</div>
[82] Fix | Delete
</div>
[83] Fix | Delete
</div>
[84] Fix | Delete
[85] Fix | Delete
<div class="double-col">
[86] Fix | Delete
<div class="well">
[87] Fix | Delete
<b><?php _e('Time now', 'wp-file-manager'); ?></b>: <?php echo date('D, F d, Y H:i');?>
[88] Fix | Delete
</div>
[89] Fix | Delete
</div>
[90] Fix | Delete
[91] Fix | Delete
<div class="dlt_success_popup">
[92] Fix | Delete
<div class="dlt_success_popup_tbl">
[93] Fix | Delete
<div class="dlt_success_popup_cel">
[94] Fix | Delete
<div class="dlt_success_popup_inner">
[95] Fix | Delete
<a href="javascript:void(0)" class="close_dlt_success">&times;</a>
[96] Fix | Delete
<div id="dlt_success_success">
[97] Fix | Delete
<h3><?php _e('SUCCESS', 'wp-file-manager'); ?></h3>
[98] Fix | Delete
<div class="dlt_success_wrap">
[99] Fix | Delete
<p><?php _e('Backup successfully deleted.', 'wp-file-manager'); ?></p>
[100] Fix | Delete
<button class="dlt_confirmed_success backup_btn_common"><?php _e('Ok', 'wp-file-manager'); ?></button>
[101] Fix | Delete
</div>
[102] Fix | Delete
</div>
[103] Fix | Delete
</div><!--dlt_success_popup_inner-->
[104] Fix | Delete
</div>
[105] Fix | Delete
</div>
[106] Fix | Delete
</div>
[107] Fix | Delete
<!--dlt_success_popup-->
[108] Fix | Delete
[109] Fix | Delete
<div class="dlt_backup_popup">
[110] Fix | Delete
<div class="dlt_backup_popup_tbl">
[111] Fix | Delete
<div class="dlt_backup_popup_cel">
[112] Fix | Delete
<div class="dlt_backup_popup_inner">
[113] Fix | Delete
<a href="javascript:void(0)" class="close_dlt_backup">&times;</a>
[114] Fix | Delete
<div id="dlt_backup">
[115] Fix | Delete
<h3><?php _e('DELETE FILES', 'wp-file-manager'); ?></h3>
[116] Fix | Delete
<div class="dlt_btn_wrap">
[117] Fix | Delete
<p><?php _e('Are you sure you want to delete this backup?', 'wp-file-manager'); ?></p>
[118] Fix | Delete
<button class="dlt_cancel backup_btn_common"><?php _e('Cancel', 'wp-file-manager'); ?></button>
[119] Fix | Delete
<button class="dlt_confirmed backup_btn_common"><?php _e('Confirm', 'wp-file-manager'); ?></button>
[120] Fix | Delete
</div>
[121] Fix | Delete
</div>
[122] Fix | Delete
</div><!--dlt_backup_popup_inner-->
[123] Fix | Delete
</div>
[124] Fix | Delete
</div>
[125] Fix | Delete
</div>
[126] Fix | Delete
<!--dlt_backup_popup-->
[127] Fix | Delete
[128] Fix | Delete
<div class="restore_backup_popup">
[129] Fix | Delete
<div class="restore_backup_popup_tbl">
[130] Fix | Delete
<div class="restore_backup_popup_cel">
[131] Fix | Delete
<div class="restore_backup_popup_inner">
[132] Fix | Delete
<a href="javascript:void(0)" class="close_restore_backup">&times;</a>
[133] Fix | Delete
<div id="restore_backup">
[134] Fix | Delete
<h3><?php _e('RESTORE FILES', 'wp-file-manager'); ?></h3>
[135] Fix | Delete
<div class="restore_btn_wrap">
[136] Fix | Delete
<p><?php _e('Are you sure you want to restore this backup?', 'wp-file-manager'); ?></p>
[137] Fix | Delete
<button class="restore_cancel backup_btn_common"><?php _e('Cancel', 'wp-file-manager'); ?></button>
[138] Fix | Delete
<button class="restore_confirmed backup_btn_common"><?php _e('Confirm', 'wp-file-manager'); ?></button>
[139] Fix | Delete
</div>
[140] Fix | Delete
</div>
[141] Fix | Delete
</div><!--restore_backup_popup_inner-->
[142] Fix | Delete
</div>
[143] Fix | Delete
</div>
[144] Fix | Delete
</div>
[145] Fix | Delete
<!--restore_backup_popup-->
[146] Fix | Delete
[147] Fix | Delete
<div class="fmbkp_console_popup">
[148] Fix | Delete
<div class="fmbkp_console_popup_tbl">
[149] Fix | Delete
<div class="fmbkp_console_popup_cel">
[150] Fix | Delete
<div class="fmbkp_console_popup_inner">
[151] Fix | Delete
<a href="javascript:void(0)" class="close_fm_console">&times;</a>
[152] Fix | Delete
<div id="fmbkp_console"></div>
[153] Fix | Delete
<div class="fmbkp_console_loader">
[154] Fix | Delete
<img src="<?php echo plugins_url('images/loader-fm-console.gif', dirname(__FILE__)); ?>"/>
[155] Fix | Delete
</div>
[156] Fix | Delete
</div><!--fmbkp_console_popup_inner-->
[157] Fix | Delete
</div>
[158] Fix | Delete
</div>
[159] Fix | Delete
</div>
[160] Fix | Delete
<!--fmbkp_console_popup-->
[161] Fix | Delete
</div>
[162] Fix | Delete
[163] Fix | Delete
<div class="log-message">
[164] Fix | Delete
<h3><?php _e('Last Log Message', 'wp-file-manager'); ?></h3>
[165] Fix | Delete
<p>
[166] Fix | Delete
<?php if(isset($backups) && !empty($backups)) { ?>
[167] Fix | Delete
<?php _e('The backup apparently succeeded and is now complete.', 'wp-file-manager'); ?> (<?php echo date('j M, Y H:i A', strtotime($backups[0]->backup_date));?>)
[168] Fix | Delete
<?php } else { ?>
[169] Fix | Delete
<?php _e('No log message', 'wp-file-manager'); ?>
[170] Fix | Delete
<?php } ?>
[171] Fix | Delete
</p>
[172] Fix | Delete
</div>
[173] Fix | Delete
[174] Fix | Delete
<div class="existing-back">
[175] Fix | Delete
<h3><?php _e('Existing Backup(s)', 'wp-file-manager'); ?> <span><?php echo count($backups);?></span> </h3>
[176] Fix | Delete
</div>
[177] Fix | Delete
[178] Fix | Delete
<div class="backup-main">
[179] Fix | Delete
<div class="backup-date">
[180] Fix | Delete
<span class="styledCheckbox mrt10">
[181] Fix | Delete
<input type="checkbox" class="bkpchkCheckAll" <?php echo count($backups) == 0 ? 'disabled="disabled"' : "";?>> <span class="fm_checkmark"></span>
[182] Fix | Delete
</span> <span class="chk-label"> <?php _e('Backup Date', 'wp-file-manager'); ?> </span>
[183] Fix | Delete
</div>
[184] Fix | Delete
<div class="download bck_action">
[185] Fix | Delete
<span> <?php _e('Backup data (click to download)', 'wp-file-manager'); ?></span>
[186] Fix | Delete
</div>
[187] Fix | Delete
<div class="action_ele">
[188] Fix | Delete
<span> <?php _e('Action', 'wp-file-manager'); ?></span>
[189] Fix | Delete
</div>
[190] Fix | Delete
</div>
[191] Fix | Delete
[192] Fix | Delete
[193] Fix | Delete
<?php if(isset($backups) && !empty($backups)) {
[194] Fix | Delete
$count = 1;
[195] Fix | Delete
$todayDate = date('Y-m-d');
[196] Fix | Delete
$todayDate = strtotime($todayDate);
[197] Fix | Delete
foreach($backups as $backup) {
[198] Fix | Delete
$backupNameExp = $backup->backup_date;
[199] Fix | Delete
$compareDate = date("Y-m-d", strtotime($backupNameExp));
[200] Fix | Delete
$compareDate = strtotime($compareDate);
[201] Fix | Delete
$backupName = date("M d, Y H:i", strtotime($backupNameExp));
[202] Fix | Delete
?>
[203] Fix | Delete
<div class="database-sec <?php echo($count++%2 == 0) ? 'even' : 'odd'?>">
[204] Fix | Delete
<div class="backup-date">
[205] Fix | Delete
<span class="styledCheckbox mrt10">
[206] Fix | Delete
<input type="checkbox" value="<?php echo $backup->id;?>" name="backupids[]" class="backupids"> <span class="fm_checkmark"></span>
[207] Fix | Delete
</span>
[208] Fix | Delete
<span class="chk-label"><?php echo date('j M, Y H:i A', strtotime($backupName)); ?> <?php echo ($todayDate == $compareDate) ? '('.__("Today", "wp-file-manager").')' : '';?> </span>
[209] Fix | Delete
</div>
[210] Fix | Delete
<div class="download bck_action">
[211] Fix | Delete
[212] Fix | Delete
<?php
[213] Fix | Delete
$backup_count = 0;
[214] Fix | Delete
foreach($backupDirs as $backupDir) {
[215] Fix | Delete
$bkpName = $backup->backup_name.'-'.$backupDir;
[216] Fix | Delete
$dir = $backup_dirname.$bkpName;
[217] Fix | Delete
if(file_exists($dir)) {
[218] Fix | Delete
$backup_count++;
[219] Fix | Delete
if($backupDir == 'db.sql.gz') {
[220] Fix | Delete
$dirName = 'Database';
[221] Fix | Delete
} else {
[222] Fix | Delete
$dirName = str_replace('.zip','',$backupDir);
[223] Fix | Delete
}
[224] Fix | Delete
$size = filesize($dir);
[225] Fix | Delete
$backup_type = explode('.',$backupDir);
[226] Fix | Delete
$id = (int) $backup->id;
[227] Fix | Delete
?>
[228] Fix | Delete
<a href="javascript:void(0)" class="bck-icon" data-token="<?php echo base64_encode($backup->id).'/'.base64_encode($backup_type[0]).'/'.base64_encode(site_url().self::fm_get_key());?>"><?php echo ucfirst($dirName); ?> (<?php echo $this->formatSizeUnits($size); ?>)</a>
[229] Fix | Delete
<?php }
[230] Fix | Delete
}
[231] Fix | Delete
if($backup_count > 1){ ?>
[232] Fix | Delete
<div class="fm-download-all button">Download All</div>
[233] Fix | Delete
<?php }
[234] Fix | Delete
?>
[235] Fix | Delete
</div>
[236] Fix | Delete
<div class="action_ele">
[237] Fix | Delete
<button class="exitBackBtn restore_btn bkpRestoreID" id="<?php echo $backup->id; ?>"><?php _e('Restore', 'wp-file-manager'); ?></button>
[238] Fix | Delete
<button class="exitBackBtn del_btn bkpDeleteID" id="<?php echo $backup->id; ?>"><?php _e('Delete', 'wp-file-manager'); ?></button>
[239] Fix | Delete
<button class="exitBackBtn log_btn bkpViewLog" id="<?php echo $backup->id; ?>"><?php _e('View Log', 'wp-file-manager'); ?></button>
[240] Fix | Delete
</div>
[241] Fix | Delete
</div>
[242] Fix | Delete
<?php } ?>
[243] Fix | Delete
<?php } else { ?>
[244] Fix | Delete
<p class="no_backup"><?php _e('Currently no backup(s) found.', 'wp-file-manager'); ?></p>
[245] Fix | Delete
<?php } ?>
[246] Fix | Delete
<div class="action-sec">
[247] Fix | Delete
<strong> <?php _e('Actions upon selected backup(s)', 'wp-file-manager'); ?></strong>
[248] Fix | Delete
<button class="exitBackBtn bkpDelete del_btn disabled_btn"><?php _e('Delete', 'wp-file-manager'); ?></button>
[249] Fix | Delete
<button class="exitBackBtn bkpCheckAll restore_btn <?php echo count($backups) == 0 ? 'disabled_btn' : '';?>"><?php _e('Select All', 'wp-file-manager'); ?></button>
[250] Fix | Delete
<button class="exitBackBtn bkpUnCheckAll log_btn disabled_btn"><?php _e('Deselect', 'wp-file-manager'); ?></button>
[251] Fix | Delete
</div>
[252] Fix | Delete
[253] Fix | Delete
</div>
[254] Fix | Delete
[255] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function