| 1 |
<?php |
| 2 |
/** |
| 3 |
* Backup admin. |
| 4 |
* |
| 5 |
* @package wpdbbkp |
| 6 |
*/ |
| 7 |
ob_start(); |
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; // Exit if accessed directly. |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Main class wpdb_admin. |
| 14 |
* |
| 15 |
* @class Wpdb_Admin |
| 16 |
*/ |
| 17 |
class Wpdb_Admin { |
| 18 |
|
| 19 |
public $mysqldump_command_path; |
| 20 |
public $root; |
| 21 |
public $files; |
| 22 |
public $mysqldump_method; |
| 23 |
public $mysqldump_verified; |
| 24 |
|
| 25 |
/** |
| 26 |
* Construct. |
| 27 |
*/ |
| 28 |
public function __construct() { |
| 29 |
add_action( 'admin_init', array( $this, 'wp_db_backup_admin_init' ) ); |
| 30 |
add_action( 'admin_init', array( $this, 'admin_scripts_style' ) ); |
| 31 |
add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 ); |
| 32 |
add_filter( 'cron_schedules', array( $this, 'wp_db_backup_cron_schedules' ) ); |
| 33 |
add_action( 'wpdbbkp_db_backup_event', array( $this, 'wp_db_backup_event_process' ) ); |
| 34 |
add_action( 'init', array( $this, 'wp_db_backup_scheduler_activation' ) ); |
| 35 |
add_action( 'wpdbbkp_db_backup_completed', array( $this, 'wp_db_backup_completed_local' ), 12 ); |
| 36 |
add_action('admin_enqueue_scripts', array( $this, 'wpdbbkp_admin_style')); |
| 37 |
add_action('admin_enqueue_scripts', array( $this, 'wpdbbkp_admin_newsletter_script')); |
| 38 |
add_action('wp_ajax_wpdbbkp_send_query_message', array( $this, 'wpdbbkp_send_query_message')); |
| 39 |
add_filter( 'plugin_action_links_' . plugin_basename( WP_BACKUP_PLUGIN_FILE ), array( $this, 'add_settings_plugin_action_wp' ), 10, 4 ); |
| 40 |
add_action( 'admin_notices', array($this, 'check_ziparchive_avalable_admin_notice' )); |
| 41 |
add_action( 'admin_notices', array($this, 'wpdbbkp_cloudbackup_notice' ) ); |
| 42 |
add_action( 'wp_ajax_wpdbbkp_cloudbackup_dismiss_notice', array($this, 'wpdbbkp_cloudbackup_dismiss_notice' ) ); |
| 43 |
add_action( 'admin_init', array($this, 'admin_backup_file_download' )); |
| 44 |
|
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* admin Notice. |
| 49 |
*/ |
| 50 |
public function check_ziparchive_avalable_admin_notice() { |
| 51 |
if (!class_exists( 'ZipArchive' ) ) { ?> |
| 52 |
<div class="notice notice-info is-dismissible"><p><strong><?php echo esc_html__('Info!', 'wpdbbkp') ?></strong> <?php echo esc_html__(' Enable Zip Extension in php.ini to work BackupForWP all functionality smoothly.', 'wpdbbkp') ?> </p></div> |
| 53 |
<?php } |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Backup Menu. |
| 58 |
*/ |
| 59 |
public function admin_menu() { |
| 60 |
add_menu_page( |
| 61 |
'Backups', |
| 62 |
'Backups', |
| 63 |
'manage_options', |
| 64 |
'wp-database-backup', |
| 65 |
array( $this, 'wp_db_backup_settings_page' ), |
| 66 |
'dashicons-database-view', |
| 67 |
99 |
| 68 |
); |
| 69 |
|
| 70 |
add_submenu_page( |
| 71 |
'wp-database-backup', |
| 72 |
'Auto Scheduler', |
| 73 |
'Auto Scheduler', |
| 74 |
'manage_options', |
| 75 |
'wp-database-backup#tab_db_schedul', |
| 76 |
array($this, 'wp_db_backup_settings_page' )); |
| 77 |
|
| 78 |
add_submenu_page( |
| 79 |
'wp-database-backup', |
| 80 |
'Save Backups to', |
| 81 |
'Save Backups to', |
| 82 |
'manage_options', |
| 83 |
'wp-database-backup#tab_db_destination', |
| 84 |
array($this, 'wp_db_backup_settings_page' )); |
| 85 |
|
| 86 |
add_submenu_page( |
| 87 |
'wp-database-backup', |
| 88 |
'Cloud Backup', |
| 89 |
'Cloud Backup', |
| 90 |
'manage_options', |
| 91 |
'wp-database-backup#tab_db_remotebackups', |
| 92 |
array($this, 'wp_db_backup_settings_page' )); |
| 93 |
|
| 94 |
add_submenu_page( |
| 95 |
'wp-database-backup', |
| 96 |
'Migration', |
| 97 |
'Migration', |
| 98 |
'manage_options', |
| 99 |
'wp-database-backup#tab_db_migrate', |
| 100 |
array($this, 'wp_db_backup_settings_page' )); |
| 101 |
|
| 102 |
add_submenu_page( |
| 103 |
'wp-database-backup', |
| 104 |
'Settings', |
| 105 |
'Settings', |
| 106 |
'manage_options', |
| 107 |
'wp-database-backup#tab_db_setting', |
| 108 |
array($this, 'wp_db_backup_settings_page' )); |
| 109 |
// if backup is not premium then show this |
| 110 |
if ( ! is_plugin_active( 'wp-database-backup-premium/wp-database-backup-premium.php' ) ) { |
| 111 |
add_submenu_page( |
| 112 |
'wp-database-backup', |
| 113 |
'Upgrade to Premium', |
| 114 |
'Upgrade to Premium', |
| 115 |
'manage_options', |
| 116 |
'wp-database-backup#tab_db_upgrade', |
| 117 |
array($this, 'wp_db_backup_settings_page' )); |
| 118 |
} |
| 119 |
add_submenu_page( |
| 120 |
'wp-database-backup', |
| 121 |
'Search and Replace', |
| 122 |
'Search and Replace', |
| 123 |
'manage_options', |
| 124 |
'wp-database-backup#searchreplace', |
| 125 |
array($this, 'wp_db_backup_settings_page' )); |
| 126 |
|
| 127 |
|
| 128 |
add_submenu_page( |
| 129 |
'wp-database-backup', |
| 130 |
'Help & Support', |
| 131 |
'Help & Support', |
| 132 |
'manage_options', |
| 133 |
'wp-database-backup#tab_db_help', |
| 134 |
array($this, 'wp_db_backup_settings_page' )); |
| 135 |
|
| 136 |
} |
| 137 |
|
| 138 |
/** |
| 139 |
* If Checked then it will remove local backup after uploading to destination. |
| 140 |
* |
| 141 |
* @param array $args - backup details. |
| 142 |
*/ |
| 143 |
public function wp_db_backup_completed_local( &$args ) { |
| 144 |
$wp_db_remove_local_backup = get_option( 'wp_db_remove_local_backup' ); |
| 145 |
if ( 1 === $wp_db_remove_local_backup ) { |
| 146 |
if ( file_exists( $args[1] ) ) { |
| 147 |
wp_delete_file( $args[1] );// File path. |
| 148 |
} |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
/** |
| 153 |
* Admin init. |
| 154 |
*/ |
| 155 |
public function wp_db_backup_admin_init() { |
| 156 |
//redirect to plugin page on activation |
| 157 |
if (get_option('wpdbbkp_activation_redirect', false)) { |
| 158 |
delete_option('wpdbbkp_activation_redirect'); |
| 159 |
if(!isset($_GET['activate-multi'])) |
| 160 |
{ |
| 161 |
wp_safe_redirect("admin.php?page=wp-database-backup"); |
| 162 |
} |
| 163 |
} |
| 164 |
|
| 165 |
// Start Fixed Vulnerability 04-08-2016 for data save in options. |
| 166 |
if ( isset( $_GET['page'] ) && 'wp-database-backup' === $_GET['page'] ) { |
| 167 |
if ( ! empty( $_POST ) && ! ( isset( $_POST['option_page'] ) && 'wp_db_backup_options' === $_POST['option_page'] ) ) { |
| 168 |
if ( false === isset( $_REQUEST['_wpnonce'] ) || false === wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ) , 'wp-database-backup' ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- using as nonce |
| 169 |
wp_die( esc_html__('WPDB :: Invalid Access', 'wpdbbkp' ) ); |
| 170 |
} |
| 171 |
} |
| 172 |
// End Fixed Vulnerability 22-06-2016 for prevent direct download. |
| 173 |
if ( is_admin() && current_user_can( 'manage_options' ) ) { |
| 174 |
if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ) , 'wp-database-backup' ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- using as nonce |
| 175 |
if ( isset( $_POST['wpsetting_search'] ) ) { |
| 176 |
if ( isset( $_POST['wp_db_backup_search_text'] ) ) { |
| 177 |
update_option( 'wp_db_backup_search_text', sanitize_text_field( wp_unslash( $_POST['wp_db_backup_search_text'] ) ), false ); |
| 178 |
} |
| 179 |
|
| 180 |
$nonce = wp_create_nonce( 'wp-database-backup' ); |
| 181 |
wp_safe_redirect( esc_url( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=save&tab=searchreplace&_wpnonce=' . $nonce ) ); |
| 182 |
} |
| 183 |
|
| 184 |
if ( isset( $_POST['wpsetting'] ) ) { |
| 185 |
if ( isset( $_POST['wp_local_db_backup_count'] ) ) { |
| 186 |
update_option( 'wp_local_db_backup_count', wpdbbkp_filter_data( sanitize_text_field( wp_unslash( $_POST['wp_local_db_backup_count'] ) ) ) , false); |
| 187 |
} |
| 188 |
|
| 189 |
if ( isset( $_POST['wp_db_log'] ) ) { |
| 190 |
update_option( 'wp_db_log', 1 , false); |
| 191 |
} else { |
| 192 |
update_option( 'wp_db_log', 0 , false); |
| 193 |
} |
| 194 |
if ( isset( $_POST['wp_db_remove_on_uninstall'] ) ) { |
| 195 |
update_option( 'wp_db_remove_on_uninstall', 1 , false); |
| 196 |
} else { |
| 197 |
update_option( 'wp_db_remove_on_uninstall', 0 , false); |
| 198 |
} |
| 199 |
if ( isset( $_POST['wp_db_remove_local_backup'] ) ) { |
| 200 |
update_option( 'wp_db_remove_local_backup', 1 , false); |
| 201 |
} else { |
| 202 |
update_option( 'wp_db_remove_local_backup', 0 , false); |
| 203 |
} |
| 204 |
if ( isset( $_POST['wp_db_save_settings_in_backup'] ) ) { |
| 205 |
update_option( 'wp_db_save_settings_in_backup', 1 , false); |
| 206 |
} else { |
| 207 |
update_option( 'wp_db_save_settings_in_backup', 0 , false); |
| 208 |
} |
| 209 |
if ( isset( $_POST['wp_db_backup_enable_auto_upgrade'] ) ) { |
| 210 |
update_option( 'wp_db_backup_enable_auto_upgrade', 1 , false); |
| 211 |
} else { |
| 212 |
update_option( 'wp_db_backup_enable_auto_upgrade', 0 , false); |
| 213 |
} |
| 214 |
|
| 215 |
if ( isset( $_POST['wp_db_exclude_table'] ) ) { |
| 216 |
$exclude_tables = $this->recursive_sanitize_text_field( wp_unslash( $_POST['wp_db_exclude_table'] ) ); // phpcs:ignore |
| 217 |
update_option( 'wp_db_exclude_table', $this->filter_valid_exclude_tables( $exclude_tables ), false ); |
| 218 |
} else { |
| 219 |
update_option( 'wp_db_exclude_table', '', false ); |
| 220 |
} |
| 221 |
$nonce = wp_create_nonce( 'wp-database-backup' ); |
| 222 |
wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=save&_wpnonce=' . $nonce ); |
| 223 |
} |
| 224 |
|
| 225 |
if ( true === isset( $_POST['wp_db_local_backup_path'] ) ) { |
| 226 |
update_option( 'wp_db_local_backup_path', wpdbbkp_filter_data( sanitize_text_field( wp_unslash( $_POST['wp_db_local_backup_path'] ) ) ) ); |
| 227 |
} |
| 228 |
|
| 229 |
if ( isset( $_POST['wp_db_backup_email_id'] ) ) { |
| 230 |
update_option( 'wp_db_backup_email_id', wpdbbkp_filter_data( sanitize_email( wp_unslash( $_POST['wp_db_backup_email_id'] ) ) ) , false); |
| 231 |
} |
| 232 |
|
| 233 |
if ( isset( $_POST['wp_db_backup_email_attachment'] ) ) { |
| 234 |
$email_attachment = sanitize_text_field( wp_unslash( $_POST['wp_db_backup_email_attachment'] ) , false); |
| 235 |
update_option( 'wp_db_backup_email_attachment', $email_attachment ); |
| 236 |
} |
| 237 |
if ( isset( $_POST['local_backup_submit'] ) && 'Save Settings' === $_POST['local_backup_submit'] ) { |
| 238 |
if ( true === isset( $_POST['wp_db_local_backup'] ) ) { |
| 239 |
update_option( 'wp_db_local_backup', 1 , false); |
| 240 |
} else { |
| 241 |
update_option( 'wp_db_local_backup', 0 , false); |
| 242 |
} |
| 243 |
} |
| 244 |
|
| 245 |
if ( isset( $_POST['wp_db_backup_options'] ) ) { |
| 246 |
$option_to_save = []; |
| 247 |
if ( isset( $_POST['wp_db_backup_options']['enable_autobackups'] ) ) { |
| 248 |
$option_to_save['enable_autobackups'] = sanitize_text_field( wp_unslash( $_POST['wp_db_backup_options']['enable_autobackups'] ) ); |
| 249 |
} |
| 250 |
if ( isset( $_POST['wp_db_backup_options']['autobackup_type'] ) ) { |
| 251 |
$option_to_save['autobackup_type'] = sanitize_text_field( wp_unslash( $_POST['wp_db_backup_options']['autobackup_type'] ) ); |
| 252 |
} |
| 253 |
if ( isset( $_POST['wp_db_backup_options']['autobackup_frequency'] ) ) { |
| 254 |
$option_to_save['autobackup_frequency'] = sanitize_text_field( wp_unslash( $_POST['wp_db_backup_options']['autobackup_frequency'] ) ); |
| 255 |
} |
| 256 |
if ( isset( $_POST['wp_db_backup_options']['autobackup_full_days'] ) ) { |
| 257 |
$option_to_save['autobackup_full_days'] = sanitize_text_field( wp_unslash( $_POST['wp_db_backup_options']['autobackup_full_days'] ) ); |
| 258 |
} |
| 259 |
if ( isset( $_POST['wp_db_backup_options']['autobackup_full_time'] ) ) { |
| 260 |
$option_to_save['autobackup_full_time'] = sanitize_text_field( wp_unslash( $_POST['wp_db_backup_options']['autobackup_full_time'] ) ); |
| 261 |
} |
| 262 |
if ( isset( $_POST['wp_db_backup_options']['autobackup_full_date'] ) ) { |
| 263 |
$option_to_save['autobackup_full_date'] = sanitize_text_field( wp_unslash( $_POST['wp_db_backup_options']['autobackup_full_date'] ) ); |
| 264 |
} |
| 265 |
if(!empty($option_to_save)) { |
| 266 |
if(update_option( 'wp_db_backup_options', $option_to_save, false)){ |
| 267 |
wp_clear_scheduled_hook( 'wpdbbkp_db_backup_event' ); |
| 268 |
wp_clear_scheduled_hook( 'wpdbkup_event_fullbackup' ); |
| 269 |
} |
| 270 |
} |
| 271 |
|
| 272 |
} |
| 273 |
|
| 274 |
|
| 275 |
if ( isset( $_POST['featureSubmit'] ) && 'Save Settings' === $_POST['featureSubmit'] ) { |
| 276 |
if ( isset( $_POST['enable_anonymization'] ) ) { |
| 277 |
update_option( 'bkpforwp_enable_anonymization', 1 ); |
| 278 |
} else { |
| 279 |
update_option( 'bkpforwp_enable_anonymization', 0 ); |
| 280 |
} |
| 281 |
|
| 282 |
if ( isset( $_POST['enable_backup_encryption'] ) ) { |
| 283 |
update_option( 'bkpforwp_enable_backup_encryption', 1 ); |
| 284 |
} else { |
| 285 |
update_option( 'bkpforwp_enable_backup_encryption', 0 ); |
| 286 |
} |
| 287 |
if ( isset( $_POST['enable_exact_backup_time'] ) ) { |
| 288 |
update_option( 'bkpforwp_enable_exact_backup_time', 1 ); |
| 289 |
} else { |
| 290 |
update_option( 'bkpforwp_enable_exact_backup_time', 0 ); |
| 291 |
} |
| 292 |
|
| 293 |
if ( isset( $_POST['anonymization_type'] ) ) { |
| 294 |
update_option( 'bkpforwp_anonymization_type', wpdbbkp_filter_data( sanitize_text_field( wp_unslash( $_POST['anonymization_type'] ) ) ) ); |
| 295 |
|
| 296 |
} |
| 297 |
|
| 298 |
if ( isset( $_POST['anonymization_pass'] )) { |
| 299 |
update_option( 'bkpforwp_anonymization_pass', wpdbbkp_filter_data( sanitize_text_field( wp_unslash($_POST['anonymization_pass'] ) ) ) ); |
| 300 |
|
| 301 |
} |
| 302 |
|
| 303 |
if ( isset( $_POST['backup_encryption_pass'] )) { |
| 304 |
update_option( 'bkpforwp_backup_encryption_pass', wpdbbkp_filter_data( sanitize_text_field( wp_unslash($_POST['backup_encryption_pass'] ) ) ) ); |
| 305 |
|
| 306 |
} |
| 307 |
} |
| 308 |
|
| 309 |
} |
| 310 |
$wp_db_backup_destination_email = get_option( 'wp_db_backup_destination_Email' , false); |
| 311 |
|
| 312 |
if ( isset( $_GET['page'] ) && 'wp-database-backup' === $_GET['page'] && isset( $_GET['action'] ) && 'unlink' === $_GET['action'] ) { |
| 313 |
// Specify the target directory and add forward slash. |
| 314 |
$dir = plugin_dir_path( __FILE__ ) . 'Destination/Dropbox/tokens/'; |
| 315 |
|
| 316 |
// Open the directory. |
| 317 |
$dir_handle = opendir( $dir ); |
| 318 |
// Loop over all of the files in the folder. |
| 319 |
$file = readdir( $dir_handle ); |
| 320 |
while ( $file ) { |
| 321 |
// If $file is NOT a directory remove it. |
| 322 |
if ( ! is_dir( $file ) ) { |
| 323 |
wp_delete_file( $dir . $file ); |
| 324 |
} |
| 325 |
} |
| 326 |
// Close the directory. |
| 327 |
closedir( $dir_handle ); |
| 328 |
wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup' ); |
| 329 |
} |
| 330 |
$nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; |
| 331 |
if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $nonce, 'wp-database-backup' ) ) { |
| 332 |
if ( isset( $_GET['action'] ) && current_user_can( 'manage_options' ) ) { |
| 333 |
switch ( (string) $_GET['action'] ) { |
| 334 |
case 'createdbbackup': |
| 335 |
$this->wp_db_backup_event_process(); |
| 336 |
wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=create&_wpnonce=' . $nonce ); |
| 337 |
break; |
| 338 |
case 'removebackup': |
| 339 |
if ( true === isset( $_GET['index'] ) ) { |
| 340 |
$index = (int) $_GET['index']; |
| 341 |
$options = get_option( 'wp_db_backup_backups' ); |
| 342 |
$newoptions = array(); |
| 343 |
$count = 0; |
| 344 |
if(!empty($options) && is_array($options)){ |
| 345 |
foreach ( $options as $option ) { |
| 346 |
if ( $count !== $index ) { |
| 347 |
$newoptions[] = $option; |
| 348 |
} |
| 349 |
$count++; |
| 350 |
} |
| 351 |
} |
| 352 |
|
| 353 |
$upload_dir = wp_upload_dir(); |
| 354 |
$actual_working_directory = getcwd(); |
| 355 |
$file_directory = $upload_dir['basedir'].'/db-backup/'; |
| 356 |
/* |
| 357 |
Fix for when you try to delete a file thats in a folder |
| 358 |
higher in the hierarchy to your working directory */ |
| 359 |
chdir($file_directory); |
| 360 |
if ( isset($options[ $index ]['filename']) && file_exists( $options[ $index ]['filename'] ) ) { |
| 361 |
wp_delete_file( $options[ $index ]['filename'] ); |
| 362 |
} |
| 363 |
if(isset($options[ $index ]['filename'])){ |
| 364 |
$file_sql = explode( '.', $options[ $index ]['filename'] ); |
| 365 |
if ( isset($file_sql[0]) && file_exists( $file_sql[0] . '.sql' ) ) { |
| 366 |
wp_delete_file( $file_sql[0] . '.sql' ); |
| 367 |
} |
| 368 |
} |
| 369 |
|
| 370 |
chdir($actual_working_directory); |
| 371 |
$newoptions = wpdbbkp_filter_unique_filenames( $newoptions ); |
| 372 |
update_option( 'wp_db_backup_backups', $newoptions , false); |
| 373 |
$nonce = wp_create_nonce( 'wp-database-backup' ); |
| 374 |
wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=delete&_wpnonce=' . $nonce ); |
| 375 |
exit; |
| 376 |
|
| 377 |
} |
| 378 |
break; |
| 379 |
case 'removeallbackup': |
| 380 |
|
| 381 |
$upload_dir = wp_upload_dir(); |
| 382 |
$actual_working_directory = getcwd(); |
| 383 |
$file_directory = $upload_dir['basedir']; |
| 384 |
global $wpdb; |
| 385 |
/* |
| 386 |
Fix for when you try to delete a file thats in a folder |
| 387 |
higher in the hierarchy to your working directory |
| 388 |
*/ |
| 389 |
chdir($file_directory); |
| 390 |
$files = glob($file_directory.'/db-backup'.'/*'); |
| 391 |
|
| 392 |
// Deleting all the files in the list |
| 393 |
if(!empty($files)){ |
| 394 |
foreach($files as $file) { |
| 395 |
if(is_file($file)){ |
| 396 |
wp_delete_file($file); |
| 397 |
} |
| 398 |
} |
| 399 |
} |
| 400 |
chdir($actual_working_directory); |
| 401 |
update_option( 'wp_db_backup_backups', array() , false); |
| 402 |
$nonce = wp_create_nonce( 'wp-database-backup' ); |
| 403 |
$table_name = $wpdb->prefix . 'wpdbbkp_processed_files'; |
| 404 |
$wpdb->query( "TRUNCATE TABLE $table_name" ); // phpcs:ignore |
| 405 |
wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=deleteall&_wpnonce=' . $nonce ); |
| 406 |
exit; |
| 407 |
|
| 408 |
|
| 409 |
break; |
| 410 |
case 'clear_temp_db_backup_file': |
| 411 |
$options = get_option( 'wp_db_backup_backups' ); |
| 412 |
$newoptions = array(); |
| 413 |
$backup_check_list = array( '.htaccess', 'index.php' ); |
| 414 |
$delete_message = 'WPDB : Deleted Files:'; |
| 415 |
if(!empty($options) && is_array($options)){ |
| 416 |
foreach ( $options as $option ) { |
| 417 |
if(!is_array($option)){ |
| 418 |
continue; |
| 419 |
} |
| 420 |
$backup_check_list[] = $option['filename']; |
| 421 |
} |
| 422 |
} |
| 423 |
$path_info = wp_upload_dir(); |
| 424 |
$wp_db_backup_path = $path_info['basedir'] . '/db-backup'; |
| 425 |
|
| 426 |
// Open a directory, and read its contents. |
| 427 |
if ( is_dir( $wp_db_backup_path ) ) { |
| 428 |
$dh = opendir( $wp_db_backup_path ); |
| 429 |
if ( $dh ) { |
| 430 |
while ( false !== ($file = readdir( $dh )) ) { |
| 431 |
if ( ! ( in_array( $file, $backup_check_list, true ) ) ) { |
| 432 |
if ( file_exists( $wp_db_backup_path . '/' . $file ) ) { |
| 433 |
wp_delete_file( $wp_db_backup_path . '/' . $file ); |
| 434 |
} |
| 435 |
$delete_message .= ' ' . $file; |
| 436 |
} |
| 437 |
} |
| 438 |
closedir( $dh ); |
| 439 |
} |
| 440 |
} |
| 441 |
wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=clear_temp_db_backup_file&_wpnonce=' . $nonce ); |
| 442 |
exit; |
| 443 |
break; |
| 444 |
case 'restorebackup': |
| 445 |
$index = isset($_GET['index'])?(int) $_GET['index']:0; |
| 446 |
$options = get_option( 'wp_db_backup_backups' ); |
| 447 |
$restore_limit = get_option( 'wp_db_restore_limit'); |
| 448 |
$newoptions = array(); |
| 449 |
$count = 0; |
| 450 |
if(!empty($options) && is_array($options)){ |
| 451 |
foreach ( $options as $option ) { |
| 452 |
if ( $count !== $index ) { |
| 453 |
$newoptions[] = $option; |
| 454 |
} |
| 455 |
$count++; |
| 456 |
} |
| 457 |
} |
| 458 |
if ( isset( $options[ $index ]['restore_limit'] ) && $options[ $index ]['restore_limit']==1) { |
| 459 |
include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 460 |
if ( !is_plugin_active( 'wp-database-backup-pro/wp-database-backup-pro.php' ) ) { |
| 461 |
wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=restore_limit&_wpnonce=' . $nonce ); |
| 462 |
} |
| 463 |
} |
| 464 |
if(!empty($options[ $index ]['restore_limit'])){ |
| 465 |
$options[ $index ]['restore_limit']=1; |
| 466 |
} |
| 467 |
|
| 468 |
if ( isset( $options[ $index ]['sqlfile'] ) ) { // Added for extract zip file V.3.3.0. |
| 469 |
$database_file = ( $options[ $index ]['sqlfile'] ); |
| 470 |
} else { |
| 471 |
$database_file = isset($options[ $index ]['dir']) ? $options[ $index ]['dir'] : ''; |
| 472 |
$file_sql = explode( '.', $database_file ); |
| 473 |
if(isset($file_sql[0])){ |
| 474 |
$database_file = ( $file_sql[0] . '.sql' ); |
| 475 |
} |
| 476 |
|
| 477 |
} |
| 478 |
$database_name = $this->wp_backup_get_config_db_name(); |
| 479 |
$database_user = $this->wp_backup_get_config_data( 'DB_USER' ); |
| 480 |
$datadase_password = $this->wp_backup_get_config_data( 'DB_PASSWORD' ); |
| 481 |
$database_host = $this->wp_backup_get_config_data( 'DB_HOST' ); |
| 482 |
$path_info = wp_upload_dir(); |
| 483 |
// Added for extract zip file V.3.3.0. |
| 484 |
$ext_path_info = $path_info['basedir'] . '/db-backup'; |
| 485 |
$database_zip_file = $options[ $index ]['dir']; |
| 486 |
|
| 487 |
if ( class_exists( 'ZipArchive' ) ) { |
| 488 |
$zip = new ZipArchive(); |
| 489 |
if ( $zip->open( $database_zip_file ) === true ) { |
| 490 |
$zip->extractTo( $ext_path_info ); |
| 491 |
$zip->close(); |
| 492 |
} |
| 493 |
} else { |
| 494 |
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; |
| 495 |
$archive = new PclZip( $database_zip_file ); |
| 496 |
$dir = $path_info['basedir'] . '/db-backup/'; |
| 497 |
|
| 498 |
if ( ! $archive->extract( PCLZIP_OPT_PATH, $dir ) ) { |
| 499 |
wp_die( esc_html__('Unable to extract zip file. Please check that zlib php extension is enabled.','wpdbbkp').'<button onclick="history.go(-1);">'.esc_html__('Go Back','wpdbbkp').'</button>', esc_html__('ZIP Error','wpdbbkp') ); |
| 500 |
} |
| 501 |
} |
| 502 |
|
| 503 |
// End for extract zip file V.3.3.0. |
| 504 |
set_time_limit( 0 ); // phpcs:ignore -- needed for long running process |
| 505 |
ignore_user_abort(true); |
| 506 |
if ('' !== trim($database_name) && '' !== trim($database_user) && '' !== trim($database_host)) { |
| 507 |
// Ensure we use WP's global DB connection. |
| 508 |
global $wpdb; |
| 509 |
if ( ! isset( $wpdb ) || ! is_object( $wpdb ) ) { |
| 510 |
$wpdb = isset( $GLOBALS['wpdb'] ) ? $GLOBALS['wpdb'] : null; |
| 511 |
} |
| 512 |
if ( ! is_object( $wpdb ) ) { |
| 513 |
wp_die( |
| 514 |
esc_html__( 'Database connection is not available. Please reload the page and try again.', 'wpdbbkp' ), |
| 515 |
esc_html__( 'Database Error', 'wpdbbkp' ) |
| 516 |
); |
| 517 |
} |
| 518 |
|
| 519 |
$wpdb->db_connect(); |
| 520 |
$wpdb->select($database_name); |
| 521 |
|
| 522 |
//phpcs:ignore -- Check if database exists |
| 523 |
$db_exists = $wpdb->get_var($wpdb->prepare( |
| 524 |
"SELECT SCHEMA_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = %s", |
| 525 |
$database_name |
| 526 |
)); |
| 527 |
|
| 528 |
if (!$db_exists) { |
| 529 |
//phpcs:ignore -- Create DB if it doesn't exist |
| 530 |
$wpdb->query( 'CREATE DATABASE IF NOT EXISTS `' . esc_sql( $database_name ) . '`' ); |
| 531 |
$wpdb->select($database_name); |
| 532 |
} |
| 533 |
//phpcs:ignore -- Show tables from database |
| 534 |
$tables = $wpdb->get_col( 'SHOW TABLES FROM `' . esc_sql( $database_name ) . '`' ); |
| 535 |
|
| 536 |
|
| 537 |
if (!empty($tables)) { |
| 538 |
foreach ($tables as $table_name) { |
| 539 |
//phpcs:ignore -- delete tables before restore |
| 540 |
$wpdb->query( 'DROP TABLE IF EXISTS `' . esc_sql( $table_name ) . '`' ); |
| 541 |
} |
| 542 |
} |
| 543 |
|
| 544 |
// Restore database content |
| 545 |
if (file_exists($database_file)) { |
| 546 |
if ( ! function_exists( 'WP_Filesystem' ) ) { |
| 547 |
require_once ABSPATH . '/wp-admin/includes/file.php'; |
| 548 |
} |
| 549 |
|
| 550 |
WP_Filesystem(); |
| 551 |
if ( $wp_filesystem ) { |
| 552 |
$sql_file = $wp_filesystem->get_contents( $database_file ); |
| 553 |
if ( $sql_file !== false ) { |
| 554 |
$sql_queries = explode(";\n", $sql_file); |
| 555 |
//phpcs:ignore -- Set sql_mode to empty |
| 556 |
$wpdb->query("SET sql_mode = ''"); |
| 557 |
|
| 558 |
foreach ($sql_queries as $query) { |
| 559 |
$query = apply_filters('wpdbbkp_sql_query_restore', $query); |
| 560 |
if (!empty(trim($query))) { |
| 561 |
|
| 562 |
/* Since $query is a dynqmic sql query from the backup file, we can't use $wpdb->prepare |
| 563 |
* as we don't know the number / types of arguments in the query. So, we are using $wpdb->query |
| 564 |
* directly to execute the query.*/ |
| 565 |
//phpcs:ignore |
| 566 |
$wpdb->query($query); |
| 567 |
} |
| 568 |
} |
| 569 |
|
| 570 |
} |
| 571 |
} |
| 572 |
} |
| 573 |
} |
| 574 |
|
| 575 |
if ( isset( $options[ $index ]['sqlfile'] ) && file_exists( $options[ $index ]['sqlfile'] ) ) { // Added for extract zip file V.3.3.0. |
| 576 |
if ( file_exists( $options[ $index ]['sqlfile'] ) ) { |
| 577 |
wp_delete_file( $options[ $index ]['sqlfile'] ); |
| 578 |
} |
| 579 |
} else { |
| 580 |
$database_file = isset($options[ $index ]['dir'] )?$options[ $index ]['dir']:''; |
| 581 |
if(!empty($database_file)){ |
| 582 |
$file_sql = explode( '.', $database_file ); |
| 583 |
if(isset($file_sql[0])){ |
| 584 |
$database_file = ( $file_sql[0] . '.sql' ); |
| 585 |
if ( file_exists( $database_file ) ) { |
| 586 |
wp_delete_file( $database_file ); |
| 587 |
} |
| 588 |
|
| 589 |
} |
| 590 |
|
| 591 |
} |
| 592 |
|
| 593 |
} |
| 594 |
wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=restore&_wpnonce=' . $nonce ); |
| 595 |
exit; |
| 596 |
break; |
| 597 |
|
| 598 |
case 'wpdbbkrestorefullbackup': |
| 599 |
$index = (int) $_GET['index']; |
| 600 |
require_once( 'class-wpdbbkp-restore.php' ); |
| 601 |
$restore = new Wpdbbkp_Restore(); |
| 602 |
$restore->start($index); |
| 603 |
if (get_option('wp_db_log') == 1) { |
| 604 |
$options = get_option('wp_db_backup_backups'); |
| 605 |
$path_info = wp_upload_dir(); |
| 606 |
if(isset($options[$index]['filename'])){ |
| 607 |
$logFileName = explode(".", $options[$index]['filename']); |
| 608 |
if(isset($logFileName[0])){ |
| 609 |
$logfile = $path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/log/' . $logFileName[0] . '.txt'; |
| 610 |
$message = "\n\n Restore Backup at " . gmdate("Y-m-d h:i:sa"); |
| 611 |
$this->write_log($logfile, $message); |
| 612 |
} |
| 613 |
|
| 614 |
} |
| 615 |
|
| 616 |
} |
| 617 |
$nonce = wp_create_nonce( 'wp-database-backup' ); |
| 618 |
wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=restore&_wpnonce=' . $nonce ); |
| 619 |
exit; |
| 620 |
break; |
| 621 |
|
| 622 |
/* END: Restore Database Content */ |
| 623 |
} |
| 624 |
} |
| 625 |
} |
| 626 |
} |
| 627 |
} |
| 628 |
|
| 629 |
if ( is_admin() && current_user_can( 'manage_options' ) ) { |
| 630 |
register_setting( 'wp_db_backup_options', 'wp_db_backup_options', array( $this, 'wp_db_backup_validate' ) ); |
| 631 |
add_settings_section( 'wp_db_backup_main', 'WP-Database-Backup', array( $this, 'wp_db_backup_section_text' ), 'manage_options' ); |
| 632 |
} |
| 633 |
} |
| 634 |
|
| 635 |
/** |
| 636 |
* Validate data. |
| 637 |
* |
| 638 |
* @param string $input - Input data. |
| 639 |
*/ |
| 640 |
public function wp_db_backup_validate( $input ) { |
| 641 |
return $input; |
| 642 |
} |
| 643 |
|
| 644 |
/** |
| 645 |
* Setting page. |
| 646 |
*/ |
| 647 |
public function wp_db_backup_settings_page() { |
| 648 |
global $wp_filesystem; |
| 649 |
if(!function_exists('WP_Filesystem')){ |
| 650 |
require_once ( ABSPATH . '/wp-admin/includes/file.php' ); |
| 651 |
} |
| 652 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 653 |
WP_Filesystem(); |
| 654 |
$wp_db_is_pro = false; |
| 655 |
if ( is_plugin_active( 'wp-database-backup-premium/wp-database-backup-premium.php' ) ) { |
| 656 |
$wp_db_is_pro = true; |
| 657 |
} |
| 658 |
$options = get_option( 'wp_db_backup_backups' ); |
| 659 |
$options = wpdbbkp_filter_unique_filenames( $options ); |
| 660 |
$settings = get_option( 'wp_db_backup_options' ); |
| 661 |
$wp_db_log = get_option( 'wp_db_log' ); |
| 662 |
$incremental_backup = get_option( 'wp_db_incremental_backup' ,false); ?> |
| 663 |
<div class="bootstrap-wrapper"> |
| 664 |
<?php |
| 665 |
$wp_db_local_backup_path = get_option( 'wp_db_local_backup_path' ); |
| 666 |
if ( false === empty( $wp_db_local_backup_path ) && false === file_exists( $wp_db_local_backup_path ) ) { |
| 667 |
echo '<div class="alert alert-warning alert-dismissible fade in" role="alert"> |
| 668 |
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> |
| 669 |
<a href="#db_destination" data-toggle="tab">'; |
| 670 |
esc_html_e( 'Invalid Local Backup Path : ', 'wpdbbkp' ); |
| 671 |
echo esc_html( $wp_db_local_backup_path ); |
| 672 |
echo '</a></div>'; |
| 673 |
} |
| 674 |
|
| 675 |
$upload_dir = wp_upload_dir(); |
| 676 |
$dir = $upload_dir['basedir'] . '/db-backup'; |
| 677 |
if ( ! is_dir( $dir ) ) { |
| 678 |
$dir = $upload_dir['basedir']; |
| 679 |
} |
| 680 |
if ( is_dir( $dir ) && !$wp_filesystem->is_writable( $dir )) { |
| 681 |
?> |
| 682 |
<div class="row"> |
| 683 |
<div class="col-xs-12 col-sm-12 col-md-12"> |
| 684 |
<div class="alert alert-danger alert-dismissible fade in" role="alert"> |
| 685 |
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> |
| 686 |
<span aria-hidden="true">×</span></button> |
| 687 |
<h4><?php esc_html_e( 'WP Database Backup', 'wpdbbkp' ); ?></h4> |
| 688 |
<p><?php esc_html_e( 'Error: Permission denied, make sure you have write permission for', 'wpdbbkp' ); ?> <?php echo esc_attr( $dir ); ?> |
| 689 |
<?php esc_html_e( 'folder', 'wpdbbkp' ); ?></p> |
| 690 |
</div> |
| 691 |
</button> |
| 692 |
</div> |
| 693 |
</div> |
| 694 |
<?php |
| 695 |
} |
| 696 |
?> |
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
<div id="wpdbbkpModal" class="modal"> |
| 701 |
<div class="wpdbbkpmodal-content"> |
| 702 |
<div class="wpdbbkp-modal-header"> |
| 703 |
<span class="wpdbbkp-close">×</span> |
| 704 |
<h2><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> <span id="wpdbbkp-modal-header-title"></span></h2> |
| 705 |
</div> |
| 706 |
<div class="wpdbbkp-modal-body"> |
| 707 |
<p id="wpdbbkp-modal-body-text"></p> |
| 708 |
</div> |
| 709 |
<div class="wpdbbkp-modal-footer"> |
| 710 |
<a class="btn btn-primary" onclick="return confirm('Are you sure you want to restore backup?')" id="wpdbbkp-proceed-btn">Continue Anyway</a> <a class="btn btn-default wpdbbkp-close">Close</a> |
| 711 |
</div> |
| 712 |
</div> |
| 713 |
</div> |
| 714 |
|
| 715 |
<div class="panel panel-default"> |
| 716 |
<div class="panel-heading head-logo"> |
| 717 |
<a href="https://backupforwp.com/" target="blank"><img |
| 718 |
src="<?php echo esc_attr( WPDB_PLUGIN_URL ); ?>/assets/images/wp-database-backup.png" width="230px"></a> |
| 719 |
</div> |
| 720 |
<div class="panel-body"> |
| 721 |
<ul class="nav nav-tabs wbdbbkp_has_nav"> |
| 722 |
<li class="active"><a href="#db_home" data-toggle="tab"><?php echo esc_html__('Backups', 'wpdbbkp') ?></a></li> |
| 723 |
<?php if($wp_db_is_pro){ |
| 724 |
do_action('wpdbbkp_pro_tab_links'); |
| 725 |
} else { ?> |
| 726 |
<li><a href="#db_remotebackups" data-toggle="tab"><?php echo esc_html__('Cloud Backup', 'wpdbbkp') ?></a></li> |
| 727 |
<?php } ?> |
| 728 |
<li><a href="#db_migrate" data-toggle="tab"><?php echo esc_html__('Migration', 'wpdbbkp') ?></a></li> |
| 729 |
<li><a href="#db_schedul" data-toggle="tab"><?php echo esc_html__('Auto Scheduler', 'wpdbbkp') ?></a></li> |
| 730 |
<li><a href="#db_destination" data-toggle="tab"><?php echo esc_html__('Save Backups to', 'wpdbbkp') ?></a></li> |
| 731 |
<li><a href="#db_setting" data-toggle="tab"><?php echo esc_html__('Settings', 'wpdbbkp') ?></a></li> |
| 732 |
<li><a href="#searchreplace" style="display:none" data-toggle="tab"><?php echo esc_html__('Search and Replace', 'wpdbbkp') ?></a></li> |
| 733 |
<li><a href="#db_features" data-toggle="tab"><?php echo esc_html__('Modules', 'wpdbbkp') ?></a></li> |
| 734 |
<li title="System Info"><a href="#db_info" data-toggle="tab"><?php echo esc_html__('Usage', 'wpdbbkp') ?></a></li> |
| 735 |
<li><a href="#db_help" data-toggle="tab"><?php echo esc_html__('Help & Support', 'wpdbbkp') ?></a></li> |
| 736 |
<?php if( ! $wp_db_is_pro ){ ?> |
| 737 |
<li><a href="#db_upgrade" class="wpdbbkp-upgrade-a" data-toggle="tab"><?php echo esc_html__('Upgrade to Premium', 'wpdbbkp') ?></a></li> |
| 738 |
<?php } ?> |
| 739 |
|
| 740 |
|
| 741 |
</ul> |
| 742 |
|
| 743 |
<?php |
| 744 |
echo '<div class="tab-content">'; |
| 745 |
echo '<div class="tab-pane active" id="db_home">'; |
| 746 |
|
| 747 |
$nonce = wp_create_nonce( 'wp-database-backup' ); |
| 748 |
$wp_db_backup_search_text = get_option( 'wp_db_backup_search_text' ); |
| 749 |
$wp_db_backup_replace_text = get_option( 'wp_db_backup_replace_text' ); |
| 750 |
if ( ( false === empty( $wp_db_backup_search_text ) ) && ( false === empty( $wp_db_backup_replace_text ) ) ) { |
| 751 |
echo '<a href="' . esc_url( site_url() ) . '/wp-admin/admin.php?page=wp-database-backup&action=createdbbackup&_wpnonce=' . esc_attr( $nonce ) . '" id="create_backup" class="btn btn-primary"> <span class="glyphicon glyphicon-plus-sign"></span> '.esc_html__('Create Database Backup with Search/Replace', 'wpdbbkp').'</a>'; |
| 752 |
echo '<p>Backup file will replace <b>' . esc_attr( $wp_db_backup_search_text ) . '</b> text with <b>' . esc_attr( $wp_db_backup_replace_text ) . '</b>. For Regular Database Backup without replace then Go to Dashboard=>Tool=>WP-DB Backup > Settings > '.esc_html__('Search and Replace - Set Blank Fields', 'wpdbbkp').' </p>'; |
| 753 |
} else { |
| 754 |
echo '<a href="' . esc_url( site_url() ) . '/wp-admin/admin.php?page=wp-database-backup&action=createdbbackup&_wpnonce=' . esc_attr( $nonce ) . '" id="create_backup" class="btn btn-primary"> <span class="glyphicon glyphicon-plus-sign"></span> '.esc_html__('Create Database Backup', 'wpdbbkp').'</a>'; |
| 755 |
echo '<a href="#" id="wpdbbkp-create-full-backup" class="btn btn-primary"> <span class="glyphicon glyphicon-plus-sign"></span> '.esc_html__('Create Full Backup', 'wpdbbkp').'</a>'; |
| 756 |
echo '<a href="#" id="wpdbbkp-stop-full-backup" class="btn btn-danger wpdbbkp-cancel-btn" style="display:none;margin-bottom: 20px;margin-left: 10px;" > <span class="glyphicon glyphicon-ban"></span> '.esc_html__('Stop Backup Process', 'wpdbbkp').'</a>'; |
| 757 |
} |
| 758 |
include_once 'admin-header-notification.php'; ?> |
| 759 |
|
| 760 |
<?php |
| 761 |
if ( !empty($options) ) { |
| 762 |
|
| 763 |
echo ' <script> |
| 764 |
var $j = jQuery.noConflict(); |
| 765 |
$j(document).ready(function () { |
| 766 |
|
| 767 |
var table = $j("#wpdbbkp_table").DataTable({ |
| 768 |
order: [[0, "desc"]], |
| 769 |
}); |
| 770 |
$j(".popoverid").popover(); |
| 771 |
}); |
| 772 |
|
| 773 |
function excludetableall(){ |
| 774 |
var checkboxes = document.getElementsByClassName("wp_db_exclude_table"); |
| 775 |
var checked = ""; |
| 776 |
if($j("#wp_db_exclude_table_all").prop("checked") == true){ |
| 777 |
checked = "checked"; |
| 778 |
} |
| 779 |
$j(".wp_db_exclude_table").each(function() { |
| 780 |
this.checked = checked; |
| 781 |
}); |
| 782 |
} |
| 783 |
</script>'; |
| 784 |
echo ' <div class="table-responsive"> |
| 785 |
<div id="wpdbbkp_dataTables" class="dataTables_wrapper form-inline" role="grid"> |
| 786 |
|
| 787 |
<table class="table table-striped table-bordered table-hover display" id="wpdbbkp_table"> |
| 788 |
<thead>'; |
| 789 |
echo '<tr class="wpdb-header">'; |
| 790 |
echo '<th class="manage-column" scope="col" width="5%" style="text-align: center;">#</th>'; |
| 791 |
echo '<th class="manage-column" scope="col" width="25%">Date</th>'; |
| 792 |
if($wp_db_log==1){ |
| 793 |
echo '<th class="manage-column" scope="col" width="5%">Log</th>'; |
| 794 |
} |
| 795 |
echo '<th class="manage-column" scope="col" width="10%">Destination</th>'; |
| 796 |
echo '<th class="manage-column" scope="col" width="15%">Type</th>'; |
| 797 |
echo '<th class="manage-column" scope="col" width="10%">Backup File</th>'; |
| 798 |
echo '<th class="manage-column" scope="col" width="10%">Size</th>'; |
| 799 |
echo '<th class="manage-column" scope="col" width="20%">Action</th>'; |
| 800 |
echo '</tr>'; |
| 801 |
echo '</thead>'; |
| 802 |
|
| 803 |
echo '<tbody>'; |
| 804 |
$count = 1; |
| 805 |
$destination_icon = array( |
| 806 |
'Local' => 'glyphicon glyphicon-home', |
| 807 |
'Local Path' => 'glyphicon glyphicon-folder-open', |
| 808 |
'Email' => 'glyphicon glyphicon-envelope', |
| 809 |
'FTP' => 'glyphicon glyphicon-tasks', |
| 810 |
'SFTP' => 'glyphicon glyphicon-tasks', |
| 811 |
'S3' => 'glyphicon glyphicon-cloud-upload', |
| 812 |
'Drive' => 'glyphicon glyphicon-hdd', |
| 813 |
'DropBox' => 'glyphicon glyphicon-inbox', |
| 814 |
'Backblaze' => 'glyphicon glyphicon-cloud-upload', |
| 815 |
'CloudDrive' => 'glyphicon glyphicon-cloud-upload', |
| 816 |
'GenericS3' => 'glyphicon glyphicon-cloud-upload' |
| 817 |
); |
| 818 |
if(!empty($options) && is_array($options)){ |
| 819 |
foreach ( $options as $option ) { |
| 820 |
if (!is_array($option)) { |
| 821 |
continue; |
| 822 |
} |
| 823 |
|
| 824 |
$size = isset( $option['size'])? $option['size'] : 0; |
| 825 |
$str_class = ( 0 === (int) $size ) ? 'text-danger' : 'wpdb_download'; |
| 826 |
echo '<tr class="' . ( ( 0 === ( $count % 2 ) ) ? esc_attr( $str_class ) . ' alternate' : esc_attr( $str_class ) ) . '">'; |
| 827 |
echo '<td style="text-align: center;">' . esc_attr( $count ) . '</td>'; |
| 828 |
$curr_date = new DateTime(gmdate( 'Y-m-d H:i:s', $option['date'] )); |
| 829 |
$curr_date->setTimezone(new DateTimeZone(wp_timezone_string())); |
| 830 |
echo '<td><span style="display:none">' . esc_attr( $curr_date->format('Y-m-d H:i:s') ) . '</span><span title="'.esc_attr( $curr_date->format('jS, F Y h:i:s A') ) .'">' .esc_html($this->wpdbbkp_get_timeago($option['date'])).'</span>'; |
| 831 |
echo '</td>'; |
| 832 |
if($wp_db_log==1){ |
| 833 |
echo '<td class="wpdb_log" align="center">'; |
| 834 |
if (!empty($option['log'])) { |
| 835 |
if(isset($option['type']) && ($option['type'] == 'complete' || $option['type'] == 'database')){ |
| 836 |
echo '<a href="' . esc_url( admin_url('?wpdbbkp_log='.basename($option['log'])) ) . '" target="_blank" class="label label-warning" title="There might be partial backup. Please check Log File for verify backup.">'; |
| 837 |
echo '<span class="glyphicon glyphicon-list-alt"></span>'; |
| 838 |
echo '</a>'; |
| 839 |
}else{ |
| 840 |
echo '<a class="popoverid btn" role="button" data-toggle="popover" data-html="true" title="There might be partial backup. Please check Log file to verify backup." data-content="' . wp_kses_post( $option['log'] ) . '"><span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span></a>'; |
| 841 |
} |
| 842 |
} |
| 843 |
echo '</td>'; |
| 844 |
} |
| 845 |
echo '<td>'; |
| 846 |
if ( ! empty( $option['destination'] ) ) { |
| 847 |
$destination = ( explode( ',', $option['destination'] ) ); |
| 848 |
if ( ! empty( $destination ) && is_array( $destination ) ) { |
| 849 |
foreach ( $destination as $dest ) { |
| 850 |
$key = trim( $dest ); |
| 851 |
if ( empty( $key ) ) { |
| 852 |
continue; |
| 853 |
} |
| 854 |
// Icon |
| 855 |
if ( array_key_exists( $key, $destination_icon ) ) { |
| 856 |
echo '<span class="' . esc_attr( $destination_icon[ $key ] ) . '" title="' . esc_attr( $key ) . '"></span> '; |
| 857 |
} |
| 858 |
// Do not add any text label; icon-only for all destinations |
| 859 |
} |
| 860 |
} |
| 861 |
} |
| 862 |
echo '</td>'; |
| 863 |
if(isset($option['type']) && !empty($option['type'])){ |
| 864 |
if($option['type'] == 'complete'){ |
| 865 |
echo '<td>'.esc_html__('Full Backup', 'wpdbbkp').'</td>'; |
| 866 |
} |
| 867 |
if($option['type'] == 'database'){ |
| 868 |
echo '<td>'.esc_html__('Database', 'wpdbbkp').'</td>'; |
| 869 |
} |
| 870 |
}else{ |
| 871 |
echo '<td>Database</td>'; |
| 872 |
} |
| 873 |
echo '<td>'; |
| 874 |
echo '<a class="btn btn-default" href="' . esc_url( admin_url('?wpdbbkp_download='.basename($option['url'])) ) . '" style="color: #21759B;border-color:#337ab7;">'; |
| 875 |
echo '<span class="glyphicon glyphicon-download-alt"></span> Download</a></td>'; |
| 876 |
echo '<td>' . esc_attr( $this->wp_db_backup_format_bytes( $option['size'] ) ) . '</td>'; |
| 877 |
$remove_backup_href = esc_url( site_url() ) . '/wp-admin/admin.php?page=wp-database-backup&action=removebackup&_wpnonce=' . esc_attr( $nonce ) . '&index=' . esc_attr( ( $count - 1 ) ); |
| 878 |
echo '<td><a title="Remove Database Backup" onclick="return confirm(\'Are you sure you want to delete database backup?\')" href="' . esc_url($remove_backup_href) . '" class="btn btn-default"><span style="color:red" class="glyphicon glyphicon-trash"></span> Remove <a/> '; |
| 879 |
if ( isset( $option['search_replace'] ) && 1 === (int) $option['search_replace'] ) { |
| 880 |
echo '<span style="margin-left:15px" title="' . esc_html( $option['log'] ) . '" class="glyphicon glyphicon-search"></span>'; |
| 881 |
} else { |
| 882 |
$restore_url_href = esc_url( site_url() ) . '/wp-admin/admin.php?page=wp-database-backup&action=restorebackup&_wpnonce=' . esc_attr( $nonce ) . '&index=' . esc_attr( ( $count - 1 ) ); |
| 883 |
if(isset($option['type']) && !empty($option['type'])){ |
| 884 |
if($option['type'] == 'complete'){ |
| 885 |
$restore_url_href = esc_url( site_url() ) . '/wp-admin/admin.php?page=wp-database-backup&action=wpdbbkrestorefullbackup&_wpnonce=' . esc_attr( $nonce ) . '&index=' . esc_attr( ( $count - 1 ) ); |
| 886 |
} |
| 887 |
|
| 888 |
} |
| 889 |
echo '<a title="Restore Database Backup" onclick="wpdbbkp_restore_backup(this);" href="javascript:void(0);" data-msg="Are you sure you want to restore database backup? It will overwrite all data /files with the respective backup and all recent changes would be lost. Are you sure you want to continue?" data-title="Restore Backup" data-href="'.esc_url($restore_url_href).'" class="btn btn-default"><span class="glyphicon glyphicon-refresh" style="color:blue"></span> Restore <a/>'; |
| 890 |
} |
| 891 |
echo '</td></tr>'; |
| 892 |
$count++; |
| 893 |
} |
| 894 |
} |
| 895 |
|
| 896 |
echo '</tbody>'; |
| 897 |
|
| 898 |
echo ' </table> |
| 899 |
</div> |
| 900 |
</div>'; |
| 901 |
} else { |
| 902 |
echo '<p>'. esc_html__('No Database Backups Created!','wpdbbkp').'</p>'; |
| 903 |
} |
| 904 |
?> |
| 905 |
|
| 906 |
<p><?php echo esc_html__('If you like ','wpdbbkp')?><b> <?php echo esc_html__('WP Database Backup ','wpdbbkp')?> </b> <?php echo esc_html__('please leave us a ','wpdbbkp')?><a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/wp-database-backup" title="Rating" sl-processed="1"> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> rating </a>. <?php echo esc_html__('Many thanks in advance!','wpdbbkp')?> </p> |
| 907 |
<?php |
| 908 |
echo '</div>'; |
| 909 |
|
| 910 |
echo '<div class="tab-pane" id="db_schedul">'; |
| 911 |
echo '<div class="panel-group">'; |
| 912 |
echo '<form method="post" action="" name="wp_auto_commenter_form">'; |
| 913 |
wp_nonce_field( 'wp-database-backup' ); |
| 914 |
$enable_autobackups = '0'; |
| 915 |
if ( isset( $settings['enable_autobackups'] ) ) { |
| 916 |
$enable_autobackups = $settings['enable_autobackups']; |
| 917 |
} |
| 918 |
|
| 919 |
$autobackup_frequency = '0'; |
| 920 |
if ( isset( $settings['autobackup_frequency'] ) ) { |
| 921 |
$autobackup_frequency = $settings['autobackup_frequency']; |
| 922 |
} |
| 923 |
$full_autobackup_frequency = 'disabled'; |
| 924 |
if ( isset( $settings['full_autobackup_frequency'] ) ) { |
| 925 |
$full_autobackup_frequency = $settings['full_autobackup_frequency']; |
| 926 |
} |
| 927 |
$autobackup_type = ''; |
| 928 |
if ( isset( $settings['autobackup_type'] ) ) { |
| 929 |
$autobackup_type = $settings['autobackup_type']; |
| 930 |
} |
| 931 |
|
| 932 |
echo '<div class="row form-group"><label class="col-sm-3" for="enable_autobackups">'. esc_html__('Enable Auto Backups','wpdbbkp') .'</label>'; |
| 933 |
echo '<div class="col-sm-9"><input type="checkbox" id="enable_autobackups" name="wp_db_backup_options[enable_autobackups]" value="1" ' . checked( 1, $enable_autobackups, false ) . '/>'; |
| 934 |
echo '<div class="alert alert-default" role="alert"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>'. esc_html__('AutoBackups will be based on Wordpress Cron so it can have execution delay of +/- 30 mins . If you have disabled Wordpress Cron then autobackup will not work until you have set Server Cron for wordpress.','wpdbbkp') .'</div>'; |
| 935 |
echo '</div>'; |
| 936 |
echo '</div>'; |
| 937 |
|
| 938 |
echo '<div class="row form-group autobackup_type" style="display:none"><label class="col-sm-3" for="autobackup_frequency">'. esc_html__('Which part should we backup for you ?','wpdbbkp').'</label>'; |
| 939 |
echo '<div class="col-sm-9"><select id="autobackup_type" class="form-control" name="wp_db_backup_options[autobackup_type]">'; |
| 940 |
echo '<option value="">'.esc_html__('Select Backup Type','wpdbbkp').'</option>'; |
| 941 |
echo '<option value="full" ' . selected( 'full', $autobackup_type, false ) . '>Full(Files + DB)</option>'; |
| 942 |
echo '<option value="files" ' . selected( 'files', $autobackup_type, false ) . '>Files Only</option>'; |
| 943 |
echo '<option value="db" ' . selected( 'db', $autobackup_type, false ) . '>Database Only</option>'; |
| 944 |
echo '</select>'; |
| 945 |
echo '</div></div>'; |
| 946 |
|
| 947 |
echo '<div class="row form-group autobackup_frequency" style="display:none"><label class="col-sm-3" for="autobackup_frequency">'.esc_html__('How often should we run Automatically?','wpdbbkp'). '</label>'; |
| 948 |
echo '<div class="col-sm-9"><select id="autobackup_frequency" class="form-control" name="wp_db_backup_options[autobackup_frequency]">'; |
| 949 |
echo '<option value="daily" ' . selected( 'daily', $autobackup_frequency, false ) . '>Daily</option>'; |
| 950 |
echo '<option value="weekly" ' . selected( 'weekly', $autobackup_frequency, false ) . '>Weekly</option>'; |
| 951 |
echo '<option value="monthly" ' . selected( 'monthly', $autobackup_frequency, false ) . '>Monthly</option>'; |
| 952 |
echo '</select>'; |
| 953 |
echo '</div></div>'; |
| 954 |
|
| 955 |
echo '<div class="row form-group autobackup_frequency_lite" style="display:none"><label class="col-sm-12 autobackup_daily_lite" >'.esc_html__('We will automatically backup at 00:00 AM daily. ','wpdbbkp'). '<b><a href="javascript:modify_backup_frequency();">'.esc_html__('Change Back Frequency Timings','wpdbbkp') .'</a></b></label></div>'; |
| 956 |
echo '<div class="row form-group autobackup_frequency_lite" style="display:none"><label class="col-sm-12 autobackup_weekly_lite" >'.esc_html__('We will automatically backup every Sunday on weekly basis.','wpdbbkp') . '<b><a href="javascript:modify_backup_frequency();">'.esc_html__('Change Back Frequency Timings','wpdbbkp') .'</a></b></label></div>'; |
| 957 |
echo '<div class="row form-group autobackup_frequency_lite" style="display:none"><label class="col-sm-12 autobackup_monthly_lite" >'.esc_html__('We will automatically backup on 1st on Monday on monthly basis.','wpdbbkp') . ' <b><a href="javascript:modify_backup_frequency();">'.esc_html__('Change Back Frequency Timings','wpdbbkp') . '</a></b></label></div>'; |
| 958 |
|
| 959 |
do_action('wpdbbkp_database_backup_options'); |
| 960 |
echo '<p class="submit">'; |
| 961 |
echo '<input type="submit" name="'.esc_html__('Submit','wpdbbkp') . '" class="btn btn-primary" value="'.esc_html__('Save Settings','wpdbbkp') . '" />'; |
| 962 |
echo '</p>'; |
| 963 |
echo '</form>'; |
| 964 |
echo '</div>'; |
| 965 |
echo '</div>'; |
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
do_action('wpdbbkp_pro_tab_content'); |
| 970 |
|
| 971 |
?> |
| 972 |
|
| 973 |
<!-- Modal Structure --> |
| 974 |
<div class="modal" id="wpdbbkp_offer_modal" data-dismiss="modal" tabindex="-1" aria-labelledby="wpdbbkp_offer_modalLabel" aria-hidden="true"> |
| 975 |
<div class="modal-dialog"> |
| 976 |
<div class="modal-content"> |
| 977 |
<div class="modal-body"> |
| 978 |
<button type="button" id="offer_close" class="close" data-dismiss="modal" aria-label="Close"> |
| 979 |
<span aria-hidden="true">×</span> |
| 980 |
</button> |
| 981 |
<h3 class="modal-title" id="wpdbbkp_offer_modalLabel"><img src="<?php echo esc_attr( WPDB_PLUGIN_URL ); /* phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage */ ?>/assets/images/wp-database-backup.png" width="230px"></h3> |
| 982 |
<p style="padding:0 50px;"><?php echo esc_html__('Cloud Backup offers a secure, reliable and affordable solution to backup your WP site to the cloud.','wpdbbkp');?></p> |
| 983 |
<div class="wpdbbkp_offer_container"> |
| 984 |
<div class="wpdbbkp_server"> |
| 985 |
<h4><?php echo esc_html__('Server Backup','wpdbbkp');?></h4> |
| 986 |
<p><?php echo esc_html__('Backup your site to server','wpdbbkp');?></p> |
| 987 |
<ul> |
| 988 |
<li>✔ <?php echo esc_html__('Easy to setup','wpdbbkp');?></li> |
| 989 |
<li>✔ <?php echo esc_html__('Takes storage on your server','wpdbbkp');?></li> |
| 990 |
<li>✔ <?php echo esc_html__('Availability subject to server','wpdbbkp');?></li> |
| 991 |
</ul> |
| 992 |
<h4><?php echo esc_html__('Free','wpdbbkp');?></h4> |
| 993 |
<button id="wpdbbkp_server_backup" class="btn btn-secondary"><?php echo esc_html__('Create a Backup on this Server','wpdbbkp');?></button> |
| 994 |
</div> |
| 995 |
<div class="wpdbbkp_remote"> |
| 996 |
<h4><?php echo esc_html__('Cloud Backup','wpdbbkp');?></h4> |
| 997 |
<p><?php echo esc_html__('Backup your site in the cloud','wpdbbkp');?></p> |
| 998 |
<ul> |
| 999 |
<li>✔ <?php echo esc_html__('Secure and reliable','wpdbbkp');?></li> |
| 1000 |
<li>✔ <?php echo esc_html__('Unlimited Storage *','wpdbbkp');?></li> |
| 1001 |
<li>✔ <?php echo esc_html__('High availability','wpdbbkp');?></li> |
| 1002 |
</ul> |
| 1003 |
<h4><?php echo esc_html__('$49','wpdbbkp');?> <small><?php echo esc_html__('per month onwards','wpdbbkp');?></small></h4> |
| 1004 |
<button id="wpdbbkp_remote_backup" class="btn btn-primary"><?php echo esc_html__('Create a Backup on Cloud Server','wpdbbkp');?></button> |
| 1005 |
|
| 1006 |
</div> |
| 1007 |
|
| 1008 |
</div> |
| 1009 |
<br><small><?php echo esc_html__('* Fair Usage Policies applies','wpdbbkp');?></small> |
| 1010 |
</div> |
| 1011 |
</div> |
| 1012 |
</div> |
| 1013 |
</div> |
| 1014 |
<div class="tab-pane" id="db_features"> |
| 1015 |
|
| 1016 |
<div class="panel-group"> |
| 1017 |
<form method="post" action="" name="db_features_form"> |
| 1018 |
<?php wp_nonce_field('wp-database-backup'); |
| 1019 |
$enable_anonymization = get_option('bkpforwp_enable_anonymization',false); |
| 1020 |
$anonymization_type = get_option('bkpforwp_anonymization_type',false); |
| 1021 |
$enable_backup_encryption = get_option('bkpforwp_enable_backup_encryption',false); |
| 1022 |
$anonymization_pass = get_option('bkpforwp_anonymization_pass',''); |
| 1023 |
$backup_encryption_pass = get_option('bkpforwp_encryption_pass',''); |
| 1024 |
$enable_exact_backup_time = get_option('bkpforwp_enable_exact_backup_time',false); |
| 1025 |
?> |
| 1026 |
<div class="row form-group"><label class="col-sm-3" for="enable_anonymization"><?php esc_html_e('Data Anonymization','wpdbbkp'); ?></label> |
| 1027 |
<div class="col-sm-9"><input type="checkbox" id="enable_anonymization" |
| 1028 |
name="enable_anonymization" value="1" <?php checked($enable_anonymization,1,1); ?> /> |
| 1029 |
|
| 1030 |
<div class="alert alert-default" role="alert"> |
| 1031 |
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> <?php esc_html_e('Data anonymization is protecting private or sensitive information by erasing or encrypting identifiers that connect an individual to stored data.','wpdbbkp'); ?><a href="https://backupforwp.com/" target="_blank">Learn More</a></div> |
| 1032 |
</div> |
| 1033 |
</div> |
| 1034 |
<div class="row form-group" id="anonymization_type_div" style="display:none"> |
| 1035 |
<label class="col-sm-3" for="anonymization_type"><?php esc_html_e('Data Anonymization Type','wpdbbkp'); ?> </label> |
| 1036 |
<div class="col-sm-9"><select id="anonymization_type" class="form-control" |
| 1037 |
name="anonymization_type"> |
| 1038 |
<option value="masked_data" <?php selected('masked_data', $anonymization_type, true) ?>> <?php esc_html_e('Masked Data','wpdbbkp'); ?> |
| 1039 |
</option> |
| 1040 |
<option value="fake_data" <?php selected('fake_data', $anonymization_type, true) ?>> <?php esc_html_e('Fake Data','wpdbbkp'); ?> |
| 1041 |
</option> |
| 1042 |
<option value="encrypted_data" <?php selected('encrypted_data', $anonymization_type, true) ?>> <?php esc_html_e('Encrypted Data','wpdbbkp'); ?> |
| 1043 |
</option> |
| 1044 |
</select> |
| 1045 |
<?php echo wp_kses_post('<table class="bkpforwp-infotable"> |
| 1046 |
<tr><th>Masked Data </th><td>Data is masked with * character and <strong class="bkpforwp-red">data can not be recovered</strong> while restore.</td></tr> |
| 1047 |
<tr><th>Fake Data </th><td>Data is replaced with fake data and <strong class="bkpforwp-red">data can not be recovered</strong> while restore.</td></tr> |
| 1048 |
<tr><th>Encrypted Data </th><td>Data is encrypted with a password and <strong class="bkpforwp-green">data can be recovered</strong> while restore by using the same password used to backup the data.You just have to add the encryption password in Data Anonymization setting before restoring backup.</td></tr> |
| 1049 |
</table>');?> |
| 1050 |
|
| 1051 |
</div> |
| 1052 |
</div> |
| 1053 |
|
| 1054 |
<div class="row form-group" id="anonymization_enc_ip" style="display:none"> |
| 1055 |
<label class="col-sm-3" for="anonymization_pass"><?php esc_html_e('Encrypted Data','wpdbbkp'); ?> <?php esc_html_e('Anonymization Password','wpdbbkp'); ?></label> |
| 1056 |
<div class="col-sm-9"> |
| 1057 |
<input type="password" name="anonymization_pass" id="anonymization_pass" class="form-control" value="<?php esc_attr($anonymization_pass);?>"> |
| 1058 |
<div class="alert alert-default" role="alert"> |
| 1059 |
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> <?php esc_html_e('Please enter the encryption password. If you lose this pass then you can not recover the encrypted data','wpdbbkp'); ?></div> |
| 1060 |
</div> |
| 1061 |
|
| 1062 |
</div> |
| 1063 |
|
| 1064 |
<div class="row form-group" style="display:none"><label class="col-sm-3" for="enable_backup_encryption"><?php esc_html_e('Backup File Encrpytion','wpdbbkp'); ?></label> |
| 1065 |
<div class="col-sm-9"><input type="checkbox" id="enable_backup_encryption" |
| 1066 |
name="enable_backup_encryption" value="1" <?php checked($enable_backup_encryption,1,1); ?> /></div> |
| 1067 |
</div> |
| 1068 |
|
| 1069 |
<div class="row form-group" id="encryption_pass_div" style="display:none"> |
| 1070 |
<label class="col-sm-3" for="backup_encryption_pass"><?php esc_html_e('Backup Password','wpdbbkp'); ?></label> |
| 1071 |
<div class="col-sm-9"> |
| 1072 |
<input type="password" name="backup_encryption_pass" id="backup_encryption_pass" class="form-control" value="<?php esc_attr($backup_encryption_pass);?>"> |
| 1073 |
</div> |
| 1074 |
</div> |
| 1075 |
|
| 1076 |
<p class="submit"> |
| 1077 |
<input type="submit" name="featureSubmit" class="btn btn-primary" value="Save Settings" /> |
| 1078 |
</p> |
| 1079 |
</form> |
| 1080 |
</div> |
| 1081 |
</div> |
| 1082 |
<div class="tab-pane" id="db_remotebackups"> |
| 1083 |
<?php |
| 1084 |
$update_msg = ''; |
| 1085 |
if ( true === isset( $_POST['wpdb_cd_s3'] ) && 'Y' === $_POST['wpdb_cd_s3'] ) { |
| 1086 |
// Validate that the contents of the form request came from the current site and not somewhere else added 21-08-15 V.3.4. |
| 1087 |
if ( ! isset( $_POST['wpdbbackup_update_cd_setting'] ) ) { |
| 1088 |
wp_die( esc_html__('Invalid form data. form request came from the somewhere else not current site!','wpdbbkp') ); |
| 1089 |
} |
| 1090 |
if ( ! wp_verify_nonce( wp_unslash( $_POST['wpdbbackup_update_cd_setting'] ) , 'wpdbbackup-update-cd-setting' ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 1091 |
wp_die( esc_html__('Invalid form data. form request came from the somewhere else not current site!','wpdbbkp') ); |
| 1092 |
} |
| 1093 |
|
| 1094 |
if ( true === isset( $_POST['wpdb_clouddrive_token'] ) ) { |
| 1095 |
update_option( 'wpdb_clouddrive_token', wpdbbkp_filter_data( sanitize_text_field( wp_unslash( $_POST['wpdb_clouddrive_token'] ) ) ), false ); |
| 1096 |
} |
| 1097 |
|
| 1098 |
// Put a "settings updated" message on the screen. |
| 1099 |
$update_msg = esc_html__('Your BackupforWP Cloud Backup setting has been saved.' , 'wpdbbkp'); |
| 1100 |
} |
| 1101 |
|
| 1102 |
$wpdb_clouddrive_token = get_option( 'wpdb_clouddrive_token',null); |
| 1103 |
|
| 1104 |
$wpdbbkp_bb_s3_status = '<small><b>'.esc_html__('Status', 'wpdbbkp').'</b>: '.esc_html__('Not Configured', 'wpdbbkp').' </small> '; |
| 1105 |
|
| 1106 |
if($wpdb_clouddrive_token && !empty($wpdb_clouddrive_token)) |
| 1107 |
{ |
| 1108 |
$wpdbbkp_bb_s3_status ='<small>'.esc_html__('Status', 'wpdbbkp').'</b>: <span class="dashicons dashicons-yes-alt" style="color:green;font-size:16px" title="'.esc_attr__('Destination enabled', 'wpdbbkp').'"></span><span class="configured">'.esc_html__('Configured', 'wpdbbkp').' </span> </small> '; |
| 1109 |
} |
| 1110 |
|
| 1111 |
?> |
| 1112 |
<h2 align="center"><strong><?php echo esc_html__('Cloud Backup by BackupforWP', 'wpdbbkp') ?></strong></h2> |
| 1113 |
<div class="panel panel-default"> |
| 1114 |
<div class="panel-heading"> |
| 1115 |
<h4 class="panel-title"> |
| 1116 |
<a data-toggle="collapse" data-parent="#accordion" href="#collapsebb"> |
| 1117 |
<?php echo '<b>'.esc_html__('Cloud Backup', 'wpdbbkp').'</b>'; ?> <?php echo wp_kses_post($wpdbbkp_bb_s3_status);?> |
| 1118 |
|
| 1119 |
</a> |
| 1120 |
</h4> |
| 1121 |
</div> |
| 1122 |
<div class="panel-body"> |
| 1123 |
<?php |
| 1124 |
if($update_msg){ |
| 1125 |
echo '<div class="updated"><p><strong>'.esc_html( $update_msg ).'</strong></p></div>'; |
| 1126 |
} |
| 1127 |
?> |
| 1128 |
<form class="form-group" name="Clouddrive3" method="post" action=""> |
| 1129 |
|
| 1130 |
<p style="padding:0 20px;"> |
| 1131 |
<?php echo '<h2 style="padding:0 20px;">'.esc_html__('Getting started with our Cloud Backup service is simple.', 'wpdbbkp').'</h2>'; ?> |
| 1132 |
|
| 1133 |
<ul style="list-style-type: style;"> |
| 1134 |
<li style="margin-left: 30px;"><?php echo esc_html__('Sign up for a free account at', 'wpdbbkp'); ?> <a href="https://backupforwp.com/register" target="_blank"><?php echo esc_html__(' Cloud Backup ', 'wpdbbkp');?> </a><?php echo esc_html__('by Backup for WP', 'wpdbbkp');?></li> |
| 1135 |
<li style="margin-left: 30px;"><?php echo esc_html__('Add the website url', 'wpdbbkp'); ?> <a href="https://app.backupforwp.com/websites" target="_blank"><?php echo esc_html__('Add Website here', 'wpdbbkp');?> </a></li> |
| 1136 |
<li style="margin-left: 30px;"><?php echo esc_html__('API token will be generated on adding website.', 'wpdbbkp'); ?></li> |
| 1137 |
<li style="margin-left: 30px;"><?php echo esc_html__('Copy the token here and Click Save.', 'wpdbbkp'); ?></li> |
| 1138 |
<li style="margin-left: 30px;"><b><?php echo esc_html__('You can see your backup files from ', 'wpdbbkp'); ?><a href="https://app.backupforwp.com/dashboard/" target="_blank"><?php echo esc_html__('here', 'wpdbbkp');?> </a></b></li> |
| 1139 |
</ul> |
| 1140 |
|
| 1141 |
|
| 1142 |
<input type="hidden" name="wpdb_cd_s3" value="Y"> |
| 1143 |
<input name="wpdbbackup_update_cd_setting" type="hidden" value="<?php echo esc_attr( wp_create_nonce( 'wpdbbackup-update-cd-setting' ) ); ?>" /> |
| 1144 |
<?php wp_nonce_field( 'wp-database-backup' ); ?> |
| 1145 |
<div class="row form-group"> |
| 1146 |
<label class="col-sm-3" for="wpdb_clouddrive_token"><?php echo esc_html__('BackforWP API Token', 'wpdbbkp') ?></label> |
| 1147 |
<div class="col-sm-6"> |
| 1148 |
|
| 1149 |
<input type="text" id="wpdb_clouddrive_token" class="form-control" name="wpdb_clouddrive_token" value="<?php echo esc_html( get_option( 'wpdb_clouddrive_token' ) ); ?>" size="25" placeholder="<?php esc_attr_e('26b18a624d2f5e01324bc81f90cfff63ba493bc15f00d790729fb437e90f54ea','wpdbbkp');?>"> |
| 1150 |
<a href="https://app.backupforwp.com/websites" target="_blank"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> |
| 1151 |
</div> |
| 1152 |
</div> |
| 1153 |
|
| 1154 |
<p style="padding-left:20px"><input type="submit" name="Submit" class="btn btn-primary" value="<?php esc_attr_e( 'Save' , 'wpdbbkp' ); ?>" /> |
| 1155 |
</p> |
| 1156 |
</form> |
| 1157 |
</div> |
| 1158 |
</div> |
| 1159 |
|
| 1160 |
|
| 1161 |
</div> |
| 1162 |
<div class="tab-pane" id="db_migrate"> |
| 1163 |
<ul class="nav nav-tabs"> |
| 1164 |
<li class="msub-tab active" id="msub-tab-export" onclick="handleNavigateChildTab(event, 'export')" style="cursor:pointer"> |
| 1165 |
<a href="#" data-toggle="tab"><?php echo esc_html__('Export', 'wpdbbkp') ?></a> |
| 1166 |
</li> |
| 1167 |
<li class="msub-tab" id="msub-tab-import" onclick="handleNavigateChildTab(event, 'import')" style="cursor:pointer"> |
| 1168 |
<a href="#" data-toggle="tab"><?php echo esc_html__('Import', 'wpdbbkp') ?></a> |
| 1169 |
</li> |
| 1170 |
</ul> |
| 1171 |
<?php |
| 1172 |
$nonce = wp_create_nonce( 'wp-database-backup' ); |
| 1173 |
$wp_db_backup_search_text = get_option( 'wp_db_backup_search_text' ); |
| 1174 |
$wp_db_backup_replace_text = get_option( 'wp_db_backup_replace_text' ); |
| 1175 |
?> |
| 1176 |
<div class="msub-tab-block" id="msub-tab-block-export" style="padding:20px;"> |
| 1177 |
<div style="width: 500px;border: 5px dotted #204d74;margin: 0 auto;padding: 20px;border-radius: 10px; |
| 1178 |
text-align: center;"> |
| 1179 |
<?php |
| 1180 |
$wpdbbkp_export_notify = get_option('wpdbbkp_export_notify',false); |
| 1181 |
if($wpdbbkp_export_notify==false){ |
| 1182 |
?> |
| 1183 |
<a href="#" id="wpdbbkp-create-full-export" class="btn btn-primary"> <span class="glyphicon glyphicon-plus-sign"></span> <?php echo esc_html__('Start Export', 'wpdbbkp');?></a> |
| 1184 |
<?php }?> |
| 1185 |
<div id="wpdb-export-process" style="display:none"> |
| 1186 |
<div class="text-center"><img width="50" height="50" src="<?php echo esc_url(WPDB_PLUGIN_URL . "/assets/images/icon_loading.gif"); /* phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage */ ?>"> |
| 1187 |
<h5 class="text-success"><strong><?php echo esc_html__('Import process is working in background, it may take some time depending on size of your |
| 1188 |
website. You can close this tab if you want', 'wpdbbkp') ?></strong></h5> |
| 1189 |
<div class="progress"> |
| 1190 |
<div id="wpdbbkp_export_progressbar" class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" |
| 1191 |
style="width:0%"> |
| 1192 |
0% |
| 1193 |
</div> |
| 1194 |
</div> |
| 1195 |
<h4 class="text-success" id="wpdbbkup_export_process_stats"><?php echo esc_html__('Processing...', 'wpdbbkp') ?></h4> |
| 1196 |
</div> |
| 1197 |
</div> |
| 1198 |
<?php |
| 1199 |
|
| 1200 |
if($wpdbbkp_export_notify){ |
| 1201 |
?> |
| 1202 |
<div class="text-center wpdbbkp_notification"><img width="50" height="50" src="<?php echo esc_url(WPDB_PLUGIN_URL. "/assets/images/success.png"); /* phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage */ ?>"> |
| 1203 |
<h4 class="text-success"> |
| 1204 |
<?php if ($wpdbbkp_export_notify=='create') { |
| 1205 |
$backup_link = false; |
| 1206 |
$backup_list = get_option('wp_db_backup_backups'); |
| 1207 |
if(!empty($backup_list) && is_array($backup_list)){ |
| 1208 |
$download_backup = end($backup_list); |
| 1209 |
if($download_backup && !empty($download_backup) && isset($download_backup['url'])) |
| 1210 |
{ |
| 1211 |
$backup_link = '<a href="' . esc_url(admin_url('?wpdbbkp_download='.basename($download_backup['url']))) . '" style="color: #21759B;">' . __('Click here to Download', 'wpdbbkp') . '</a>'; |
| 1212 |
} |
| 1213 |
} |
| 1214 |
update_option('wpdbbkp_export_notify',false); |
| 1215 |
esc_html_e('Export Completed. ', 'wpdbbkp'); |
| 1216 |
} |
| 1217 |
?> |
| 1218 |
</h4> |
| 1219 |
<?php if ($backup_link) { ?> |
| 1220 |
<h5 class="text-success"><strong><?php echo wp_kses_post($backup_link); ?> </strong></h5> |
| 1221 |
<?php } ?> |
| 1222 |
</div> |
| 1223 |
<?php }?> |
| 1224 |
<p><?php echo esc_html__('If you like ','wpdbbkp');?> |
| 1225 |
<b><?php echo esc_html__('WP Database Backup','wpdbbkp');?> </b> |
| 1226 |
<?php echo esc_html__('please leave us a','wpdbbkp');?> |
| 1227 |
<a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/wp-database-backup" title="Rating" sl-processed="1"> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> <?php echo esc_html__('rating','wpdbbkp');?> </a>. <?php echo esc_html__('Many thanks in advance!','wpdbbkp');?></p> |
| 1228 |
</div> |
| 1229 |
</div> |
| 1230 |
<div class="msub-tab-block" id="msub-tab-block-import" style="padding:20px;display:none"> |
| 1231 |
<div style="border: 5px dotted #5cb85c;margin: 0 auto;padding: 20px;border-radius: 10px; |
| 1232 |
text-align: center;"> |
| 1233 |
<input type="file" accept=".zip,.rar,.7zip" id="wpdbbkp-upload-import" style="display:none"y/> |
| 1234 |
<a href="#" id="wpdbbkp-create-full-import" class="btn btn-success"> <span class="glyphicon glyphicon-plus-sign"></span> <?php echo esc_html__('Select File to Import', 'wpdbbkp');?></a> |
| 1235 |
<a href="#" id="wpdbbkp-start-full-import" class="btn btn-success" style="display:none"> <span class="glyphicon glyphicon-plus-sign"></span> <?php echo esc_html__('Start Import', 'wpdbbkp');?></a> |
| 1236 |
<a href="#" id="wpdbbkp-stop-full-import" class="btn btn-danger wpdbbkp-cancel-btn" style="display:none;margin-bottom: 20px;margin-left: 10px;" > <span class="glyphicon glyphicon-ban"></span><?php echo esc_html__('Stop Backup Process', 'wpdbbkp');?></a> |
| 1237 |
<p style="font-weight: bold;font-size: 14px;margin-top: 5px;color:#5cb85c" id="imported-file-name"></p> |
| 1238 |
|
| 1239 |
<div id="wpdb-import-process" style="display:none"> |
| 1240 |
<div class="text-center"><img width="50" height="50" src="<?php echo esc_url(WPDB_PLUGIN_URL . "/assets/images/icon_loading.gif"); /* phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage */ ?>"> |
| 1241 |
<h5 class="text-success"><strong><?php echo esc_html__('Import process is working, it may take some time depending on size of import file.', 'wpdbbkp') ?></strong></h5> |
| 1242 |
<div class="progress"> |
| 1243 |
<div id="wpdbbkp_import_progressbar" class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" |
| 1244 |
style="width:0%;text-align:center"> |
| 1245 |
0% |
| 1246 |
</div> |
| 1247 |
</div> |
| 1248 |
<h4 class="text-success" id="wpdbbkup_import_process_stats" style="font-size:12px"><?php echo esc_html__('Processing...', 'wpdbbkp') ?></h4> |
| 1249 |
</div> |
| 1250 |
</div> |
| 1251 |
<p><?php echo esc_html__('If you like ','wpdbbkp'); ?> <b> <?php echo esc_html__('WP Database Backup ','wpdbbkp'); ?></b> <?php echo esc_html__('please leave us a ','wpdbbkp'); ?><a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/wp-database-backup" title="<?php echo esc_html__('Rating','wpdbbkp'); ?>" sl-processed="1"> |
| 1252 |
<?php for($i=0;$i<5;$i++){?> |
| 1253 |
<span class="glyphicon glyphicon-star" aria-hidden="true" style="color:#5cb85c"></span> |
| 1254 |
<?php }?> |
| 1255 |
<?php echo esc_html__('rating','wpdbbkp'); ?> </a>. <?php echo esc_html__('Many thanks in advance!','wpdbbkp'); ?></p> |
| 1256 |
</div> |
| 1257 |
</div> |
| 1258 |
</div> |
| 1259 |
|
| 1260 |
<div class="tab-pane" id="db_help"> |
| 1261 |
<div class="panel-group "> |
| 1262 |
<div class="gn-flex-container row"> |
| 1263 |
<div class="wpdbbkp-left-side col-md-8"> |
| 1264 |
<p> <?php echo esc_html__('We are dedicated to provide Technical support & Help to our users. Use the below form for sending your questions. ', 'wpdbbkp') ?> </p> |
| 1265 |
<div class="wpdbbkp_support_div_form" id="technical-form"> |
| 1266 |
<ul> |
| 1267 |
<li> |
| 1268 |
<label class="wpdbbkp-support-label"> <?php echo esc_html__('Email', 'wpdbbkp') ?> <span class="wpdbbkp-star-mark">*</span> |
| 1269 |
</label> |
| 1270 |
<div class="support-input"> |
| 1271 |
<input type="text" id="wpdbbkp_query_email" name="wpdbbkp_query_email" size="47" placeholder="<?php esc_attr_e('Enter your Email','wpdbbkp');?>" required=""> |
| 1272 |
</div> |
| 1273 |
</li> |
| 1274 |
<li> |
| 1275 |
<label class="wpdbbkp-support-label"> <?php echo esc_html__('Query', 'wpdbbkp') ?> <span class="wpdbbkp-star-mark">*</span> |
| 1276 |
</label> |
| 1277 |
<div class="support-input"> |
| 1278 |
<textarea rows="5" cols="50" id="wpdbbkp_query_message" name="wpdbbkp_query_message" placeholder="<?php esc_attr_e('Write your query','wpdbbkp');?>"></textarea> |
| 1279 |
</div> |
| 1280 |
</li> |
| 1281 |
<li> |
| 1282 |
<button class="button button-primary wpdbbkp-send-query"> <?php echo esc_html__('Send Support Request', 'wpdbbkp') ?> </button> |
| 1283 |
</li> |
| 1284 |
</ul> |
| 1285 |
<div class="clear"></div> |
| 1286 |
<span class="wpdbbkp-query-success wpdbbkp-result wpdbbkp-hide"> <?php echo esc_html__('Message sent successfully, Please wait we will get back to you shortly', 'wpdbbkp') ?> </span> |
| 1287 |
<span class="wpdbbkp-query-error wpdbbkp-result wpdbbkp-hide"> <?php echo esc_html__('Message not sent. please check your network connection', 'wpdbbkp') ?> </span> |
| 1288 |
</div> |
| 1289 |
</div> |
| 1290 |
<div class="wpdbbkp-right-side col-md-4"> |
| 1291 |
<div class="wpdbbkp-bio-box" id="wpdbbkp_Bio"> |
| 1292 |
<h3><?php echo esc_html__('Vision & Mission', 'wpdbbkp') ?></h3> |
| 1293 |
<p class="wpdbbkp-p"><?php echo esc_html__('We strive to provide the best Backup Plugin in the world.', 'wpdbbkp') ?></p> |
| 1294 |
<p class="wpdbbkp_boxdesk"> <?php echo esc_html__(' Delivering a good user experience means a lot to us, so we try our best to reply each and every question.', 'wpdbbkp') ?></p> |
| 1295 |
</div> |
| 1296 |
</div> |
| 1297 |
</div> |
| 1298 |
</div> |
| 1299 |
</div> |
| 1300 |
|
| 1301 |
<div class="tab-pane" id="db_upgrade"> |
| 1302 |
<style> .fe-t h4,.fe-t img{vertical-align:middle}.pri-tb h5,.rcm{letter-spacing:2px}.ampfaq h4,.f-cnt,.pr-btn,.pri-tb,.wpdb-tlt,.tru-us,.upg-t,.wpdbbkp-feature,.wpdbbkp-hero{text-align:center}.f-cnt a,.pr-btn a,.pri-tb a,.tru-us a{text-decoration:none}.wpdbbkp-hero{background:#337ab7;color:#fff;padding:100px 20px 80px;position:relative}.wpdbbkp-hero::after{content:"";position:absolute;inset:0}.d-amt sup,.pri-lst .rec,.pri-tb,.pri-tb .amt sup,.wpdb,.wpdb-tlt span{position:relative}.wpdbbkp-hero-content{position:relative;z-index:1}.wpdbbkp-hero-content h1{font-size:48px;margin:0 0 20px}.wpdbbkp-hero-content p{font-size:18px;margin-bottom:30px}.wpdbbkp-btn{background:#7ed957;color:#fff;padding:14px 28px;font-size:16px;border:none;border-radius:25px;cursor:pointer}.wpdbbkp-features{display:flex!important;justify-content:space-around;padding:60px 20px;background:#f9f9f9;flex-wrap:wrap}.wpdbbkp-feature{max-width:300px;margin:20px}.wpdbbkp-feature-icon{font-size:40px;color:#8b5cf6;margin-bottom:15px}.wpdbbkp-feature h3{margin-bottom:10px;font-size:22px}.wpdbbkp-feature p{font-size:15px;color:#555}.ex-1 h4,.fe-2,.fr-fe,.upg-t{color:#222}.wpdb{top:-16px;border:1px solid #eee;padding-bottom:40px}.ext{display:grid;grid-template-columns:1fr 1fr 1fr;background:#f9f9f9;padding:45px 0 45px 25px}.wpdb-cnt,.wpdb-tlt span{display:inline-block}.ex-1{width:250px}.ampfaq,.fet,.pr-btn,.pri-lst,.wpdb-cnt,.wpdb-tlt{width:100%}.ex-1 h4{margin:15px 0 12px;font-size:18px;font-weight:500}.ex-1 p{font-size:14px;color:#555;font-weight:400;margin:0}.e-1 img{width:65px!important}.e-2 img{width:45px!important}.e-3 img{width:49px!important}.wpdb-tlt{margin:70px 0 60px}.wpdb-tlt h2{font-size:36px;line-height:1.4;color:#000;font-weight:500;margin:0}.wpdb-tlt span{font-size:16px;color:#000;margin-top:15px;top:4px}.wpdb-cmp{display:grid;grid-template-columns:1fr 2fr}.fr{border-right:1px solid #eee}.fr h1,.pr h1{font-size:36px;font-weight:700;line-height:1.5;border-bottom:1px solid #efefef;padding:0 0 20px 35px}.lt,.pr h1{padding-left:50px}.fr-fe{padding-top:10px}.fe-1{padding:22px 35px 35px}.fe-1 h4{margin:0 0 10px;font-size:20px;line-height:1.4;font-weight:400;color:#000}.fe-1 p{font-size:15px;line-height:1.4;margin:0;color:#333}.pr-fe{padding:34px 35px 35px}.pr-fe span{font-family:georgia;font-size:16px;font-weight:700;color:#000;font-style:italic;line-height:1.3}.fe-2 p,.fe-t h4{line-height:1.4;margin:0}.fet{display:grid;grid-template-columns:1fr 1fr;grid-gap:25px;margin-top:40px}.fe-t h4,.fe-t img,.pr-btn,.pr-btn a,.upg-t>span{display:inline-block}.fe-t img{width:22px!important}.fe-t h4{font-size:19px;color:#000;font-weight:400;padding-left:8px}.fe-2 p{font-size:15px;color:#555;padding-top:8px}.pr-btn{margin:50px 0 25px}.pr-btn a{color:#fff;padding:12px 35px 17px;border-radius:5px;font-size:28px;line-height:1.2;background:#eb3349;font-weight:600;margin-top:0;box-shadow:0 .15em .65em 0 rgba(0,0,0,.25)}.Backup for WP-upg{background:#f5f5f5;padding:60px 10px 0}.upg-t h2{margin:0;font-size:35px;color:#060606;line-height:1.3;font-weight:500}.pri-by,.pri-tb h5,.upg-t>span{line-height:1.2}.upg-t>span{font-size:14px;margin-top:15px;color:#666}.pri-lst{display:grid;grid-template-columns:1fr 1fr 1fr 1fr 1fr;margin-top:70px;grid-gap:1px;box-shadow:0 10px 15px 1px #ddd}.pri-tb{background:#fff;border:1px solid #f9f9f9}.f-cnt a,.pri-by{background:#333;display:inline-block}.pri-tb:hover{border:1px solid #489bff}.pri-lst .rec .pri-by,.pri-tb a:hover .pri-by{background:#1e8fff}.pri-tb a{display:inline-block;color:#222;padding:20px 12px}.pri-tb h5{margin:0 0 20px;font-size:13px;font-weight:400;color:#000}.pri-by,.pri-tb .amt,.pri-tb .d-amt,.pri-tb .s-amt,.tru-us h2{font-weight:500}.pri-tb span{display:inline-block}.pri-tb .amt{font-size:40px;margin-bottom:20px;display:block}.pri-tb .d-amt{font-size:24px;color:#666;margin-bottom:15px;display:none;text-decoration:line-through}.d-amt sup{line-height:0;top:7px}.pri-tb .s-amt{font-size:13px;color:#4caf50;margin-bottom:10px;display:block}.pri-tb .amt sup{font-size:22px;padding:0 4px 0 0;top:7px}.pri-tb .bil{color:#aaa;font-size:12px;margin-bottom:20px}.pri-tb .e,.pri-tb .f,.pri-tb .s{font-size:14px;margin-bottom:15px;color:#3b4750}.pri-tb .sv{font-size:12px;color:#fff;background:#4caf50;margin:0 auto;padding:1px 7px 2px;border-radius:45px;display:none}.pri-by{font-size:15px;border-radius:2px;padding:9px 18px 10px;color:#fff;margin-top:29px}.pri-lst .rec{box-shadow:0 1px 40px 0 #ccc;background:#fff;z-index:9;margin-top:-20px}.pri-lst .rec:hover .rcm{background:#e04371;color:#fff}.rcm{background:#dedede;color:#888;position:absolute;top:-20px;left:0;right:-1px;bottom:auto;padding:2px 0;font-size:11px}.tru-us{padding:60px 0;margin:0 auto;font-size:16px;color:#222}.tru-us h2{margin:20px 0 0;font-size:28px}.tru-us p{font-size:17px;margin:19px 15% 18px;color:#666;line-height:29px}.tru-us a{font-size:18px;color:#489bff;font-weight:400}.ampfaq h4,.f-cnt a,.f-cnt span{font-weight:500}.ampfaq{margin:25px 0}.ampfaq h4{margin:0;font-size:20px;color:#333}.faq-lst{margin-top:50px;display:grid;grid-template-columns:1fr 1fr}.lt,.rt{width:70%}.lt ul,.rt ul{margin:0}.lt ul li,.rt ul li{color:#222;margin-bottom:30px!important}.lt span,.rt span{font-size:17px;font-weight:500;margin-bottom:6px;display:inline-block}.lt p,.rt p{font-size:15px;margin:0}.f-cnt{margin-top:20px;color:#222}.f-cnt span{font-size:17px;margin:8px 0}.f-cnt p{font-size:15px;margin:6px 0}.faq-lst li span,h4{font-weight:600}.f-cnt a{color:#fff;padding:15px 30px;font-size:18px;margin-top:15px}@media (max-width:1366px){.Backup for WP-upg{padding:60px 0 0}}@media (max-width:768px){.ext,.faq-lst,.wpdb-cmp{grid-template-columns:1fr}.ext{grid-gap:30px 0px;padding:30px}.wpdb-tlt h2{font-size:26px}.pr-btn a{font-size:22px}.pri-lst{grid-template-columns:1fr 1fr 1fr}.ex-1{width:100%}.rt{padding-left:50px}} |
| 1303 |
.wpdbbkp-hero-content a {color:#fff;font-size:24px;font-weight:500;text-decoration:none}.wpdbbkp-hero-content a:hover{color:#fff;text-decoration:underline}.wpdbbkp-hero-content h1{font-size:48px;margin:0 0 20px}.wpdbbkp-hero-content p{font-size:18px;margin-bottom:30px}.wpdbbkp-btn a{color:#fff;text-decoration:none}.wpdbbkp-btn a:hover{color:#fff;text-decoration:underline}.wpdb-tlt h3{font-weight: bold;}.wpdb-tlt{color:#000;} |
| 1304 |
</style> |
| 1305 |
<div class="panel-group "> |
| 1306 |
<div class="wpdb"> |
| 1307 |
<div class="wpdb-cnt"> |
| 1308 |
<div class="wpdb-tlt"> |
| 1309 |
<h1>Upgrade for Unlimited Storage</h1> |
| 1310 |
<h3>Compare Pro vs. Free Version</h3> |
| 1311 |
<span>See what you'll get with the professional version</span> |
| 1312 |
</div> |
| 1313 |
<div class="wpdb-cmp"> |
| 1314 |
<div class="fr"> |
| 1315 |
<h1>FREE</h1> |
| 1316 |
<div class="fr-fe"> |
| 1317 |
<div class="fe-1"> |
| 1318 |
<h4>Continuous Development</h4> |
| 1319 |
<p>We take bug reports and feature requests seriously. We're continuously developing & improving this product for the last 2 years with passion and love.</p> |
| 1320 |
</div> |
| 1321 |
<div class="fe-1"> |
| 1322 |
<h4>50+ Features</h4> |
| 1323 |
<p>We're constantly expanding the plugin and make it more useful. We have wide variety of features which will fit any use-case.</p> |
| 1324 |
</div> |
| 1325 |
<div class="fe-1"> |
| 1326 |
<h4>Technical Support</h4> |
| 1327 |
<p>We have a full time team which helps you with each and every issue regarding Backup for WP.</p> |
| 1328 |
</div> |
| 1329 |
</div><!-- /. fr-fe --> |
| 1330 |
</div><!-- /. fr --> |
| 1331 |
<div class="pr"> |
| 1332 |
<h1>PRO</h1> |
| 1333 |
<div class="pr-fe"> |
| 1334 |
<span>Everything in Free, and:</span> |
| 1335 |
<div class="fet"> |
| 1336 |
<div class="fe-2"> |
| 1337 |
<div class="fe-t"><img src="<?php echo esc_url(WPDB_PLUGIN_URL.'/assets/images/right-tick.png'); ?>" /> |
| 1338 |
<h4>Unlimited Backup<sup>*</sup></h4> |
| 1339 |
</div> |
| 1340 |
<p>Unlimited Storage for your websites</p> |
| 1341 |
</div> |
| 1342 |
<div class="fe-2"> |
| 1343 |
<div class="fe-t"><img src="<?php echo esc_url(WPDB_PLUGIN_URL.'/assets/images/right-tick.png'); ?>" /> |
| 1344 |
<h4>Secure and reliable</h4> |
| 1345 |
</div> |
| 1346 |
<p>We follow industry-best practices to safeguard against unauthorized access, corruption, and loss</p> |
| 1347 |
</div> |
| 1348 |
<div class="fe-2"> |
| 1349 |
<div class="fe-t"><img src="<?php echo esc_url(WPDB_PLUGIN_URL.'/assets/images/right-tick.png'); ?>" /> |
| 1350 |
<h4>High availability</h4> |
| 1351 |
</div> |
| 1352 |
<p>Our system is built on a globally distributed cloud infrastructure with 99% uptime</p> |
| 1353 |
</div> |
| 1354 |
|
| 1355 |
|
| 1356 |
<div class="fe-2"> |
| 1357 |
<div class="fe-t"><img src="<?php echo esc_url(WPDB_PLUGIN_URL.'/assets/images/right-tick.png'); ?>" /> |
| 1358 |
<h4>Dedicated Support</h4> |
| 1359 |
</div> |
| 1360 |
<p>With a Dedicated person helping you with the extension setup and questions.</p> |
| 1361 |
</div> |
| 1362 |
<div class="fe-2"> |
| 1363 |
<div class="fe-t"><img src="<?php echo esc_url(WPDB_PLUGIN_URL.'/assets/images/right-tick.png'); ?>" /> |
| 1364 |
<h4>Continious Updates</h4> |
| 1365 |
</div> |
| 1366 |
<p>We're continiously updating our premium features and releasing them.</p> |
| 1367 |
</div> |
| 1368 |
<div class="fe-2"> |
| 1369 |
<div class="fe-t"><img src="<?php echo esc_url(WPDB_PLUGIN_URL.'/assets/images/right-tick.png'); ?>" /> |
| 1370 |
<h4>Innovation</h4> |
| 1371 |
</div> |
| 1372 |
<p>Be the first one to get the innovative features that we build in the future.</p> |
| 1373 |
</div> |
| 1374 |
</div><!-- /. fet --> |
| 1375 |
<div class="pr-btn"> |
| 1376 |
<a href="#upgrade">Upgrade to Pro</a> |
| 1377 |
</div><!-- /. pr-btn --> |
| 1378 |
</div><!-- /. pr-fe --> |
| 1379 |
</div><!-- /.pr --> |
| 1380 |
</div><!-- /. wpdb-cmp --> |
| 1381 |
</div><!-- /. wpdb-cnt --> |
| 1382 |
<div id="upgrade" class="Backup for WP-upg"> |
| 1383 |
<div class="upg-t"> |
| 1384 |
<h2>Let's Get Your Backups Ready</h2> |
| 1385 |
<span>Choose your plan and upgrade in minutes!</span> |
| 1386 |
</div> |
| 1387 |
<div class="pri-lst"> |
| 1388 |
<div class="pri-tb"> |
| 1389 |
<a href="https://backupforwp.com/checkout?edd_action=add_to_cart&download_id=1123&edd_options[price_id]=1"> |
| 1390 |
<h5>PERSONAL</h5> |
| 1391 |
<span class="d-amt"><sup>$</sup>49</span> |
| 1392 |
<span class="amt"><sup>$</sup>49</span> |
| 1393 |
<span class="s-amt">(Save $59)</span> |
| 1394 |
<span class="bil">Billed Annually</span> |
| 1395 |
<span class="s">1 Site License</span> |
| 1396 |
<span class="e">E-mail support</span> |
| 1397 |
<span class="f">Pro Features</span> |
| 1398 |
<span class="sv">Save $800+</span> |
| 1399 |
<span class="pri-by">Buy Now</span> |
| 1400 |
</a> |
| 1401 |
</div> |
| 1402 |
<div class="pri-tb rec"> |
| 1403 |
<a href="https://backupforwp.com/checkout?edd_action=add_to_cart&download_id=1123&edd_options[price_id]=2"> |
| 1404 |
<h5>MULTIPLE</h5> |
| 1405 |
<span class="d-amt"><sup>$</sup>99</span> |
| 1406 |
<span class="amt"><sup>$</sup>99</span> |
| 1407 |
<span class="s-amt">(Save $79)</span> |
| 1408 |
<span class="bil">Billed Annually</span> |
| 1409 |
<span class="s">3 Site License</span> |
| 1410 |
<span class="e">E-mail support</span> |
| 1411 |
<span class="f">Pro Features</span> |
| 1412 |
<span class="sv">Save 55%</span> |
| 1413 |
<span class="pri-by">Buy Now</span> |
| 1414 |
<span class="rcm">RECOMMENDED</span> |
| 1415 |
</a> |
| 1416 |
</div> |
| 1417 |
<div class="pri-tb"> |
| 1418 |
<a href="https://backupforwp.com/checkout?edd_action=add_to_cart&download_id=1123&edd_options[price_id]=3"> |
| 1419 |
<h5>WEBMASTER</h5> |
| 1420 |
<span class="d-amt"><sup>$</sup>199</span> |
| 1421 |
<span class="amt"><sup>$</sup>199</span> |
| 1422 |
<span class="s-amt">(Save $99)</span> |
| 1423 |
<span class="bil">Billed Annually</span> |
| 1424 |
<span class="s">10 Site License</span> |
| 1425 |
<span class="e">E-mail support</span> |
| 1426 |
<span class="f">Pro Features</span> |
| 1427 |
<span class="sv">Save 83%</span> |
| 1428 |
<span class="pri-by">Buy Now</span> |
| 1429 |
</a> |
| 1430 |
</div> |
| 1431 |
<div class="pri-tb"> |
| 1432 |
<a href="https://backupforwp.com/checkout?edd_action=add_to_cart&download_id=1123&edd_options[price_id]=4"> |
| 1433 |
<h5>FREELANCER</h5> |
| 1434 |
<span class="d-amt"><sup>$</sup>299</span> |
| 1435 |
<span class="amt"><sup>$</sup>299</span> |
| 1436 |
<span class="s-amt">(Save $119)</span> |
| 1437 |
<span class="bil">Billed Annually</span> |
| 1438 |
<span class="s">25 Site License</span> |
| 1439 |
<span class="e">E-mail support</span> |
| 1440 |
<span class="f">Pro Features</span> |
| 1441 |
<span class="sv">Save 90%</span> |
| 1442 |
<span class="pri-by">Buy Now</span> |
| 1443 |
</a> |
| 1444 |
</div> |
| 1445 |
<div class="pri-tb"> |
| 1446 |
<a href="https://backupforwp.com/checkout?edd_action=add_to_cart&download_id=1123&edd_options[price_id]=5"> |
| 1447 |
<h5>AGENCY</h5> |
| 1448 |
<span class="d-amt"><sup>$</sup>499</span> |
| 1449 |
<span class="amt"><sup>$</sup>499</span> |
| 1450 |
<span class="s-amt">(Save $199)</span> |
| 1451 |
<span class="bil">Billed Annually</span> |
| 1452 |
<span class="s">Unlimited</span> |
| 1453 |
<span class="e">E-mail support</span> |
| 1454 |
<span class="f">Pro Features</span> |
| 1455 |
<span class="sv">UNLIMITED</span> |
| 1456 |
<span class="pri-by">Buy Now</span> |
| 1457 |
</a> |
| 1458 |
</div> |
| 1459 |
</div><!-- /.pri-lst --> |
| 1460 |
<div class="tru-us"><img src="<?php echo esc_url(WPDB_PLUGIN_URL.'/assets/images/rating.png'); ?>" /> |
| 1461 |
|
| 1462 |
<h2>Trusted by more that 30000+ Users!</h2> |
| 1463 |
<p>More than 30k Websites, Blogs & E-Commerce website are powered by our Backup for WP making it the #1 Rated Backup for WP plugin in WordPress Community.</p> |
| 1464 |
<a href="https://wordpress.org/support/plugin/wp-database-backup/reviews" target="_blank">Read The Reviews</a> |
| 1465 |
</div> |
| 1466 |
</div><!--/ .Backup for WP-upg --> |
| 1467 |
<div class="ampfaq"> |
| 1468 |
<h4>Frequently Asked Questions</h4> |
| 1469 |
<div class="faq-lst"> |
| 1470 |
<div class="lt"> |
| 1471 |
<ul> |
| 1472 |
<li> |
| 1473 |
<span>Is there a setup fee?</span> |
| 1474 |
<p>No. There are no setup fees on any of our plans</p> |
| 1475 |
</li> |
| 1476 |
<li> |
| 1477 |
<span>What's the time span for your contracts?</span> |
| 1478 |
<p>All the plans are year-to-year which are subscribed annually.</p> |
| 1479 |
</li> |
| 1480 |
<li> |
| 1481 |
<span>What payment methods are accepted?</span> |
| 1482 |
<p>We accepts PayPal and Credit Card payments.</p> |
| 1483 |
</li> |
| 1484 |
<li> |
| 1485 |
<span>Do you offer support if I need help?</span> |
| 1486 |
<p>Yes! Top-notch customer support for our paid customers is key for a quality product, so we’ll do our very best to resolve any issues you encounter via our support page.</p> |
| 1487 |
</li> |
| 1488 |
<li> |
| 1489 |
<span>Can I use the plugins after my subscription is expired?</span> |
| 1490 |
<p>Yes, you can use the plugins but you will not get future updates for those plugins.</p> |
| 1491 |
</li> |
| 1492 |
</ul> |
| 1493 |
</div> |
| 1494 |
<div class="rt"> |
| 1495 |
<ul> |
| 1496 |
<li> |
| 1497 |
<span>Can I cancel my membership at any time?</span> |
| 1498 |
<p>Yes. You can cancel your membership by contacting us.</p> |
| 1499 |
</li> |
| 1500 |
<li> |
| 1501 |
<span>Can I change my plan later on?</span> |
| 1502 |
<p>Yes. You can upgrade or downgrade your plan by contacting us.</p> |
| 1503 |
</li> |
| 1504 |
<li> |
| 1505 |
<span>Do you offer refunds?</span> |
| 1506 |
<p>You are fully protected by our 100% Money Back Guarantee Unconditional. If during the next 14 days you experience an issue that makes the plugin unusable and we are unable to resolve it, we’ll happily offer a full refund.</p> |
| 1507 |
</li> |
| 1508 |
<li> |
| 1509 |
<span>Do I get updates for the premium plugin?</span> |
| 1510 |
<p>Yes, you will get updates for all the premium plugins until your subscription is active.</p> |
| 1511 |
</li> |
| 1512 |
</ul> |
| 1513 |
</div> |
| 1514 |
</div><!-- /.faq-lst --> |
| 1515 |
<div class="f-cnt"> |
| 1516 |
<span>I have other pre-sale questions, can you help?</span> |
| 1517 |
<p>All the plans are year-to-year which are subscribed annually.</p> |
| 1518 |
<a href="https://backupforwp.com/contact/?utm_medium=freevspro&utm_campaign=Plugin" target="_blank"> Contact a Human</a> |
| 1519 |
</div><!-- /.f-cnt --> |
| 1520 |
</div><!-- /.faq --> |
| 1521 |
</div><!-- /. wpdb --> |
| 1522 |
</div> |
| 1523 |
|
| 1524 |
</div> |
| 1525 |
|
| 1526 |
<div class="tab-pane" id="db_info"> |
| 1527 |
|
| 1528 |
<div class="panel panel-group panel-default"> |
| 1529 |
<div class="panel-heading"> |
| 1530 |
<a class="toggle_anchor" data-toggle="collapse" data-parent="#accordion" href="#collapsedb"> |
| 1531 |
<h4 class="panel-title"> |
| 1532 |
<?php esc_attr_e( 'System Check', 'wpdbbkp' ); ?> |
| 1533 |
</h4> |
| 1534 |
</a> |
| 1535 |
</div> |
| 1536 |
<div id="collapsedb" class="panel-collapse collapse in"> |
| 1537 |
<div class="panel-body list-group"> |
| 1538 |
|
| 1539 |
<div class="row list-group-item"> |
| 1540 |
<?php |
| 1541 |
$df = $dt = $dp = $du = 'NA'; |
| 1542 |
if(function_exists('disk_free_space')){ |
| 1543 |
/* get disk space free (in bytes) */ |
| 1544 |
$df = disk_free_space( WPDB_ROOTPATH ); |
| 1545 |
/* and get disk space total (in bytes) */ |
| 1546 |
$dt = disk_total_space( WPDB_ROOTPATH ); |
| 1547 |
/* now we calculate the disk space used (in bytes) */ |
| 1548 |
$du = $dt - $df; |
| 1549 |
/* percentage of disk used - this will be used to also set the width % of the progress bar */ |
| 1550 |
if($dt>0){ |
| 1551 |
$dp = sprintf( '%.2f', ( $du / $dt ) * 100 ); |
| 1552 |
} |
| 1553 |
$dp = isset( $dp )? $dp : 'NA'; |
| 1554 |
/* and we formate the size from bytes to MB, GB, etc. */ |
| 1555 |
$df = $this->wp_db_backup_format_bytes( $df ); |
| 1556 |
$du = $this->wp_db_backup_format_bytes( $du ); |
| 1557 |
$dt = $this->wp_db_backup_format_bytes( $dt ); |
| 1558 |
} |
| 1559 |
|
| 1560 |
?> |
| 1561 |
<div class="col-md-1"><a href="" target="_blank" title="Help"><span |
| 1562 |
class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> |
| 1563 |
</div> |
| 1564 |
<div class="col-md-12">Disk Space</div> |
| 1565 |
<div class="col-md-5"> |
| 1566 |
<div class="progress"> |
| 1567 |
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="<?php echo esc_attr( trim( $dp ) ); ?>" aria-valuemin="0" aria-valuemax="100" style="width:<?php echo esc_attr( trim( $dp ) ); ?>%"> <?php echo esc_attr( $dp ); ?>% |
| 1568 |
</div> |
| 1569 |
</div> |
| 1570 |
</div> |
| 1571 |
<div class="col-md-1"></div> |
| 1572 |
<div class="col-md-4"></div> |
| 1573 |
<div class="col-md-5"> |
| 1574 |
<div class='prginfo'> |
| 1575 |
<p><?php echo esc_attr( $du ) . ' of ' . esc_attr( $dt ) . ' used '; ?></p> |
| 1576 |
<p><?php echo esc_attr( $df ) . ' of ' . esc_attr( $dt ) . ' free '; ?></p> |
| 1577 |
<p> |
| 1578 |
<small> |
| 1579 |
<?php esc_attr_e( 'Note: This value is the physical servers hard-drive allocation.', 'wpdbbkp' ); ?> |
| 1580 |
<br/> |
| 1581 |
<?php esc_attr_e( "On shared hosts check your control panel for the 'TRUE' disk space quota value.", 'wpdbbkp' ); ?> |
| 1582 |
</small> |
| 1583 |
</p> |
| 1584 |
</div> |
| 1585 |
|
| 1586 |
</div> |
| 1587 |
</div> |
| 1588 |
|
| 1589 |
<div class=""><br> |
| 1590 |
<a type="button" href="<?php echo esc_url( site_url() ); ?>/wp-admin/admin.php?page=wp-database-backup&action=clear_temp_db_backup_file&_wpnonce=<?php echo esc_attr( $nonce ); ?>" class="btn btn-warning"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Clear all old/temp database backup files</a> |
| 1591 |
<p><?php echo esc_html__("Click above button to clear all your old or temporary created database backup |
| 1592 |
files. |
| 1593 |
It only delete file from backup directory which is not in 'Database Backups' |
| 1594 |
listing(all other file excluding backup files listed in 'Database Backups' ). |
| 1595 |
Before |
| 1596 |
using this option make sure that you have save your database backup on safe |
| 1597 |
place.", 'wpdbbkp') ?></p> |
| 1598 |
<p><?php echo esc_html__("The disk that your backup is saved on doesn't have enough free space? Backup disk |
| 1599 |
is |
| 1600 |
almost full? Low disk space for backup? Backup failed due to lack of space? As |
| 1601 |
you |
| 1602 |
may set up a schedule to automatically do backup daily or weekly, and the size |
| 1603 |
of |
| 1604 |
disk space is limited, so your backup disk will run out of space quickly or |
| 1605 |
someday. |
| 1606 |
It is a real pain to manually delete old backups. Don't worry about it. WP |
| 1607 |
Database |
| 1608 |
Backup makes it easy to delete old/temparary backup files using this option.", 'wpdbbkp') ?></p> |
| 1609 |
|
| 1610 |
</div> |
| 1611 |
|
| 1612 |
<div class="row list-group-item"> |
| 1613 |
<div class="col-md-1"><a href="" target="_blank" title="Help"><span |
| 1614 |
class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> |
| 1615 |
</div> |
| 1616 |
<?php if ( true === isset( $_SERVER['DOCUMENT_ROOT'] ) ) { ?> |
| 1617 |
<div class="col-md-3"><?php echo esc_html__('Root Path', 'wpdbbkp') ?></div> |
| 1618 |
<div class="col-md-5"><?php echo esc_attr( sanitize_text_field( wp_unslash( $_SERVER['DOCUMENT_ROOT'] ) ) ); ?></div> |
| 1619 |
<?php } ?> |
| 1620 |
</div> |
| 1621 |
|
| 1622 |
|
| 1623 |
<div class="row list-group-item"> |
| 1624 |
<div class="col-md-1"><a href="" target="_blank" title="Help"><span |
| 1625 |
class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> |
| 1626 |
</div> |
| 1627 |
<div class="col-md-3"><?php echo esc_html__('ABSPATH', 'wpdbbkp') ?></div> |
| 1628 |
<div class="col-md-5"><?php echo esc_attr( ABSPATH ); ?></div> |
| 1629 |
</div> |
| 1630 |
|
| 1631 |
<div class="row list-group-item"> |
| 1632 |
<div class="col-md-1"><a href="" target="_blank" title="Help"><span |
| 1633 |
class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> |
| 1634 |
</div> |
| 1635 |
<div class="col-md-3"><?php esc_attr_e( 'Upload directory URL', 'wpdbbkp' ); ?></div> |
| 1636 |
<div class="col-md-5"> |
| 1637 |
<?php |
| 1638 |
$upload_dir = wp_upload_dir(); |
| 1639 |
echo esc_url( $upload_dir['baseurl'] ); |
| 1640 |
global $wp_filesystem; |
| 1641 |
if(!function_exists('WP_Filesystem')){ |
| 1642 |
require_once ( ABSPATH . '/wp-admin/includes/file.php' ); |
| 1643 |
} |
| 1644 |
WP_Filesystem(); |
| 1645 |
?> |
| 1646 |
</div> |
| 1647 |
<div class="col-md-3"></div> |
| 1648 |
</div> |
| 1649 |
|
| 1650 |
<div class="row list-group-item"> |
| 1651 |
<div class="col-md-1"><a href="" target="_blank" title="Help"><span |
| 1652 |
class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> |
| 1653 |
</div> |
| 1654 |
<div class="col-md-3"><?php esc_attr_e( 'Upload directory', 'wpdbbkp' ); ?></div> |
| 1655 |
<div class="col-md-5"><?php echo esc_attr( $upload_dir['basedir'] ); ?></div> |
| 1656 |
<div class="col-md-1"> |
| 1657 |
<?php echo esc_attr( substr( sprintf( '%o', fileperms( $upload_dir['basedir'] ) ), -4 ) ); ?></div> |
| 1658 |
<div |
| 1659 |
class="col-md-2"><?php echo ( ! $wp_filesystem->is_writable( $upload_dir['basedir']) ) ? '<p class="text-danger"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Not writable </p>' : '<p class="text-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span> writable</p>'; ?> |
| 1660 |
</div> |
| 1661 |
</div> |
| 1662 |
|
| 1663 |
<div class="row list-group-item"> |
| 1664 |
<div class="col-md-1"><a href="" target="_blank" title="Help"><span |
| 1665 |
class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> |
| 1666 |
</div> |
| 1667 |
<div class="col-md-3"><?php echo esc_html__('Loaded PHP INI', 'wpdbbkp') ?></div> |
| 1668 |
<div class="col-md-5"><?php echo esc_attr( php_ini_loaded_file() ); ?></div> |
| 1669 |
</div> |
| 1670 |
<div class="row list-group-item"> |
| 1671 |
<div class="col-md-1"><a href="" target="_blank" title="Help"><span |
| 1672 |
class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> |
| 1673 |
</div> |
| 1674 |
<div class="col-md-3"><?php echo esc_html__('Memory Limit', 'wpdbbkp') ?></div> |
| 1675 |
<div class="col-md-5"> |
| 1676 |
<?php |
| 1677 |
echo esc_attr( WP_MEMORY_LIMIT ); |
| 1678 |
echo '(Max ' . esc_attr( WP_MAX_MEMORY_LIMIT ); |
| 1679 |
?> ) |
| 1680 |
</div> |
| 1681 |
</div> |
| 1682 |
|
| 1683 |
|
| 1684 |
<div class="row list-group-item"> |
| 1685 |
<div class="col-md-1"><a href="" target="_blank" title="Help"><span |
| 1686 |
class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> |
| 1687 |
</div> |
| 1688 |
<div class="col-md-3"><?php esc_attr_e( 'Max Execution Time', 'wpdbbkp' ); ?></div> |
| 1689 |
<div class="col-md-5"> <?php echo esc_attr( ini_get( 'max_execution_time' ) ); ?></div> |
| 1690 |
<div class="col-md-1"></div> |
| 1691 |
<div |
| 1692 |
class="col-md-2"><?php echo esc_attr( ini_get( 'max_execution_time' ) ) < 60 ? '<p class="text-danger" data-toggle="tooltip" data-placement="left" title="For large site set high"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Low </p>' : ''; ?></div> |
| 1693 |
</div> |
| 1694 |
<div class="row list-group-item"> |
| 1695 |
<div class="col-md-1"><a href="" target="_blank" title="Help"><span |
| 1696 |
class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> |
| 1697 |
</div> |
| 1698 |
<div class="col-md-3"><?php esc_attr_e( 'Database backup directory', 'wpdbbkp' ); ?></div> |
| 1699 |
<div |
| 1700 |
class="col-md-5"> <?php echo esc_attr( $upload_dir['basedir'] . '/db-backup' ); ?></div> |
| 1701 |
<div |
| 1702 |
class="col-md-1"><?php echo esc_attr( substr( sprintf( '%o', @fileperms( esc_attr( $upload_dir['basedir'] ) . '/db-backup' ) ), -4 ) ); ?></div> |
| 1703 |
<div |
| 1704 |
class="col-md-2"><?php echo ( ! $wp_filesystem->is_writable( $upload_dir['basedir'] . '/db-backup' ) ) ? '<p class="text-danger"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Not writable </p>' : '<p class="text-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span> writable</p>'; ?></div> |
| 1705 |
</div> |
| 1706 |
|
| 1707 |
<div class="row list-group-item"> |
| 1708 |
<div class="col-md-1"><a href="" target="_blank" title="Help"><span |
| 1709 |
class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> |
| 1710 |
</div> |
| 1711 |
<div class="col-md-3"><?php esc_attr_e( 'Class ZipArchive Present : ', 'wpdbbkp' ); ?></div> |
| 1712 |
<div class="col-md-5"> |
| 1713 |
<?php |
| 1714 |
echo ( class_exists( 'ZipArchive' ) ) ? 'Yes </p>' : '<p class="">No</p>'; |
| 1715 |
?> |
| 1716 |
</div> |
| 1717 |
<div class="col-md-3"></div> |
| 1718 |
</div> |
| 1719 |
|
| 1720 |
<div class="row list-group-item"> |
| 1721 |
<div class="col-md-1"><a href="" target="_blank" title="Help"><span |
| 1722 |
class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> |
| 1723 |
</div> |
| 1724 |
<div class="col-md-3"><?php esc_attr_e( 'mysqldump (cmd) Present : ', 'wpdbbkp' ); ?></div> |
| 1725 |
<div class="col-md-5"> |
| 1726 |
<?php |
| 1727 |
$wpdb_admin = new Wpdb_Admin(); |
| 1728 |
echo ( $wpdb_admin->get_mysqldump_command_path() ) ? 'Yes </p>' : '<p class="">No</p>'; |
| 1729 |
?> |
| 1730 |
</div> |
| 1731 |
<div class="col-md-3"></div> |
| 1732 |
</div> |
| 1733 |
|
| 1734 |
</div> |
| 1735 |
</div> |
| 1736 |
</div> |
| 1737 |
|
| 1738 |
<div class="panel panel-default"> |
| 1739 |
<div class="panel-heading"> |
| 1740 |
<a class="toggle_anchor" data-toggle="collapse" data-parent="#accordion" href="#collapsedbinfo"> |
| 1741 |
<h4 class="panel-title"><?php echo esc_html__('Database Information', 'wpdbbkp') ?></h4> |
| 1742 |
</a> |
| 1743 |
</div> |
| 1744 |
|
| 1745 |
<div id="collapsedbinfo" class="panel-collapse collapse in"> |
| 1746 |
<div class="panel-body"> |
| 1747 |
<table class="table table-condensed"> |
| 1748 |
<tr class="success"> |
| 1749 |
<th><?php echo esc_html__('Setting', 'wpdbbkp') ?></th> |
| 1750 |
<th><?php echo esc_html__('Value', 'wpdbbkp') ?></th> |
| 1751 |
</tr> |
| 1752 |
<tr> |
| 1753 |
<td><?php echo esc_html__('Database Host', 'wpdbbkp') ?></td> |
| 1754 |
<td><?php echo esc_attr( DB_HOST ); ?></td> |
| 1755 |
</tr> |
| 1756 |
<tr class="default"> |
| 1757 |
<td><?php echo esc_html__('Database Name', 'wpdbbkp') ?></td> |
| 1758 |
<td> <?php echo esc_attr( DB_NAME ); ?></td> |
| 1759 |
</tr> |
| 1760 |
<tr> |
| 1761 |
<td><?php echo esc_html__('Database User', 'wpdbbkp') ?></td> |
| 1762 |
<td><?php echo esc_attr( DB_USER ); ?></td> |
| 1763 |
</td> |
| 1764 |
</tr> |
| 1765 |
<tr> |
| 1766 |
<td><?php echo esc_html__('Database Type', 'wpdbbkp') ?></td> |
| 1767 |
<td><?php echo esc_html__('MYSQL', 'wpdbbkp') ?></td> |
| 1768 |
</tr> |
| 1769 |
<tr> |
| 1770 |
<?php |
| 1771 |
// Get MYSQL Version. |
| 1772 |
global $wpdb; |
| 1773 |
$mysqlversion = wp_cache_get( 'wpdb_mysqlversion' ); |
| 1774 |
if ( true === empty( $mysqlversion ) ) { |
| 1775 |
$mysqlversion = $wpdb->get_var( 'SELECT VERSION() AS version' ); // phpcs:ignore |
| 1776 |
wp_cache_set( 'wpdb_mysqlversion', $mysqlversion, '', 18000 ); |
| 1777 |
} |
| 1778 |
?> |
| 1779 |
<td><?php echo esc_html__('Database Version', 'wpdbbkp') ?></td> |
| 1780 |
<td>v<?php echo esc_attr( $mysqlversion ); ?></td> |
| 1781 |
</tr> |
| 1782 |
</table> |
| 1783 |
|
| 1784 |
</div> |
| 1785 |
</div> |
| 1786 |
</div> |
| 1787 |
|
| 1788 |
<div class="panel panel-default"> |
| 1789 |
<div class="panel-heading"> |
| 1790 |
|
| 1791 |
<a class="toggle_anchor" data-toggle="collapse" data-parent="#accordion" href="#collapsedbtable"> |
| 1792 |
<h4 class="panel-title"> |
| 1793 |
<?php echo esc_html__('Tables Information', 'wpdbbkp') ?> |
| 1794 |
</h4> |
| 1795 |
</a> |
| 1796 |
|
| 1797 |
</div> |
| 1798 |
<div id="collapsedbtable" class="panel-collapse collapse in"> |
| 1799 |
<div class="panel-body"> |
| 1800 |
<table class="table table-condensed"> |
| 1801 |
<tr class="success"> |
| 1802 |
<th><?php echo esc_html__('No.', 'wpdbbkp') ?></th> |
| 1803 |
<th><?php echo esc_html__('Tables', 'wpdbbkp') ?></th> |
| 1804 |
<th><?php echo esc_html__('Records', 'wpdbbkp') ?></th> |
| 1805 |
|
| 1806 |
</tr> |
| 1807 |
<?php |
| 1808 |
$no = 0; |
| 1809 |
$row_usage = 0; |
| 1810 |
$data_usage = 0; |
| 1811 |
$tablesstatus = $wpdb->get_results( 'SHOW TABLE STATUS' ); // phpcs:ignore |
| 1812 |
if($tablesstatus != null && !empty($tablesstatus)){ |
| 1813 |
foreach ( $tablesstatus as $tablestatus ) { |
| 1814 |
$tablestatus_arr = (array) $tablestatus; |
| 1815 |
if ( 0 === ( $no % 2 ) ) { |
| 1816 |
$style = ''; |
| 1817 |
} else { |
| 1818 |
$style = ' class="alternate"'; |
| 1819 |
} |
| 1820 |
$no++; |
| 1821 |
echo '<tr' . esc_attr( $style ) . '>'; |
| 1822 |
echo '<td>' . esc_attr( number_format_i18n( $no ) ) . '</td>'; |
| 1823 |
echo '<td>' . esc_attr( $tablestatus_arr['Name'] ) . '</td>'; |
| 1824 |
echo '<td>' . esc_attr( number_format_i18n( isset($tablestatus_arr['Rows'])?$tablestatus_arr['Rows']:0 ) ) . '</td>'; |
| 1825 |
|
| 1826 |
$row_usage += $tablestatus_arr['Rows']; |
| 1827 |
|
| 1828 |
echo '</tr>'; |
| 1829 |
} |
| 1830 |
} |
| 1831 |
echo '<tr class="thead">'; |
| 1832 |
echo '<th> Total:</th>'; |
| 1833 |
echo '<th>' . esc_attr( number_format_i18n( $no ) ) . ' Table </th>'; |
| 1834 |
echo '<th>' . esc_attr( number_format_i18n( $row_usage ) ) . ' Records</th>'; |
| 1835 |
|
| 1836 |
echo '</tr>'; |
| 1837 |
?> |
| 1838 |
</table> |
| 1839 |
|
| 1840 |
</div> |
| 1841 |
</div> |
| 1842 |
</div> |
| 1843 |
<div class="panel panel-default"> |
| 1844 |
<div class="panel-heading"> |
| 1845 |
|
| 1846 |
<a class="toggle_anchor" data-toggle="collapse" data-parent="#accordion" href="#collapsewp"> |
| 1847 |
<h4 class="panel-title"> |
| 1848 |
<?php echo esc_html__('WordPress Information', 'wpdbbkp') ?> |
| 1849 |
</h4> |
| 1850 |
</a> |
| 1851 |
|
| 1852 |
</div> |
| 1853 |
<div id="collapsewp" class="panel-collapse collapse in"> |
| 1854 |
<div class="panel-body"> |
| 1855 |
<table class="table table-condensed"> |
| 1856 |
<tr class="success"> |
| 1857 |
<th><?php echo esc_html__('Setting', 'wpdbbkp') ?></th> |
| 1858 |
<th><?php echo esc_html__('Value', 'wpdbbkp') ?></th> |
| 1859 |
|
| 1860 |
</tr> |
| 1861 |
<tr> |
| 1862 |
<td><?php echo esc_html__('WordPress Version', 'wpdbbkp') ?></td> |
| 1863 |
<td><?php bloginfo( 'version' ); ?></td> |
| 1864 |
</tr> |
| 1865 |
<tr> |
| 1866 |
<td><?php echo esc_html__('Home URL', 'wpdbbkp') ?></td> |
| 1867 |
<td> <?php echo esc_url( home_url() ); ?></td> |
| 1868 |
</tr> |
| 1869 |
<tr> |
| 1870 |
<td><?php echo esc_html__('Site URL', 'wpdbbkp') ?></td> |
| 1871 |
<td><?php echo esc_url( site_url() ); ?></td> |
| 1872 |
</tr> |
| 1873 |
<tr> |
| 1874 |
<td><?php echo esc_html__('Upload directory URL', 'wpdbbkp') ?></td> |
| 1875 |
<td><?php $upload_dir = wp_upload_dir(); ?> |
| 1876 |
<?php echo esc_url( $upload_dir['baseurl'] ); ?></td> |
| 1877 |
</tr> |
| 1878 |
</table> |
| 1879 |
|
| 1880 |
</div> |
| 1881 |
</div> |
| 1882 |
</div> |
| 1883 |
|
| 1884 |
<div class="panel panel-default"> |
| 1885 |
<div class="panel-heading"> |
| 1886 |
|
| 1887 |
<a class="toggle_anchor" data-toggle="collapse" data-parent="#accordion" href="#collapsewpsetting"> |
| 1888 |
<h4 class="panel-title"> |
| 1889 |
<?php echo esc_html__('WordPress Settings', 'wpdbbkp') ?> |
| 1890 |
</h4> |
| 1891 |
</a> |
| 1892 |
|
| 1893 |
</div> |
| 1894 |
<div id="collapsewpsetting" class="panel-collapse collapse in"> |
| 1895 |
<div class="panel-body"> |
| 1896 |
<table class="table table-condensed"> |
| 1897 |
<tr class="success"> |
| 1898 |
<th><?php echo esc_html__('Plugin Name', 'wpdbbkp') ?></th> |
| 1899 |
<th><?php echo esc_html__('Version', 'wpdbbkp') ?></th> |
| 1900 |
</tr> |
| 1901 |
<?php |
| 1902 |
$plugins = get_plugins(); |
| 1903 |
if(!empty($plugins) && is_array($plugins)){ |
| 1904 |
foreach ( $plugins as $plugin ) { |
| 1905 |
echo '<tr> |
| 1906 |
<td>' . esc_attr( $plugin['Name'] ) . '</td> |
| 1907 |
<td>' . esc_attr( $plugin['Version'] ) . '</td> |
| 1908 |
</tr>'; |
| 1909 |
} |
| 1910 |
} |
| 1911 |
|
| 1912 |
?> |
| 1913 |
</table> |
| 1914 |
<table class="table table-condensed"> |
| 1915 |
<tr class="success"> |
| 1916 |
<th><?php echo esc_html__('Active Theme Name', 'wpdbbkp') ?></th> |
| 1917 |
<th><?php echo esc_html__('Version', 'wpdbbkp') ?></th> |
| 1918 |
</tr> |
| 1919 |
<?php |
| 1920 |
$my_theme = wp_get_theme(); |
| 1921 |
|
| 1922 |
echo '<tr> |
| 1923 |
<td>' . esc_attr( $my_theme->get( 'Name' ) ) . '</td> |
| 1924 |
<td>' . esc_attr( $my_theme->get( 'Version' ) ) . '</td> |
| 1925 |
</tr>'; |
| 1926 |
?> |
| 1927 |
</table> |
| 1928 |
<div class="row"> |
| 1929 |
<button class="btn btn-primary" type="button"> |
| 1930 |
<?php echo esc_html__('Drafts Post Count', 'wpdbbkp') ?> <span class="badge"> |
| 1931 |
<?php |
| 1932 |
$count_posts = wp_count_posts(); |
| 1933 |
echo esc_attr( $count_posts->draft ); |
| 1934 |
?> |
| 1935 |
</span> |
| 1936 |
</button> |
| 1937 |
<button class="btn btn-primary" type="button"> |
| 1938 |
<?php echo esc_html__('Publish Post Count', 'wpdbbkp') ?> <span class="badge"> |
| 1939 |
<?php |
| 1940 |
|
| 1941 |
echo esc_attr( $count_posts->publish ); |
| 1942 |
?> |
| 1943 |
</span> |
| 1944 |
</button> |
| 1945 |
<button class="btn btn-primary" type="button"> |
| 1946 |
<?php echo esc_html__('Drafts Pages Count', 'wpdbbkp') ?> <span class="badge"> |
| 1947 |
<?php |
| 1948 |
$count_pages = wp_count_posts( 'page' ); |
| 1949 |
echo esc_attr( $count_pages->draft ); |
| 1950 |
?> |
| 1951 |
</span> |
| 1952 |
</button> |
| 1953 |
<button class="btn btn-primary" type="button"> |
| 1954 |
<?php echo esc_html__('Publish Pages Count', 'wpdbbkp') ?> <span class="badge"> |
| 1955 |
<?php |
| 1956 |
|
| 1957 |
echo esc_attr( $count_pages->publish ); |
| 1958 |
?> |
| 1959 |
</span> |
| 1960 |
</button> |
| 1961 |
<button class="btn btn-primary" type="button"> |
| 1962 |
<?php echo esc_html__('Approved Comments Count', 'wpdbbkp') ?> <span class="badge"> |
| 1963 |
<?php |
| 1964 |
$comments_count = wp_count_comments(); |
| 1965 |
echo esc_attr( $comments_count->approved ); |
| 1966 |
?> |
| 1967 |
</span> |
| 1968 |
</button> |
| 1969 |
</div> |
| 1970 |
</div> |
| 1971 |
</div> |
| 1972 |
</div> |
| 1973 |
|
| 1974 |
|
| 1975 |
</div> |
| 1976 |
|
| 1977 |
<div class="tab-pane" id="db_setting"> |
| 1978 |
|
| 1979 |
<div class="panel-group"> |
| 1980 |
<?php |
| 1981 |
$wp_local_db_backup_count = get_option( 'wp_local_db_backup_count' ); |
| 1982 |
$wp_db_log = get_option( 'wp_db_log' ); |
| 1983 |
$wp_db_exclude_table = array(); |
| 1984 |
$wp_db_exclude_table = get_option( 'wp_db_exclude_table' ); |
| 1985 |
$wp_db_backup_enable_auto_upgrade = get_option( 'wp_db_backup_enable_auto_upgrade' ); |
| 1986 |
if ( 1 === (int) $wp_db_backup_enable_auto_upgrade ) { |
| 1987 |
$wp_db_backup_enable_auto_upgrade_checked = 'checked'; |
| 1988 |
} else { |
| 1989 |
$wp_db_backup_enable_auto_upgrade_checked = ''; |
| 1990 |
} |
| 1991 |
if ( 1 === (int) $wp_db_log ) { |
| 1992 |
$checked = 'checked'; |
| 1993 |
} else { |
| 1994 |
$checked = ''; |
| 1995 |
} |
| 1996 |
$wp_db_remove_local_backup = get_option( 'wp_db_remove_local_backup' ); |
| 1997 |
$wp_db_remove_on_uninstall = get_option( 'wp_db_remove_on_uninstall'); |
| 1998 |
$wp_db_incremental_backup = get_option( 'wp_db_incremental_backup'); |
| 1999 |
$wp_db_save_settings_in_backup = get_option( 'wp_db_save_settings_in_backup',1); |
| 2000 |
if ( 1 === (int) $wp_db_remove_local_backup ) { |
| 2001 |
$remove_local_backup = 'checked'; |
| 2002 |
} else { |
| 2003 |
$remove_local_backup = ''; |
| 2004 |
} |
| 2005 |
if ( 1 === (int) $wp_db_remove_on_uninstall ) { |
| 2006 |
$remove_on_uninstall = 'checked'; |
| 2007 |
} else { |
| 2008 |
$remove_on_uninstall = ''; |
| 2009 |
} |
| 2010 |
if ( 1 === (int) $wp_db_incremental_backup ) { |
| 2011 |
$incremental_backup = 'checked'; |
| 2012 |
} else { |
| 2013 |
$incremental_backup = ''; |
| 2014 |
} |
| 2015 |
if ( 1 === (int) $wp_db_save_settings_in_backup ) { |
| 2016 |
$save_on_backup = 'checked'; |
| 2017 |
} else { |
| 2018 |
$save_on_backup = ''; |
| 2019 |
} |
| 2020 |
?> |
| 2021 |
<form action="" method="post"> |
| 2022 |
<?php wp_nonce_field( 'wp-database-backup' ); ?> |
| 2023 |
<div class="input-group"> |
| 2024 |
<span class="input-group-addon" id="sizing-addon2"><?php echo esc_html__('Maximum Local Backups', 'wpdbbkp') ?></span> |
| 2025 |
<input type="number" name="wp_local_db_backup_count" value="<?php echo esc_html( $wp_local_db_backup_count ); ?>" class="form-control" placeholder="<?php esc_attr_e('Maximum Local Backups','wpdbbkp');?>" aria-describedby="sizing-addon2"> |
| 2026 |
|
| 2027 |
</div><br> |
| 2028 |
<p><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span><?php echo esc_html__(' The maximum |
| 2029 |
number of Local Database Backups that should be kept, regardless of their size.', 'wpdbbkp') ?></br> |
| 2030 |
<?php echo esc_html__('Leave blank for keep unlimited database backups.', 'wpdbbkp') ?> |
| 2031 |
</p> |
| 2032 |
|
| 2033 |
<hr> |
| 2034 |
<div class="input-group"> |
| 2035 |
<label><input type="checkbox" <?php echo esc_attr( $checked ); ?> name="wp_db_log"> <?php echo esc_html__('Enable Log', 'wpdbbkp') ?></label> |
| 2036 |
</div> |
| 2037 |
<br> |
| 2038 |
<p><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> |
| 2039 |
<?php echo esc_html__(' Create a log file to record details of each backup operation. ', 'wpdbbkp') ?> |
| 2040 |
</p> |
| 2041 |
|
| 2042 |
<hr> |
| 2043 |
<div class="input-group"> |
| 2044 |
<label><input type="checkbox" <?php echo esc_attr( $wp_db_backup_enable_auto_upgrade_checked ); ?> name="wp_db_backup_enable_auto_upgrade"> <?php echo esc_html__('Enable Auto Backups Before Upgrade', 'wpdbbkp') ?></label> |
| 2045 |
<p><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> |
| 2046 |
<?php echo esc_html__('If checked then it will create database backup on(before) upgrade/update plugin, theme, WordPress.', 'wpdbbkp') ?> |
| 2047 |
<br><?php echo esc_html__('Leave blank/un-checked for disable this feature.', 'wpdbbkp') ?> |
| 2048 |
</p> |
| 2049 |
</div> |
| 2050 |
<hr> |
| 2051 |
<div class="input-group"> |
| 2052 |
<label><input type="checkbox" <?php echo esc_attr( $remove_local_backup ); ?> name="wp_db_remove_local_backup"> <?php echo esc_html__('Remove local backup', 'wpdbbkp') ?></label> |
| 2053 |
<p><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> |
| 2054 |
<?php echo esc_html__('If Checked then it will remove local backup.', 'wpdbbkp') ?> |
| 2055 |
<?php echo esc_html__('Use this option only when you have set any destination.', 'wpdbbkp') ?> |
| 2056 |
<?php echo esc_html__('If somesites you need only external backup.', 'wpdbbkp') ?> |
| 2057 |
</p> |
| 2058 |
</div> |
| 2059 |
<hr> |
| 2060 |
<div class="input-group"> |
| 2061 |
<label><input type="checkbox" <?php echo esc_attr( $save_on_backup ); ?> name="wp_db_save_settings_in_backup"> <?php echo esc_html__('Skip plugin settings from database backup', 'wpdbbkp') ?></label> |
| 2062 |
<p><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> |
| 2063 |
<?php echo esc_html__('If Checked then it will skip Backup for WP plugin settings from the DB backup file .', 'wpdbbkp') ?> |
| 2064 |
</p> |
| 2065 |
</div> |
| 2066 |
<hr> |
| 2067 |
<div class="input-group"> |
| 2068 |
<label><input type="checkbox" <?php echo esc_attr( $remove_on_uninstall ); ?> name="wp_db_remove_on_uninstall"> <?php echo esc_html__('Delete Data and options on uninstall', 'wpdbbkp') ?></label> |
| 2069 |
<p><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> |
| 2070 |
<?php echo esc_html__('If Checked then it will delete all backup files and options when plugin is uninstalled', 'wpdbbkp') ?> |
| 2071 |
|
| 2072 |
</p> |
| 2073 |
</div> |
| 2074 |
|
| 2075 |
<?php |
| 2076 |
$remove_backup_href = esc_url( site_url() ) . '/wp-admin/admin.php?page=wp-database-backup&action=removeallbackup&_wpnonce=' . esc_attr( $nonce ); ?> |
| 2077 |
|
| 2078 |
<div class="input-group"> |
| 2079 |
<a title="Remove Database Backup" onclick="return confirm('Are you sure you want to delete all the backups? Deleted backups can not be recovered.')" href="<?php echo esc_url($remove_backup_href)?>" class="btn btn-danger" style="margin-bottom:10px;"><span class="glyphicon glyphicon-trash"></span> <?php esc_html_e('Delete all Backups', 'wpdbbkp')?></a> |
| 2080 |
<p> <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> |
| 2081 |
<?php echo esc_html__('Warning :This is will delete all the backups on the website. Once deleted backups can not be recovered.', 'wpdbbkp') ?> |
| 2082 |
</p> |
| 2083 |
|
| 2084 |
|
| 2085 |
</div> |
| 2086 |
<hr> |
| 2087 |
<div class="panel panel-default"> |
| 2088 |
<div class="panel-heading"> |
| 2089 |
<a data-toggle="collapse" data-parent="#accordion" href="#collapseExclude"> |
| 2090 |
<h4 class="panel-title"> |
| 2091 |
<?php echo esc_html__('Exclude Table From Database Backup', 'wpdbbkp') ?> |
| 2092 |
</h4> |
| 2093 |
</a> |
| 2094 |
</div> |
| 2095 |
<div id="collapseExclude" class="panel-collapse collapse in"> |
| 2096 |
<div class="panel-body"> |
| 2097 |
<table class="table table-condensed"> |
| 2098 |
<tr class="success"> |
| 2099 |
<th><?php echo esc_html__('No.', 'wpdbbkp') ?></th> |
| 2100 |
<th><?php echo esc_html__('Tables', 'wpdbbkp') ?></th> |
| 2101 |
<th><?php echo esc_html__('Records', 'wpdbbkp') ?></th> |
| 2102 |
<th><?php echo esc_html__('Exclude Table', 'wpdbbkp') ?></th> |
| 2103 |
</tr> |
| 2104 |
<?php |
| 2105 |
$no = 0; |
| 2106 |
$row_usage = 0; |
| 2107 |
$data_usage = 0; |
| 2108 |
$tablesstatus = $wpdb->get_results( 'SHOW TABLE STATUS' ); // phpcs:ignore |
| 2109 |
if($tablesstatus != null && !empty($tablesstatus)){ |
| 2110 |
foreach ( $tablesstatus as $tablestatus ) { |
| 2111 |
$tablestatus_arr = (array) $tablestatus; |
| 2112 |
if ( 0 === ( $no % 2 ) ) { |
| 2113 |
$style = ''; |
| 2114 |
} else { |
| 2115 |
$style = ' class="alternate"'; |
| 2116 |
} |
| 2117 |
$no++; |
| 2118 |
echo '<tr' . esc_attr( $style ) . '>'; |
| 2119 |
echo '<td>' . esc_attr( number_format_i18n( $no ) ) . '</td>'; |
| 2120 |
echo '<td>' . esc_attr( $tablestatus_arr['Name'] ) . '</td>'; |
| 2121 |
echo '<td>' . esc_attr( number_format_i18n( isset($tablestatus_arr['Rows'])?$tablestatus_arr['Rows']:0 ) ) . '</td>'; |
| 2122 |
if ( false === empty( $wp_db_exclude_table ) && in_array( $tablestatus_arr['Name'], $wp_db_exclude_table, true ) ) { |
| 2123 |
$checked = 'checked'; |
| 2124 |
} else { |
| 2125 |
$checked = ''; |
| 2126 |
} |
| 2127 |
echo '<td> <input class="wp_db_exclude_table" type="checkbox" ' . esc_attr( $checked ) . ' value="' . esc_attr( $tablestatus_arr['Name'] ) . '" name="wp_db_exclude_table[' . esc_attr( $tablestatus_arr['Name'] ) . ']"></td>'; |
| 2128 |
|
| 2129 |
$row_usage += $tablestatus_arr['Rows']; |
| 2130 |
|
| 2131 |
echo '</tr>'; |
| 2132 |
} |
| 2133 |
} |
| 2134 |
echo '<tr class="thead">'; |
| 2135 |
echo '<th>Total:</th>'; |
| 2136 |
echo '<th>' . esc_attr( number_format_i18n( $no ) ) . ' Table</th>'; |
| 2137 |
echo '<th>' . esc_attr( number_format_i18n( $row_usage ) ) . ' Records</th>'; |
| 2138 |
echo '<th></th>'; |
| 2139 |
echo '</tr>'; |
| 2140 |
?> |
| 2141 |
</table> |
| 2142 |
</div> |
| 2143 |
</div> |
| 2144 |
</div> |
| 2145 |
<hr> |
| 2146 |
<input class="btn btn-primary" type="submit" name="wpsetting" value="Save"> |
| 2147 |
</form> |
| 2148 |
</div> |
| 2149 |
</div> |
| 2150 |
|
| 2151 |
<div class="tab-pane" id="searchreplace"> |
| 2152 |
<div class="panel-group"> |
| 2153 |
<?php |
| 2154 |
$wp_db_backup_search_text = get_option( 'wp_db_backup_search_text' ); |
| 2155 |
$wp_db_backup_replace_text = get_option( 'wp_db_backup_replace_text' ); |
| 2156 |
?> |
| 2157 |
<form action="" method="post"> |
| 2158 |
<?php wp_nonce_field( 'wp-database-backup' ); ?> |
| 2159 |
|
| 2160 |
<p><?php echo esc_html__('If you even need to migrate your WordPress site to a different domain name, |
| 2161 |
or add an SSL certificate to it, you must update the URLs in your database backup file |
| 2162 |
then you can use this feature.','wpdbbkp'); ?> <br> |
| 2163 |
<?php echo esc_html__(' This feature allow you to Search and Replace text in your database backup file. ','wpdbbkp'); ?> |
| 2164 |
<br> <?php echo esc_html__('if you want only exclude tables from search and replace text then Go to Dashboard=>Tool=>WP-DB Backup > Setting > Exclude Table From Database Backup setting. The tables you selected will be skipped over for each backup you make.', 'wpdbbkp') ?> |
| 2165 |
</p> |
| 2166 |
<br> |
| 2167 |
<div class="input-group"> |
| 2168 |
<span class="input-group-addon" id="wp_db_backup_search_text"><?php echo esc_html__('Search For', 'wpdbbkp') ?></span> |
| 2169 |
<input type="text" name="wp_db_backup_search_text" value="<?php echo esc_html( $wp_db_backup_search_text ); ?>" class="form-control" placeholder="<?php esc_attr_e('https://example.com/wordpress','wpdbbkp'); ?>" aria-describedby="wp_db_backup_search_text"> |
| 2170 |
|
| 2171 |
</div> |
| 2172 |
<br> |
| 2173 |
<div class="input-group"> |
| 2174 |
<span class="input-group-addon" id="wp_db_backup_replace_text"><?php echo esc_html__('Replace With', 'wpdbbkp') ?></span> |
| 2175 |
<input type="text" name="wp_db_backup_replace_text" value="<?php echo esc_html( $wp_db_backup_replace_text ); ?>" class="form-control" placeholder="<?php esc_attr_e('http://site.com','wpdbbkp');?>" aria-describedby="wp_db_backup_replace_text"> |
| 2176 |
|
| 2177 |
</div> |
| 2178 |
|
| 2179 |
<div class="alert alert-default" role="alert"> |
| 2180 |
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> |
| 2181 |
<?php echo esc_html__("Leave blank those fields if you don't want use this feature and want only regular Database backup.", 'wpdbbkp') ?> |
| 2182 |
<br> |
| 2183 |
<?php echo esc_html__('Ex:', 'wpdbbkp') ?> |
| 2184 |
<br><?php echo esc_html__('Search For:', 'wpdbbkp') ?> <?php echo esc_url('http://example.com/wordpress/', 'wpdbbkp'); ?> |
| 2185 |
<br><?php echo esc_html__('Replace With:', 'wpdbbkp') ?> <?php echo esc_url('http://domain.com/', 'wpdbbkp') ?> |
| 2186 |
|
| 2187 |
<br><br> |
| 2188 |
<?php echo esc_html__('Note - This is Search & Replace data in your WordPress Database Backup File not in current Database installation.', 'wpdbbkp') ?> |
| 2189 |
|
| 2190 |
</div> |
| 2191 |
|
| 2192 |
<input class="btn btn-primary" type="submit" name="wpsetting_search" value="Save"> |
| 2193 |
</form> |
| 2194 |
</div> |
| 2195 |
|
| 2196 |
|
| 2197 |
|
| 2198 |
</div> |
| 2199 |
<div class="tab-pane panel-group" id="db_destination"> |
| 2200 |
<?php |
| 2201 |
include plugin_dir_path( __FILE__ ) . 'Destination/wp-backup-destination.php'; |
| 2202 |
?> |
| 2203 |
</div> |
| 2204 |
|
| 2205 |
|
| 2206 |
</div> |
| 2207 |
</div> |
| 2208 |
|
| 2209 |
|
| 2210 |
</div> |
| 2211 |
<a aria-label="Open Support" aria-expanded="false" class="wpdbbkp-support-button" href="https://backupforwp.com/support/" target="_blank"> |
| 2212 |
<span class="wpdbbkp-support-icon"> |
| 2213 |
<svg width="24" height="22" xmlns="http://www.w3.org/2000/svg"><path d="M20.347 20.871l-.003-.05c0 .017.001.034.003.05zm-.243-4.278a2 2 0 0 1 .513-1.455c1.11-1.226 1.383-2.212 1.383-4.74C22 5.782 18.046 2 13.125 2h-2.25C5.954 2 2 5.78 2 10.399c0 4.675 4.01 8.626 8.875 8.626h2.25c.834 0 1.606-.207 3.212-.798a2 2 0 0 1 1.575.083l2.355 1.161-.163-2.878zM10.875 0h2.25C19.13 0 24 4.656 24 10.399c0 2.6-.25 4.257-1.9 6.08l.243 4.279c.072.845-.807 1.471-1.633 1.162l-3.682-1.816c-1.212.446-2.527.921-3.903.921h-2.25C4.869 21.025 0 16.142 0 10.4 0 4.656 4.869 0 10.875 0z" fill="#FFF"></path></svg> |
| 2214 |
</span> |
| 2215 |
</a> |
| 2216 |
<?php |
| 2217 |
} |
| 2218 |
|
| 2219 |
/** |
| 2220 |
* Redirect to premium website |
| 2221 |
*/ |
| 2222 |
public function wp_db_backup_premium_interface_render() |
| 2223 |
{ |
| 2224 |
wp_safe_redirect("https://backupforwp.com/pricing/#price"); |
| 2225 |
exit; |
| 2226 |
} |
| 2227 |
|
| 2228 |
/** |
| 2229 |
* Run after complete backup. |
| 2230 |
* |
| 2231 |
* @param bool $bytes - bytes details. |
| 2232 |
* @param int $precision - precision details. |
| 2233 |
*/ |
| 2234 |
public function wp_db_backup_format_bytes( $bytes, $precision = 2 ) { |
| 2235 |
$units = array( 'B', 'KB', 'MB', 'GB', 'TB' ); |
| 2236 |
$bytes = max( $bytes, 0 ); |
| 2237 |
$pow = floor( ( $bytes ? log( $bytes ) : 0 ) / log( 1024 ) ); |
| 2238 |
$pow = min( $pow, count( $units ) - 1 ); |
| 2239 |
$bytes /= pow( 1024, $pow ); |
| 2240 |
return round( $bytes, $precision ) . ' ' . $units[ $pow ]; |
| 2241 |
} |
| 2242 |
|
| 2243 |
/** |
| 2244 |
* Create database bakup function. |
| 2245 |
*/ |
| 2246 |
public function wp_db_backup_create_mysql_backup() { |
| 2247 |
global $wpdb; |
| 2248 |
/* BEGIN : Prevent saving backup plugin settings in the database dump */ |
| 2249 |
$options_backup = get_option( 'wp_db_backup_backups' ); |
| 2250 |
$settings_backup = get_option( 'wp_db_backup_options' ); |
| 2251 |
$wp_db_save_settings_in_backup = get_option( 'wp_db_save_settings_in_backup',1); |
| 2252 |
if($wp_db_save_settings_in_backup){ |
| 2253 |
delete_option( 'wp_db_backup_backups' ); |
| 2254 |
delete_option( 'wp_db_backup_options' ); |
| 2255 |
} |
| 2256 |
/* END : Prevent saving backup plugin settings in the database dump */ |
| 2257 |
$wp_db_exclude_table = array(); |
| 2258 |
$wp_db_exclude_table = get_option( 'wp_db_exclude_table' ); |
| 2259 |
$tables = $wpdb->get_col( 'SHOW TABLES' ); // phpcs:ignore |
| 2260 |
$output = ''; |
| 2261 |
if(!empty($tables) && !is_array($tables)){ |
| 2262 |
foreach ( $tables as $table ) { |
| 2263 |
if ( empty( $wp_db_exclude_table ) || ( ! ( in_array( $table, $wp_db_exclude_table, true ) ) ) ) { |
| 2264 |
|
| 2265 |
$check_count = $wpdb->get_var( "SELECT count(*) FROM {$table}"); // phpcs:ignore |
| 2266 |
$check_count = intval($check_count); |
| 2267 |
$sub_limit =500; |
| 2268 |
if(isset($check_count) && $check_count>$sub_limit){ |
| 2269 |
$result =array(); |
| 2270 |
$t_sub_queries= ceil($check_count/$sub_limit); |
| 2271 |
for($sub_i=0;$sub_i<$t_sub_queries;$sub_i++) |
| 2272 |
{ |
| 2273 |
$sub_offset = $sub_i*$sub_limit; |
| 2274 |
$sub_result = false; |
| 2275 |
if ( false === $sub_result ) { |
| 2276 |
// phpcs:ignore -- using direct query to get the data of table in chunks. |
| 2277 |
$sub_result = $wpdb->get_results( $wpdb->prepare("SELECT * FROM {$table} LIMIT %d OFFSET %d",array($sub_limit,$sub_offset)), ARRAY_A ); |
| 2278 |
} |
| 2279 |
|
| 2280 |
if($sub_result){ |
| 2281 |
$result = array_merge($result,$sub_result); |
| 2282 |
} |
| 2283 |
sleep(1); |
| 2284 |
} |
| 2285 |
} |
| 2286 |
else{ |
| 2287 |
$result = $wpdb->get_results( $wpdb->prepare("SELECT * FROM {$table}"), ARRAY_A ); // phpcs:ignore |
| 2288 |
} |
| 2289 |
|
| 2290 |
|
| 2291 |
$row2 = $wpdb->get_row( 'SHOW CREATE TABLE ' . $table, ARRAY_N ); // phpcs:ignore |
| 2292 |
$output .= "\n\n" . $row2[1] . ";\n\n"; |
| 2293 |
$result_count = count( $result ); |
| 2294 |
for ( $i = 0; $i < $result_count; $i++ ) { |
| 2295 |
if(isset($result[ $i ])){ |
| 2296 |
$row = $result[ $i ]; |
| 2297 |
$output .= 'INSERT INTO ' . $table . ' VALUES('; |
| 2298 |
$result_o_index = count( $result[0] ); |
| 2299 |
$j=0; |
| 2300 |
foreach ($row as $key => $value) { |
| 2301 |
$row[ $key] = $wpdb->_real_escape( apply_filters( 'wpdbbkp_process_db_fields', $row[$key],$table,$key) ); |
| 2302 |
$output .= ( isset( $row[ $key ] ) ) ? '"' . $row[ $key ] . '"' : '""'; |
| 2303 |
if ( $j < ( $result_o_index - 1 ) ) { |
| 2304 |
$output .= ','; |
| 2305 |
} |
| 2306 |
$j++; |
| 2307 |
} |
| 2308 |
$output .= ");\n"; |
| 2309 |
} |
| 2310 |
|
| 2311 |
} |
| 2312 |
$output .= "\n"; |
| 2313 |
} |
| 2314 |
sleep(1); |
| 2315 |
} |
| 2316 |
|
| 2317 |
} |
| 2318 |
|
| 2319 |
$wpdb->flush(); |
| 2320 |
/* BEGIN : Prevent saving backup plugin settings in the database dump */ |
| 2321 |
$options_backup = wpdbbkp_filter_unique_filenames( $options_backup ); |
| 2322 |
add_option( 'wp_db_backup_backups', $options_backup ); |
| 2323 |
add_option( 'wp_db_backup_options', $settings_backup ); |
| 2324 |
/* END : Prevent saving backup plugin settings in the database dump */ |
| 2325 |
return $output; |
| 2326 |
} |
| 2327 |
|
| 2328 |
/** |
| 2329 |
* Create database backup new function. |
| 2330 |
*/ |
| 2331 |
public function wp_db_backup_create_mysql_backup_new( $table, $file_path ) { |
| 2332 |
global $wpdb, $wp_filesystem; |
| 2333 |
|
| 2334 |
// Ensure WP Filesystem is loaded |
| 2335 |
if ( ! function_exists( 'WP_Filesystem' ) ) { |
| 2336 |
require_once ABSPATH . 'wp-admin/includes/file.php'; |
| 2337 |
} |
| 2338 |
WP_Filesystem(); |
| 2339 |
|
| 2340 |
// Define file size threshold (e.g., 10MB) |
| 2341 |
$file_size_threshold = 10 * 1024 * 1024; // 10MB |
| 2342 |
|
| 2343 |
// Initialize the file with table creation statement if it doesn't exist |
| 2344 |
|
| 2345 |
$table = esc_sql( $table ); |
| 2346 |
$row2 = $wpdb->get_row( "SHOW CREATE TABLE `{$table}`", ARRAY_N ); // phpcs:ignore |
| 2347 |
$initial_output = "\n\n" . $row2[1] . ";\n\n"; |
| 2348 |
|
| 2349 |
$use_php_methods = false; |
| 2350 |
if ( $wp_filesystem->exists( $file_path ) ) { |
| 2351 |
// Check file size |
| 2352 |
$file_size = $wp_filesystem->size( $file_path ); |
| 2353 |
if ( $file_size !== false && $file_size > $file_size_threshold ) { |
| 2354 |
$use_php_methods = true; |
| 2355 |
} |
| 2356 |
} |
| 2357 |
|
| 2358 |
// Function to append content |
| 2359 |
$append_content = function( $new_content ) use ( $file_path, $wp_filesystem, $use_php_methods ) { |
| 2360 |
if ( $use_php_methods ) { |
| 2361 |
// Using PHP methods to append |
| 2362 |
if ( ! $wp_filesystem->exists( $file_path ) ) { |
| 2363 |
// phpcs:ignore -- WP Filesystem fileing for large files |
| 2364 |
file_put_contents( $file_path, $new_content ); |
| 2365 |
} else { |
| 2366 |
// phpcs:ignore -- WP Filesystem fileing for large files |
| 2367 |
file_put_contents( $file_path, $new_content, FILE_APPEND ); |
| 2368 |
} |
| 2369 |
} else { |
| 2370 |
// Use WP Filesystem to append |
| 2371 |
if ( ! $wp_filesystem->exists( $file_path ) ) { |
| 2372 |
$wp_filesystem->put_contents( $file_path, $new_content, FS_CHMOD_FILE ); |
| 2373 |
} else { |
| 2374 |
// Read current contents |
| 2375 |
$current_contents = $wp_filesystem->get_contents( $file_path ); |
| 2376 |
if ( $current_contents === false ) { |
| 2377 |
// Handle error if reading fails |
| 2378 |
return false; |
| 2379 |
} |
| 2380 |
// Append new content |
| 2381 |
$updated_contents = $current_contents . $new_content; |
| 2382 |
// Write back updated contents |
| 2383 |
if ( ! $wp_filesystem->put_contents( $file_path, $updated_contents, FS_CHMOD_FILE ) ) { |
| 2384 |
// Handle error if writing fails |
| 2385 |
return false; |
| 2386 |
} |
| 2387 |
} |
| 2388 |
} |
| 2389 |
return true; |
| 2390 |
}; |
| 2391 |
|
| 2392 |
// Write the initial output to the file |
| 2393 |
if ( ! $append_content( $initial_output ) ) { |
| 2394 |
return false; // Handle error if initial content writing fails |
| 2395 |
} |
| 2396 |
|
| 2397 |
$sub_limit = 500; |
| 2398 |
// phpcs:ignore |
| 2399 |
$check_count = $wpdb->get_var( "SELECT COUNT(*) FROM `{$table}`" ); |
| 2400 |
$check_count = intval( $check_count ); |
| 2401 |
|
| 2402 |
if ( $check_count > $sub_limit ) { |
| 2403 |
$t_sub_queries = ceil( $check_count / $sub_limit ); |
| 2404 |
|
| 2405 |
for ( $sub_i = 0; $sub_i < $t_sub_queries; $sub_i++ ) { |
| 2406 |
$sub_offset = $sub_i * $sub_limit; |
| 2407 |
$sub_result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `{$table}` LIMIT %d OFFSET %d", array( $sub_limit, $sub_offset ) ), ARRAY_A ); // phpcs:ignore |
| 2408 |
|
| 2409 |
if ( $sub_result ) { |
| 2410 |
$output = ''; |
| 2411 |
foreach ( $sub_result as $row ) { |
| 2412 |
$output .= 'INSERT INTO ' . $table . ' VALUES('; |
| 2413 |
$result_o_index = count( $row ); |
| 2414 |
$j = 0; |
| 2415 |
foreach ( $row as $key => $value ) { |
| 2416 |
$row[ $key ] = $wpdb->_real_escape( apply_filters( 'wpdbbkp_process_db_fields', $value, $table, $key ) ); |
| 2417 |
$output .= ( isset( $row[ $key ] ) ) ? '"' . $row[ $key ] . '"' : '""'; |
| 2418 |
if ( $j < ( $result_o_index - 1 ) ) { |
| 2419 |
$output .= ','; |
| 2420 |
} |
| 2421 |
$j++; |
| 2422 |
} |
| 2423 |
$output .= ");\n"; |
| 2424 |
} |
| 2425 |
// Append to the file |
| 2426 |
if ( ! $append_content( $output ) ) { |
| 2427 |
return false; // Handle error if appending content fails |
| 2428 |
} |
| 2429 |
} |
| 2430 |
sleep(1); |
| 2431 |
} |
| 2432 |
} else { |
| 2433 |
$result = $wpdb->get_results( "SELECT * FROM `{$table}`", ARRAY_A ); // phpcs:ignore |
| 2434 |
|
| 2435 |
$output = ''; |
| 2436 |
foreach ( $result as $row ) { |
| 2437 |
$output .= 'INSERT INTO ' . $table . ' VALUES('; |
| 2438 |
$result_o_index = count( $row ); |
| 2439 |
$j = 0; |
| 2440 |
foreach ( $row as $key => $value ) { |
| 2441 |
$row[ $key ] = $wpdb->_real_escape( apply_filters( 'wpdbbkp_process_db_fields', $value, $table, $key ) ); |
| 2442 |
$output .= ( isset( $row[ $key ] ) ) ? '"' . $row[ $key ] . '"' : '""'; |
| 2443 |
if ( $j < ( $result_o_index - 1 ) ) { |
| 2444 |
$output .= ','; |
| 2445 |
} |
| 2446 |
$j++; |
| 2447 |
} |
| 2448 |
$output .= ");\n"; |
| 2449 |
} |
| 2450 |
// Append to the file |
| 2451 |
if ( ! $append_content( $output ) ) { |
| 2452 |
return false; // Handle error if appending content fails |
| 2453 |
} |
| 2454 |
} |
| 2455 |
|
| 2456 |
// Flush the database cache |
| 2457 |
$wpdb->flush(); |
| 2458 |
return true; |
| 2459 |
} |
| 2460 |
|
| 2461 |
|
| 2462 |
/** |
| 2463 |
* Mysql Dump set path. |
| 2464 |
* |
| 2465 |
* @param string $path - Path. |
| 2466 |
*/ |
| 2467 |
public function set_mysqldump_command_path( $path ) { |
| 2468 |
$this->mysqldump_command_path = $path; |
| 2469 |
} |
| 2470 |
|
| 2471 |
/** |
| 2472 |
* Mysql Dump get path. |
| 2473 |
*/ |
| 2474 |
public function get_mysqldump_command_path() { |
| 2475 |
|
| 2476 |
// Check shell_exec is available. |
| 2477 |
if ( ! self::is_shell_exec_available() ) { |
| 2478 |
return ''; |
| 2479 |
} |
| 2480 |
|
| 2481 |
// Return now if it's already been set. |
| 2482 |
if ( isset( $this->mysqldump_command_path ) ) { |
| 2483 |
return $this->mysqldump_command_path; |
| 2484 |
} |
| 2485 |
|
| 2486 |
$this->mysqldump_command_path = ''; |
| 2487 |
|
| 2488 |
// Does mysqldump work. |
| 2489 |
if ( is_null( shell_exec( 'hash mysqldump 2>&1' ) ) ) { // phpcs:ignore |
| 2490 |
|
| 2491 |
// If so store it for later. |
| 2492 |
$this->set_mysqldump_command_path( 'mysqldump' ); |
| 2493 |
|
| 2494 |
// And return now. |
| 2495 |
return $this->mysqldump_command_path; |
| 2496 |
} |
| 2497 |
|
| 2498 |
// List of possible mysqldump locations. |
| 2499 |
$mysqldump_locations = array( |
| 2500 |
'/usr/local/bin/mysqldump', |
| 2501 |
'/usr/local/mysql/bin/mysqldump', |
| 2502 |
'/usr/mysql/bin/mysqldump', |
| 2503 |
'/usr/bin/mysqldump', |
| 2504 |
'/opt/local/lib/mysql6/bin/mysqldump', |
| 2505 |
'/opt/local/lib/mysql5/bin/mysqldump', |
| 2506 |
'/opt/local/lib/mysql4/bin/mysqldump', |
| 2507 |
'/xwpdbbkpp/mysql/bin/mysqldump', |
| 2508 |
'/Program Files/xwpdbbkpp/mysql/bin/mysqldump', |
| 2509 |
'/Program Files/MySQL/MySQL Server 6.0/bin/mysqldump', |
| 2510 |
'/Program Files/MySQL/MySQL Server 5.5/bin/mysqldump', |
| 2511 |
'/Program Files/MySQL/MySQL Server 5.4/bin/mysqldump', |
| 2512 |
'/Program Files/MySQL/MySQL Server 5.1/bin/mysqldump', |
| 2513 |
'/Program Files/MySQL/MySQL Server 5.0/bin/mysqldump', |
| 2514 |
'/Program Files/MySQL/MySQL Server 4.1/bin/mysqldump', |
| 2515 |
); |
| 2516 |
|
| 2517 |
// Find the one which works. |
| 2518 |
foreach ( $mysqldump_locations as $location ) { |
| 2519 |
if ( is_executable( self::conform_dir( $location ) ) ) { |
| 2520 |
$this->set_mysqldump_command_path( $location ); |
| 2521 |
} |
| 2522 |
} |
| 2523 |
|
| 2524 |
return $this->mysqldump_command_path; |
| 2525 |
} |
| 2526 |
|
| 2527 |
/** |
| 2528 |
* Check dir. |
| 2529 |
* |
| 2530 |
* @param string $dir - Dir Details. |
| 2531 |
* @param bool $recursive - Recursive. |
| 2532 |
*/ |
| 2533 |
public static function conform_dir( $dir, $recursive = false ) { |
| 2534 |
|
| 2535 |
// Assume empty dir is root. |
| 2536 |
if ( ! $dir ) { |
| 2537 |
$dir = '/'; |
| 2538 |
} |
| 2539 |
|
| 2540 |
// Replace single forward slash (looks like double slash because we have to escape it). |
| 2541 |
$dir = str_replace( '\\', '/', $dir ); |
| 2542 |
$dir = str_replace( '//', '/', $dir ); |
| 2543 |
|
| 2544 |
// Remove the trailing slash. |
| 2545 |
if ( '/' !== $dir ) { |
| 2546 |
$dir = untrailingslashit( $dir ); |
| 2547 |
} |
| 2548 |
|
| 2549 |
// Carry on until completely normalized. |
| 2550 |
if ( ! $recursive && self::conform_dir( $dir, true ) !== $dir ) { |
| 2551 |
return self::conform_dir( $dir ); |
| 2552 |
} |
| 2553 |
|
| 2554 |
return (string) $dir; |
| 2555 |
} |
| 2556 |
|
| 2557 |
/** |
| 2558 |
* Check Shell. |
| 2559 |
*/ |
| 2560 |
public static function is_shell_exec_available() { |
| 2561 |
|
| 2562 |
// Are we in Safe Mode. |
| 2563 |
if ( self::is_safe_mode_active() ) { |
| 2564 |
return false; |
| 2565 |
} |
| 2566 |
|
| 2567 |
// Is shell_exec or escapeshellcmd or escapeshellarg disabled? |
| 2568 |
if ( array_intersect( array( 'shell_exec', 'escapeshellarg', 'escapeshellcmd' ), array_map( 'trim', explode( ',', ini_get( 'disable_functions' ) ) ) ) ) { |
| 2569 |
return false; |
| 2570 |
} |
| 2571 |
|
| 2572 |
// Can we issue a simple echo command? |
| 2573 |
if ( ! shell_exec( 'echo WP Backup' ) ) { // phpcs:ignore |
| 2574 |
return false; |
| 2575 |
} |
| 2576 |
|
| 2577 |
return true; |
| 2578 |
} |
| 2579 |
|
| 2580 |
/** |
| 2581 |
* Check Safe mode active. |
| 2582 |
* |
| 2583 |
* @param string $ini_get_callback - String cmd. |
| 2584 |
* @return bool |
| 2585 |
*/ |
| 2586 |
public static function is_safe_mode_active( $ini_get_callback = 'ini_get' ) { |
| 2587 |
$safe_mode = call_user_func( $ini_get_callback, 'safe_mode' ); |
| 2588 |
if ( ( $safe_mode ) && 'off' !== strtolower( $safe_mode ) ) { |
| 2589 |
return true; |
| 2590 |
} |
| 2591 |
|
| 2592 |
return false; |
| 2593 |
} |
| 2594 |
|
| 2595 |
/** |
| 2596 |
* Database dump. |
| 2597 |
* |
| 2598 |
* @param string $sql_filename - File name. |
| 2599 |
*/ |
| 2600 |
public function mysqldump( $sql_filename ) { |
| 2601 |
$this->mysqldump_method = 'mysqldump'; |
| 2602 |
|
| 2603 |
$host = explode( ':', DB_HOST ); |
| 2604 |
|
| 2605 |
$host = reset( $host ); |
| 2606 |
$port = strpos( DB_HOST, ':' ) ? end( explode( ':', DB_HOST ) ) : ''; |
| 2607 |
|
| 2608 |
// Path to the mysqldump executable. |
| 2609 |
$cmd = escapeshellarg( $this->get_mysqldump_command_path() ); |
| 2610 |
|
| 2611 |
// We don't want to create a new DB. |
| 2612 |
$cmd .= ' --no-create-db'; |
| 2613 |
|
| 2614 |
// Allow lock-tables to be overridden. |
| 2615 |
if ( ! defined( 'WPDB_MYSQLDUMP_SINGLE_TRANSACTION' ) || WPDB_MYSQLDUMP_SINGLE_TRANSACTION !== false ) { |
| 2616 |
$cmd .= ' --single-transaction'; |
| 2617 |
} |
| 2618 |
|
| 2619 |
// Make sure binary data is exported properly. |
| 2620 |
$cmd .= ' --hex-blob'; |
| 2621 |
|
| 2622 |
// Username. |
| 2623 |
$cmd .= ' -u ' . escapeshellarg( DB_USER ); |
| 2624 |
|
| 2625 |
// Don't pass the password if it's blank. |
| 2626 |
if ( DB_PASSWORD ) { |
| 2627 |
$cmd .= ' -p' . escapeshellarg( DB_PASSWORD ); |
| 2628 |
} |
| 2629 |
|
| 2630 |
// Set the host. |
| 2631 |
$cmd .= ' -h ' . escapeshellarg( $host ); |
| 2632 |
|
| 2633 |
// Set the port if it was set. |
| 2634 |
if ( ! empty( $port ) && is_numeric( $port ) ) { |
| 2635 |
$cmd .= ' -P ' . $port; |
| 2636 |
} |
| 2637 |
|
| 2638 |
// The file we're saving too. |
| 2639 |
$cmd .= ' -r ' . escapeshellarg( $sql_filename ); |
| 2640 |
|
| 2641 |
$wp_db_exclude_table = get_option( 'wp_db_exclude_table' ); |
| 2642 |
if ( ! empty( $wp_db_exclude_table ) && is_array( $wp_db_exclude_table ) ) { |
| 2643 |
foreach ( $this->filter_valid_exclude_tables( $wp_db_exclude_table ) as $exclude_table ) { |
| 2644 |
$cmd .= ' --ignore-table=' . escapeshellarg( DB_NAME . '.' . $exclude_table ); |
| 2645 |
} |
| 2646 |
} |
| 2647 |
|
| 2648 |
// The database we're dumping. |
| 2649 |
$cmd .= ' ' . escapeshellarg( DB_NAME ); |
| 2650 |
|
| 2651 |
// Pipe STDERR to STDOUT. |
| 2652 |
$cmd .= ' 2>&1'; |
| 2653 |
// Store any returned data in an error. |
| 2654 |
$stderr = shell_exec( $cmd ); // phpcs:ignore |
| 2655 |
|
| 2656 |
// Skip the new password warning that is output in mysql > 5.6. |
| 2657 |
if ( trim( $stderr ) === 'Warning: Using a password on the command line interface can be insecure.' ) { |
| 2658 |
$stderr = ''; |
| 2659 |
} |
| 2660 |
|
| 2661 |
if ( $stderr ) { |
| 2662 |
$this->error( $this->get_mysqldump_method(), $stderr ); |
| 2663 |
} |
| 2664 |
|
| 2665 |
return $this->verify_mysqldump( $sql_filename ); |
| 2666 |
} |
| 2667 |
|
| 2668 |
/** |
| 2669 |
* Error. |
| 2670 |
* |
| 2671 |
* @param string $context - Data. |
| 2672 |
* @param object $error - Error data. |
| 2673 |
*/ |
| 2674 |
public function error( $context, $error ) { |
| 2675 |
if ( empty( $context ) || empty( $error ) ) { |
| 2676 |
return; |
| 2677 |
} |
| 2678 |
$error_str = implode( ':', (array) $error ); |
| 2679 |
$_key = md5( $error_str ); |
| 2680 |
$this->errors[ $context ][ $_key ] = $error; |
| 2681 |
} |
| 2682 |
|
| 2683 |
/** |
| 2684 |
* Verify Dump. |
| 2685 |
* |
| 2686 |
* @param string $sql_filename - Sql file. |
| 2687 |
* @return bool |
| 2688 |
*/ |
| 2689 |
public function verify_mysqldump( $sql_filename ) { |
| 2690 |
|
| 2691 |
// If we've already passed then no need to check again. |
| 2692 |
if ( ! empty( $this->mysqldump_verified ) ) { |
| 2693 |
return true; |
| 2694 |
} |
| 2695 |
|
| 2696 |
// If there are mysqldump errors delete the database dump file as mysqldump will still have written one. |
| 2697 |
if ( $this->get_errors( $this->get_mysqldump_method() ) && file_exists( $sql_filename ) ) { |
| 2698 |
if ( file_exists( $sql_filename ) ) { |
| 2699 |
wp_delete_file( $sql_filename ); |
| 2700 |
} |
| 2701 |
} |
| 2702 |
|
| 2703 |
// If we have an empty file delete it. |
| 2704 |
if ( 0 === filesize( $sql_filename ) ) { |
| 2705 |
if ( file_exists( $sql_filename ) ) { |
| 2706 |
wp_delete_file( $sql_filename ); |
| 2707 |
} |
| 2708 |
} |
| 2709 |
|
| 2710 |
// If the file still exists then it must be good. |
| 2711 |
if ( file_exists( $sql_filename ) ) { |
| 2712 |
$this->mysqldump_verified = true; |
| 2713 |
return $this->mysqldump_verified; |
| 2714 |
} |
| 2715 |
|
| 2716 |
return false; |
| 2717 |
} |
| 2718 |
|
| 2719 |
/** |
| 2720 |
* Get error. |
| 2721 |
* |
| 2722 |
* @param string $context - Data. |
| 2723 |
* @return string |
| 2724 |
*/ |
| 2725 |
public function get_errors( $context = null ) { |
| 2726 |
if ( ! empty( $context ) ) { |
| 2727 |
return isset( $this->errors[ $context ] ) ? $this->errors[ $context ] : array(); |
| 2728 |
} |
| 2729 |
|
| 2730 |
return $this->errors; |
| 2731 |
} |
| 2732 |
|
| 2733 |
/** |
| 2734 |
* Get mysql dump method. |
| 2735 |
* |
| 2736 |
* @return string |
| 2737 |
*/ |
| 2738 |
public function get_mysqldump_method() { |
| 2739 |
return $this->mysqldump_method; |
| 2740 |
} |
| 2741 |
|
| 2742 |
// End : Generate SQL DUMP using cmd 06-03-2016. |
| 2743 |
|
| 2744 |
/** |
| 2745 |
* Create zip. |
| 2746 |
*/ |
| 2747 |
public function wp_db_backup_create_archive() { |
| 2748 |
// Begin : Setup Upload Directory, Secure it and generate a random file name. |
| 2749 |
|
| 2750 |
$source_directory = $this->wp_db_backup_wp_config_path(); |
| 2751 |
|
| 2752 |
$path_info = wp_upload_dir(); |
| 2753 |
$htasses_text = ''; |
| 2754 |
global $wpdb,$wp_filesystem; |
| 2755 |
if ( ! function_exists( 'WP_Filesystem' ) ) { |
| 2756 |
require_once ABSPATH . '/wp-admin/includes/file.php'; |
| 2757 |
} |
| 2758 |
WP_Filesystem(); |
| 2759 |
|
| 2760 |
if(!$wp_filesystem){ |
| 2761 |
return false; |
| 2762 |
} |
| 2763 |
|
| 2764 |
wp_mkdir_p($path_info['basedir'] . '/' . WPDB_BACKUPS_DIR); |
| 2765 |
wp_mkdir_p($path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/log'); |
| 2766 |
$file_contents = "<?php\n// Silence is golden.\n"; |
| 2767 |
|
| 2768 |
// Create the file with the given contents |
| 2769 |
$wp_filesystem->put_contents( $path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/index.php', $file_contents, FS_CHMOD_FILE ); |
| 2770 |
$wp_filesystem->put_contents( $path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/log/index.php', $file_contents, FS_CHMOD_FILE ); |
| 2771 |
|
| 2772 |
|
| 2773 |
// Added htaccess file 08-05-2015 for prevent directory listing. |
| 2774 |
// Fixed Vulnerability 22-06-2016 for prevent direct download. |
| 2775 |
|
| 2776 |
$htaccess_content = '# Disable public access to this folder |
| 2777 |
<IfModule mod_authz_core.c> |
| 2778 |
Require all denied |
| 2779 |
</IfModule> |
| 2780 |
|
| 2781 |
<IfModule !mod_authz_core.c> |
| 2782 |
Deny from all |
| 2783 |
</IfModule>'; |
| 2784 |
$wp_filesystem->put_contents( $path_info['basedir'] . '/db-backup/.htaccess', $htaccess_content, FS_CHMOD_FILE ); |
| 2785 |
|
| 2786 |
// Begin : Generate SQL DUMP and save to file database.sql. |
| 2787 |
$wp_site_name = preg_replace('/[^\p{L}\p{M}]+/u', '_', get_bloginfo('name')); |
| 2788 |
$wp_db_file_name = $wp_site_name . '_' . gmdate( 'Y_m_d' ) . '_' . time() . '_' . substr( md5( wp_rand(100,9999999) ), 0, 9 ) . '_wpdb'; |
| 2789 |
$sql_filename = $wp_db_file_name . '.sql'; |
| 2790 |
$filename = $wp_db_file_name . '.zip'; |
| 2791 |
$logname = $wp_db_file_name . '.txt'; |
| 2792 |
|
| 2793 |
// Begin : Generate SQL DUMP using cmd 06-03-2016. |
| 2794 |
$my_sql_dump = 0; |
| 2795 |
if ( $this->get_mysqldump_command_path() ) { |
| 2796 |
if ( ! $this->mysqldump( $path_info['basedir'] . '/db-backup/' . $sql_filename ) ) { |
| 2797 |
$my_sql_dump = 1; |
| 2798 |
} |
| 2799 |
} else { |
| 2800 |
$my_sql_dump = 1; |
| 2801 |
} |
| 2802 |
|
| 2803 |
if ( 1 === (int) $my_sql_dump ) { |
| 2804 |
/* BEGIN : Prevent saving backup plugin settings in the database dump */ |
| 2805 |
$options_backup = get_option( 'wp_db_backup_backups' ); |
| 2806 |
$settings_backup = get_option( 'wp_db_backup_options' ); |
| 2807 |
$wp_db_save_settings_in_backup = get_option( 'wp_db_save_settings_in_backup',1); |
| 2808 |
if($wp_db_save_settings_in_backup){ |
| 2809 |
delete_option( 'wp_db_backup_backups' ); |
| 2810 |
delete_option( 'wp_db_backup_options' ); |
| 2811 |
} |
| 2812 |
/* END : Prevent saving backup plugin settings in the database dump */ |
| 2813 |
//phpcs:ignore -- using direct query get all tables name to be backedup. |
| 2814 |
$tables = $wpdb->get_col( 'SHOW TABLES' ); |
| 2815 |
$wp_db_exclude_table = get_option( 'wp_db_exclude_table',array()); |
| 2816 |
if(!empty($tables)){ |
| 2817 |
foreach($tables as $table){ |
| 2818 |
if ( empty( $wp_db_exclude_table ) || ( ! ( in_array( $table, $wp_db_exclude_table, true ) ) ) ) { |
| 2819 |
$this->wp_db_backup_create_mysql_backup_new($table, $path_info['basedir'] . '/db-backup/' . $sql_filename ); |
| 2820 |
} |
| 2821 |
} |
| 2822 |
|
| 2823 |
} |
| 2824 |
/* BEGIN : Prevent saving backup plugin settings in the database dump */ |
| 2825 |
$options_backup = wpdbbkp_filter_unique_filenames( $options_backup ); |
| 2826 |
add_option( 'wp_db_backup_backups', $options_backup ); |
| 2827 |
add_option( 'wp_db_backup_options', $settings_backup ); |
| 2828 |
/* END : Prevent saving backup plugin settings in the database dump */ |
| 2829 |
} |
| 2830 |
/* End : Generate SQL DUMP using cmd 06-03-2016 */ |
| 2831 |
|
| 2832 |
$wp_db_backup_search_text = get_option( 'wp_db_backup_search_text' ); |
| 2833 |
$wp_db_backup_replace_text = get_option( 'wp_db_backup_replace_text' ); |
| 2834 |
if ( ( false === empty( $wp_db_backup_search_text ) ) && ( false === empty( $wp_db_backup_replace_text ) ) ) { |
| 2835 |
$filecontent = wp_remote_get( $path_info['basedir'] . '/db-backup/' . $sql_filename ); |
| 2836 |
if (! is_wp_error( $filecontent ) && isset($filecontent['body']) ) { |
| 2837 |
$backup_str = str_replace( $wp_db_backup_search_text, $wp_db_backup_replace_text, $filecontent['body'] ); |
| 2838 |
$wp_filesystem->put_contents( $path_info['basedir'] . '/db-backup/' . $sql_filename, $backup_str, FS_CHMOD_FILE ); |
| 2839 |
} |
| 2840 |
} |
| 2841 |
|
| 2842 |
/* End : Generate SQL DUMP and save to file database.sql */ |
| 2843 |
$upload_path = array( |
| 2844 |
'filename' => ( $filename ), |
| 2845 |
'dir' => ( $path_info['basedir'] . '/db-backup/' . $filename ), |
| 2846 |
'url' => ( $path_info['baseurl'] . '/db-backup/' . $filename ), |
| 2847 |
'log_dir' => ( $path_info['basedir'] . '/db-backup/log/' . $logname ), |
| 2848 |
'log_url' => ( $path_info['baseurl'] . '/db-backup/log/' . $logname ), |
| 2849 |
'size' => 0, |
| 2850 |
); |
| 2851 |
$arcname = $path_info['basedir'] . '/db-backup/' . $wp_db_file_name . '.zip'; |
| 2852 |
if ( class_exists( 'ZipArchive' ) ) { |
| 2853 |
$zip = new ZipArchive(); |
| 2854 |
$zip->open( $arcname, ZipArchive::CREATE ); |
| 2855 |
$zip->addFile( $path_info['basedir'] . '/db-backup/' . $sql_filename, $sql_filename ); |
| 2856 |
$zip->close(); |
| 2857 |
} else { |
| 2858 |
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; |
| 2859 |
$archive = new PclZip( $arcname ); |
| 2860 |
$v_dir = $path_info['basedir'] . '/db-backup/' . $sql_filename; |
| 2861 |
$v_remove = $path_info['basedir'] . '/db-backup'; |
| 2862 |
// Create the archive. |
| 2863 |
$v_list = $archive->create( $v_dir, PCLZIP_OPT_REMOVE_PATH, $v_remove ); |
| 2864 |
} |
| 2865 |
|
| 2866 |
|
| 2867 |
$mysqlversion = wp_cache_get( 'wpdb_mysqlversion' ); |
| 2868 |
if ( true === empty( $mysqlversion ) ) { |
| 2869 |
$mysqlversion = $wpdb->get_var( 'SELECT VERSION() AS version' ); // phpcs:ignore |
| 2870 |
wp_cache_set( 'wpdb_mysqlversion', $mysqlversion, '', 18000 ); |
| 2871 |
} |
| 2872 |
if ( ! function_exists( 'get_plugins' ) ) { |
| 2873 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 2874 |
} |
| 2875 |
$my_theme = wp_get_theme(); |
| 2876 |
$active_plugin = count(get_option('active_plugins')); |
| 2877 |
$total_plugin = count(get_plugins()); |
| 2878 |
$log_message = '<b>WordPress Version</b> : ' . get_bloginfo( 'version' ); |
| 2879 |
$log_message .= '<br> <b>Database Version</b> : ' . $mysqlversion; |
| 2880 |
$log_message .= '<br> <b>Active Theme Name</b> : ' . $my_theme->get( 'Name' ); |
| 2881 |
$log_message .= '<br> <b>Theme Version</b> : ' . $my_theme->get( 'Version' ); |
| 2882 |
$log_message .= '<br> <b>Plugin Count</b> : ' . $total_plugin; |
| 2883 |
$log_message .= '<br> <b>Active Plugins</b> : ' . $active_plugin; |
| 2884 |
|
| 2885 |
$upload_path['size'] = filesize( $upload_path['dir'] ); |
| 2886 |
$upload_path['sqlfile'] = $path_info['basedir'] . '/db-backup/' . $sql_filename; |
| 2887 |
$wp_db_log = get_option( 'wp_db_log' ); |
| 2888 |
if ( 1 === (int) $wp_db_log ) { |
| 2889 |
$wp_db_exclude_table = get_option( 'wp_db_exclude_table' ); |
| 2890 |
if ( ! empty( $wp_db_exclude_table ) ) { |
| 2891 |
$log_message .= '<br> <b>Exclude Table</b> : ' . implode( ', ', $wp_db_exclude_table ); |
| 2892 |
} |
| 2893 |
$upload_path['log'] = $log_message; |
| 2894 |
} |
| 2895 |
$options = get_option( 'wp_db_backup_backups' ); |
| 2896 |
$newoptions = array(); |
| 2897 |
$number_of_existing_backups = count( (array) $options ); |
| 2898 |
$number_of_backups_from_user = get_option( 'wp_local_db_backup_count' ); |
| 2899 |
if ( ! empty( $number_of_backups_from_user ) ) { |
| 2900 |
if ( ! ( $number_of_existing_backups < $number_of_backups_from_user ) ) { |
| 2901 |
$diff = $number_of_existing_backups - $number_of_backups_from_user; |
| 2902 |
for ( $i = 0; $i <= $diff; $i++ ) { |
| 2903 |
$index = $i; |
| 2904 |
if ( isset($options[ $index ]['dir']) && file_exists( $options[ $index ]['dir'] ) ) { |
| 2905 |
wp_delete_file( $options[ $index ]['dir'] ); |
| 2906 |
} |
| 2907 |
$file_sql = explode( '.', $options[ $index ]['dir'] ); |
| 2908 |
if ( isset($file_sql[0]) && file_exists( $file_sql[0] . '.sql' ) ) { |
| 2909 |
wp_delete_file( $file_sql[0] . '.sql' ); |
| 2910 |
} |
| 2911 |
} |
| 2912 |
for ( $i = ( $diff + 1 ); $i < $number_of_existing_backups; $i++ ) { |
| 2913 |
$index = $i; |
| 2914 |
|
| 2915 |
$newoptions[] = $options[ $index ]; |
| 2916 |
} |
| 2917 |
$newoptions = wpdbbkp_filter_unique_filenames( $newoptions ); |
| 2918 |
|
| 2919 |
update_option( 'wp_db_backup_backups', $newoptions , false); |
| 2920 |
} |
| 2921 |
} |
| 2922 |
|
| 2923 |
if ( file_exists( $path_info['basedir'] . '/db-backup/' . $sql_filename ) ) { |
| 2924 |
wp_delete_file( $path_info['basedir'] . '/db-backup/' . $sql_filename ); |
| 2925 |
} |
| 2926 |
return $upload_path; |
| 2927 |
} |
| 2928 |
|
| 2929 |
/** |
| 2930 |
* Config Path. |
| 2931 |
*/ |
| 2932 |
public function wp_db_backup_wp_config_path() { |
| 2933 |
$path = str_replace('\\', '/', ABSPATH); |
| 2934 |
|
| 2935 |
return $path; |
| 2936 |
} |
| 2937 |
|
| 2938 |
/** |
| 2939 |
* Backup Process. |
| 2940 |
*/ |
| 2941 |
public function wp_db_backup_event_process() { |
| 2942 |
// Added in v.3.9.5! |
| 2943 |
global $wp_filesystem; |
| 2944 |
if(!function_exists('WP_Filesystem')){ |
| 2945 |
require_once ( ABSPATH . '/wp-admin/includes/file.php' ); |
| 2946 |
} |
| 2947 |
WP_Filesystem(); |
| 2948 |
|
| 2949 |
$cron_condition = apply_filters('wpdbbkp_dbback_cron_condition',true ); |
| 2950 |
if(wp_doing_cron() && !$cron_condition){ |
| 2951 |
return false; |
| 2952 |
} |
| 2953 |
|
| 2954 |
set_time_limit( 0 ); //phpcs:ignore -- increase time limit for backup process. |
| 2955 |
ignore_user_abort(true); |
| 2956 |
|
| 2957 |
$details = $this->wp_db_backup_create_archive(); |
| 2958 |
$options = get_option( 'wp_db_backup_backups' ); |
| 2959 |
|
| 2960 |
if ( ! $options ) { |
| 2961 |
$options = array(); |
| 2962 |
} |
| 2963 |
$is_search_replace_flag = 0; |
| 2964 |
$wp_db_log = get_option( 'wp_db_log' ); |
| 2965 |
if ( 1 === (int) $wp_db_log ) { |
| 2966 |
$log_message = $details['log']; |
| 2967 |
$wp_db_backup_search_text = get_option( 'wp_db_backup_search_text' ); |
| 2968 |
$wp_db_backup_replace_text = get_option( 'wp_db_backup_replace_text' ); |
| 2969 |
if ( ( false === empty( $wp_db_backup_search_text ) ) && ( false === empty( $wp_db_backup_replace_text ) ) ) { |
| 2970 |
$log_message .= ' Replaced/Search text - ' . $wp_db_backup_search_text . ' With -' . $wp_db_backup_replace_text; |
| 2971 |
$is_search_replace_flag = 1; |
| 2972 |
} |
| 2973 |
} else { |
| 2974 |
$log_message = ''; |
| 2975 |
} |
| 2976 |
$wp_db_remove_local_backup = get_option( 'wp_db_remove_local_backup' ); |
| 2977 |
$destination = ( 1 === (int) $wp_db_remove_local_backup ) ? '' : 'Local, '; |
| 2978 |
|
| 2979 |
$args = array( $details['filename'], $details['dir'], $log_message, $details['size'], $destination ); |
| 2980 |
|
| 2981 |
do_action_ref_array( 'wpdbbkp_db_backup_completed', array( &$args ) ); |
| 2982 |
|
| 2983 |
// Ensure enabled destinations are reflected in the saved Destination string for table display |
| 2984 |
// Note: Hook handlers may have already added destinations, so check before appending |
| 2985 |
$destination_for_table = $args[4]; |
| 2986 |
if ( get_option( 'wp_db_backup_destination_generics3' ) == 1 && !empty(get_option( 'wpdb_dest_generics3_bucket_key' ) ) && !empty(get_option( 'wpdb_dest_generics3_bucket_secret' ) ) ) { |
| 2987 |
$destination_for_table .= 'GenericS3, '; |
| 2988 |
} |
| 2989 |
if ( get_option( 'wp_db_backup_destination_bb' ) == 1 && !empty(get_option( 'wpdb_dest_bb_s3_bucket_key' ) ) ) { |
| 2990 |
$destination_for_table .= 'Backblaze, '; |
| 2991 |
} |
| 2992 |
if ( get_option( 'wp_db_backup_destination_s3' ) == 1 && !empty(get_option( 'wpdb_dest_amazon_s3_bucket_key' ) ) && !empty(get_option( 'wpdb_dest_amazon_s3_bucket_secret' ) ) ) { |
| 2993 |
$destination_for_table .= 'S3, '; |
| 2994 |
} |
| 2995 |
if ( get_option( 'wp_db_backup_destination_SFTP' ) == 1 && !empty(get_option( 'wpdb_dest_sftp_host' ) ) && !empty(get_option( 'wpdb_dest_sftp_port' ) ) && !empty(get_option( 'wpdb_dest_sftp_username' ) ) && !empty(get_option( 'wpdb_dest_sftp_password' ) ) ) { |
| 2996 |
$destination_for_table .= 'SFTP, '; |
| 2997 |
} |
| 2998 |
if ( get_option( 'wp_db_backup_destination_FTP' ) == 1 && !empty(get_option( 'wpdb_dest_ftp_host' ) ) && !empty(get_option( 'wpdb_dest_ftp_port' ) ) && !empty(get_option( 'wpdb_dest_ftp_username' ) ) && !empty(get_option( 'wpdb_dest_ftp_password' ) ) ) { |
| 2999 |
$destination_for_table .= 'FTP, '; |
| 3000 |
} |
| 3001 |
if ( get_option( 'wp_db_backup_destination_Email' ) == 1 && strpos( $destination_for_table, 'Email' ) === false ) { |
| 3002 |
$destination_for_table .= 'Email, '; |
| 3003 |
} |
| 3004 |
|
| 3005 |
$options[] = array( |
| 3006 |
'date' => time(), |
| 3007 |
'filename' => $details['filename'], |
| 3008 |
'url' => $details['url'], |
| 3009 |
'dir' => $details['dir'], |
| 3010 |
'log' => $details['log_url'], |
| 3011 |
'search_replace' => $is_search_replace_flag, |
| 3012 |
'sqlfile' => $details['sqlfile'], |
| 3013 |
'size' => $details['size'], |
| 3014 |
'type' =>'database', |
| 3015 |
'destination' => $destination_for_table |
| 3016 |
); |
| 3017 |
if ( 1 !== (int) $wp_db_remove_local_backup ) { |
| 3018 |
$options = wpdbbkp_filter_unique_filenames( $options ); |
| 3019 |
update_option( 'wp_db_backup_backups', $options , false); |
| 3020 |
} |
| 3021 |
|
| 3022 |
if(isset($details['log_dir']) && !empty($details['log_dir'])) |
| 3023 |
{ |
| 3024 |
$log_file_path = $details['log_dir']; |
| 3025 |
$log_dir = dirname($log_file_path); |
| 3026 |
|
| 3027 |
if ( $wp_filesystem->is_writable( $log_dir ) ) { |
| 3028 |
$wp_filesystem->put_contents( $log_file_path, str_replace(array("<br>","<b>","</b>"), array("\n","",""), $args[2]), FS_CHMOD_FILE ); |
| 3029 |
} |
| 3030 |
} |
| 3031 |
} |
| 3032 |
|
| 3033 |
/** |
| 3034 |
* Cron schedule. |
| 3035 |
* |
| 3036 |
* @param array $schedules - Schedules details. |
| 3037 |
*/ |
| 3038 |
public function wp_db_backup_cron_schedules( $schedules ) { |
| 3039 |
$schedules['hourly'] = array( |
| 3040 |
'interval' => 3600, |
| 3041 |
'display' => 'hourly', |
| 3042 |
); |
| 3043 |
$schedules['twicedaily'] = array( |
| 3044 |
'interval' => 43200, |
| 3045 |
'display' => 'twicedaily', |
| 3046 |
); |
| 3047 |
$schedules['daily'] = array( |
| 3048 |
'interval' => 86400, |
| 3049 |
'display' => 'daily', |
| 3050 |
); |
| 3051 |
$schedules['weekly'] = array( |
| 3052 |
'interval' => 604800, |
| 3053 |
'display' => 'Once Weekly', |
| 3054 |
); |
| 3055 |
$schedules['monthly'] = array( |
| 3056 |
'interval' => 2635200, |
| 3057 |
'display' => 'Once a month', |
| 3058 |
); |
| 3059 |
return $schedules; |
| 3060 |
} |
| 3061 |
|
| 3062 |
/** |
| 3063 |
* Schedular activation. |
| 3064 |
*/ |
| 3065 |
public function wp_db_backup_scheduler_activation() { |
| 3066 |
$options = get_option( 'wp_db_backup_options' ); |
| 3067 |
if ( ( ! wp_next_scheduled( 'wpdbbkp_db_backup_event' ) ) && ( true === isset( $options['enable_autobackups'] ) ) ) { |
| 3068 |
$cron_freq = apply_filters( 'wpdbbkp_dbback_cron_frequency',$options['autobackup_frequency']); |
| 3069 |
if(isset($options['autobackup_type']) && $options['autobackup_type'] == 'db') |
| 3070 |
{ |
| 3071 |
$timestamp = strtotime('today 23:59'); // Start at the next midnight |
| 3072 |
wp_schedule_event( $timestamp , $cron_freq, 'wpdbbkp_db_backup_event' ); |
| 3073 |
|
| 3074 |
} |
| 3075 |
}else{ |
| 3076 |
if( !empty($options) && ( false === isset( $options['enable_autobackups'] ) ) || ( true === isset( $options['enable_autobackups'] ) ) && isset($options['autobackup_type']) && $options['autobackup_type'] != 'db') |
| 3077 |
{ |
| 3078 |
wp_clear_scheduled_hook( 'wpdbbkp_db_backup_event' ); |
| 3079 |
} |
| 3080 |
|
| 3081 |
} |
| 3082 |
} |
| 3083 |
|
| 3084 |
/** |
| 3085 |
* Config data. |
| 3086 |
* |
| 3087 |
* @param string $key - key name. |
| 3088 |
*/ |
| 3089 |
public function wp_backup_get_config_data( $key ) { |
| 3090 |
$filepath = get_home_path() . '/wp-config.php'; |
| 3091 |
$config_file = @file_get_contents( "$filepath", true ); |
| 3092 |
if($config_file){ |
| 3093 |
switch ( $key ) { |
| 3094 |
case 'DB_NAME': |
| 3095 |
preg_match( "/'DB_NAME',\s*'(.*)?'/", $config_file, $matches ); |
| 3096 |
break; |
| 3097 |
case 'DB_USER': |
| 3098 |
preg_match( "/'DB_USER',\s*'(.*)?'/", $config_file, $matches ); |
| 3099 |
break; |
| 3100 |
case 'DB_PASSWORD': |
| 3101 |
preg_match( "/'DB_PASSWORD',\s*'(.*)?'/", $config_file, $matches ); |
| 3102 |
break; |
| 3103 |
case 'DB_HOST': |
| 3104 |
preg_match( "/'DB_HOST',\s*'(.*)?'/", $config_file, $matches ); |
| 3105 |
break; |
| 3106 |
} |
| 3107 |
return $matches[1]; |
| 3108 |
} |
| 3109 |
|
| 3110 |
return ''; |
| 3111 |
|
| 3112 |
} |
| 3113 |
|
| 3114 |
/** |
| 3115 |
* Get db name from config. |
| 3116 |
*/ |
| 3117 |
public function wp_backup_get_config_db_name() { |
| 3118 |
$filepath = get_home_path() . '/wp-config.php'; |
| 3119 |
$config_file = @file_get_contents( "$filepath", true ); |
| 3120 |
if($config_file){ |
| 3121 |
preg_match( "/'DB_NAME',\s*'(.*)?'/", $config_file, $matches ); |
| 3122 |
return $matches[1]; |
| 3123 |
} |
| 3124 |
return ''; |
| 3125 |
} |
| 3126 |
|
| 3127 |
/** |
| 3128 |
* Restrict exclude-table names to tables that exist in the database. |
| 3129 |
* |
| 3130 |
* @param array|string $exclude_tables Tables requested for exclusion. |
| 3131 |
* |
| 3132 |
* @return array |
| 3133 |
*/ |
| 3134 |
public function filter_valid_exclude_tables( $exclude_tables ) { |
| 3135 |
global $wpdb; |
| 3136 |
|
| 3137 |
if ( ! is_array( $exclude_tables ) ) { |
| 3138 |
return array(); |
| 3139 |
} |
| 3140 |
|
| 3141 |
$valid_tables = $wpdb->get_col( 'SHOW TABLES' ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching |
| 3142 |
|
| 3143 |
if ( empty( $valid_tables ) ) { |
| 3144 |
return array(); |
| 3145 |
} |
| 3146 |
|
| 3147 |
$valid_tables = array_flip( $valid_tables ); |
| 3148 |
$filtered = array(); |
| 3149 |
|
| 3150 |
foreach ( $exclude_tables as $exclude_table ) { |
| 3151 |
if ( is_string( $exclude_table ) && isset( $valid_tables[ $exclude_table ] ) ) { |
| 3152 |
$filtered[] = $exclude_table; |
| 3153 |
} |
| 3154 |
} |
| 3155 |
|
| 3156 |
return array_values( array_unique( $filtered ) ); |
| 3157 |
} |
| 3158 |
|
| 3159 |
/** |
| 3160 |
* Recursive sanitation for an array |
| 3161 |
* |
| 3162 |
* @param array $array - Array data to sanitize. |
| 3163 |
* |
| 3164 |
* @return mixed |
| 3165 |
*/ |
| 3166 |
public function recursive_sanitize_text_field( $array ) { |
| 3167 |
if( ! is_array( $array ) ) { |
| 3168 |
return sanitize_text_field( $array ); |
| 3169 |
} |
| 3170 |
foreach ( $array as $key => &$value ) { |
| 3171 |
if ( is_array( $value ) ) { |
| 3172 |
$value = $this->recursive_sanitize_text_field( $value ); |
| 3173 |
} else { |
| 3174 |
$value = sanitize_text_field( $value ); |
| 3175 |
} |
| 3176 |
} |
| 3177 |
|
| 3178 |
return $array; |
| 3179 |
} |
| 3180 |
|
| 3181 |
/** |
| 3182 |
* Enqueue scripts and style |
| 3183 |
*/ |
| 3184 |
public function admin_scripts_style() { |
| 3185 |
if ( true === $this->is_wpdb_page() ) { |
| 3186 |
wp_enqueue_script( 'jquery' ); |
| 3187 |
|
| 3188 |
wp_register_script( 'bootstrapjs', WPDB_PLUGIN_URL . '/assets/js/bootstrap.min.js', array( 'jquery' ), WPDB_VERSION, false ); |
| 3189 |
wp_enqueue_script( 'bootstrapjs' ); |
| 3190 |
|
| 3191 |
wp_register_style( 'bootstrapcss', WPDB_PLUGIN_URL . '/assets/css/bootstrap.min.css', array(), WPDB_VERSION ); |
| 3192 |
wp_enqueue_style( 'bootstrapcss' ); |
| 3193 |
|
| 3194 |
wp_register_script( 'dataTablesjs', WPDB_PLUGIN_URL . '/assets/js/jquery.dataTables.js', array( 'jquery' ), WPDB_VERSION, false ); |
| 3195 |
wp_enqueue_script( 'dataTablesjs' ); |
| 3196 |
|
| 3197 |
wp_register_style( 'dataTablescss', WPDB_PLUGIN_URL . '/assets/css/jquery.dataTables.css', array(), WPDB_VERSION ); |
| 3198 |
wp_enqueue_style( 'dataTablescss' ); |
| 3199 |
|
| 3200 |
wp_register_style( 'wpdbcss', WPDB_PLUGIN_URL . '/assets/css/wpdb_admin.css', array(), WPDB_VERSION ); |
| 3201 |
wp_enqueue_style( 'wpdbcss' ); |
| 3202 |
} |
| 3203 |
} |
| 3204 |
|
| 3205 |
/** |
| 3206 |
* Check is plugin page. |
| 3207 |
*/ |
| 3208 |
public function is_wpdb_page() { |
| 3209 |
|
| 3210 |
if ( is_admin() ) { |
| 3211 |
|
| 3212 |
return isset( $_REQUEST['page'] ) && preg_match( '/wp-database-backup/', $_REQUEST['page'] ) ? true : false; // phpcs:ignore |
| 3213 |
|
| 3214 |
} else { |
| 3215 |
|
| 3216 |
return true; |
| 3217 |
} |
| 3218 |
} |
| 3219 |
|
| 3220 |
// loading admin scripts/styles on admin page only |
| 3221 |
|
| 3222 |
public function wpdbbkp_admin_style($hook_suffix) |
| 3223 |
{ |
| 3224 |
if($hook_suffix=="tools_page_wp-database-backup" || $hook_suffix=="toplevel_page_wp-database-backup") |
| 3225 |
{ |
| 3226 |
wp_register_script('wpdbbkp-admin-script', WPDB_PLUGIN_URL . '/assets/js/wpdbbkp-admin.js', array('jquery'), WPDB_VERSION, 'true' ); |
| 3227 |
wp_localize_script('wpdbbkp-admin-script', 'wpdbbkp_script_vars', array( |
| 3228 |
'nonce' => wp_create_nonce( 'wpdbbkp-admin-nonce' ), |
| 3229 |
'siteurl' => base64_encode(site_url( )), |
| 3230 |
'ud'=>wpdbbkp_get_current_user_name_email(), |
| 3231 |
'is_subscribed'=>wpdbbkp_if_remote_active(), |
| 3232 |
)); |
| 3233 |
wp_enqueue_script('wpdbbkp-admin-script'); |
| 3234 |
|
| 3235 |
// Adding custom js |
| 3236 |
$local = array( |
| 3237 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 3238 |
'wpdbbkp_admin_security_nonce' => wp_create_nonce('wpdbbkp_ajax_check_nonce'), |
| 3239 |
'home_url' =>get_home_url() |
| 3240 |
); |
| 3241 |
wp_register_script('wpdbbkp-admin-fb', WPDB_PLUGIN_URL . '/assets/js/wpdbbkp-admin-cron-backup.js', array(), WPDB_VERSION , true ); |
| 3242 |
|
| 3243 |
wp_localize_script('wpdbbkp-admin-fb', 'wpdbbkp_localize_admin_data', $local ); |
| 3244 |
wp_enqueue_script('wpdbbkp-admin-fb'); |
| 3245 |
wp_register_script('wpdbbkp-admin-export', WPDB_PLUGIN_URL . '/assets/js/wpdbbkp-admin-cron-export.js', array(), WPDB_VERSION , true ); |
| 3246 |
wp_enqueue_script('wpdbbkp-admin-export'); |
| 3247 |
// Custom Js ends |
| 3248 |
} |
| 3249 |
} |
| 3250 |
|
| 3251 |
public function wpdbbkp_admin_newsletter_script($hook_suffix ) { |
| 3252 |
if($hook_suffix=="tools_page_wp-database-backup" || $hook_suffix=="toplevel_page_wp-database-backup") |
| 3253 |
{ |
| 3254 |
wp_enqueue_script('wpdbbkp-admin-newsletter-script', WPDB_PLUGIN_URL . '/assets/js/wpdbbkp-admin-newsletter.js', array('jquery'), WPDB_VERSION, 'true' ); |
| 3255 |
|
| 3256 |
$current_screen = get_current_screen(); |
| 3257 |
|
| 3258 |
if(isset($current_screen->post_type)){ |
| 3259 |
$post_type = $current_screen->post_type; |
| 3260 |
} |
| 3261 |
|
| 3262 |
$post_id = get_the_ID(); |
| 3263 |
//phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no form submission |
| 3264 |
if(isset($_GET['tag_ID'])){ |
| 3265 |
//phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no form submission |
| 3266 |
$post_id = intval($_GET['tag_ID']); |
| 3267 |
} |
| 3268 |
|
| 3269 |
|
| 3270 |
|
| 3271 |
$data = array( |
| 3272 |
'current_url' => wpdbbkp_get_current_url(), |
| 3273 |
'post_id' => $post_id, |
| 3274 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 3275 |
'post_type' => $post_type, |
| 3276 |
'page_now' => $hook_suffix, |
| 3277 |
'wpdbbkp_security_nonce' => wp_create_nonce('wpdbbkp_ajax_check_nonce'), |
| 3278 |
); |
| 3279 |
|
| 3280 |
$data = apply_filters('wpdbbkp_localize_filter',$data,'wpdbbkp_localize_data'); |
| 3281 |
|
| 3282 |
wp_localize_script( 'wpdbbkp-admin-newsletter-script', 'wpdbbkp_localize_data', $data ); |
| 3283 |
|
| 3284 |
} |
| 3285 |
|
| 3286 |
} |
| 3287 |
|
| 3288 |
public function wpdbbkp_sanitize_textarea_field( $str ) { |
| 3289 |
|
| 3290 |
if ( is_object( $str ) || is_array( $str ) ) { |
| 3291 |
return ''; |
| 3292 |
} |
| 3293 |
|
| 3294 |
$str = (string) $str; |
| 3295 |
|
| 3296 |
$filtered = wp_check_invalid_utf8( $str ); |
| 3297 |
|
| 3298 |
if ( strpos( $filtered, '<' ) !== false ) { |
| 3299 |
$filtered = wp_pre_kses_less_than( $filtered ); |
| 3300 |
// This will strip extra whitespace for us. |
| 3301 |
$filtered = wp_strip_all_tags( $filtered, false ); |
| 3302 |
|
| 3303 |
// Use HTML entities in a special case to make sure no later |
| 3304 |
// newline stripping stage could lead to a functional tag. |
| 3305 |
$filtered = str_replace( "<\n", "<\n", $filtered ); |
| 3306 |
} |
| 3307 |
|
| 3308 |
$filtered = trim( $filtered ); |
| 3309 |
|
| 3310 |
$found = false; |
| 3311 |
while ( preg_match( '/%[a-f0-9]{2}/i', $filtered, $match ) ) { |
| 3312 |
$filtered = str_replace( $match[0], '', $filtered ); |
| 3313 |
$found = true; |
| 3314 |
} |
| 3315 |
|
| 3316 |
if ( $found ) { |
| 3317 |
// Strip out the whitespace that may now exist after removing the octets. |
| 3318 |
$filtered = trim( preg_replace( '/ +/', ' ', $filtered ) ); |
| 3319 |
} |
| 3320 |
|
| 3321 |
return $filtered; |
| 3322 |
} |
| 3323 |
|
| 3324 |
public function wpdbbkp_send_query_message(){ |
| 3325 |
|
| 3326 |
if ( ! isset( $_POST['wpdbbkp_security_nonce'] ) ){ |
| 3327 |
return; |
| 3328 |
} |
| 3329 |
if ( !wp_verify_nonce( wp_unslash($_POST['wpdbbkp_security_nonce']), 'wpdbbkp-admin-nonce' ) ){ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- used as nonce |
| 3330 |
return; |
| 3331 |
} |
| 3332 |
|
| 3333 |
if( ! current_user_can( 'manage_options' ) ) { |
| 3334 |
return; |
| 3335 |
} |
| 3336 |
|
| 3337 |
$message = isset($_POST['message']) ? $this->wpdbbkp_sanitize_textarea_field(wp_unslash($_POST['message'])) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitized using custom function |
| 3338 |
$email = isset($_POST['email']) ? $this->wpdbbkp_sanitize_textarea_field(wp_unslash($_POST['email'])) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitized using custom function |
| 3339 |
|
| 3340 |
if(function_exists('wp_get_current_user')){ |
| 3341 |
|
| 3342 |
$user = wp_get_current_user(); |
| 3343 |
|
| 3344 |
$message = '<p>'.$message.'</p><br><br>'.'Query from BackupforWP plugin support tab'; |
| 3345 |
|
| 3346 |
$user_data = $user->data; |
| 3347 |
$user_email = $user_data->user_email; |
| 3348 |
|
| 3349 |
if($email){ |
| 3350 |
$user_email = $email; |
| 3351 |
} |
| 3352 |
//php mailer variables |
| 3353 |
$sendto = 'team@magazine3.in'; |
| 3354 |
$subject = "BackupforWP Query"; |
| 3355 |
|
| 3356 |
$headers[] = 'Content-Type: text/html; charset=UTF-8'; |
| 3357 |
$headers[] = 'From: '. esc_attr($user_email); |
| 3358 |
$headers[] = 'Reply-To: ' . esc_attr($user_email); |
| 3359 |
// Load WP components, no themes. |
| 3360 |
|
| 3361 |
$sent = wp_mail($sendto, $subject, $message, $headers); |
| 3362 |
|
| 3363 |
if($sent){ |
| 3364 |
|
| 3365 |
echo wp_json_encode(array('status'=>'t')); |
| 3366 |
|
| 3367 |
}else{ |
| 3368 |
|
| 3369 |
echo wp_json_encode(array('status'=>'f')); |
| 3370 |
|
| 3371 |
} |
| 3372 |
|
| 3373 |
} |
| 3374 |
|
| 3375 |
wp_die(); |
| 3376 |
} |
| 3377 |
public function add_settings_plugin_action_wp( $actions, $plugin_file, $plugin_data, $context ) { |
| 3378 |
$plugin_actions['settings'] = sprintf( |
| 3379 |
'<a href="%s">' . _x( 'Settings', 'Content translation' ,'wpdbbkp' ) . '</a>', |
| 3380 |
admin_url( 'options-general.php?page=wp-database-backup' ) |
| 3381 |
); |
| 3382 |
$actions = array_merge( $actions, $plugin_actions ); |
| 3383 |
return $actions; |
| 3384 |
} |
| 3385 |
|
| 3386 |
public function wpdbbkp_update_backup_info($FileName, $logFile, $logMessage = '') { |
| 3387 |
$path_info = wp_upload_dir(); |
| 3388 |
$filename = $FileName . '.sql'; |
| 3389 |
$WPDBFileName = $FileName . '.zip'; |
| 3390 |
wp_delete_file($this->wp_db_backup_wp_config_path() . '/' . $filename); |
| 3391 |
wp_delete_file($this->wp_db_backup_wp_config_path() . '/wp_installer.php'); |
| 3392 |
@$filesize = filesize($path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/' . $WPDBFileName); |
| 3393 |
|
| 3394 |
$upload_path = array( |
| 3395 |
'filename' => ($WPDBFileName), |
| 3396 |
'dir' => ($path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/' . $WPDBFileName), |
| 3397 |
'url' => ($path_info['baseurl'] . '/' . WPDB_BACKUPS_DIR . '/' . $WPDBFileName), |
| 3398 |
'size' => ($filesize), |
| 3399 |
'type' => get_option('wp_db_backup_backup_type') |
| 3400 |
); |
| 3401 |
|
| 3402 |
|
| 3403 |
if (get_option('wp_db_log') == 1) { |
| 3404 |
$this->write_log($logFile, $logMessage); |
| 3405 |
$upload_path['logfile'] = $path_info['baseurl'] . '/' . WPDB_BACKUPS_DIR . '/log/' . $FileName . '.txt'; |
| 3406 |
$upload_path['logfileDir'] = $logFile; |
| 3407 |
} else { |
| 3408 |
$upload_path['logfile'] = ""; |
| 3409 |
} |
| 3410 |
$args = array($FileName, $logFile, $logMessage); |
| 3411 |
do_action_ref_array('wpdbbkp_backup_completed', array(&$args)); |
| 3412 |
return $upload_path; |
| 3413 |
} |
| 3414 |
|
| 3415 |
private function write_log($logFile, $logMessage) { |
| 3416 |
// Actually write the log file |
| 3417 |
if ( empty( $logMessage ) || empty( $logFile ) ) { |
| 3418 |
return false; |
| 3419 |
} |
| 3420 |
global $wp_filesystem; |
| 3421 |
if(!function_exists('WP_Filesystem')){ |
| 3422 |
require_once ( ABSPATH . '/wp-admin/includes/file.php' ); |
| 3423 |
} |
| 3424 |
WP_Filesystem(); |
| 3425 |
$logDir = dirname( $logFile ); |
| 3426 |
if ($wp_filesystem && $wp_filesystem->is_writable($logDir)) { |
| 3427 |
$wp_filesystem->put_contents( $logFile, $logMessage, FS_CHMOD_FILE ); |
| 3428 |
return true; |
| 3429 |
} |
| 3430 |
} |
| 3431 |
|
| 3432 |
public function get_zip_command_path() { |
| 3433 |
|
| 3434 |
// Check shell_exec is available |
| 3435 |
if (!self::is_shell_exec_available()) |
| 3436 |
return ''; |
| 3437 |
|
| 3438 |
// Return now if it's already been set |
| 3439 |
if (isset($this->zip_command_path)) |
| 3440 |
return $this->zip_command_path; |
| 3441 |
|
| 3442 |
$this->zip_command_path = ''; |
| 3443 |
|
| 3444 |
// Does zip work |
| 3445 |
if (is_null(shell_exec('hash zip 2>&1'))) { |
| 3446 |
|
| 3447 |
// If so store it for later |
| 3448 |
$this->set_zip_command_path('zip'); |
| 3449 |
|
| 3450 |
// And return now |
| 3451 |
return $this->zip_command_path; |
| 3452 |
} |
| 3453 |
|
| 3454 |
// List of possible zip locations |
| 3455 |
$zip_locations = array( |
| 3456 |
'/usr/bin/zip' |
| 3457 |
); |
| 3458 |
|
| 3459 |
// Find the one which works |
| 3460 |
foreach ($zip_locations as $location) |
| 3461 |
if (@is_executable(self::conform_dir($location))) |
| 3462 |
$this->set_zip_command_path($location); |
| 3463 |
|
| 3464 |
return $this->zip_command_path; |
| 3465 |
} |
| 3466 |
|
| 3467 |
public function set_zip_command_path($path) { |
| 3468 |
|
| 3469 |
$this->zip_command_path = $path; |
| 3470 |
} |
| 3471 |
|
| 3472 |
/* Begin : Generate Zip using cmd 06-03-2016 V.3.9 */ |
| 3473 |
|
| 3474 |
public function zip($WPDBFileName) { |
| 3475 |
|
| 3476 |
$this->archive_method = 'zip'; |
| 3477 |
$wp_all_backup_exclude_dir = get_option('wp_db_backup_exclude_dir'); |
| 3478 |
if (empty($wp_all_backup_exclude_dir)) { |
| 3479 |
$excludes = WPDB_BACKUPS_DIR; |
| 3480 |
} else { |
| 3481 |
$excludes = WPDB_BACKUPS_DIR . '|' . $wp_all_backup_exclude_dir; |
| 3482 |
} |
| 3483 |
// Zip up $this->root with excludes |
| 3484 |
if (!empty($excludes)) { |
| 3485 |
$stderr = shell_exec('cd ' . escapeshellarg($this->get_root()) . ' && ' . escapeshellcmd($this->get_zip_command_path()) . ' -rq ' . escapeshellarg($WPDBFileName) . ' ./' . ' -x ' . $this->exclude_string('zip') . ' 2>&1'); |
| 3486 |
} |
| 3487 |
|
| 3488 |
// Zip up $this->root without excludes |
| 3489 |
else { |
| 3490 |
|
| 3491 |
$stderr = shell_exec('cd ' . escapeshellarg($this->get_root()) . ' && ' . escapeshellcmd($this->get_zip_command_path()) . ' -rq ' . escapeshellarg($WPDBFileName) . ' ./' . ' 2>&1'); |
| 3492 |
} |
| 3493 |
if (!empty($stderr)) |
| 3494 |
$this->warning($this->get_archive_method(), $stderr); |
| 3495 |
|
| 3496 |
return $this->verify_archive($WPDBFileName); |
| 3497 |
} |
| 3498 |
|
| 3499 |
public function get_root() { |
| 3500 |
|
| 3501 |
if (empty($this->root)) |
| 3502 |
$this->set_root(self::conform_dir(self::get_home_path())); |
| 3503 |
|
| 3504 |
return $this->root; |
| 3505 |
} |
| 3506 |
|
| 3507 |
public function set_root($path) { |
| 3508 |
|
| 3509 |
if (empty($path) || !is_string($path) || !is_dir($path)) |
| 3510 |
throw new Exception('Invalid root path <code>' . esc_html($path) . '</code> must be a valid directory path'); |
| 3511 |
|
| 3512 |
$this->root = self::conform_dir($path); |
| 3513 |
} |
| 3514 |
|
| 3515 |
public static function get_home_path() { |
| 3516 |
|
| 3517 |
$home_url = home_url(); |
| 3518 |
$site_url = site_url(); |
| 3519 |
|
| 3520 |
$home_path = ABSPATH; |
| 3521 |
|
| 3522 |
// If site_url contains home_url and they differ then assume WordPress is installed in a sub directory |
| 3523 |
if ($home_url !== $site_url && strpos($site_url, $home_url) === 0) |
| 3524 |
$home_path = trailingslashit(substr(self::conform_dir(ABSPATH), 0, strrpos(self::conform_dir(ABSPATH), str_replace($home_url, '', $site_url)))); |
| 3525 |
|
| 3526 |
return self::conform_dir($home_path); |
| 3527 |
} |
| 3528 |
|
| 3529 |
private function warning($context, $warning) { |
| 3530 |
|
| 3531 |
if (empty($context) || empty($warning)) |
| 3532 |
return; |
| 3533 |
$this->warnings[$context][$_key = md5(implode(':', (array) $warning))] = $warning; |
| 3534 |
} |
| 3535 |
|
| 3536 |
public function exclude_string($context = 'zip') { |
| 3537 |
|
| 3538 |
// Return a comma separated list by default |
| 3539 |
$separator = ', '; |
| 3540 |
$wildcard = ''; |
| 3541 |
|
| 3542 |
// The zip command |
| 3543 |
if ($context === 'zip') { |
| 3544 |
$wildcard = '*'; |
| 3545 |
$separator = ' -x '; |
| 3546 |
|
| 3547 |
// The PclZip fallback library |
| 3548 |
} elseif ($context === 'regex') { |
| 3549 |
$wildcard = '([\s\S]*?)'; |
| 3550 |
$separator = '|'; |
| 3551 |
} |
| 3552 |
|
| 3553 |
$wp_all_backup_exclude_dir = get_option('wp_db_backup_exclude_dir'); |
| 3554 |
if (empty($wp_all_backup_exclude_dir)) { |
| 3555 |
$excludes = WPDB_BACKUPS_DIR; |
| 3556 |
} else { |
| 3557 |
$excludes = WPDB_BACKUPS_DIR . '|' . $wp_all_backup_exclude_dir; |
| 3558 |
} |
| 3559 |
|
| 3560 |
$excludes = explode("|", $excludes); |
| 3561 |
if(!empty($excludes) && is_array($excludes)){ |
| 3562 |
foreach ($excludes as $key => &$rule) { |
| 3563 |
|
| 3564 |
$file = $absolute = $fragment = false; |
| 3565 |
|
| 3566 |
// Files don't end with / |
| 3567 |
if (!in_array(substr($rule, -1), array('\\', '/'))) |
| 3568 |
$file = true; |
| 3569 |
|
| 3570 |
// If rule starts with a / then treat as absolute path |
| 3571 |
elseif (in_array(substr($rule, 0, 1), array('\\', '/'))) |
| 3572 |
$absolute = true; |
| 3573 |
|
| 3574 |
// Otherwise treat as dir fragment |
| 3575 |
else |
| 3576 |
$fragment = true; |
| 3577 |
|
| 3578 |
// Strip $this->root and conform |
| 3579 |
$rule = str_ireplace($this->get_root(), '', untrailingslashit(self::conform_dir($rule))); |
| 3580 |
|
| 3581 |
// Strip the preceeding slash |
| 3582 |
if (in_array(substr($rule, 0, 1), array('\\', '/'))) |
| 3583 |
$rule = substr($rule, 1); |
| 3584 |
|
| 3585 |
// Escape string for regex |
| 3586 |
if ($context === 'regex') |
| 3587 |
$rule = str_replace('.', '\.', $rule); |
| 3588 |
|
| 3589 |
// Convert any existing wildcards |
| 3590 |
if ($wildcard !== '*' && strpos($rule, '*') !== false) |
| 3591 |
$rule = str_replace('*', $wildcard, $rule); |
| 3592 |
|
| 3593 |
// Wrap directory fragments and files in wildcards for zip |
| 3594 |
if ($context === 'zip' && ( $fragment || $file )) |
| 3595 |
$rule = $wildcard . $rule . $wildcard; |
| 3596 |
|
| 3597 |
// Add a wildcard to the end of absolute url for zips |
| 3598 |
if ($context === 'zip' && $absolute) |
| 3599 |
$rule .= $wildcard; |
| 3600 |
|
| 3601 |
// Add and end carrot to files for pclzip but only if it doesn't end in a wildcard |
| 3602 |
if ($file && $context === 'regex') |
| 3603 |
$rule .= '$'; |
| 3604 |
|
| 3605 |
// Add a start carrot to absolute urls for pclzip |
| 3606 |
if ($absolute && $context === 'regex') |
| 3607 |
$rule = '^' . $rule; |
| 3608 |
} |
| 3609 |
} |
| 3610 |
|
| 3611 |
|
| 3612 |
// Escape shell args for zip command |
| 3613 |
if ($context === 'zip') |
| 3614 |
$excludes = array_map('escapeshellarg', array_unique($excludes)); |
| 3615 |
|
| 3616 |
return implode($separator, $excludes); |
| 3617 |
} |
| 3618 |
|
| 3619 |
public function get_archive_method() { |
| 3620 |
return $this->archive_method; |
| 3621 |
} |
| 3622 |
|
| 3623 |
public function verify_archive($WPDBFileName) { |
| 3624 |
// If we've already passed then no need to check again |
| 3625 |
if (!empty($this->archive_verified)) |
| 3626 |
return true; |
| 3627 |
|
| 3628 |
// If there are errors delete the backup file. |
| 3629 |
if ($this->get_errors($this->get_archive_method()) && file_exists($WPDBFileName)) |
| 3630 |
wp_delete_file($WPDBFileName); |
| 3631 |
|
| 3632 |
// If the archive file still exists assume it's good |
| 3633 |
if (file_exists($WPDBFileName)) |
| 3634 |
return $this->archive_verified = true; |
| 3635 |
|
| 3636 |
return false; |
| 3637 |
} |
| 3638 |
|
| 3639 |
public function get_files() { |
| 3640 |
|
| 3641 |
if (!empty($this->files)) |
| 3642 |
return $this->files; |
| 3643 |
|
| 3644 |
$this->files = array(); |
| 3645 |
|
| 3646 |
// We only want to use the RecursiveDirectoryIterator if the FOLLOW_SYMLINKS flag is available |
| 3647 |
if (defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS')) { |
| 3648 |
|
| 3649 |
$this->files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->get_root(), RecursiveDirectoryIterator::FOLLOW_SYMLINKS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD); |
| 3650 |
|
| 3651 |
// Skip dot files if the SKIP_Dots flag is available |
| 3652 |
if (defined('RecursiveDirectoryIterator::SKIP_DOTS')) |
| 3653 |
$this->files->setFlags(RecursiveDirectoryIterator::SKIP_DOTS + RecursiveDirectoryIterator::FOLLOW_SYMLINKS); |
| 3654 |
|
| 3655 |
|
| 3656 |
// If RecursiveDirectoryIterator::FOLLOW_SYMLINKS isn't available then fallback to a less memory efficient method |
| 3657 |
} else { |
| 3658 |
|
| 3659 |
$this->files = $this->get_files_fallback($this->get_root()); |
| 3660 |
} |
| 3661 |
|
| 3662 |
return $this->files; |
| 3663 |
} |
| 3664 |
|
| 3665 |
public function wpdbbkp_get_timeago( $time ) |
| 3666 |
{ |
| 3667 |
$time = intval($time) > 0 ? intval($time) : time(); |
| 3668 |
|
| 3669 |
$time_difference = time() - $time; |
| 3670 |
|
| 3671 |
if( $time_difference < 1 ) { return 'less than 1 second ago'; } |
| 3672 |
$condition = array( 12 * 30 * 24 * 60 * 60 => 'year', |
| 3673 |
30 * 24 * 60 * 60 => 'month', |
| 3674 |
24 * 60 * 60 => 'day', |
| 3675 |
60 * 60 => 'hour', |
| 3676 |
60 => 'minute', |
| 3677 |
1 => 'second' |
| 3678 |
); |
| 3679 |
|
| 3680 |
foreach( $condition as $secs => $str ) |
| 3681 |
{ |
| 3682 |
$d = $time_difference / $secs; |
| 3683 |
|
| 3684 |
if( $d >= 1 ) |
| 3685 |
{ |
| 3686 |
$t = floor( $d ); |
| 3687 |
return 'About ' . $t . ' ' . $str . ( $t > 1 ? 's' : '' ) . ' ago'; |
| 3688 |
} |
| 3689 |
} |
| 3690 |
} |
| 3691 |
|
| 3692 |
private function wpdbbkp_append_to_file($file_path, $content_to_append){ |
| 3693 |
global $wp_filesystem; |
| 3694 |
|
| 3695 |
if (!function_exists('WP_Filesystem')) { |
| 3696 |
require_once ABSPATH . 'wp-admin/includes/file.php'; |
| 3697 |
} |
| 3698 |
|
| 3699 |
|
| 3700 |
if (empty($wp_filesystem)) { |
| 3701 |
WP_Filesystem(); |
| 3702 |
} |
| 3703 |
|
| 3704 |
if (!$wp_filesystem) { |
| 3705 |
return false; |
| 3706 |
} |
| 3707 |
|
| 3708 |
// Check if the file exists |
| 3709 |
if ($wp_filesystem->exists($file_path)) { |
| 3710 |
// Open the file in append mode |
| 3711 |
$handle = $wp_filesystem->get_contents($file_path); |
| 3712 |
|
| 3713 |
if ($handle) { |
| 3714 |
// Append the new content |
| 3715 |
$result = $wp_filesystem->put_contents($file_path, $handle . $content_to_append, FS_CHMOD_FILE); |
| 3716 |
return $result !== false; |
| 3717 |
} |
| 3718 |
} else { |
| 3719 |
// If the file doesn't exist, create it with the initial content |
| 3720 |
$result = $wp_filesystem->put_contents($file_path, $content_to_append, FS_CHMOD_FILE); |
| 3721 |
return $result !== false; |
| 3722 |
} |
| 3723 |
|
| 3724 |
return false; |
| 3725 |
} |
| 3726 |
|
| 3727 |
public function wpdbbkp_cloudbackup_notice(){ |
| 3728 |
$user_id = get_current_user_id(); |
| 3729 |
$wpdbbkp_cloudbackup_notice = get_option( 'wpdb_clouddrive_token', false ); |
| 3730 |
|
| 3731 |
if( $wpdbbkp_cloudbackup_notice ){ |
| 3732 |
return; |
| 3733 |
} |
| 3734 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 3735 |
return; |
| 3736 |
} |
| 3737 |
|
| 3738 |
if ( get_user_meta( $user_id, 'wpdbbkp_cloudbackup_notice_dismissed', true ) ) { |
| 3739 |
return; |
| 3740 |
} |
| 3741 |
|
| 3742 |
$nonce = wp_create_nonce( 'wpdbbkp_cloudbackup_notice_dismissed' ) |
| 3743 |
?> |
| 3744 |
<div class="notice notice-info is-dismissible" id="wpdbbkp_cloudbackup_dismiss"> |
| 3745 |
<p><?php echo esc_html__('Take a free 14-day trial of BackupforWP Cloud Backup.', 'wpdbbkp').'<a href="'.esc_url('https://backupforwp.com/register?from=plugin_notice').'" target="_blank">'.esc_html__('Get Started in 2 Minutes.', 'wpdbbkp'). '</a>';?></p> |
| 3746 |
</div> |
| 3747 |
<script type="text/javascript"> |
| 3748 |
jQuery(document).ready(function($) { |
| 3749 |
// Handle dismiss action |
| 3750 |
$(document).on('click', '#wpdbbkp_cloudbackup_dismiss .notice-dismiss', function() { |
| 3751 |
var ajaxurl = "<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>"; |
| 3752 |
$.post(ajaxurl, { |
| 3753 |
action: 'wpdbbkp_cloudbackup_dismiss_notice', |
| 3754 |
nonce: '<?php echo esc_js( $nonce ); ?>' |
| 3755 |
}); |
| 3756 |
}); |
| 3757 |
}); |
| 3758 |
</script> |
| 3759 |
<?php |
| 3760 |
} |
| 3761 |
public function wpdbbkp_cloudbackup_dismiss_notice() { |
| 3762 |
|
| 3763 |
|
| 3764 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 3765 |
wp_die( esc_html__( 'Permission denied', 'wpdbbkp' ), '', [ 'response' => 403 ] ); |
| 3766 |
} |
| 3767 |
|
| 3768 |
// Verify the nonce |
| 3769 |
if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['nonce'] ), 'wpdbbkp_cloudbackup_notice_dismissed' ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- using as nonce |
| 3770 |
wp_die( esc_html__( 'Invalid nonce', 'wpdbbkp' ), '', [ 'response' => 403 ] ); |
| 3771 |
} |
| 3772 |
|
| 3773 |
$user_id = get_current_user_id(); |
| 3774 |
update_user_meta( $user_id, 'wpdbbkp_cloudbackup_notice_dismissed', 1 ); |
| 3775 |
wp_die(); |
| 3776 |
} |
| 3777 |
|
| 3778 |
public function admin_backup_file_download() { |
| 3779 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 3780 |
return; |
| 3781 |
} |
| 3782 |
|
| 3783 |
// Check for a specific query parameter, e.g., ?download_backup=filename.zip |
| 3784 |
if ( isset( $_GET['wpdbbkp_download'] ) && ! empty( $_GET['wpdbbkp_download'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no form submission |
| 3785 |
$path_info = wp_upload_dir(); |
| 3786 |
$backup_dir = $path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/'; |
| 3787 |
$file_name = basename( sanitize_text_field( wp_unslash( $_GET['wpdbbkp_download'] ) ) ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no form submission |
| 3788 |
$file_path = trailingslashit( $backup_dir ) . $file_name; |
| 3789 |
|
| 3790 |
|
| 3791 |
// Check if file exists |
| 3792 |
if ( file_exists( $file_path ) ) { |
| 3793 |
// Serve the file |
| 3794 |
header( 'Content-Description: File Transfer' ); |
| 3795 |
header( 'Content-Type: application/octet-stream' ); |
| 3796 |
header( 'Content-Disposition: attachment; filename="' . $file_name . '"' ); |
| 3797 |
header( 'Content-Length: ' . filesize( $file_path ) ); |
| 3798 |
readfile( $file_path ); //phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_readfile -- readfile is used to read the file with buffer |
| 3799 |
exit; |
| 3800 |
} else { |
| 3801 |
wp_die( esc_html__( 'Backup file not found.', 'wpdbbkp' ) ); |
| 3802 |
} |
| 3803 |
} |
| 3804 |
// Check for a specific query parameter, e.g., ?download_backup=filename.zip |
| 3805 |
if ( isset( $_GET['wpdbbkp_log'] ) && ! empty( $_GET['wpdbbkp_log'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no form submission |
| 3806 |
$path_info = wp_upload_dir(); |
| 3807 |
$backup_dir = $path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/log/'; |
| 3808 |
$file_name = basename( sanitize_text_field( wp_unslash( $_GET['wpdbbkp_log'] ) ) ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no form submission |
| 3809 |
$file_path = trailingslashit( $backup_dir ) . $file_name; |
| 3810 |
|
| 3811 |
|
| 3812 |
// Check if file exists |
| 3813 |
if ( file_exists( $file_path ) ) { |
| 3814 |
// Serve the file |
| 3815 |
header( 'Content-Description: File Transfer' ); |
| 3816 |
header( 'Content-Type: application/octet-stream' ); |
| 3817 |
header( 'Content-Disposition: attachment; filename="' . $file_name . '"' ); |
| 3818 |
header( 'Content-Length: ' . filesize( $file_path ) ); |
| 3819 |
readfile( $file_path ); //phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_readfile -- readfile is used to read the file with buffer |
| 3820 |
exit; |
| 3821 |
} else { |
| 3822 |
wp_die( esc_html__( 'Backup file not found.', 'wpdbbkp' ) ); |
| 3823 |
} |
| 3824 |
} |
| 3825 |
} |
| 3826 |
|
| 3827 |
} |
| 3828 |
|
| 3829 |
new Wpdb_Admin(); |
| 3830 |
|