| @@ -16,10 +16,8 @@ | ||
| 16 | 16 | */ |
| 17 | 17 | class Wpdb_Admin { |
| 18 | 18 | |
| 19 | 19 | public $mysqldump_command_path; |
| 20 | - public $root; | |
| 21 | - public $files; | |
| 22 | 20 | |
| 23 | 21 | /** |
| 24 | 22 | * Construct. |
| 25 | 23 | */ |
| @@ -27,9 +25,9 @@ | ||
| 27 | 25 | add_action( 'admin_init', array( $this, 'wp_db_backup_admin_init' ) ); |
| 28 | 26 | add_action( 'admin_init', array( $this, 'admin_scripts_style' ) ); |
| 29 | 27 | add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 ); |
| 30 | 28 | add_filter( 'cron_schedules', array( $this, 'wp_db_backup_cron_schedules' ) ); |
| 31 | - add_action( 'wpdbbkp_db_backup_event', array( $this, 'wp_db_backup_event_process' ) ); | |
| 29 | + add_action( 'wp_db_backup_event', array( $this, 'wp_db_backup_event_process' ) ); | |
| 32 | 30 | add_action( 'init', array( $this, 'wp_db_backup_scheduler_activation' ) ); |
| 33 | 31 | add_action( 'wp_logout', array( $this, 'wp_db_cookie_expiration' ) ); // Fixed Vulnerability 22-06-2016 for prevent direct download. |
| 34 | 32 | add_action( 'wp_db_backup_completed', array( $this, 'wp_db_backup_completed_local' ), 12 ); |
| 35 | 33 | add_action('admin_enqueue_scripts', array( $this, 'wpdbbkp_admin_style')); |
| @@ -78,16 +76,8 @@ | ||
| 78 | 76 | 'manage_options', |
| 79 | 77 | 'wp-database-backup#tab_db_destination', |
| 80 | 78 | array($this, 'wp_db_backup_settings_page' )); |
| 81 | 79 | |
| 82 | - add_submenu_page( | |
| 83 | - 'wp-database-backup', | |
| 84 | - 'Cloud Backup', | |
| 85 | - 'Cloud Backup', | |
| 86 | - 'manage_options', | |
| 87 | - 'wp-database-backup#tab_db_remotebackups', | |
| 88 | - array($this, 'wp_db_backup_settings_page' )); | |
| 89 | - | |
| 90 | 80 | add_submenu_page( |
| 91 | 81 | 'wp-database-backup', |
| 92 | 82 | 'Settings', |
| 93 | 83 | 'Settings', |
| @@ -93,17 +83,11 @@ | ||
| 93 | 83 | 'Settings', |
| 94 | 84 | 'manage_options', |
| 95 | 85 | 'wp-database-backup#tab_db_setting', |
| 96 | 86 | array($this, 'wp_db_backup_settings_page' )); |
| 97 | - add_submenu_page( | |
| 98 | - 'wp-database-backup', | |
| 99 | - 'Search and Replace', | |
| 100 | - 'Search and Replace', | |
| 101 | - 'manage_options', | |
| 102 | - 'wp-database-backup#searchreplace', | |
| 103 | - array($this, 'wp_db_backup_settings_page' )); | |
| 104 | 87 | |
| 105 | 88 | |
| 89 | + | |
| 106 | 90 | add_submenu_page( |
| 107 | 91 | 'wp-database-backup', |
| 108 | 92 | 'Help & Support', |
| 109 | 93 | 'Help & Support', |
| @@ -110,33 +94,33 @@ | ||
| 110 | 94 | 'manage_options', |
| 111 | 95 | 'wp-database-backup#tab_db_help', |
| 112 | 96 | array($this, 'wp_db_backup_settings_page' )); |
| 113 | 97 | |
| 114 | - // if(!defined('BKPFORWP_VERSION')){ | |
| 115 | - // add_submenu_page( | |
| 116 | - // 'wp-database-backup', | |
| 117 | - // 'Upgrade to Premium', | |
| 118 | - // 'Upgrade to Premium', | |
| 119 | - // 'manage_options', | |
| 120 | - // 'wp-database-backup#tab_db_upgrade', | |
| 121 | - // array($this, 'wp_db_backup_settings_page' )); | |
| 122 | - // } | |
| 123 | - // else{ | |
| 124 | - // add_submenu_page( | |
| 125 | - // 'wp-database-backup', | |
| 126 | - // 'Modules', | |
| 127 | - // 'Modules', | |
| 128 | - // 'manage_options', | |
| 129 | - // 'wp-database-backup#tab_db_features', | |
| 130 | - // array($this, 'wp_db_backup_settings_page' )); | |
| 131 | - // add_submenu_page( | |
| 132 | - // 'wp-database-backup', | |
| 133 | - // 'Licence', | |
| 134 | - // 'Licence', | |
| 135 | - // 'manage_options', | |
| 136 | - // 'wp-database-backup#tab_db_licence', | |
| 137 | - // array($this, 'wp_db_backup_settings_page' )); | |
| 138 | - // } | |
| 98 | + if(!defined('BKPFORWP_VERSION')){ | |
| 99 | + add_submenu_page( | |
| 100 | + 'wp-database-backup', | |
| 101 | + 'Upgrade to Premium', | |
| 102 | + 'Upgrade to Premium', | |
| 103 | + 'manage_options', | |
| 104 | + 'wp-database-backup#tab_db_upgrade', | |
| 105 | + array($this, 'wp_db_backup_settings_page' )); | |
| 106 | + } | |
| 107 | + else{ | |
| 108 | + add_submenu_page( | |
| 109 | + 'wp-database-backup', | |
| 110 | + 'Modules', | |
| 111 | + 'Modules', | |
| 112 | + 'manage_options', | |
| 113 | + 'wp-database-backup#tab_db_features', | |
| 114 | + array($this, 'wp_db_backup_settings_page' )); | |
| 115 | + add_submenu_page( | |
| 116 | + 'wp-database-backup', | |
| 117 | + 'Licence', | |
| 118 | + 'Licence', | |
| 119 | + 'manage_options', | |
| 120 | + 'wp-database-backup#tab_db_licence', | |
| 121 | + array($this, 'wp_db_backup_settings_page' )); | |
| 122 | + } | |
| 139 | 123 | |
| 140 | 124 | |
| 141 | 125 | |
| 142 | 126 | } |
| @@ -159,9 +143,9 @@ | ||
| 159 | 143 | public function wp_db_backup_completed_local( &$args ) { |
| 160 | 144 | $wp_db_remove_local_backup = get_option( 'wp_db_remove_local_backup' ); |
| 161 | 145 | if ( 1 === $wp_db_remove_local_backup ) { |
| 162 | 146 | if ( file_exists( $args[1] ) ) { |
| 163 | - wp_delete_file( $args[1] );// File path. | |
| 147 | + unlink( $args[1] );// File path. | |
| 164 | 148 | } |
| 165 | 149 | } |
| 166 | 150 | } |
| 167 | 151 | |
| @@ -224,23 +208,13 @@ | ||
| 224 | 208 | update_option( 'wp_db_remove_on_uninstall', 1 , false); |
| 225 | 209 | } else { |
| 226 | 210 | update_option( 'wp_db_remove_on_uninstall', 0 , false); |
| 227 | 211 | } |
| 228 | - if ( isset( $_POST['wp_db_incremental_backup'] ) ) { | |
| 229 | - update_option( 'wp_db_incremental_backup', 1 , false); | |
| 230 | - } else { | |
| 231 | - update_option( 'wp_db_incremental_backup', 0 , false); | |
| 232 | - } | |
| 233 | 212 | if ( isset( $_POST['wp_db_remove_local_backup'] ) ) { |
| 234 | 213 | update_option( 'wp_db_remove_local_backup', 1 , false); |
| 235 | 214 | } else { |
| 236 | 215 | update_option( 'wp_db_remove_local_backup', 0 , false); |
| 237 | 216 | } |
| 238 | - if ( isset( $_POST['wp_db_save_settings_in_backup'] ) ) { | |
| 239 | - update_option( 'wp_db_save_settings_in_backup', 1 , false); | |
| 240 | - } else { | |
| 241 | - update_option( 'wp_db_save_settings_in_backup', 0 , false); | |
| 242 | - } | |
| 243 | 217 | if ( isset( $_POST['wp_db_backup_enable_auto_upgrade'] ) ) { |
| 244 | 218 | update_option( 'wp_db_backup_enable_auto_upgrade', 1 , false); |
| 245 | 219 | } else { |
| 246 | 220 | update_option( 'wp_db_backup_enable_auto_upgrade', 0 , false); |
| @@ -251,9 +225,9 @@ | ||
| 251 | 225 | } else { |
| 252 | 226 | update_option( 'wp_db_backup_enable_htaccess', 0 , false); |
| 253 | 227 | $path_info = wp_upload_dir(); |
| 254 | 228 | if ( file_exists( $path_info['basedir'] . '/db-backup/.htaccess' ) ) { |
| 255 | - wp_delete_file( $path_info['basedir'] . '/db-backup/.htaccess' ); | |
| 229 | + unlink( $path_info['basedir'] . '/db-backup/.htaccess' ); | |
| 256 | 230 | } |
| 257 | 231 | } |
| 258 | 232 | |
| 259 | 233 | if ( isset( $_POST['wp_db_exclude_table'] ) ) { |
| @@ -285,71 +259,12 @@ | ||
| 285 | 259 | } |
| 286 | 260 | } |
| 287 | 261 | |
| 288 | 262 | if ( isset( $_POST['wp_db_backup_options'] ) ) { |
| 289 | - $option_to_save = []; | |
| 290 | - if ( isset( $_POST['wp_db_backup_options']['enable_autobackups'] ) ) { | |
| 291 | - $option_to_save['enable_autobackups'] = sanitize_text_field( wp_unslash( $_POST['wp_db_backup_options']['enable_autobackups'] ) ); | |
| 292 | - } | |
| 293 | - if ( isset( $_POST['wp_db_backup_options']['autobackup_type'] ) ) { | |
| 294 | - $option_to_save['autobackup_type'] = sanitize_text_field( wp_unslash( $_POST['wp_db_backup_options']['autobackup_type'] ) ); | |
| 295 | - } | |
| 296 | - if ( isset( $_POST['wp_db_backup_options']['autobackup_frequency'] ) ) { | |
| 297 | - $option_to_save['autobackup_frequency'] = sanitize_text_field( wp_unslash( $_POST['wp_db_backup_options']['autobackup_frequency'] ) ); | |
| 298 | - } | |
| 299 | - if ( isset( $_POST['wp_db_backup_options']['autobackup_full_days'] ) ) { | |
| 300 | - $option_to_save['autobackup_full_days'] = sanitize_text_field( wp_unslash( $_POST['wp_db_backup_options']['autobackup_full_days'] ) ); | |
| 301 | - } | |
| 302 | - if ( isset( $_POST['wp_db_backup_options']['autobackup_full_time'] ) ) { | |
| 303 | - $option_to_save['autobackup_full_time'] = sanitize_text_field( wp_unslash( $_POST['wp_db_backup_options']['autobackup_full_time'] ) ); | |
| 304 | - } | |
| 305 | - if ( isset( $_POST['wp_db_backup_options']['autobackup_full_date'] ) ) { | |
| 306 | - $option_to_save['autobackup_full_date'] = sanitize_text_field( wp_unslash( $_POST['wp_db_backup_options']['autobackup_full_date'] ) ); | |
| 307 | - } | |
| 308 | - if(!empty($option_to_save)) { | |
| 309 | - if(update_option( 'wp_db_backup_options', $option_to_save, false)){ | |
| 310 | - wp_clear_scheduled_hook( 'wpdbbkp_db_backup_event' ); | |
| 311 | - wp_clear_scheduled_hook( 'wpdbkup_event_fullbackup' ); | |
| 312 | - } | |
| 313 | - } | |
| 314 | - | |
| 263 | + update_option( 'wp_db_backup_options', $_POST['wp_db_backup_options'], false); | |
| 315 | 264 | } |
| 316 | 265 | |
| 317 | - | |
| 318 | - if ( isset( $_POST['featureSubmit'] ) && 'Save Settings' === $_POST['featureSubmit'] ) { | |
| 319 | - if ( isset( $_POST['enable_anonymization'] ) ) { | |
| 320 | - update_option( 'bkpforwp_enable_anonymization', 1 ); | |
| 321 | - } else { | |
| 322 | - update_option( 'bkpforwp_enable_anonymization', 0 ); | |
| 323 | - } | |
| 324 | - | |
| 325 | - if ( isset( $_POST['enable_backup_encryption'] ) ) { | |
| 326 | - update_option( 'bkpforwp_enable_backup_encryption', 1 ); | |
| 327 | - } else { | |
| 328 | - update_option( 'bkpforwp_enable_backup_encryption', 0 ); | |
| 329 | - } | |
| 330 | - if ( isset( $_POST['enable_exact_backup_time'] ) ) { | |
| 331 | - update_option( 'bkpforwp_enable_exact_backup_time', 1 ); | |
| 332 | - } else { | |
| 333 | - update_option( 'bkpforwp_enable_exact_backup_time', 0 ); | |
| 334 | - } | |
| 335 | - | |
| 336 | - if ( isset( $_POST['anonymization_type'] ) ) { | |
| 337 | - update_option( 'bkpforwp_anonymization_type', wp_db_filter_data( sanitize_text_field( $_POST['anonymization_type'] ) ) ); | |
| 338 | - | |
| 339 | - } | |
| 340 | - | |
| 341 | - if ( isset( $_POST['anonymization_pass'] )) { | |
| 342 | - update_option( 'bkpforwp_anonymization_pass', wp_db_filter_data( sanitize_text_field( $_POST['anonymization_pass'] ) ) ); | |
| 343 | - | |
| 344 | - } | |
| 345 | - | |
| 346 | - if ( isset( $_POST['backup_encryption_pass'] )) { | |
| 347 | - update_option( 'bkpforwp_backup_encryption_pass', wp_db_filter_data( sanitize_text_field( $_POST['backup_encryption_pass'] ) ) ); | |
| 348 | - | |
| 349 | - } | |
| 350 | - } | |
| 351 | - | |
| 266 | + do_action('wpdbbkp_save_pro_options'); | |
| 352 | 267 | } |
| 353 | 268 | $wp_db_backup_destination_email = get_option( 'wp_db_backup_destination_Email' , false); |
| 354 | 269 | |
| 355 | 270 | if ( isset( $_GET['page'] ) && 'wp-database-backup' === $_GET['page'] && isset( $_GET['action'] ) && 'unlink' === $_GET['action'] ) { |
| @@ -362,9 +277,9 @@ | ||
| 362 | 277 | $file = readdir( $dir_handle ); |
| 363 | 278 | while ( $file ) { |
| 364 | 279 | // If $file is NOT a directory remove it. |
| 365 | 280 | if ( ! is_dir( $file ) ) { |
| 366 | - wp_delete_file( $dir . $file ); | |
| 281 | + unlink( $dir . $file ); | |
| 367 | 282 | } |
| 368 | 283 | } |
| 369 | 284 | // Close the directory. |
| 370 | 285 | closedir( $dir_handle ); |
| @@ -383,17 +298,14 @@ | ||
| 383 | 298 | $index = (int) $_GET['index']; |
| 384 | 299 | $options = get_option( 'wp_db_backup_backups' ); |
| 385 | 300 | $newoptions = array(); |
| 386 | 301 | $count = 0; |
| 387 | - if(!empty($options) && is_array($options)){ | |
| 388 | - foreach ( $options as $option ) { | |
| 389 | - if ( $count !== $index ) { | |
| 390 | - $newoptions[] = $option; | |
| 391 | - } | |
| 392 | - $count++; | |
| 302 | + foreach ( $options as $option ) { | |
| 303 | + if ( $count !== $index ) { | |
| 304 | + $newoptions[] = $option; | |
| 393 | 305 | } |
| 306 | + $count++; | |
| 394 | 307 | } |
| 395 | - | |
| 396 | 308 | $upload_dir = wp_upload_dir(); |
| 397 | 309 | $actual_working_directory = getcwd(); |
| 398 | 310 | $file_directory = $upload_dir['basedir'].'/db-backup/'; |
| 399 | 311 | /* |
| @@ -399,20 +311,16 @@ | ||
| 399 | 311 | /* |
| 400 | 312 | Fix for when you try to delete a file thats in a folder |
| 401 | 313 | higher in the hierarchy to your working directory */ |
| 402 | 314 | chdir($file_directory); |
| 403 | - if ( isset($options[ $index ]['filename']) && file_exists( $options[ $index ]['filename'] ) ) { | |
| 404 | - wp_delete_file( $options[ $index ]['filename'] ); | |
| 315 | + if ( file_exists( $options[ $index ]['filename'] ) ) { | |
| 316 | + unlink( $options[ $index ]['filename'] ); | |
| 405 | 317 | } |
| 406 | - if(isset($options[ $index ]['filename'])){ | |
| 407 | - $file_sql = explode( '.', $options[ $index ]['filename'] ); | |
| 408 | - if ( isset($file_sql[0]) && file_exists( $file_sql[0] . '.sql' ) ) { | |
| 409 | - wp_delete_file( $file_sql[0] . '.sql' ); | |
| 410 | - } | |
| 318 | + $file_sql = explode( '.', $options[ $index ]['filename'] ); | |
| 319 | + if ( file_exists( $file_sql[0] . '.sql' ) ) { | |
| 320 | + unlink( $file_sql[0] . '.sql' ); | |
| 411 | 321 | } |
| 412 | - | |
| 413 | 322 | chdir($actual_working_directory); |
| 414 | - $newoptions = wpdbbkp_filter_unique_filenames( $newoptions ); | |
| 415 | 323 | update_option( 'wp_db_backup_backups', $newoptions , false); |
| 416 | 324 | $nonce = wp_create_nonce( 'wp-database-backup' ); |
| 417 | 325 | wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=delete&_wpnonce=' . $nonce ); |
| 418 | 326 | exit; |
| @@ -423,9 +331,8 @@ | ||
| 423 | 331 | |
| 424 | 332 | $upload_dir = wp_upload_dir(); |
| 425 | 333 | $actual_working_directory = getcwd(); |
| 426 | 334 | $file_directory = $upload_dir['basedir']; |
| 427 | - global $wpdb; | |
| 428 | 335 | /* |
| 429 | 336 | Fix for when you try to delete a file thats in a folder |
| 430 | 337 | higher in the hierarchy to your working directory |
| 431 | 338 | */ |
| @@ -432,20 +339,16 @@ | ||
| 432 | 339 | chdir($file_directory); |
| 433 | 340 | $files = glob($file_directory.'/db-backup'.'/*'); |
| 434 | 341 | |
| 435 | 342 | // Deleting all the files in the list |
| 436 | - if(!empty($files)){ | |
| 437 | - foreach($files as $file) { | |
| 438 | - if(is_file($file)){ | |
| 439 | - wp_delete_file($file); | |
| 440 | - } | |
| 441 | - } | |
| 442 | - } | |
| 343 | + foreach($files as $file) { | |
| 344 | + if(is_file($file)){ | |
| 345 | + unlink($file); | |
| 346 | + } | |
| 347 | + } | |
| 443 | 348 | chdir($actual_working_directory); |
| 444 | 349 | update_option( 'wp_db_backup_backups', array() , false); |
| 445 | 350 | $nonce = wp_create_nonce( 'wp-database-backup' ); |
| 446 | - $table_name = $wpdb->prefix . 'wpdbbkp_processed_files'; | |
| 447 | - $wpdb->query( "TRUNCATE TABLE $table_name" ); // phpcs:ignore | |
| 448 | 351 | wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=deleteall&_wpnonce=' . $nonce ); |
| 449 | 352 | exit; |
| 450 | 353 | |
| 451 | 354 | |
| @@ -454,15 +357,10 @@ | ||
| 454 | 357 | $options = get_option( 'wp_db_backup_backups' ); |
| 455 | 358 | $newoptions = array(); |
| 456 | 359 | $backup_check_list = array( '.htaccess', 'index.php' ); |
| 457 | 360 | $delete_message = 'WPDB : Deleted Files:'; |
| 458 | - if(!empty($options) && is_array($options)){ | |
| 459 | - foreach ( $options as $option ) { | |
| 460 | - if(!is_array($option)){ | |
| 461 | - continue; | |
| 462 | - } | |
| 463 | - $backup_check_list[] = $option['filename']; | |
| 464 | - } | |
| 361 | + foreach ( $options as $option ) { | |
| 362 | + $backup_check_list[] = $option['filename']; | |
| 465 | 363 | } |
| 466 | 364 | $path_info = wp_upload_dir(); |
| 467 | 365 | $wp_db_backup_path = $path_info['basedir'] . '/db-backup'; |
| 468 | 366 | |
| @@ -472,9 +370,9 @@ | ||
| 472 | 370 | if ( $dh ) { |
| 473 | 371 | while ( false !== ($file = readdir( $dh )) ) { |
| 474 | 372 | if ( ! ( in_array( $file, $backup_check_list, true ) ) ) { |
| 475 | 373 | if ( file_exists( $wp_db_backup_path . '/' . $file ) ) { |
| 476 | - wp_delete_file( $wp_db_backup_path . '/' . $file ); | |
| 374 | + unlink( $wp_db_backup_path . '/' . $file ); | |
| 477 | 375 | } |
| 478 | 376 | $delete_message .= ' ' . $file; |
| 479 | 377 | } |
| 480 | 378 | } |
| @@ -484,20 +382,18 @@ | ||
| 484 | 382 | wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=clear_temp_db_backup_file&_wpnonce=' . $nonce ); |
| 485 | 383 | exit; |
| 486 | 384 | break; |
| 487 | 385 | case 'restorebackup': |
| 488 | - $index = isset($_GET['index'])?(int) $_GET['index']:0; | |
| 386 | + $index = (int) $_GET['index']; | |
| 489 | 387 | $options = get_option( 'wp_db_backup_backups' ); |
| 490 | 388 | $restore_limit = get_option( 'wp_db_restore_limit'); |
| 491 | 389 | $newoptions = array(); |
| 492 | 390 | $count = 0; |
| 493 | - if(!empty($options) && is_array($options)){ | |
| 494 | - foreach ( $options as $option ) { | |
| 495 | - if ( $count !== $index ) { | |
| 496 | - $newoptions[] = $option; | |
| 497 | - } | |
| 498 | - $count++; | |
| 391 | + foreach ( $options as $option ) { | |
| 392 | + if ( $count !== $index ) { | |
| 393 | + $newoptions[] = $option; | |
| 499 | 394 | } |
| 395 | + $count++; | |
| 500 | 396 | } |
| 501 | 397 | if ( isset( $options[ $index ]['restore_limit'] ) && $options[ $index ]['restore_limit']==1) { |
| 502 | 398 | include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 503 | 399 | if ( !is_plugin_active( 'wp-database-backup-pro/wp-database-backup-pro.php' ) ) { |
| @@ -510,14 +406,11 @@ | ||
| 510 | 406 | |
| 511 | 407 | if ( isset( $options[ $index ]['sqlfile'] ) ) { // Added for extract zip file V.3.3.0. |
| 512 | 408 | $database_file = ( $options[ $index ]['sqlfile'] ); |
| 513 | 409 | } else { |
| 514 | - $database_file = isset($options[ $index ]['dir']) ? $options[ $index ]['dir'] : ''; | |
| 515 | - $file_sql = explode( '.', $database_file ); | |
| 516 | - if(isset($file_sql[0])){ | |
| 517 | - $database_file = ( $file_sql[0] . '.sql' ); | |
| 518 | - } | |
| 519 | - | |
| 410 | + $database_file = ( $options[ $index ]['dir'] ); | |
| 411 | + $file_sql = explode( '.', $options[ $index ]['dir'] ); | |
| 412 | + $database_file = ( $file_sql[0] . '.sql' ); | |
| 520 | 413 | } |
| 521 | 414 | $database_name = $this->wp_backup_get_config_db_name(); |
| 522 | 415 | $database_user = $this->wp_backup_get_config_data( 'DB_USER' ); |
| 523 | 416 | $datadase_password = $this->wp_backup_get_config_data( 'DB_PASSWORD' ); |
| @@ -545,87 +438,69 @@ | ||
| 545 | 438 | |
| 546 | 439 | // End for extract zip file V.3.3.0. |
| 547 | 440 | set_time_limit( 0 ); |
| 548 | 441 | ignore_user_abort(true); |
| 549 | - if ('' !== trim($database_name) && '' !== trim($database_user) && '' !== trim($database_host)) { | |
| 550 | - $wpdb->db_connect(); | |
| 551 | - $wpdb->select($database_name); | |
| 552 | - | |
| 553 | - //phpcs:ignore -- Check if database exists | |
| 554 | - $db_exists = $wpdb->get_var($wpdb->prepare( | |
| 555 | - "SELECT SCHEMA_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = %s", | |
| 556 | - $database_name | |
| 557 | - )); | |
| 558 | - | |
| 559 | - if (!$db_exists) { | |
| 560 | - //phpcs:ignore -- Create DB if it doesn't exist | |
| 561 | - $wpdb->query($wpdb->prepare("CREATE DATABASE IF NOT EXISTS `%s`", $database_name)); | |
| 562 | - $wpdb->select($database_name); | |
| 563 | - } | |
| 564 | - //phpcs:ignore -- Show tables from database | |
| 565 | - $tables = $wpdb->get_col($wpdb->prepare("SHOW TABLES FROM `%s`", $database_name)); | |
| 566 | - | |
| 567 | - | |
| 568 | - if (!empty($tables)) { | |
| 569 | - foreach ($tables as $table_name) { | |
| 570 | - //phpcs:ignore -- delete tables before restore | |
| 571 | - $wpdb->query($wpdb->prepare("DROP TABLE IF EXISTS `%s`", $table_name)); | |
| 442 | + if ( '' !== ( trim( (string) $database_name ) ) && '' !== ( trim( (string) $database_user ) ) && '' !== ( trim( (string) $database_host ) ) ) { | |
| 443 | + $conn = mysqli_connect( (string) $database_host, (string) $database_user, (string) $datadase_password ); // phpcs:ignore | |
| 444 | + if ( $conn ) { | |
| 445 | + // Start Select the database. | |
| 446 | + if ( ! mysqli_select_db( $conn, (string) $database_name) ) { // phpcs:ignore | |
| 447 | + $sql = 'CREATE DATABASE IF NOT EXISTS `' . (string) $database_name . '`'; | |
| 448 | + mysqli_query($conn, $sql); // phpcs:ignore | |
| 449 | + mysqli_select_db($conn, (string) $database_name ); // phpcs:ignore | |
| 572 | 450 | } |
| 573 | - } | |
| 574 | - | |
| 575 | - // Restore database content | |
| 576 | - if (file_exists($database_file)) { | |
| 577 | - if ( ! function_exists( 'WP_Filesystem' ) ) { | |
| 578 | - require_once ABSPATH . '/wp-admin/includes/file.php'; | |
| 451 | + /* END: Select the Database */ | |
| 452 | + | |
| 453 | + /* BEGIN: Remove All Tables from the Database */ | |
| 454 | + $found_tables = null; | |
| 455 | + $result = mysqli_query( $conn, 'SHOW TABLES FROM `' . (string) $database_name . '`' ); // phpcs:ignore | |
| 456 | + | |
| 457 | + if ( $result ) { | |
| 458 | + while ($row = mysqli_fetch_row($result)) { | |
| 459 | + $found_tables[] = $row[0]; | |
| 579 | 460 | } |
| 580 | - | |
| 581 | - WP_Filesystem(); | |
| 582 | - if ( $wp_filesystem ) { | |
| 583 | - $sql_file = $wp_filesystem->get_contents( $database_file ); | |
| 584 | - if ( $sql_file !== false ) { | |
| 585 | - $sql_queries = explode(";\n", $sql_file); | |
| 586 | - //phpcs:ignore -- Set sql_mode to empty | |
| 587 | - $wpdb->query("SET sql_mode = ''"); | |
| 588 | - | |
| 589 | - foreach ($sql_queries as $query) { | |
| 590 | - $query = apply_filters('wpdbbkp_sql_query_restore', $query); | |
| 591 | - if (!empty(trim($query))) { | |
| 592 | 461 | |
| 593 | - /* Since $query is a dynqmic sql query from the backup file, we can't use $wpdb->prepare | |
| 594 | - * as we don't know the number / types of arguments in the query. So, we are using $wpdb->query | |
| 595 | - * directly to execute the query.*/ | |
| 596 | - //phpcs:ignore | |
| 597 | - $wpdb->query($query); | |
| 598 | - } | |
| 599 | - } | |
| 600 | - | |
| 601 | - } else { | |
| 602 | - error_log("Failed to Open file :".esc_html($database_file)); | |
| 462 | + if ( count( $found_tables ) > 0 ) { | |
| 463 | + foreach ( $found_tables as $table_name ) { | |
| 464 | + mysqli_query( $conn, "DROP TABLE " . (string) $database_name . ".".$table_name ); // phpcs:ignore | |
| 603 | 465 | } |
| 604 | - } else { | |
| 605 | - error_log("Failed to initialize WP_Filesystem"); | |
| 606 | 466 | } |
| 467 | + } | |
| 468 | + | |
| 469 | + /* END: Remove All Tables from the Database */ | |
| 470 | + | |
| 471 | + /* BEGIN: Restore Database Content */ | |
| 472 | + if ( isset( $database_file ) ) { | |
| 473 | + if ( file_exists( $database_file ) ) { | |
| 474 | + $sql_file = file_get_contents( $database_file, true ); | |
| 475 | + if($sql_file){ | |
| 476 | + $sql_queries = explode( ";\n", $sql_file ); | |
| 477 | + $sql_queries_count = count( $sql_queries ); | |
| 478 | + | |
| 479 | + mysqli_query($conn, "SET sql_mode = ''"); | |
| 480 | + | |
| 481 | + for ( $i = 0; $i < $sql_queries_count; $i++ ) { | |
| 482 | + $sql_query_=apply_filters( 'wpdbbkp_sql_query_restore', $sql_queries[ $i ] ); | |
| 483 | + mysqli_query($conn, $sql_query_ ); // phpcs:ignore | |
| 484 | + } | |
| 485 | + } | |
| 486 | + | |
| 487 | + } | |
| 488 | + } | |
| 607 | 489 | } |
| 608 | 490 | } |
| 609 | 491 | |
| 610 | 492 | if ( isset( $options[ $index ]['sqlfile'] ) && file_exists( $options[ $index ]['sqlfile'] ) ) { // Added for extract zip file V.3.3.0. |
| 611 | 493 | if ( file_exists( $options[ $index ]['sqlfile'] ) ) { |
| 612 | - wp_delete_file( $options[ $index ]['sqlfile'] ); | |
| 494 | + unlink( $options[ $index ]['sqlfile'] ); | |
| 613 | 495 | } |
| 614 | 496 | } else { |
| 615 | - $database_file = isset($options[ $index ]['dir'] )?$options[ $index ]['dir']:''; | |
| 616 | - if(!empty($database_file)){ | |
| 617 | - $file_sql = explode( '.', $database_file ); | |
| 618 | - if(isset($file_sql[0])){ | |
| 619 | - $database_file = ( $file_sql[0] . '.sql' ); | |
| 620 | - if ( file_exists( $database_file ) ) { | |
| 621 | - wp_delete_file( $database_file ); | |
| 622 | - } | |
| 623 | - | |
| 624 | - } | |
| 625 | - | |
| 497 | + $database_file = ( $options[ $index ]['dir'] ); | |
| 498 | + $file_sql = explode( '.', $options[ $index ]['dir'] ); | |
| 499 | + $database_file = ( $file_sql[0] . '.sql' ); | |
| 500 | + if ( file_exists( $database_file ) ) { | |
| 501 | + unlink( $database_file ); | |
| 626 | 502 | } |
| 627 | - | |
| 628 | 503 | } |
| 629 | 504 | wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=restore&_wpnonce=' . $nonce ); |
| 630 | 505 | exit; |
| 631 | 506 | break; |
| @@ -631,24 +506,18 @@ | ||
| 631 | 506 | break; |
| 632 | 507 | |
| 633 | 508 | case 'wpdbbkrestorefullbackup': |
| 634 | 509 | $index = (int) $_GET['index']; |
| 635 | - require_once( 'class-wpdbbkp-restore.php' ); | |
| 636 | - $restore = new Wpdbbkp_Restore(); | |
| 510 | + require_once( 'class-restore.php' ); | |
| 511 | + $restore = new Wpbp_Restore(); | |
| 637 | 512 | $restore->start($index); |
| 638 | 513 | if (get_option('wp_db_log') == 1) { |
| 639 | 514 | $options = get_option('wp_db_backup_backups'); |
| 640 | 515 | $path_info = wp_upload_dir(); |
| 641 | - if(isset($options[$index]['filename'])){ | |
| 642 | - $logFileName = explode(".", $options[$index]['filename']); | |
| 643 | - if(isset($logFileName[0])){ | |
| 644 | - $logfile = $path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/log/' . $logFileName[0] . '.txt'; | |
| 645 | - $message = "\n\n Restore Backup at " . gmdate("Y-m-d h:i:sa"); | |
| 646 | - $this->write_log($logfile, $message); | |
| 647 | - } | |
| 648 | - | |
| 649 | - } | |
| 650 | - | |
| 516 | + $logFileName = explode(".", $options[$index]['filename']); | |
| 517 | + $logfile = $path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/log/' . $logFileName[0] . '.txt'; | |
| 518 | + $message = "\n\n Restore Backup at " . date("Y-m-d h:i:sa"); | |
| 519 | + $this->write_log($logfile, $message); | |
| 651 | 520 | } |
| 652 | 521 | $nonce = wp_create_nonce( 'wp-database-backup' ); |
| 653 | 522 | wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=restore&_wpnonce=' . $nonce ); |
| 654 | 523 | exit; |
| @@ -679,19 +548,12 @@ | ||
| 679 | 548 | /** |
| 680 | 549 | * Setting page. |
| 681 | 550 | */ |
| 682 | 551 | public function wp_db_backup_settings_page() { |
| 683 | - global $wp_filesystem; | |
| 684 | - if(!function_exists('WP_Filesystem')){ | |
| 685 | - require_once ( ABSPATH . '/wp-admin/includes/file.php' ); | |
| 686 | - } | |
| 687 | - WP_Filesystem(); | |
| 688 | - | |
| 552 | + | |
| 689 | 553 | $options = get_option( 'wp_db_backup_backups' ); |
| 690 | - $options = wpdbbkp_filter_unique_filenames( $options ); | |
| 691 | 554 | $settings = get_option( 'wp_db_backup_options' ); |
| 692 | - $wp_db_log = get_option( 'wp_db_log' ); | |
| 693 | - $incremental_backup = get_option( 'wp_db_incremental_backup' ,false); ?> | |
| 555 | + $wp_db_log = get_option( 'wp_db_log' ); ?> | |
| 694 | 556 | <div class="bootstrap-wrapper"> |
| 695 | 557 | <?php |
| 696 | 558 | $wp_db_local_backup_path = get_option( 'wp_db_local_backup_path' ); |
| 697 | 559 | if ( false === empty( $wp_db_local_backup_path ) && false === file_exists( $wp_db_local_backup_path ) ) { |
| @@ -697,10 +559,10 @@ | ||
| 697 | 559 | if ( false === empty( $wp_db_local_backup_path ) && false === file_exists( $wp_db_local_backup_path ) ) { |
| 698 | 560 | echo '<div class="alert alert-warning alert-dismissible fade in" role="alert"> |
| 699 | 561 | <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> |
| 700 | 562 | <a href="#db_destination" data-toggle="tab">'; |
| 701 | - esc_html_e( 'Invalid Local Backup Path : ', 'wpdbbkp' ); | |
| 702 | - echo esc_html( $wp_db_local_backup_path ); | |
| 563 | + esc_attr_e( 'Invalid Local Backup Path : ', 'wp-database-backup' ); | |
| 564 | + echo esc_attr( $wp_db_local_backup_path ); | |
| 703 | 565 | echo '</a></div>'; |
| 704 | 566 | } |
| 705 | 567 | |
| 706 | 568 | $upload_dir = wp_upload_dir(); |
| @@ -707,9 +569,9 @@ | ||
| 707 | 569 | $dir = $upload_dir['basedir'] . '/db-backup'; |
| 708 | 570 | if ( ! is_dir( $dir ) ) { |
| 709 | 571 | $dir = $upload_dir['basedir']; |
| 710 | 572 | } |
| 711 | - if ( is_dir( $dir ) && !$wp_filesystem->is_writable( $dir )) { | |
| 573 | + if ( is_dir( $dir ) && ! is_writable( $dir ) ) { | |
| 712 | 574 | ?> |
| 713 | 575 | <div class="row"> |
| 714 | 576 | <div class="col-xs-12 col-sm-12 col-md-12"> |
| 715 | 577 | <div class="alert alert-danger alert-dismissible fade in" role="alert"> |
| @@ -714,11 +576,11 @@ | ||
| 714 | 576 | <div class="col-xs-12 col-sm-12 col-md-12"> |
| 715 | 577 | <div class="alert alert-danger alert-dismissible fade in" role="alert"> |
| 716 | 578 | <button type="button" class="close" data-dismiss="alert" aria-label="Close"> |
| 717 | 579 | <span aria-hidden="true">×</span></button> |
| 718 | - <h4><?php esc_html_e( 'WP Database Backup', 'wpdbbkp' ); ?></h4> | |
| 719 | - <p><?php esc_html_e( 'Error: Permission denied, make sure you have write permission for', 'wpdbbkp' ); ?> <?php echo esc_attr( $dir ); ?> | |
| 720 | - <?php esc_html_e( 'folder', 'wpdbbkp' ); ?></p> | |
| 580 | + <h4>WP Database Backup</h4> | |
| 581 | + <p>Error: Permission denied, make sure you have write permission for <?php echo esc_attr( $dir ); ?> | |
| 582 | + folder</p> | |
| 721 | 583 | </div> |
| 722 | 584 | </button> |
| 723 | 585 | </div> |
| 724 | 586 | </div> |
| @@ -723,19 +585,9 @@ | ||
| 723 | 585 | </div> |
| 724 | 586 | </div> |
| 725 | 587 | <?php |
| 726 | 588 | } |
| 727 | - $cloud_drive_flag = get_option( 'wp_db_backup_destination_cd', false ); | |
| 728 | - if ( !$cloud_drive_flag ) { | |
| 729 | - ?><br> | |
| 730 | - <div class="alert alert-info " role="alert"> | |
| 731 | - <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> | |
| 732 | - <?php esc_html_e( 'Try Backup for WP Cloud Backup free for 14 days', 'wpdbbkp' ); ?> <a href="https://app.backupforwp.com/register"><?php echo esc_html__( 'Try now for free' , 'wpdbbkp'); ?></a> </div> | |
| 733 | - <?php | |
| 734 | - } | |
| 735 | 589 | ?> |
| 736 | - | |
| 737 | - | |
| 738 | 590 | |
| 739 | 591 | <div id="wpdbbkpModal" class="modal"> |
| 740 | 592 | <div class="wpdbbkpmodal-content"> |
| 741 | 593 | <div class="wpdbbkp-modal-header"> |
| @@ -758,18 +610,17 @@ | ||
| 758 | 610 | </div> |
| 759 | 611 | <div class="panel-body"> |
| 760 | 612 | <ul class="nav nav-tabs wbdbbkp_has_nav"> |
| 761 | 613 | <li class="active"><a href="#db_home" data-toggle="tab"><?php echo esc_html__('Backups', 'wpdbbkp') ?></a></li> |
| 762 | - <li><a href="#db_remotebackups" data-toggle="tab"><?php echo esc_html__('Cloud Backup', 'wpdbbkp') ?></a></li> | |
| 763 | 614 | <li><a href="#db_schedul" data-toggle="tab"><?php echo esc_html__('Auto Scheduler', 'wpdbbkp') ?></a></li> |
| 764 | 615 | <li><a href="#db_destination" data-toggle="tab"><?php echo esc_html__('Save Backups to', 'wpdbbkp') ?></a></li> |
| 765 | 616 | <li><a href="#db_setting" data-toggle="tab"><?php echo esc_html__('Settings', 'wpdbbkp') ?></a></li> |
| 766 | - <li><a href="#searchreplace" style="display:none" data-toggle="tab"><?php echo esc_html__('Search and Replace', 'wpdbbkp') ?></a></li> | |
| 767 | - <li><a href="#db_features" data-toggle="tab"><?php echo esc_html__('Modules', 'wpdbbkp') ?></a></li> | |
| 768 | - <li title="System Info"><a href="#db_info" data-toggle="tab"><?php echo esc_html__('Usage', 'wpdbbkp') ?></a></li> | |
| 617 | + <li><a href="#searchreplace" data-toggle="tab"><?php echo esc_html__('Search and Replace', 'wpdbbkp') ?></a></li> | |
| 618 | + <li style="display:none"><a href="#db_upgrade" data-toggle="tab"><?php echo esc_html__('Upgrade', 'wpdbbkp') ?></a></li> | |
| 619 | + <?php do_action( 'wpdbbkp_pro_tab_links' ); ?> | |
| 769 | 620 | <li><a href="#db_help" data-toggle="tab"><?php echo esc_html__('Help & Support', 'wpdbbkp') ?></a></li> |
| 621 | + <li id="db_info_link" title="System Info"><a href="#db_info" data-toggle="tab"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a></li> | |
| 770 | 622 | |
| 771 | - | |
| 772 | 623 | </ul> |
| 773 | 624 | |
| 774 | 625 | <?php |
| 775 | 626 | echo '<div class="tab-content">'; |
| @@ -788,9 +639,9 @@ | ||
| 788 | 639 | } |
| 789 | 640 | include_once 'admin-header-notification.php'; ?> |
| 790 | 641 | |
| 791 | 642 | <?php |
| 792 | - if ( !empty($options) ) { | |
| 643 | + if ( $options ) { | |
| 793 | 644 | |
| 794 | 645 | echo ' <script> |
| 795 | 646 | var $j = jQuery.noConflict(); |
| 796 | 647 | $j(document).ready(function () { |
| @@ -798,8 +649,14 @@ | ||
| 798 | 649 | var table = $j("#wpdbbkp_table").DataTable({ |
| 799 | 650 | order: [[0, "desc"]], |
| 800 | 651 | }); |
| 801 | 652 | $j(".popoverid").popover(); |
| 653 | + $j("#create_backup").click(function() { | |
| 654 | + $j(".wpdbbkp_notification").hide(); | |
| 655 | + $j("#backup_process").show(); | |
| 656 | + $j("#create_backup").attr("disabled", true); | |
| 657 | + | |
| 658 | + }); | |
| 802 | 659 | }); |
| 803 | 660 | |
| 804 | 661 | function excludetableall(){ |
| 805 | 662 | var checkboxes = document.getElementsByClassName("wp_db_exclude_table"); |
| @@ -810,8 +667,9 @@ | ||
| 810 | 667 | $j(".wp_db_exclude_table").each(function() { |
| 811 | 668 | this.checked = checked; |
| 812 | 669 | }); |
| 813 | 670 | } |
| 671 | + | |
| 814 | 672 | </script>'; |
| 815 | 673 | echo ' <div class="table-responsive"> |
| 816 | 674 | <div id="wpdbbkp_dataTables" class="dataTables_wrapper form-inline" role="grid"> |
| 817 | 675 | |
| @@ -842,89 +700,72 @@ | ||
| 842 | 700 | 'S3' => 'glyphicon glyphicon-cloud-upload', |
| 843 | 701 | 'Drive' => 'glyphicon glyphicon-hdd', |
| 844 | 702 | 'DropBox' => 'glyphicon glyphicon-inbox', |
| 845 | 703 | 'Backblaze' => 'glyphicon glyphicon-cloud-upload', |
| 846 | - 'CloudDrive' => 'glyphicon glyphicon-cloud-upload' | |
| 847 | 704 | ); |
| 848 | - if(!empty($options) && is_array($options)){ | |
| 849 | - foreach ( $options as $option ) { | |
| 850 | - if (!is_array($option)) { | |
| 851 | - continue; | |
| 705 | + foreach ( $options as $option ) { | |
| 706 | + $str_class = ( 0 === (int) $option['size'] ) ? 'text-danger' : 'wpdb_download'; | |
| 707 | + echo '<tr class="' . ( ( 0 === ( $count % 2 ) ) ? esc_attr( $str_class ) . ' alternate' : esc_attr( $str_class ) ) . '">'; | |
| 708 | + echo '<td style="text-align: center;">' . esc_attr( $count ) . '</td>'; | |
| 709 | + $curr_date = new DateTime(date( 'Y-m-d H:i:s', $option['date'] )); | |
| 710 | + $curr_date->setTimezone(new DateTimeZone(wp_timezone_string())); | |
| 711 | + 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') ) .'">' .$this->wpdbbkp_get_timeago($option['date']).'</span>'; | |
| 712 | + echo '</td>'; | |
| 713 | + if($wp_db_log==1){ | |
| 714 | + echo '<td class="wpdb_log" align="center">'; | |
| 715 | + if (!empty($option['log'])) { | |
| 716 | + if(isset($option['type']) && ($option['type'] == 'complete' || $option['type'] == 'database')){ | |
| 717 | + echo '<a href="' . $option['log'] . '" target="_blank" class="label label-warning" title="There might be partial backup. Please check Log File for verify backup.">'; | |
| 718 | + echo '<span class="glyphicon glyphicon-list-alt"></span>'; | |
| 719 | + echo '</a>'; | |
| 720 | + }else{ | |
| 721 | + 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>'; | |
| 852 | 722 | } |
| 853 | - | |
| 854 | - if (!empty($option['destination'])) { | |
| 855 | - if (strpos($option['destination'], 'CloudDrive') !== false) { | |
| 856 | - continue; | |
| 723 | + } | |
| 724 | + echo '</td>'; | |
| 725 | + } | |
| 726 | + echo '<td>'; | |
| 727 | + if ( ! empty( $option['destination'] ) ) { | |
| 728 | + $destination = ( explode( ',', $option['destination'] ) ); | |
| 729 | + foreach ( $destination as $dest ) { | |
| 730 | + $key = trim( $dest ); | |
| 731 | + if ( ! empty( $dest ) && array_key_exists( $key, $destination_icon ) ) { | |
| 732 | + echo '<span class="' . esc_attr( $destination_icon[ $key ] ) . '" title="' . esc_attr( $dest ) . '"></span> '; | |
| 857 | 733 | } |
| 858 | 734 | } |
| 859 | - $size = isset( $option['size'])? $option['size'] : 0; | |
| 860 | - $str_class = ( 0 === (int) $size ) ? 'text-danger' : 'wpdb_download'; | |
| 861 | - echo '<tr class="' . ( ( 0 === ( $count % 2 ) ) ? esc_attr( $str_class ) . ' alternate' : esc_attr( $str_class ) ) . '">'; | |
| 862 | - echo '<td style="text-align: center;">' . esc_attr( $count ) . '</td>'; | |
| 863 | - $curr_date = new DateTime(gmdate( 'Y-m-d H:i:s', $option['date'] )); | |
| 864 | - $curr_date->setTimezone(new DateTimeZone(wp_timezone_string())); | |
| 865 | - 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>'; | |
| 866 | - echo '</td>'; | |
| 867 | - if($wp_db_log==1){ | |
| 868 | - echo '<td class="wpdb_log" align="center">'; | |
| 869 | - if (!empty($option['log'])) { | |
| 870 | - if(isset($option['type']) && ($option['type'] == 'complete' || $option['type'] == 'database')){ | |
| 871 | - echo '<a href="' . esc_url($option['log']) . '" target="_blank" class="label label-warning" title="There might be partial backup. Please check Log File for verify backup.">'; | |
| 872 | - echo '<span class="glyphicon glyphicon-list-alt"></span>'; | |
| 873 | - echo '</a>'; | |
| 874 | - }else{ | |
| 875 | - 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>'; | |
| 876 | - } | |
| 735 | + } | |
| 736 | + echo '</td>'; | |
| 737 | + if(isset($option['type']) && !empty($option['type'])){ | |
| 738 | + if($option['type'] == 'complete'){ | |
| 739 | + echo '<td>'.esc_html__('Full Backup', 'wpdbbkp').'</td>'; | |
| 877 | 740 | } |
| 878 | - echo '</td>'; | |
| 741 | + if($option['type'] == 'database'){ | |
| 742 | + echo '<td>'.esc_html__('Database', 'wpdbbkp').'</td>'; | |
| 879 | 743 | } |
| 880 | - echo '<td>'; | |
| 881 | - if ( ! empty( $option['destination'] ) ) { | |
| 882 | - $destination = ( explode( ',', $option['destination'] ) ); | |
| 883 | - if(!empty($destination) && is_array($destination)){ | |
| 884 | - foreach ( $destination as $dest ) { | |
| 885 | - $key = trim( $dest ); | |
| 886 | - if ( ! empty( $dest ) && array_key_exists( $key, $destination_icon ) ) { | |
| 887 | - echo '<span class="' . esc_attr( $destination_icon[ $key ] ) . '" title="' . esc_attr( $dest ) . '"></span> '; | |
| 888 | - } | |
| 889 | - } | |
| 890 | - } | |
| 891 | - | |
| 892 | - } | |
| 893 | - echo '</td>'; | |
| 744 | + }else{ | |
| 745 | + echo '<td>Database</td>'; | |
| 746 | + } | |
| 747 | + echo '<td>'; | |
| 748 | + echo '<a class="btn btn-default" href="' . esc_url( $option['url'] ) . '" style="color: #21759B;border-color:#337ab7;">'; | |
| 749 | + echo '<span class="glyphicon glyphicon-download-alt"></span> Download</a></td>'; | |
| 750 | + echo '<td>' . esc_attr( $this->wp_db_backup_format_bytes( $option['size'] ) ) . '</td>'; | |
| 751 | + $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 ) ); | |
| 752 | + echo '<td><a title="Remove Database Backup" onclick="return confirm(\'Are you sure you want to delete database backup?\')" href="' . $remove_backup_href . '" class="btn btn-default"><span style="color:red" class="glyphicon glyphicon-trash"></span> Remove <a/> '; | |
| 753 | + if ( isset( $option['search_replace'] ) && 1 === (int) $option['search_replace'] ) { | |
| 754 | + echo '<span style="margin-left:15px" title="' . esc_html( $option['log'] ) . '" class="glyphicon glyphicon-search"></span>'; | |
| 755 | + } else { | |
| 756 | + $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 ) ); | |
| 894 | 757 | if(isset($option['type']) && !empty($option['type'])){ |
| 895 | 758 | if($option['type'] == 'complete'){ |
| 896 | - echo '<td>'.esc_html__('Full Backup', 'wpdbbkp').'</td>'; | |
| 759 | + $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 ) ); | |
| 897 | 760 | } |
| 898 | - if($option['type'] == 'database'){ | |
| 899 | - echo '<td>'.esc_html__('Database', 'wpdbbkp').'</td>'; | |
| 900 | - } | |
| 901 | - }else{ | |
| 902 | - echo '<td>Database</td>'; | |
| 761 | + | |
| 903 | 762 | } |
| 904 | - echo '<td>'; | |
| 905 | - echo '<a class="btn btn-default" href="' . esc_url( $option['url'] ) . '" style="color: #21759B;border-color:#337ab7;">'; | |
| 906 | - echo '<span class="glyphicon glyphicon-download-alt"></span> Download</a></td>'; | |
| 907 | - echo '<td>' . esc_attr( $this->wp_db_backup_format_bytes( $option['size'] ) ) . '</td>'; | |
| 908 | - $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 ) ); | |
| 909 | - 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/> '; | |
| 910 | - if ( isset( $option['search_replace'] ) && 1 === (int) $option['search_replace'] ) { | |
| 911 | - echo '<span style="margin-left:15px" title="' . esc_html( $option['log'] ) . '" class="glyphicon glyphicon-search"></span>'; | |
| 912 | - } else { | |
| 913 | - $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 ) ); | |
| 914 | - if(isset($option['type']) && !empty($option['type'])){ | |
| 915 | - if($option['type'] == 'complete'){ | |
| 916 | - $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 ) ); | |
| 917 | - } | |
| 918 | - | |
| 919 | - } | |
| 920 | - 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/>'; | |
| 921 | - } | |
| 922 | - echo '</td></tr>'; | |
| 923 | - $count++; | |
| 763 | + 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="'.$restore_url_href.'" class="btn btn-default"><span class="glyphicon glyphicon-refresh" style="color:blue"></span> Restore <a/>'; | |
| 924 | 764 | } |
| 765 | + echo '</td></tr>'; | |
| 766 | + $count++; | |
| 925 | 767 | } |
| 926 | - | |
| 927 | 768 | echo '</tbody>'; |
| 928 | 769 | |
| 929 | 770 | echo ' </table> |
| 930 | 771 | </div> |
| @@ -991,202 +832,164 @@ | ||
| 991 | 832 | echo '</p>'; |
| 992 | 833 | echo '</form>'; |
| 993 | 834 | echo '</div>'; |
| 994 | 835 | echo '</div>'; |
| 995 | - | |
| 996 | 836 | |
| 997 | - | |
| 998 | 837 | do_action('wpdbbkp_pro_tab_content'); |
| 999 | 838 | |
| 1000 | 839 | ?> |
| 1001 | 840 | |
| 1002 | -<!-- Modal Structure --> | |
| 1003 | -<div class="modal" id="wpdbbkp_offer_modal" data-dismiss="modal" tabindex="-1" aria-labelledby="wpdbbkp_offer_modalLabel" aria-hidden="true"> | |
| 1004 | - <div class="modal-dialog"> | |
| 1005 | - <div class="modal-content"> | |
| 1006 | - <div class="modal-body"> | |
| 1007 | - <button type="button" id="offer_close" class="close" data-dismiss="modal" aria-label="Close"> | |
| 1008 | - <span aria-hidden="true">×</span> | |
| 1009 | - </button> | |
| 1010 | - <h3 class="modal-title" id="wpdbbkp_offer_modalLabel"><img src="<?php echo esc_attr( WPDB_PLUGIN_URL ); ?>/assets/images/wp-database-backup.png" width="230px"></h3> | |
| 1011 | - <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> | |
| 1012 | - <div class="wpdbbkp_offer_container"> | |
| 1013 | - <div class="wpdbbkp_server"> | |
| 1014 | - <h4><?php echo esc_html__('Server Backup','wpdbbkp');?></h4> | |
| 1015 | - <p><?php echo esc_html__('Backup your site to server','wpdbbkp');?></p> | |
| 1016 | - <ul> | |
| 1017 | - <li>✔ <?php echo esc_html__('Easy to setup','wpdbbkp');?></li> | |
| 1018 | - <li>✔ <?php echo esc_html__('Takes storage on your server','wpdbbkp');?></li> | |
| 1019 | - <li>✔ <?php echo esc_html__('Availability subject to server','wpdbbkp');?></li> | |
| 1020 | - </ul> | |
| 1021 | - <h4><?php echo esc_html__('Free','wpdbbkp');?></h4> | |
| 1022 | - <button id="wpdbbkp_server_backup" class="btn btn-secondary"><?php echo esc_html__('Create a Backup on this Server','wpdbbkp');?></button> | |
| 1023 | - </div> | |
| 1024 | - <div class="wpdbbkp_remote"> | |
| 1025 | - <h4><?php echo esc_html__('Cloud Backup','wpdbbkp');?></h4> | |
| 1026 | - <p><?php echo esc_html__('Backup your site in the cloud','wpdbbkp');?></p> | |
| 1027 | - <ul> | |
| 1028 | - <li>✔ <?php echo esc_html__('Secure and reliable','wpdbbkp');?></li> | |
| 1029 | - <li>✔ <?php echo esc_html__('Only pay for what you use','wpdbbkp');?></li> | |
| 1030 | - <li>✔ <?php echo esc_html__('High availability','wpdbbkp');?></li> | |
| 1031 | - </ul> | |
| 1032 | - <h4><?php echo esc_html__('$1 per 50GB','wpdbbkp');?> <small><?php echo esc_html__('per month','wpdbbkp');?></small></h4> | |
| 1033 | - <button id="wpdbbkp_remote_backup" class="btn btn-primary"><?php echo esc_html__('Create a Backup on Cloud Server','wpdbbkp');?></button> | |
| 1034 | - </div> | |
| 1035 | - | |
| 1036 | - </div> | |
| 1037 | - </div> | |
| 1038 | - </div> | |
| 1039 | - </div> | |
| 1040 | -</div> | |
| 1041 | -<div class="tab-pane" id="db_features"> | |
| 841 | + <div class="tab-pane" id="db_upgrade"> | |
| 842 | + <div class="panel-group "> | |
| 843 | + <div class="gn-flex-container row"> | |
| 844 | + <div class=" col-md-12"> | |
| 845 | + <div class="wpdbbkp-wrapper"> | |
| 846 | + <div class="wpdbbkp-wr"> | |
| 847 | + <div class="bkp-wpdbbkp-img"> | |
| 848 | + <span class="sp_ov"></span> | |
| 849 | + </div> | |
| 850 | + <div class="bkp-wpdbbkp-cnt"> | |
| 851 | + <h1><?php esc_html_e('UPGRADE to PRO Version','wpdbbkp');?></h1> | |
| 852 | + <a class="buy" href="https://backupforwp.com/pricing/#pricings" target="_blank">Purchase Now</a> | |
| 853 | + </div> | |
| 854 | + <div class="pvf"> | |
| 855 | + <div class="pvf-cnt"> | |
| 856 | + <div class="pvf-tlt"> | |
| 857 | + <h2><?php esc_html_e('Compare Pro vs. Free Version','wpdbbkp');?></h2> | |
| 858 | + <span><?php esc_html_e('See what you\'ll get with the professional version','wpdbbkp');?></span> | |
| 859 | + </div> | |
| 860 | + <div class="pvf-cmp"> | |
| 861 | + <div class="fr"> | |
| 862 | + <h1><?php esc_html_e('FREE','wpdbbkp');?></h1> | |
| 863 | + <div class="fr-fe"> | |
| 864 | + <div class="fe-1"> | |
| 865 | + <h4><?php esc_html_e('Continious Development','wpdbbkp');?></h4> | |
| 866 | + <p><?php esc_html_e('We take bug reports and feature requests seriously. We\'re continiously developing & improve this product for last 2 years with passion and love.','wpdbbkp');?></p> | |
| 867 | + </div> | |
| 868 | + <div class="fe-1"> | |
| 869 | + <h4><?php esc_html_e('10+ Features','wpdbbkp');?></h4> | |
| 870 | + <p><?php esc_html_e('We\'re constantly expanding the plugin and make it more useful. We have wide variety of features which will fit any use-case.','wpdbbkp');?></p> | |
| 871 | + </div> | |
| 872 | + </div><!-- /. fr-fe --> | |
| 873 | + </div><!-- /. fr --> | |
| 874 | + <div class="pr"> | |
| 875 | + <h1>PRO</h1> | |
| 876 | + <div class="pr-fe"> | |
| 877 | + <span><?php esc_html_e('Everything in Free, and:','wpdbbkp');?></span> | |
| 878 | + <div class="fet"> | |
| 879 | + <div class="fe-2"> | |
| 880 | + <div class="fe-t"> | |
| 881 | + <img src="<?php echo WPDB_PLUGIN_URL;?>/assets/images/right-tick.png" alt="right-tick"> | |
| 882 | + <h4><?php esc_html_e('Anonymization Function','wpdbbkp');?></h4> | |
| 883 | + </div> | |
| 884 | + <p><?php esc_html_e('Anonymization you critical data during backup with three methods','wpdbbkp');?> </p> | |
| 885 | + </div> | |
| 886 | + <div class="fe-2"> | |
| 887 | + <div class="fe-t"> | |
| 888 | + <img src="<?php echo WPDB_PLUGIN_URL;?>/assets/images/right-tick.png" alt="right-tick"> | |
| 889 | + <h4><?php esc_html_e('Pre-update backups','wpdbbkp');?></h4> | |
| 890 | + </div> | |
| 891 | + <p> <?php esc_html_e('Automatically backs up your website before any updates to plugins, themes and WordPress core.','wpdbbkp');?></p> | |
| 892 | + </div> | |
| 1042 | 893 | |
| 1043 | - <div class="panel-group"> | |
| 1044 | - <form method="post" action="" name="db_features_form"> | |
| 1045 | - <?php wp_nonce_field('wp-database-backup'); | |
| 1046 | - $enable_anonymization = get_option('bkpforwp_enable_anonymization',false); | |
| 1047 | - $anonymization_type = get_option('bkpforwp_anonymization_type',false); | |
| 1048 | - $enable_backup_encryption = get_option('bkpforwp_enable_backup_encryption',false); | |
| 1049 | - $anonymization_pass = get_option('bkpforwp_anonymization_pass',''); | |
| 1050 | - $backup_encryption_pass = get_option('bkpforwp_encryption_pass',''); | |
| 1051 | - $enable_exact_backup_time = get_option('bkpforwp_enable_exact_backup_time',false); | |
| 1052 | - ?> | |
| 1053 | - <div class="row form-group"><label class="col-sm-3" for="enable_anonymization"><?php esc_html_e('Data Anonymization','backupforwp-pro'); ?></label> | |
| 1054 | - <div class="col-sm-9"><input type="checkbox" id="enable_anonymization" | |
| 1055 | - name="enable_anonymization" value="1" <?php checked($enable_anonymization,1,1); ?> /> | |
| 1056 | - | |
| 1057 | - <div class="alert alert-default" role="alert"> | |
| 1058 | - <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.','backupforwp-pro'); ?><a href="https://backupforwp.com/" target="_blank">Learn More</a></div> | |
| 1059 | - </div> | |
| 1060 | - </div> | |
| 1061 | - <div class="row form-group" id="anonymization_type_div" style="display:none"> | |
| 1062 | - <label class="col-sm-3" for="anonymization_type"><?php esc_html_e('Data Anonymization Type','backupforwp-pro'); ?> </label> | |
| 1063 | - <div class="col-sm-9"><select id="anonymization_type" class="form-control" | |
| 1064 | - name="anonymization_type"> | |
| 1065 | - <option value="masked_data" <?php selected('masked_data', $anonymization_type, true) ?>> <?php esc_html_e('Masked Data','backupforwp-pro'); ?> | |
| 1066 | - </option> | |
| 1067 | - <option value="fake_data" <?php selected('fake_data', $anonymization_type, true) ?>> <?php esc_html_e('Fake Data','backupforwp-pro'); ?> | |
| 1068 | - </option> | |
| 1069 | - <option value="encrypted_data" <?php selected('encrypted_data', $anonymization_type, true) ?>> <?php esc_html_e('Encrypted Data','backupforwp-pro'); ?> | |
| 1070 | - </option> | |
| 1071 | - </select> | |
| 1072 | - <?php echo wp_kses_post('<table class="bkpforwp-infotable"> | |
| 1073 | - <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> | |
| 1074 | - <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> | |
| 1075 | - <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> | |
| 1076 | - </table>');?> | |
| 1077 | - | |
| 1078 | - </div> | |
| 1079 | - </div> | |
| 1080 | - | |
| 1081 | - <div class="row form-group" id="anonymization_enc_ip" style="display:none"> | |
| 1082 | - <label class="col-sm-3" for="anonymization_pass"><?php esc_html_e('Encrypted Data','backupforwp-pro'); ?> <?php esc_html_e('Anonymization Password','backupforwp-pro'); ?></label> | |
| 1083 | - <div class="col-sm-9"> | |
| 1084 | - <input type="password" name="anonymization_pass" id="anonymization_pass" class="form-control" value="<?php esc_attr($anonymization_pass);?>"> | |
| 1085 | - <div class="alert alert-default" role="alert"> | |
| 1086 | - <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','backupforwp-pro'); ?></div> | |
| 1087 | - </div> | |
| 1088 | - | |
| 1089 | - </div> | |
| 894 | + <div class="fe-2"> | |
| 895 | + <div class="fe-t"> | |
| 896 | + <img src="<?php echo WPDB_PLUGIN_URL;?>/assets/images/right-tick.png" alt="right-tick"> | |
| 897 | + <h4><?php esc_html_e('Backup time and scheduling','wpdbbkp'); ?></h4> | |
| 898 | + </div> | |
| 899 | + <p><?php esc_html_e('Set exact times to create or delete backups.','wpdbbkp');?></p> | |
| 900 | + </div> | |
| 1090 | 901 | |
| 1091 | - <div class="row form-group" style="display:none"><label class="col-sm-3" for="enable_backup_encryption"><?php esc_html_e('Backup File Encrpytion','backupforwp-pro'); ?></label> | |
| 1092 | - <div class="col-sm-9"><input type="checkbox" id="enable_backup_encryption" | |
| 1093 | - name="enable_backup_encryption" value="1" <?php checked($enable_backup_encryption,1,1); ?> /></div> | |
| 1094 | - </div> | |
| 1095 | 902 | |
| 1096 | - <div class="row form-group" id="encryption_pass_div" style="display:none"> | |
| 1097 | - <label class="col-sm-3" for="backup_encryption_pass"><?php esc_html_e('Backup Password','backupforwp-pro'); ?></label> | |
| 1098 | - <div class="col-sm-9"> | |
| 1099 | - <input type="password" name="backup_encryption_pass" id="backup_encryption_pass" class="form-control" value="<?php esc_attr($backup_encryption_pass);?>"> | |
| 1100 | - </div> | |
| 1101 | - </div> | |
| 1102 | - | |
| 1103 | - <p class="submit"> | |
| 1104 | - <input type="submit" name="featureSubmit" class="btn btn-primary" value="Save Settings" /> | |
| 1105 | - </p> | |
| 1106 | - </form> | |
| 1107 | - </div> | |
| 1108 | - </div> | |
| 1109 | -<div class="tab-pane" id="db_remotebackups"> | |
| 1110 | -<?php | |
| 1111 | -$update_msg = ''; | |
| 1112 | -if ( true === isset( $_POST['wpdb_cd_s3'] ) && 'Y' === $_POST['wpdb_cd_s3'] ) { | |
| 1113 | - // Validate that the contents of the form request came from the current site and not somewhere else added 21-08-15 V.3.4. | |
| 1114 | - if ( ! isset( $_POST['wpdbbackup_update_cd_setting'] ) ) { | |
| 1115 | - wp_die( esc_html__('Invalid form data. form request came from the somewhere else not current site!','wpdbbkp') ); | |
| 1116 | - } | |
| 1117 | - if ( ! wp_verify_nonce( $_POST['wpdbbackup_update_cd_setting'] , 'wpdbbackup-update-cd-setting' ) ) { | |
| 1118 | - wp_die( esc_html__('Invalid form data. form request came from the somewhere else not current site!','wpdbbkp') ); | |
| 1119 | - } | |
| 1120 | - | |
| 1121 | - if ( true === isset( $_POST['wpdb_clouddrive_token'] ) ) { | |
| 1122 | - update_option( 'wpdb_clouddrive_token', wp_db_filter_data( sanitize_text_field( wp_unslash( $_POST['wpdb_clouddrive_token'] ) ) ), false ); | |
| 1123 | - } | |
| 1124 | - | |
| 1125 | - // Put a "settings updated" message on the screen. | |
| 1126 | - $update_msg = esc_html__('Your BackupforWP Cloud Backup setting has been saved.' , 'wpdbbkp'); | |
| 1127 | -} | |
| 1128 | - | |
| 1129 | -$wpdb_clouddrive_token = get_option( 'wpdb_clouddrive_token',null); | |
| 1130 | - | |
| 1131 | -$wpdbbkp_bb_s3_status = '<small><b>'.esc_html__('Status', 'wpdbbkp').'</b>: '.esc_html__('Not Configured', 'wpdbbkp').' </small> '; | |
| 1132 | - | |
| 1133 | -if($wpdb_clouddrive_token && !empty($wpdb_clouddrive_token)) | |
| 1134 | -{ | |
| 1135 | - $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> '; | |
| 1136 | -} | |
| 1137 | - | |
| 1138 | -?> | |
| 1139 | -<h2 align="center"><strong><?php echo esc_html__('Cloud Backup by BackupforWP', 'wpdbbkp') ?></strong></h2> | |
| 1140 | -<div class="panel panel-default"> | |
| 1141 | - <div class="panel-heading"> | |
| 1142 | - <h4 class="panel-title"> | |
| 1143 | - <a data-toggle="collapse" data-parent="#accordion" href="#collapsebb"> | |
| 1144 | - <?php echo '<b>'.esc_html__('Cloud Backup', 'wpdbbkp').'</b>'; ?> <?php echo wp_kses_post($wpdbbkp_bb_s3_status);?> | |
| 1145 | - | |
| 1146 | - </a> | |
| 1147 | - </h4> | |
| 1148 | - </div> | |
| 1149 | - <div class="panel-body"> | |
| 1150 | - <?php | |
| 1151 | - if($update_msg){ | |
| 1152 | - echo '<div class="updated"><p><strong>'.esc_html( $update_msg ).'</strong></p></div>'; | |
| 1153 | - } | |
| 1154 | - ?> | |
| 1155 | - <form class="form-group" name="Clouddrive3" method="post" action=""> | |
| 1156 | - | |
| 1157 | - <p style="padding:0 20px;"> | |
| 1158 | - <?php echo '<h2 style="padding:0 20px;">'.esc_html__('Getting started with our Cloud Backup service is simple.', 'wpdbbkp').'</h2>'; ?> | |
| 1159 | - | |
| 1160 | - <ul style="list-style-type: style;"> | |
| 1161 | - <li style="margin-left: 30px;"><?php echo esc_html__('Sign up for a free account at', 'wpdbbkp'); ?> <a href="https://app.backupforwp.com/register" target="_blank"><?php echo esc_html__(' Cloud Backup ', 'wpdbbkp');?> </a><?php echo esc_html__('by Backup for WP', 'wpdbbkp');?></li> | |
| 1162 | - <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> | |
| 1163 | - <li style="margin-left: 30px;"><?php echo esc_html__('API token will be generated on adding website.', 'wpdbbkp'); ?></li> | |
| 1164 | - <li style="margin-left: 30px;"><?php echo esc_html__('Copy the token here and Click Save.', 'wpdbbkp'); ?></li> | |
| 1165 | - </ul> | |
| 903 | + <div class="fe-2"> | |
| 904 | + <div class="fe-t"> | |
| 905 | + <img src="<?php echo WPDB_PLUGIN_URL;?>/assets/images/right-tick.png" alt="right-tick"> | |
| 906 | + <h4><?php esc_html_e('Fast, personal support','wpdbbkp'); ?></h4> | |
| 907 | + </div> | |
| 908 | + <p><?php esc_html_e('Provides expert help and support from the developers whenever you need it.','wpdbbkp'); ?></p> | |
| 909 | + </div> | |
| 910 | + <div class="fe-2"> | |
| 911 | + <div class="fe-t"> | |
| 912 | + <img src="<?php echo WPDB_PLUGIN_URL;?>/assets/images/right-tick.png" alt="right-tick"> | |
| 913 | + <h4><?php esc_html_e('Continuous Updates','wpdbbkp'); ?></h4> | |
| 914 | + </div> | |
| 915 | + <p><?php esc_html_e('We\'re continuously updating our premium features and releasing them.','wpdbbkp'); ?></p> | |
| 916 | + </div> | |
| 917 | + <div class="fe-2"> | |
| 918 | + <div class="fe-t"> | |
| 919 | + <img src="<?php echo WPDB_PLUGIN_URL;?>/assets/images/right-tick.png" alt="right-tick"> | |
| 920 | + <h4><?php esc_html_e('Documentation','wpdbbkp'); ?></h4> | |
| 921 | + </div> | |
| 922 | + <p><?php esc_html_e('We create tutorials for every possible feature and keep it updated for you.','wpdbbkp'); ?></p> | |
| 923 | + </div> | |
| 924 | + </div><!-- /. fet --> | |
| 925 | + <div class="pr-btn"> | |
| 926 | + <a href="https://backupforwp.com/pricing/#pricings" target="_blank"><?php esc_html_e('Upgrade to Pro','wpdbbkp'); ?></a> | |
| 927 | + </div><!-- /. pr-btn --> | |
| 928 | + </div><!-- /. pr-fe --> | |
| 929 | + </div><!-- /.pr --> | |
| 930 | + </div><!-- /. pvf-cmp --> | |
| 931 | + </div><!-- /. pvf-cnt --> | |
| 932 | + | |
| 933 | + <div class="wpdbbkpfaq"> | |
| 934 | + <h2><?php esc_html_e('Frequently Asked Questions','wpdbbkp'); ?></h2> | |
| 935 | + <div class="faq-lst"> | |
| 936 | + <div class="lt"> | |
| 937 | + <ul> | |
| 938 | + <li> | |
| 939 | + <span><?php esc_html_e('Is there a setup fee?','wpdbbkp'); ?></span> | |
| 940 | + <p><?php esc_html_e('No. There are no setup fees on any of our plans','wpdbbkp'); ?></p> | |
| 941 | + </li> | |
| 942 | + <li> | |
| 943 | + <span><?php esc_html_e('What\'s the time span for your contracts?','wpdbbkp'); ?></span> | |
| 944 | + <p><?php esc_html_e('All the plans are year-to-year which are subscribed annually except for lifetime plan.','wpdbbkp'); ?></p> | |
| 945 | + </li> | |
| 946 | + <li> | |
| 947 | + <span><?php esc_html_e('What payment methods are accepted?','wpdbbkp'); ?></span> | |
| 948 | + <p><?php esc_html_e('We accepts PayPal and Credit Card payments.','wpdbbkp'); ?></p> | |
| 949 | + </li> | |
| 950 | + <li> | |
| 951 | + <span><?php esc_html_e('Do you offer support if I need help?','wpdbbkp'); ?></span> | |
| 952 | + <p><?php esc_html_e('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.','wpdbbkp'); ?></p> | |
| 953 | + </li> | |
| 954 | + <li> | |
| 955 | + <span><?php esc_html_e('Can I use the plugins after my subscription is expired?','wpdbbkp'); ?></span> | |
| 956 | + <p><?php esc_html_e('Yes, you can use the plugins, but you will not get future updates for those plugins.','wpdbbkp'); ?></p> | |
| 957 | + </li> | |
| 958 | + </ul> | |
| 959 | + </div> | |
| 960 | + <div class="rt"> | |
| 961 | + <ul> | |
| 962 | + <li> | |
| 963 | + <span><?php esc_html_e('Can I cancel my membership at any time?','wpdbbkp'); ?></span> | |
| 964 | + <p><?php esc_html_e('Yes. You can cancel your membership by contacting us.','wpdbbkp'); ?></p> | |
| 965 | + </li> | |
| 966 | + <li> | |
| 967 | + <span><?php esc_html_e('Can I change my plan later on?','wpdbbkp'); ?></span> | |
| 968 | + <p><?php esc_html_e('Yes. You can upgrade your plan by contacting us.','wpdbbkp'); ?></p> | |
| 969 | + </li> | |
| 970 | + <li> | |
| 971 | + <span><?php esc_html_e('Do you offer refunds?','wpdbbkp'); ?></span> | |
| 972 | + <p><?php esc_html_e('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.','wpdbbkp'); ?></p> | |
| 973 | + </li> | |
| 974 | + <li> | |
| 975 | + <span><?php esc_html_e('Do I get updates for the premium plugin?','wpdbbkp'); ?></span> | |
| 976 | + <p><?php esc_html_e('Yes, you will get updates for all the premium plugins until your subscription is active.','wpdbbkp'); ?></p> | |
| 977 | + </li> | |
| 978 | + </ul> | |
| 979 | + </div> | |
| 980 | + </div><!-- /.faq-lst --> | |
| 981 | + </div><!-- /.faq --> | |
| 982 | + </div><!-- /. pvf --> | |
| 983 | + </div> | |
| 984 | + </div> | |
| 1166 | 985 | |
| 986 | + </div> | |
| 987 | + </div> | |
| 988 | + </div> | |
| 989 | + </div> | |
| 1167 | 990 | |
| 1168 | - <input type="hidden" name="wpdb_cd_s3" value="Y"> | |
| 1169 | - <input name="wpdbbackup_update_cd_setting" type="hidden" value="<?php echo esc_attr( wp_create_nonce( 'wpdbbackup-update-cd-setting' ) ); ?>" /> | |
| 1170 | - <?php wp_nonce_field( 'wp-database-backup' ); ?> | |
| 1171 | - <div class="row form-group"> | |
| 1172 | - <label class="col-sm-3" for="wpdb_clouddrive_token"><?php echo esc_html__('BackforWP API Token', 'wpdbbkp') ?></label> | |
| 1173 | - <div class="col-sm-6"> | |
| 1174 | 991 | |
| 1175 | - <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');?>"> | |
| 1176 | - <a href="https://app.backupforwp.com/websites" target="_blank"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 1177 | - </div> | |
| 1178 | - </div> | |
| 1179 | - | |
| 1180 | - <p style="padding-left:20px"><input type="submit" name="Submit" class="btn btn-primary" value="<?php esc_attr_e( 'Save' , 'wpdbbkp' ); ?>" /> | |
| 1181 | - </p> | |
| 1182 | - </form> | |
| 1183 | - <h2 style="padding:20px;"><?php echo esc_html__('Access you backups', 'wpdbbkp'); ?> <a href="https://app.backupforwp.com/dashboard/" target="_blank"> <?php echo esc_html__('HERE', 'wpdbbkp'); ?> </a> </h2> | |
| 1184 | - </div> | |
| 1185 | -</div> | |
| 1186 | - | |
| 1187 | - | |
| 1188 | -</div> | |
| 1189 | 992 | <div class="tab-pane" id="db_help"> |
| 1190 | 993 | <div class="panel-group "> |
| 1191 | 994 | <div class="gn-flex-container row"> |
| 1192 | 995 | <div class="wpdbbkp-left-side col-md-8"> |
| @@ -1196,9 +999,9 @@ | ||
| 1196 | 999 | <li> |
| 1197 | 1000 | <label class="wpdbbkp-support-label"> <?php echo esc_html__('Email', 'wpdbbkp') ?> <span class="wpdbbkp-star-mark">*</span> |
| 1198 | 1001 | </label> |
| 1199 | 1002 | <div class="support-input"> |
| 1200 | - <input type="text" id="wpdbbkp_query_email" name="wpdbbkp_query_email" size="47" placeholder="<?php esc_attr_e('Enter your Email','wpdbbkp');?>" required=""> | |
| 1003 | + <input type="text" id="wpdbbkp_query_email" name="wpdbbkp_query_email" size="47" placeholder="Enter your Email" required=""> | |
| 1201 | 1004 | </div> |
| 1202 | 1005 | </li> |
| 1203 | 1006 | <li> |
| 1204 | 1007 | <label class="wpdbbkp-support-label"> <?php echo esc_html__('Query', 'wpdbbkp') ?> <span class="wpdbbkp-star-mark">*</span> |
| @@ -1203,9 +1006,9 @@ | ||
| 1203 | 1006 | <li> |
| 1204 | 1007 | <label class="wpdbbkp-support-label"> <?php echo esc_html__('Query', 'wpdbbkp') ?> <span class="wpdbbkp-star-mark">*</span> |
| 1205 | 1008 | </label> |
| 1206 | 1009 | <div class="support-input"> |
| 1207 | - <textarea rows="5" cols="50" id="wpdbbkp_query_message" name="wpdbbkp_query_message" placeholder="<?php esc_attr_e('Write your query','wpdbbkp');?>"></textarea> | |
| 1010 | + <textarea rows="5" cols="50" id="wpdbbkp_query_message" name="wpdbbkp_query_message" placeholder="Write your query"></textarea> | |
| 1208 | 1011 | </div> |
| 1209 | 1012 | </li> |
| 1210 | 1013 | <li> |
| 1211 | 1014 | <button class="button button-primary wpdbbkp-send-query"> <?php echo esc_html__('Send Support Request', 'wpdbbkp') ?> </button> |
| @@ -1241,9 +1044,8 @@ | ||
| 1241 | 1044 | <div class="panel-body list-group"> |
| 1242 | 1045 | |
| 1243 | 1046 | <div class="row list-group-item"> |
| 1244 | 1047 | <?php |
| 1245 | - $df = $dt = $dp = $du = 'NA'; | |
| 1246 | 1048 | if(function_exists('disk_free_space')){ |
| 1247 | 1049 | /* get disk space free (in bytes) */ |
| 1248 | 1050 | $df = disk_free_space( WPDB_ROOTPATH ); |
| 1249 | 1051 | /* and get disk space total (in bytes) */ |
| @@ -1257,14 +1059,14 @@ | ||
| 1257 | 1059 | $df = $this->wp_db_backup_format_bytes( $df ); |
| 1258 | 1060 | $du = $this->wp_db_backup_format_bytes( $du ); |
| 1259 | 1061 | $dt = $this->wp_db_backup_format_bytes( $dt ); |
| 1260 | 1062 | } |
| 1261 | - | |
| 1063 | + $du=$dp=$df=$dt='NA'; | |
| 1262 | 1064 | ?> |
| 1263 | 1065 | <div class="col-md-1"><a href="" target="_blank" title="Help"><span |
| 1264 | 1066 | class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> |
| 1265 | 1067 | </div> |
| 1266 | - <div class="col-md-12">Disk Space</div> | |
| 1068 | + <div class="col-md-3">Disk Space</div> | |
| 1267 | 1069 | <div class="col-md-5"> |
| 1268 | 1070 | <div class="progress"> |
| 1269 | 1071 | <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 ); ?>% |
| 1270 | 1072 | </div> |
| @@ -1337,14 +1139,9 @@ | ||
| 1337 | 1139 | <div class="col-md-3"><?php esc_attr_e( 'Upload directory URL', 'wpdbbk' ); ?></div> |
| 1338 | 1140 | <div class="col-md-5"> |
| 1339 | 1141 | <?php |
| 1340 | 1142 | $upload_dir = wp_upload_dir(); |
| 1341 | - echo esc_url( $upload_dir['baseurl'] ); | |
| 1342 | - global $wp_filesystem; | |
| 1343 | - if(!function_exists('WP_Filesystem')){ | |
| 1344 | - require_once ( ABSPATH . '/wp-admin/includes/file.php' ); | |
| 1345 | - } | |
| 1346 | - WP_Filesystem(); | |
| 1143 | + echo esc_url( $upload_dir['baseurl'] ) | |
| 1347 | 1144 | ?> |
| 1348 | 1145 | </div> |
| 1349 | 1146 | <div class="col-md-3"></div> |
| 1350 | 1147 | </div> |
| @@ -1357,9 +1154,9 @@ | ||
| 1357 | 1154 | <div class="col-md-5"><?php echo esc_attr( $upload_dir['basedir'] ); ?></div> |
| 1358 | 1155 | <div class="col-md-1"> |
| 1359 | 1156 | <?php echo esc_attr( substr( sprintf( '%o', fileperms( $upload_dir['basedir'] ) ), -4 ) ); ?></div> |
| 1360 | 1157 | <div |
| 1361 | - 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>'; ?> | |
| 1158 | + class="col-md-2"><?php echo ( ! 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>'; ?> | |
| 1362 | 1159 | </div> |
| 1363 | 1160 | </div> |
| 1364 | 1161 | |
| 1365 | 1162 | <div class="row list-group-item"> |
| @@ -1377,9 +1174,10 @@ | ||
| 1377 | 1174 | <div class="col-md-5"> |
| 1378 | 1175 | <?php |
| 1379 | 1176 | echo esc_attr( WP_MEMORY_LIMIT ); |
| 1380 | 1177 | echo '(Max ' . esc_attr( WP_MAX_MEMORY_LIMIT ); |
| 1381 | - ?> ) | |
| 1178 | + ?> | |
| 1179 | + ) | |
| 1382 | 1180 | </div> |
| 1383 | 1181 | </div> |
| 1384 | 1182 | |
| 1385 | 1183 | |
| @@ -1402,9 +1200,9 @@ | ||
| 1402 | 1200 | class="col-md-5"> <?php echo esc_attr( $upload_dir['basedir'] . '/db-backup' ); ?></div> |
| 1403 | 1201 | <div |
| 1404 | 1202 | class="col-md-1"><?php echo esc_attr( substr( sprintf( '%o', @fileperms( esc_attr( $upload_dir['basedir'] ) . '/db-backup' ) ), -4 ) ); ?></div> |
| 1405 | 1203 | <div |
| 1406 | - 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> | |
| 1204 | + class="col-md-2"><?php echo ( ! 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> | |
| 1407 | 1205 | </div> |
| 1408 | 1206 | |
| 1409 | 1207 | <div class="row list-group-item"> |
| 1410 | 1208 | <div class="col-md-1"><a href="" target="_blank" title="Help"><span |
| @@ -1601,17 +1399,14 @@ | ||
| 1601 | 1399 | <th><?php echo esc_html__('Version', 'wpdbbkp') ?></th> |
| 1602 | 1400 | </tr> |
| 1603 | 1401 | <?php |
| 1604 | 1402 | $plugins = get_plugins(); |
| 1605 | - if(!empty($plugins) && is_array($plugins)){ | |
| 1606 | - foreach ( $plugins as $plugin ) { | |
| 1607 | - echo '<tr> | |
| 1608 | - <td>' . esc_attr( $plugin['Name'] ) . '</td> | |
| 1609 | - <td>' . esc_attr( $plugin['Version'] ) . '</td> | |
| 1610 | - </tr>'; | |
| 1611 | - } | |
| 1403 | + foreach ( $plugins as $plugin ) { | |
| 1404 | + echo '<tr> | |
| 1405 | + <td>' . esc_attr( $plugin['Name'] ) . '</td> | |
| 1406 | + <td>' . esc_attr( $plugin['Version'] ) . '</td> | |
| 1407 | + </tr>'; | |
| 1612 | 1408 | } |
| 1613 | - | |
| 1614 | 1409 | ?> |
| 1615 | 1410 | </table> |
| 1616 | 1411 | <table class="table table-condensed"> |
| 1617 | 1412 | <tr class="success"> |
| @@ -1696,10 +1491,8 @@ | ||
| 1696 | 1491 | $checked = ''; |
| 1697 | 1492 | } |
| 1698 | 1493 | $wp_db_remove_local_backup = get_option( 'wp_db_remove_local_backup' ); |
| 1699 | 1494 | $wp_db_remove_on_uninstall = get_option( 'wp_db_remove_on_uninstall'); |
| 1700 | - $wp_db_incremental_backup = get_option( 'wp_db_incremental_backup'); | |
| 1701 | - $wp_db_save_settings_in_backup = get_option( 'wp_db_save_settings_in_backup',1); | |
| 1702 | 1495 | if ( 1 === (int) $wp_db_remove_local_backup ) { |
| 1703 | 1496 | $remove_local_backup = 'checked'; |
| 1704 | 1497 | } else { |
| 1705 | 1498 | $remove_local_backup = ''; |
| @@ -1708,40 +1501,25 @@ | ||
| 1708 | 1501 | $remove_on_uninstall = 'checked'; |
| 1709 | 1502 | } else { |
| 1710 | 1503 | $remove_on_uninstall = ''; |
| 1711 | 1504 | } |
| 1712 | - if ( 1 === (int) $wp_db_incremental_backup ) { | |
| 1713 | - $incremental_backup = 'checked'; | |
| 1714 | - } else { | |
| 1715 | - $incremental_backup = ''; | |
| 1716 | - } | |
| 1717 | - if ( 1 === (int) $wp_db_save_settings_in_backup ) { | |
| 1718 | - $save_on_backup = 'checked'; | |
| 1719 | - } else { | |
| 1720 | - $save_on_backup = ''; | |
| 1721 | - } | |
| 1722 | 1505 | ?> |
| 1723 | 1506 | <form action="" method="post"> |
| 1724 | 1507 | <?php wp_nonce_field( 'wp-database-backup' ); ?> |
| 1725 | 1508 | <div class="input-group"> |
| 1726 | 1509 | <span class="input-group-addon" id="sizing-addon2"><?php echo esc_html__('Maximum Local Backups', 'wpdbbkp') ?></span> |
| 1727 | - <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"> | |
| 1510 | + <input type="number" name="wp_local_db_backup_count" value="<?php echo esc_html( $wp_local_db_backup_count ); ?>" class="form-control" placeholder="Maximum Local Backups" aria-describedby="sizing-addon2"> | |
| 1728 | 1511 | |
| 1729 | - </div><br> | |
| 1730 | - <p><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span><?php echo esc_html__(' The maximum | |
| 1512 | + </div> | |
| 1513 | + <div class="alert alert-default" role="alert"> | |
| 1514 | + <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span><?php echo esc_html__(' The maximum | |
| 1731 | 1515 | number of Local Database Backups that should be kept, regardless of their size.', 'wpdbbkp') ?></br> |
| 1732 | 1516 | <?php echo esc_html__('Leave blank for keep unlimited database backups.', 'wpdbbkp') ?> |
| 1733 | - </p> | |
| 1734 | - | |
| 1517 | + </div> | |
| 1735 | 1518 | <hr> |
| 1736 | 1519 | <div class="input-group"> |
| 1737 | 1520 | <label><input type="checkbox" <?php echo esc_attr( $checked ); ?> name="wp_db_log"> <?php echo esc_html__('Enable Log', 'wpdbbkp') ?></label> |
| 1738 | 1521 | </div> |
| 1739 | - <br> | |
| 1740 | - <p><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> | |
| 1741 | - <?php echo esc_html__(' Create a log file to record details of each backup operation. ', 'wpdbbkp') ?> | |
| 1742 | - </p> | |
| 1743 | - | |
| 1744 | 1522 | <hr> |
| 1745 | 1523 | <div class="input-group"> |
| 1746 | 1524 | <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> |
| 1747 | 1525 | <p><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> |
| @@ -1753,21 +1531,14 @@ | ||
| 1753 | 1531 | <div class="input-group"> |
| 1754 | 1532 | <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> |
| 1755 | 1533 | <p><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> |
| 1756 | 1534 | <?php echo esc_html__('If Checked then it will remove local backup.', 'wpdbbkp') ?> |
| 1757 | - <?php echo esc_html__('Use this option only when you have set any destination.', 'wpdbbkp') ?> | |
| 1758 | - <?php echo esc_html__('If somesites you need only external backup.', 'wpdbbkp') ?> | |
| 1535 | + <br><?php echo esc_html__('Use this option only when you have set any destination.', 'wpdbbkp') ?> | |
| 1536 | + <br><?php echo esc_html__('If somesites you need only external backup.', 'wpdbbkp') ?> | |
| 1759 | 1537 | </p> |
| 1760 | 1538 | </div> |
| 1761 | 1539 | <hr> |
| 1762 | 1540 | <div class="input-group"> |
| 1763 | - <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> | |
| 1764 | - <p><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> | |
| 1765 | - <?php echo esc_html__('If Checked then it will skip Backup for WP plugin settings from the DB backup file .', 'wpdbbkp') ?> | |
| 1766 | - </p> | |
| 1767 | - </div> | |
| 1768 | - <hr> | |
| 1769 | - <div class="input-group"> | |
| 1770 | 1541 | <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> |
| 1771 | 1542 | <p><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> |
| 1772 | 1543 | <?php echo esc_html__('If Checked then it will delete all backup files and options when plugin is uninstalled', 'wpdbbkp') ?> |
| 1773 | 1544 | |
| @@ -1772,18 +1543,15 @@ | ||
| 1772 | 1543 | <?php echo esc_html__('If Checked then it will delete all backup files and options when plugin is uninstalled', 'wpdbbkp') ?> |
| 1773 | 1544 | |
| 1774 | 1545 | </p> |
| 1775 | 1546 | </div> |
| 1776 | - | |
| 1547 | + <hr> | |
| 1777 | 1548 | <?php |
| 1778 | 1549 | $remove_backup_href = esc_url( site_url() ) . '/wp-admin/admin.php?page=wp-database-backup&action=removeallbackup&_wpnonce=' . esc_attr( $nonce ); ?> |
| 1779 | 1550 | |
| 1780 | 1551 | <div class="input-group"> |
| 1781 | - <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> | |
| 1782 | - <p> <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> | |
| 1783 | - <?php echo esc_html__('Warning :This is will delete all the backups on the website. Once deleted backups can not be recovered.', 'wpdbbkp') ?> | |
| 1784 | - </p> | |
| 1785 | - | |
| 1552 | + <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"><span class="glyphicon glyphicon-trash"></span> <?php esc_html_e('Delete all Backups', 'wpdbbkp')?></a> | |
| 1553 | + <br><?php echo esc_html__('Warning :This is will delete all the backups on the website. Once deleted backups can not be recovered.', 'wpdbbkp') ?> | |
| 1786 | 1554 | |
| 1787 | 1555 | </div> |
| 1788 | 1556 | <hr> |
| 1789 | 1557 | <div class="panel panel-default"> |
| @@ -1867,15 +1635,15 @@ | ||
| 1867 | 1635 | </p> |
| 1868 | 1636 | <br> |
| 1869 | 1637 | <div class="input-group"> |
| 1870 | 1638 | <span class="input-group-addon" id="wp_db_backup_search_text"><?php echo esc_html__('Search For', 'wpdbbkp') ?></span> |
| 1871 | - <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('http://localhost/wordpress','wpdbbkp'); //phpcs:ignore ?>" aria-describedby="wp_db_backup_search_text"> | |
| 1639 | + <input type="text" name="wp_db_backup_search_text" value="<?php echo esc_html( $wp_db_backup_search_text ); ?>" class="form-control" placeholder="http://localhost/wordpress" aria-describedby="wp_db_backup_search_text"> | |
| 1872 | 1640 | |
| 1873 | 1641 | </div> |
| 1874 | 1642 | <br> |
| 1875 | 1643 | <div class="input-group"> |
| 1876 | 1644 | <span class="input-group-addon" id="wp_db_backup_replace_text"><?php echo esc_html__('Replace With', 'wpdbbkp') ?></span> |
| 1877 | - <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"> | |
| 1645 | + <input type="text" name="wp_db_backup_replace_text" value="<?php echo esc_html( $wp_db_backup_replace_text ); ?>" class="form-control" placeholder="http://site.com" aria-describedby="wp_db_backup_replace_text"> | |
| 1878 | 1646 | |
| 1879 | 1647 | </div> |
| 1880 | 1648 | |
| 1881 | 1649 | <div class="alert alert-default" role="alert"> |
| @@ -1882,10 +1650,10 @@ | ||
| 1882 | 1650 | <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> |
| 1883 | 1651 | <?php echo esc_html__("Leave blank those fields if you don't want use this feature and want only regular Database backup.", 'wpdbbkp') ?> |
| 1884 | 1652 | <br> |
| 1885 | 1653 | <?php echo esc_html__('Ex:', 'wpdbbkp') ?> |
| 1886 | - <br><?php echo esc_html__('Search For:', 'wpdbbkp') ?> <?php echo esc_url('http://localhost/wordpress/', 'wpdbbkp'); //phpcs:ignore ?> | |
| 1887 | - <br><?php echo esc_html__('Replace With:', 'wpdbbkp') ?> <?php echo esc_url('http://domain.com/', 'wpdbbkp') ?> | |
| 1654 | + <br><?php echo esc_html__('Search For:', 'wpdbbkp') ?> http://localhost/wordpress/ | |
| 1655 | + <br><?php echo esc_html__('Replace With:', 'wpdbbkp') ?> http://domain.com/ | |
| 1888 | 1656 | |
| 1889 | 1657 | <br><br> |
| 1890 | 1658 | <?php echo esc_html__('Note - This is Search & Replace data in your WordPress Database Backup File not in current Database installation.', 'wpdbbkp') ?> |
| 1891 | 1659 | |
| @@ -1949,79 +1717,63 @@ | ||
| 1949 | 1717 | global $wpdb; |
| 1950 | 1718 | /* BEGIN : Prevent saving backup plugin settings in the database dump */ |
| 1951 | 1719 | $options_backup = get_option( 'wp_db_backup_backups' ); |
| 1952 | 1720 | $settings_backup = get_option( 'wp_db_backup_options' ); |
| 1953 | - $wp_db_save_settings_in_backup = get_option( 'wp_db_save_settings_in_backup',1); | |
| 1954 | - if($wp_db_save_settings_in_backup){ | |
| 1955 | - delete_option( 'wp_db_backup_backups' ); | |
| 1956 | - delete_option( 'wp_db_backup_options' ); | |
| 1957 | - } | |
| 1721 | + delete_option( 'wp_db_backup_backups' ); | |
| 1722 | + delete_option( 'wp_db_backup_options' ); | |
| 1958 | 1723 | /* END : Prevent saving backup plugin settings in the database dump */ |
| 1959 | 1724 | $wp_db_exclude_table = array(); |
| 1960 | 1725 | $wp_db_exclude_table = get_option( 'wp_db_exclude_table' ); |
| 1961 | 1726 | $tables = $wpdb->get_col( 'SHOW TABLES' ); // phpcs:ignore |
| 1962 | 1727 | $output = ''; |
| 1963 | - if(!empty($tables) && !is_array($tables)){ | |
| 1964 | - foreach ( $tables as $table ) { | |
| 1965 | - if ( empty( $wp_db_exclude_table ) || ( ! ( in_array( $table, $wp_db_exclude_table, true ) ) ) ) { | |
| 1966 | - | |
| 1967 | - $check_count = $wpdb->get_var( "SELECT count(*) FROM {$table}"); // phpcs:ignore | |
| 1968 | - $check_count = intval($check_count); | |
| 1969 | - $sub_limit =500; | |
| 1970 | - if(isset($check_count) && $check_count>$sub_limit){ | |
| 1971 | - $result =array(); | |
| 1972 | - $t_sub_queries= ceil($check_count/$sub_limit); | |
| 1973 | - for($sub_i=0;$sub_i<$t_sub_queries;$sub_i++) | |
| 1974 | - { | |
| 1975 | - $sub_offset = $sub_i*$sub_limit; | |
| 1976 | - $sub_result = false; | |
| 1977 | - if ( false === $sub_result ) { | |
| 1978 | - // phpcs:ignore -- using direct query to get the data of table in chunks. | |
| 1979 | - $sub_result = $wpdb->get_results( $wpdb->prepare("SELECT * FROM {$table} LIMIT %d OFFSET %d",array($sub_limit,$sub_offset)), ARRAY_A ); | |
| 1980 | - } | |
| 1981 | - | |
| 1982 | - if($sub_result){ | |
| 1983 | - $result = array_merge($result,$sub_result); | |
| 1984 | - } | |
| 1985 | - sleep(1); | |
| 1728 | + foreach ( $tables as $table ) { | |
| 1729 | + if ( empty( $wp_db_exclude_table ) || ( ! ( in_array( $table, $wp_db_exclude_table, true ) ) ) ) { | |
| 1730 | + | |
| 1731 | + $check_count = $wpdb->get_var( "SELECT count(*) FROM {$table}"); // phpcs:ignore | |
| 1732 | + $check_count = intval($check_count); | |
| 1733 | + $sub_limit =500; | |
| 1734 | + if(isset($check_count) && $check_count>$sub_limit){ | |
| 1735 | + $result =array(); | |
| 1736 | + $t_sub_queries= ceil($check_count/$sub_limit); | |
| 1737 | + for($sub_i=0;$sub_i<$t_sub_queries;$sub_i++) | |
| 1738 | + { | |
| 1739 | + $sub_offset = $sub_i*$sub_limit; | |
| 1740 | + $sub_result = $wpdb->get_results( $wpdb->prepare("SELECT * FROM %i LIMIT %d OFFSET %d",array($table,$sub_limit,$sub_offset)), ARRAY_A ); | |
| 1741 | + if($sub_result){ | |
| 1742 | + $result = array_merge($result,$sub_result); | |
| 1986 | 1743 | } |
| 1744 | + sleep(1); | |
| 1987 | 1745 | } |
| 1988 | - else{ | |
| 1989 | - $result = $wpdb->get_results( $wpdb->prepare("SELECT * FROM {$table}"), ARRAY_A ); // phpcs:ignore | |
| 1990 | - } | |
| 1991 | - | |
| 1992 | - | |
| 1993 | - $row2 = $wpdb->get_row( 'SHOW CREATE TABLE ' . $table, ARRAY_N ); // phpcs:ignore | |
| 1994 | - $output .= "\n\n" . $row2[1] . ";\n\n"; | |
| 1995 | - $result_count = count( $result ); | |
| 1996 | - for ( $i = 0; $i < $result_count; $i++ ) { | |
| 1997 | - if(isset($result[ $i ])){ | |
| 1998 | - $row = $result[ $i ]; | |
| 1999 | - $output .= 'INSERT INTO ' . $table . ' VALUES('; | |
| 2000 | - $result_o_index = count( $result[0] ); | |
| 2001 | - $j=0; | |
| 2002 | - foreach ($row as $key => $value) { | |
| 2003 | - $row[ $key] = $wpdb->_real_escape( apply_filters( 'wpdbbkp_process_db_fields', $row[$key],$table,$key) ); | |
| 2004 | - $output .= ( isset( $row[ $key ] ) ) ? '"' . $row[ $key ] . '"' : '""'; | |
| 2005 | - if ( $j < ( $result_o_index - 1 ) ) { | |
| 2006 | - $output .= ','; | |
| 2007 | - } | |
| 2008 | - $j++; | |
| 2009 | - } | |
| 2010 | - $output .= ");\n"; | |
| 1746 | + } | |
| 1747 | + else{ | |
| 1748 | + $result = $wpdb->get_results( $wpdb->prepare("SELECT * FROM %i",array($table)), ARRAY_A ); // phpcs:ignore | |
| 1749 | + } | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + $row2 = $wpdb->get_row( 'SHOW CREATE TABLE ' . $table, ARRAY_N ); // phpcs:ignore | |
| 1753 | + $output .= "\n\n" . $row2[1] . ";\n\n"; | |
| 1754 | + $result_count = count( $result ); | |
| 1755 | + for ( $i = 0; $i < $result_count; $i++ ) { | |
| 1756 | + $row = $result[ $i ]; | |
| 1757 | + $output .= 'INSERT INTO ' . $table . ' VALUES('; | |
| 1758 | + $result_o_index = count( $result[0] ); | |
| 1759 | + $j=0; | |
| 1760 | + foreach ($row as $key => $value) { | |
| 1761 | + $row[ $key] = $wpdb->_real_escape( apply_filters( 'wpdbbkp_process_db_fields', $row[$key],$table,$key) ); | |
| 1762 | + $output .= ( isset( $row[ $key ] ) ) ? '"' . $row[ $key ] . '"' : '""'; | |
| 1763 | + if ( $j < ( $result_o_index - 1 ) ) { | |
| 1764 | + $output .= ','; | |
| 2011 | 1765 | } |
| 2012 | - | |
| 1766 | + $j++; | |
| 2013 | 1767 | } |
| 2014 | - $output .= "\n"; | |
| 1768 | + $output .= ");\n"; | |
| 2015 | 1769 | } |
| 2016 | - sleep(1); | |
| 1770 | + $output .= "\n"; | |
| 2017 | 1771 | } |
| 2018 | - | |
| 1772 | + sleep(1); | |
| 2019 | 1773 | } |
| 2020 | - | |
| 2021 | 1774 | $wpdb->flush(); |
| 2022 | 1775 | /* BEGIN : Prevent saving backup plugin settings in the database dump */ |
| 2023 | - $options_backup = wpdbbkp_filter_unique_filenames( $options_backup ); | |
| 2024 | 1776 | add_option( 'wp_db_backup_backups', $options_backup ); |
| 2025 | 1777 | add_option( 'wp_db_backup_options', $settings_backup ); |
| 2026 | 1778 | /* END : Prevent saving backup plugin settings in the database dump */ |
| 2027 | 1779 | return $output; |
| @@ -2029,138 +1781,61 @@ | ||
| 2029 | 1781 | |
| 2030 | 1782 | /** |
| 2031 | 1783 | * Create database backup new function. |
| 2032 | 1784 | */ |
| 2033 | - public function wp_db_backup_create_mysql_backup_new( $table, $file_path ) { | |
| 2034 | - global $wpdb, $wp_filesystem; | |
| 2035 | - | |
| 2036 | - // Ensure WP Filesystem is loaded | |
| 2037 | - if ( ! function_exists( 'WP_Filesystem' ) ) { | |
| 2038 | - require_once ABSPATH . 'wp-admin/includes/file.php'; | |
| 2039 | - } | |
| 2040 | - WP_Filesystem(); | |
| 2041 | - | |
| 2042 | - // Define file size threshold (e.g., 10MB) | |
| 2043 | - $file_size_threshold = 10 * 1024 * 1024; // 10MB | |
| 2044 | - | |
| 2045 | - // Initialize the file with table creation statement if it doesn't exist | |
| 1785 | + public function wp_db_backup_create_mysql_backup_new($table) { | |
| 1786 | + global $wpdb; | |
| 1787 | + $output = ''; | |
| 2046 | 1788 | |
| 2047 | - $table = esc_sql( $table ); | |
| 2048 | - $row2 = $wpdb->get_row( "SHOW CREATE TABLE `{$table}`", ARRAY_N ); // phpcs:ignore | |
| 2049 | - $initial_output = "\n\n" . $row2[1] . ";\n\n"; | |
| 2050 | - | |
| 2051 | - $use_php_methods = false; | |
| 2052 | - if ( $wp_filesystem->exists( $file_path ) ) { | |
| 2053 | - // Check file size | |
| 2054 | - $file_size = $wp_filesystem->size( $file_path ); | |
| 2055 | - if ( $file_size !== false && $file_size > $file_size_threshold ) { | |
| 2056 | - $use_php_methods = true; | |
| 1789 | + $check_count = $wpdb->get_var( "SELECT count(*) FROM {$table}"); // phpcs:ignore | |
| 1790 | + $check_count = intval($check_count); | |
| 1791 | + $sub_limit =500; | |
| 1792 | + if(isset($check_count) && $check_count>$sub_limit){ | |
| 1793 | + $result =array(); | |
| 1794 | + $t_sub_queries= ceil($check_count/$sub_limit); | |
| 1795 | + for($sub_i=0;$sub_i<$t_sub_queries;$sub_i++) | |
| 1796 | + { | |
| 1797 | + $sub_offset = $sub_i*$sub_limit; | |
| 1798 | + $sub_result = $wpdb->get_results( $wpdb->prepare("SELECT * FROM %i LIMIT %d OFFSET %d",array($table,$sub_limit,$sub_offset)), ARRAY_A ); | |
| 1799 | + if($sub_result){ | |
| 1800 | + $result = array_merge($result,$sub_result); | |
| 1801 | + } | |
| 1802 | + sleep(1); | |
| 2057 | 1803 | } |
| 2058 | 1804 | } |
| 2059 | - | |
| 2060 | - // Function to append content | |
| 2061 | - $append_content = function( $new_content ) use ( $file_path, $wp_filesystem, $use_php_methods ) { | |
| 2062 | - if ( $use_php_methods ) { | |
| 2063 | - // Using PHP methods to append | |
| 2064 | - if ( ! $wp_filesystem->exists( $file_path ) ) { | |
| 2065 | - // phpcs:ignore -- WP Filesystem fileing for large files | |
| 2066 | - file_put_contents( $file_path, $new_content ); | |
| 2067 | - } else { | |
| 2068 | - // phpcs:ignore -- WP Filesystem fileing for large files | |
| 2069 | - file_put_contents( $file_path, $new_content, FILE_APPEND ); | |
| 2070 | - } | |
| 2071 | - } else { | |
| 2072 | - // Use WP Filesystem to append | |
| 2073 | - if ( ! $wp_filesystem->exists( $file_path ) ) { | |
| 2074 | - $wp_filesystem->put_contents( $file_path, $new_content, FS_CHMOD_FILE ); | |
| 2075 | - } else { | |
| 2076 | - // Read current contents | |
| 2077 | - $current_contents = $wp_filesystem->get_contents( $file_path ); | |
| 2078 | - if ( $current_contents === false ) { | |
| 2079 | - // Handle error if reading fails | |
| 2080 | - return false; | |
| 2081 | - } | |
| 2082 | - // Append new content | |
| 2083 | - $updated_contents = $current_contents . $new_content; | |
| 2084 | - // Write back updated contents | |
| 2085 | - if ( ! $wp_filesystem->put_contents( $file_path, $updated_contents, FS_CHMOD_FILE ) ) { | |
| 2086 | - // Handle error if writing fails | |
| 2087 | - return false; | |
| 2088 | - } | |
| 2089 | - } | |
| 2090 | - } | |
| 2091 | - return true; | |
| 2092 | - }; | |
| 2093 | - | |
| 2094 | - // Write the initial output to the file | |
| 2095 | - if ( ! $append_content( $initial_output ) ) { | |
| 2096 | - return false; // Handle error if initial content writing fails | |
| 1805 | + else{ | |
| 1806 | + $result = $wpdb->get_results( $wpdb->prepare("SELECT * FROM %i",array($table)), ARRAY_A ); // phpcs:ignore | |
| 2097 | 1807 | } |
| 2098 | - | |
| 2099 | - $sub_limit = 500; | |
| 2100 | - // phpcs:ignore | |
| 2101 | - $check_count = $wpdb->get_var( "SELECT COUNT(*) FROM `{$table}`" ); | |
| 2102 | - $check_count = intval( $check_count ); | |
| 2103 | - | |
| 2104 | - if ( $check_count > $sub_limit ) { | |
| 2105 | - $t_sub_queries = ceil( $check_count / $sub_limit ); | |
| 2106 | - | |
| 2107 | - for ( $sub_i = 0; $sub_i < $t_sub_queries; $sub_i++ ) { | |
| 2108 | - $sub_offset = $sub_i * $sub_limit; | |
| 2109 | - $sub_result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `{$table}` LIMIT %d OFFSET %d", array( $sub_limit, $sub_offset ) ), ARRAY_A ); // phpcs:ignore | |
| 2110 | - | |
| 2111 | - if ( $sub_result ) { | |
| 2112 | - $output = ''; | |
| 2113 | - foreach ( $sub_result as $row ) { | |
| 2114 | - $output .= 'INSERT INTO ' . $table . ' VALUES('; | |
| 2115 | - $result_o_index = count( $row ); | |
| 2116 | - $j = 0; | |
| 2117 | - foreach ( $row as $key => $value ) { | |
| 2118 | - $row[ $key ] = $wpdb->_real_escape( apply_filters( 'wpdbbkp_process_db_fields', $value, $table, $key ) ); | |
| 2119 | - $output .= ( isset( $row[ $key ] ) ) ? '"' . $row[ $key ] . '"' : '""'; | |
| 2120 | - if ( $j < ( $result_o_index - 1 ) ) { | |
| 2121 | - $output .= ','; | |
| 2122 | - } | |
| 2123 | - $j++; | |
| 2124 | - } | |
| 2125 | - $output .= ");\n"; | |
| 2126 | - } | |
| 2127 | - // Append to the file | |
| 2128 | - if ( ! $append_content( $output ) ) { | |
| 2129 | - return false; // Handle error if appending content fails | |
| 2130 | - } | |
| 2131 | - } | |
| 2132 | - sleep(1); | |
| 2133 | - } | |
| 2134 | - } else { | |
| 2135 | - $result = $wpdb->get_results( "SELECT * FROM `{$table}`", ARRAY_A ); // phpcs:ignore | |
| 2136 | - | |
| 2137 | - $output = ''; | |
| 2138 | - foreach ( $result as $row ) { | |
| 2139 | - $output .= 'INSERT INTO ' . $table . ' VALUES('; | |
| 2140 | - $result_o_index = count( $row ); | |
| 2141 | - $j = 0; | |
| 2142 | - foreach ( $row as $key => $value ) { | |
| 2143 | - $row[ $key ] = $wpdb->_real_escape( apply_filters( 'wpdbbkp_process_db_fields', $value, $table, $key ) ); | |
| 2144 | - $output .= ( isset( $row[ $key ] ) ) ? '"' . $row[ $key ] . '"' : '""'; | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + $row2 = $wpdb->get_row( 'SHOW CREATE TABLE ' . $table, ARRAY_N ); // phpcs:ignore | |
| 1811 | + $output .= "\n\n" . $row2[1] . ";\n\n"; | |
| 1812 | + $result_count = count( $result ); | |
| 1813 | + for ( $i = 0; $i < $result_count; $i++ ) { | |
| 1814 | + $row = $result[ $i ]; | |
| 1815 | + $output .= 'INSERT INTO ' . $table . ' VALUES('; | |
| 1816 | + $result_o_index = count( $result[0] ); | |
| 1817 | + $j=0; | |
| 1818 | + if(!empty($row)){ | |
| 1819 | + foreach ($row as $key => $value) { | |
| 1820 | + $row[ $key] = $wpdb->_real_escape( apply_filters( 'wpdbbkp_process_db_fields', $row[$key],$table,$key) ); | |
| 1821 | + $output .= ( isset( $row[ $key ] ) ) ? '"' . $row[ $key ] . '"' : '""'; | |
| 2145 | 1822 | if ( $j < ( $result_o_index - 1 ) ) { |
| 2146 | 1823 | $output .= ','; |
| 2147 | 1824 | } |
| 2148 | 1825 | $j++; |
| 2149 | 1826 | } |
| 1827 | + } | |
| 2150 | 1828 | $output .= ");\n"; |
| 2151 | 1829 | } |
| 2152 | - // Append to the file | |
| 2153 | - if ( ! $append_content( $output ) ) { | |
| 2154 | - return false; // Handle error if appending content fails | |
| 2155 | - } | |
| 2156 | - } | |
| 2157 | - | |
| 2158 | - // Flush the database cache | |
| 1830 | + $output .= "\n"; | |
| 1831 | + | |
| 1832 | + sleep(1); | |
| 1833 | + | |
| 2159 | 1834 | $wpdb->flush(); |
| 2160 | - return true; | |
| 1835 | + | |
| 1836 | + return $output; | |
| 2161 | 1837 | } |
| 2162 | - | |
| 2163 | 1838 | |
| 2164 | 1839 | /** |
| 2165 | 1840 | * Mysql Dump set path. |
| 2166 | 1841 | * |
| @@ -2398,9 +2073,9 @@ | ||
| 2398 | 2073 | |
| 2399 | 2074 | // If there are mysqldump errors delete the database dump file as mysqldump will still have written one. |
| 2400 | 2075 | if ( $this->get_errors( $this->get_mysqldump_method() ) && file_exists( $sql_filename ) ) { |
| 2401 | 2076 | if ( file_exists( $sql_filename ) ) { |
| 2402 | - wp_delete_file( $sql_filename ); | |
| 2077 | + unlink( $sql_filename ); | |
| 2403 | 2078 | } |
| 2404 | 2079 | } |
| 2405 | 2080 | |
| 2406 | 2081 | // If we have an empty file delete it. |
| @@ -2405,9 +2080,9 @@ | ||
| 2405 | 2080 | |
| 2406 | 2081 | // If we have an empty file delete it. |
| 2407 | 2082 | if ( 0 === filesize( $sql_filename ) ) { |
| 2408 | 2083 | if ( file_exists( $sql_filename ) ) { |
| 2409 | - wp_delete_file( $sql_filename ); | |
| 2084 | + unlink( $sql_filename ); | |
| 2410 | 2085 | } |
| 2411 | 2086 | } |
| 2412 | 2087 | |
| 2413 | 2088 | // If the file still exists then it must be good. |
| @@ -2453,44 +2128,31 @@ | ||
| 2453 | 2128 | $source_directory = $this->wp_db_backup_wp_config_path(); |
| 2454 | 2129 | |
| 2455 | 2130 | $path_info = wp_upload_dir(); |
| 2456 | 2131 | $htasses_text = ''; |
| 2457 | - global $wpdb,$wp_filesystem; | |
| 2458 | - if ( ! function_exists( 'WP_Filesystem' ) ) { | |
| 2459 | - require_once ABSPATH . '/wp-admin/includes/file.php'; | |
| 2460 | - } | |
| 2461 | - WP_Filesystem(); | |
| 2462 | - | |
| 2463 | - if(!$wp_filesystem){ | |
| 2464 | - error_log('Could not initialize WP_Filesystem'); | |
| 2465 | - return false; | |
| 2466 | - } | |
| 2467 | - | |
| 2468 | 2132 | wp_mkdir_p($path_info['basedir'] . '/' . WPDB_BACKUPS_DIR); |
| 2469 | 2133 | wp_mkdir_p($path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/log'); |
| 2470 | - $file_contents = "<?php\n// Silence is golden.\n"; | |
| 2471 | - | |
| 2472 | - // Create the file with the given contents | |
| 2473 | - $wp_filesystem->put_contents( $path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/index.php', $file_contents, FS_CHMOD_FILE ); | |
| 2474 | - $wp_filesystem->put_contents( $path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/log/index.php', $file_contents, FS_CHMOD_FILE ); | |
| 2475 | - | |
| 2476 | - | |
| 2134 | + fclose(fopen($path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/index.php', 'w')); | |
| 2135 | + fclose(fopen($path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/log/index.php', 'w')); | |
| 2477 | 2136 | // Added htaccess file 08-05-2015 for prevent directory listing. |
| 2478 | 2137 | // Fixed Vulnerability 22-06-2016 for prevent direct download. |
| 2479 | 2138 | if ( 1 === (int) get_option( 'wp_db_backup_enable_htaccess' ) ) { |
| 2480 | - $htaccess_content = '#These next two lines will already exist in your .htaccess file | |
| 2139 | + $f = fopen( $path_info['basedir'] . '/db-backup/.htaccess', 'w' ); // phpcs:ignore | |
| 2140 | + fwrite( // phpcs:ignore | |
| 2141 | + $f, | |
| 2142 | + '#These next two lines will already exist in your .htaccess file | |
| 2481 | 2143 | RewriteEngine On |
| 2482 | 2144 | RewriteBase / |
| 2483 | 2145 | # Add these lines right after the preceding two |
| 2484 | 2146 | RewriteCond %{REQUEST_FILENAME} ^.*(.zip)$ |
| 2485 | 2147 | RewriteCond %{HTTP_COOKIE} !^.*can_download.*$ [NC] |
| 2486 | - RewriteRule . - [R=403,L]'; | |
| 2487 | - $wp_filesystem->put_contents( $path_info['basedir'] . '/db-backup/.htaccess', $htaccess_content, FS_CHMOD_FILE ); | |
| 2488 | - | |
| 2148 | + RewriteRule . - [R=403,L]' | |
| 2149 | + ); // phpcs:ignore | |
| 2150 | + fclose( $f ); // phpcs:ignore | |
| 2489 | 2151 | } |
| 2490 | 2152 | // Begin : Generate SQL DUMP and save to file database.sql. |
| 2491 | 2153 | $wp_site_name = preg_replace('/[^\p{L}\p{M}]+/u', '_', get_bloginfo('name')); |
| 2492 | - $wp_db_file_name = $wp_site_name . '_' . gmdate( 'Y_m_d' ) . '_' . time() . '_' . substr( md5( AUTH_KEY ), 0, 7 ) . '_wpdb'; | |
| 2154 | + $wp_db_file_name = $wp_site_name . '_' . date( 'Y_m_d' ) . '_' . time() . '_' . substr( md5( AUTH_KEY ), 0, 7 ) . '_wpdb'; | |
| 2493 | 2155 | $sql_filename = $wp_db_file_name . '.sql'; |
| 2494 | 2156 | $filename = $wp_db_file_name . '.zip'; |
| 2495 | 2157 | $logname = $wp_db_file_name . '.txt'; |
| 2496 | 2158 | |
| @@ -2507,27 +2169,25 @@ | ||
| 2507 | 2169 | if ( 1 === (int) $my_sql_dump ) { |
| 2508 | 2170 | /* BEGIN : Prevent saving backup plugin settings in the database dump */ |
| 2509 | 2171 | $options_backup = get_option( 'wp_db_backup_backups' ); |
| 2510 | 2172 | $settings_backup = get_option( 'wp_db_backup_options' ); |
| 2511 | - $wp_db_save_settings_in_backup = get_option( 'wp_db_save_settings_in_backup',1); | |
| 2512 | - if($wp_db_save_settings_in_backup){ | |
| 2513 | - delete_option( 'wp_db_backup_backups' ); | |
| 2514 | - delete_option( 'wp_db_backup_options' ); | |
| 2515 | - } | |
| 2173 | + delete_option( 'wp_db_backup_backups' ); | |
| 2174 | + delete_option( 'wp_db_backup_options' ); | |
| 2516 | 2175 | /* END : Prevent saving backup plugin settings in the database dump */ |
| 2517 | - //phpcs:ignore -- using direct query get all tables name to be backedup. | |
| 2176 | + global $wpdb; | |
| 2518 | 2177 | $tables = $wpdb->get_col( 'SHOW TABLES' ); |
| 2519 | 2178 | $wp_db_exclude_table = get_option( 'wp_db_exclude_table',array()); |
| 2520 | 2179 | if(!empty($tables)){ |
| 2521 | 2180 | foreach($tables as $table){ |
| 2522 | 2181 | if ( empty( $wp_db_exclude_table ) || ( ! ( in_array( $table, $wp_db_exclude_table, true ) ) ) ) { |
| 2523 | - $this->wp_db_backup_create_mysql_backup_new($table, $path_info['basedir'] . '/db-backup/' . $sql_filename ); | |
| 2182 | + $handle = fopen( $path_info['basedir'] . '/db-backup/' . $sql_filename, 'a' ); // phpcs:ignore | |
| 2183 | + fwrite( $handle, $this->wp_db_backup_create_mysql_backup_new($table) ); // phpcs:ignore | |
| 2184 | + fclose( $handle ); // phpcs:ignore | |
| 2185 | + | |
| 2524 | 2186 | } |
| 2525 | 2187 | } |
| 2526 | - | |
| 2527 | 2188 | } |
| 2528 | 2189 | /* BEGIN : Prevent saving backup plugin settings in the database dump */ |
| 2529 | - $options_backup = wpdbbkp_filter_unique_filenames( $options_backup ); | |
| 2530 | 2190 | add_option( 'wp_db_backup_backups', $options_backup ); |
| 2531 | 2191 | add_option( 'wp_db_backup_options', $settings_backup ); |
| 2532 | 2192 | /* END : Prevent saving backup plugin settings in the database dump */ |
| 2533 | 2193 | } |
| @@ -2537,10 +2197,10 @@ | ||
| 2537 | 2197 | $wp_db_backup_replace_text = get_option( 'wp_db_backup_replace_text' ); |
| 2538 | 2198 | if ( ( false === empty( $wp_db_backup_search_text ) ) && ( false === empty( $wp_db_backup_replace_text ) ) ) { |
| 2539 | 2199 | $filecontent = wp_remote_get( $path_info['basedir'] . '/db-backup/' . $sql_filename ); |
| 2540 | 2200 | if (! is_wp_error( $filecontent ) && isset($filecontent['body']) ) { |
| 2541 | - $backup_str = str_replace( $wp_db_backup_search_text, $wp_db_backup_replace_text, $filecontent['body'] ); | |
| 2542 | - $wp_filesystem->put_contents( $path_info['basedir'] . '/db-backup/' . $sql_filename, $backup_str, FS_CHMOD_FILE ); | |
| 2201 | + $backup_str = str_replace( $wp_db_backup_search_text, $wp_db_backup_replace_text, $filecontent['body'] ); // phpcs:ignore | |
| 2202 | + file_put_contents( $path_info['basedir'] . '/db-backup/' . $sql_filename, $backup_str ); // phpcs:ignore | |
| 2543 | 2203 | } |
| 2544 | 2204 | } |
| 2545 | 2205 | |
| 2546 | 2206 | /* End : Generate SQL DUMP and save to file database.sql */ |
| @@ -2566,9 +2226,9 @@ | ||
| 2566 | 2226 | // Create the archive. |
| 2567 | 2227 | $v_list = $archive->create( $v_dir, PCLZIP_OPT_REMOVE_PATH, $v_remove ); |
| 2568 | 2228 | } |
| 2569 | 2229 | |
| 2570 | - | |
| 2230 | + global $wpdb; | |
| 2571 | 2231 | $mysqlversion = wp_cache_get( 'wpdb_mysqlversion' ); |
| 2572 | 2232 | if ( true === empty( $mysqlversion ) ) { |
| 2573 | 2233 | $mysqlversion = $wpdb->get_var( 'SELECT VERSION() AS version' ); // phpcs:ignore |
| 2574 | 2234 | wp_cache_set( 'wpdb_mysqlversion', $mysqlversion, '', 18000 ); |
| @@ -2604,14 +2264,14 @@ | ||
| 2604 | 2264 | if ( ! ( $number_of_existing_backups < $number_of_backups_from_user ) ) { |
| 2605 | 2265 | $diff = $number_of_existing_backups - $number_of_backups_from_user; |
| 2606 | 2266 | for ( $i = 0; $i <= $diff; $i++ ) { |
| 2607 | 2267 | $index = $i; |
| 2608 | - if ( isset($options[ $index ]['dir']) && file_exists( $options[ $index ]['dir'] ) ) { | |
| 2609 | - wp_delete_file( $options[ $index ]['dir'] ); | |
| 2268 | + if ( file_exists( $options[ $index ]['dir'] ) ) { | |
| 2269 | + unlink( $options[ $index ]['dir'] ); | |
| 2610 | 2270 | } |
| 2611 | 2271 | $file_sql = explode( '.', $options[ $index ]['dir'] ); |
| 2612 | - if ( isset($file_sql[0]) && file_exists( $file_sql[0] . '.sql' ) ) { | |
| 2613 | - wp_delete_file( $file_sql[0] . '.sql' ); | |
| 2272 | + if ( file_exists( $file_sql[0] . '.sql' ) ) { | |
| 2273 | + unlink( $file_sql[0] . '.sql' ); | |
| 2614 | 2274 | } |
| 2615 | 2275 | } |
| 2616 | 2276 | for ( $i = ( $diff + 1 ); $i < $number_of_existing_backups; $i++ ) { |
| 2617 | 2277 | $index = $i; |
| @@ -2617,9 +2277,8 @@ | ||
| 2617 | 2277 | $index = $i; |
| 2618 | 2278 | |
| 2619 | 2279 | $newoptions[] = $options[ $index ]; |
| 2620 | 2280 | } |
| 2621 | - $newoptions = wpdbbkp_filter_unique_filenames( $newoptions ); | |
| 2622 | 2281 | |
| 2623 | 2282 | update_option( 'wp_db_backup_backups', $newoptions , false); |
| 2624 | 2283 | } |
| 2625 | 2284 | } |
| @@ -2624,9 +2283,9 @@ | ||
| 2624 | 2283 | } |
| 2625 | 2284 | } |
| 2626 | 2285 | |
| 2627 | 2286 | if ( file_exists( $path_info['basedir'] . '/db-backup/' . $sql_filename ) ) { |
| 2628 | - wp_delete_file( $path_info['basedir'] . '/db-backup/' . $sql_filename ); | |
| 2287 | + unlink( $path_info['basedir'] . '/db-backup/' . $sql_filename ); | |
| 2629 | 2288 | } |
| 2630 | 2289 | return $upload_path; |
| 2631 | 2290 | } |
| 2632 | 2291 | |
| @@ -2655,17 +2314,12 @@ | ||
| 2655 | 2314 | * Backup Process. |
| 2656 | 2315 | */ |
| 2657 | 2316 | public function wp_db_backup_event_process() { |
| 2658 | 2317 | // Added in v.3.9.5! |
| 2659 | - global $wp_filesystem; | |
| 2660 | - if(!function_exists('WP_Filesystem')){ | |
| 2661 | - require_once ( ABSPATH . '/wp-admin/includes/file.php' ); | |
| 2662 | - } | |
| 2663 | - WP_Filesystem(); | |
| 2664 | 2318 | |
| 2665 | 2319 | $cron_condition = apply_filters('wpdbbkp_dbback_cron_condition',true ); |
| 2666 | 2320 | if(wp_doing_cron() && !$cron_condition){ |
| 2667 | - return false; | |
| 2321 | + wp_die(); | |
| 2668 | 2322 | } |
| 2669 | 2323 | |
| 2670 | 2324 | set_time_limit( 0 ); |
| 2671 | 2325 | ignore_user_abort(true); |
| @@ -2707,15 +2361,22 @@ | ||
| 2707 | 2361 | 'type' =>'database', |
| 2708 | 2362 | 'destination' => $args[4] |
| 2709 | 2363 | ); |
| 2710 | 2364 | if ( 1 !== (int) $wp_db_remove_local_backup ) { |
| 2711 | - $options = wpdbbkp_filter_unique_filenames( $options ); | |
| 2712 | 2365 | update_option( 'wp_db_backup_backups', $options , false); |
| 2713 | 2366 | } |
| 2714 | 2367 | if(isset($details['log_dir']) && !empty($details['log_dir'])) |
| 2715 | 2368 | { |
| 2716 | - if ($wp_filesystem->is_writable($details['log_dir']) || file_exists($details['log_dir'])) { | |
| 2717 | - $wp_filesystem->put_contents( $details['log_dir'], str_replace(array("<br>","<b>","</b>"), array("\n","",""), $args[2]), FS_CHMOD_FILE ); | |
| 2369 | + if (is_writable($details['log_dir']) || !file_exists($details['log_dir'])) { | |
| 2370 | + | |
| 2371 | + if ($handle = @fopen($details['log_dir'], 'a')) | |
| 2372 | + { | |
| 2373 | + if (fwrite($handle, str_replace(array("<br>","<b>","</b>"), array("\n","",""), $args[2]))) | |
| 2374 | + { | |
| 2375 | + fclose($handle); | |
| 2376 | + } | |
| 2377 | + } | |
| 2378 | + | |
| 2718 | 2379 | } |
| 2719 | 2380 | } |
| 2720 | 2381 | } |
| 2721 | 2382 | |
| @@ -2752,22 +2413,11 @@ | ||
| 2752 | 2413 | * Schedular activation. |
| 2753 | 2414 | */ |
| 2754 | 2415 | public function wp_db_backup_scheduler_activation() { |
| 2755 | 2416 | $options = get_option( 'wp_db_backup_options' ); |
| 2756 | - if ( ( ! wp_next_scheduled( 'wpdbbkp_db_backup_event' ) ) && ( true === isset( $options['enable_autobackups'] ) ) ) { | |
| 2417 | + if ( ( ! wp_next_scheduled( 'wp_db_backup_event' ) ) && ( true === isset( $options['enable_autobackups'] ) ) ) { | |
| 2757 | 2418 | $cron_freq = apply_filters( 'wpdbbkp_dbback_cron_frequency',$options['autobackup_frequency']); |
| 2758 | - if(isset($options['autobackup_type']) && $options['autobackup_type'] == 'db') | |
| 2759 | - { | |
| 2760 | - $timestamp = strtotime('today 23:59'); // Start at the next midnight | |
| 2761 | - wp_schedule_event( $timestamp , $cron_freq, 'wpdbbkp_db_backup_event' ); | |
| 2762 | - | |
| 2763 | - } | |
| 2764 | - }else{ | |
| 2765 | - if( !empty($options) && ( false === isset( $options['enable_autobackups'] ) ) || ( true === isset( $options['enable_autobackups'] ) ) && isset($options['autobackup_type']) && $options['autobackup_type'] != 'db') | |
| 2766 | - { | |
| 2767 | - wp_clear_scheduled_hook( 'wpdbbkp_db_backup_event' ); | |
| 2768 | - } | |
| 2769 | - | |
| 2419 | + wp_schedule_event( time(), $cron_freq, 'wp_db_backup_event' ); | |
| 2770 | 2420 | } |
| 2771 | 2421 | } |
| 2772 | 2422 | |
| 2773 | 2423 | /** |
| @@ -2776,9 +2426,9 @@ | ||
| 2776 | 2426 | * @param string $key - key name. |
| 2777 | 2427 | */ |
| 2778 | 2428 | public function wp_backup_get_config_data( $key ) { |
| 2779 | 2429 | $filepath = get_home_path() . '/wp-config.php'; |
| 2780 | - $config_file = @file_get_contents( "$filepath", true ); | |
| 2430 | + $config_file = file_get_contents( "$filepath", true ); | |
| 2781 | 2431 | if($config_file){ |
| 2782 | 2432 | switch ( $key ) { |
| 2783 | 2433 | case 'DB_NAME': |
| 2784 | 2434 | preg_match( "/'DB_NAME',\s*'(.*)?'/", $config_file, $matches ); |
| @@ -2804,9 +2454,9 @@ | ||
| 2804 | 2454 | * Get db name from config. |
| 2805 | 2455 | */ |
| 2806 | 2456 | public function wp_backup_get_config_db_name() { |
| 2807 | 2457 | $filepath = get_home_path() . '/wp-config.php'; |
| 2808 | - $config_file = @file_get_contents( "$filepath", true ); | |
| 2458 | + $config_file = file_get_contents( "$filepath", true ); | |
| 2809 | 2459 | if($config_file){ |
| 2810 | 2460 | preg_match( "/'DB_NAME',\s*'(.*)?'/", $config_file, $matches ); |
| 2811 | 2461 | return $matches[1]; |
| 2812 | 2462 | } |
| @@ -2820,11 +2470,8 @@ | ||
| 2820 | 2470 | * |
| 2821 | 2471 | * @return mixed |
| 2822 | 2472 | */ |
| 2823 | 2473 | public function recursive_sanitize_text_field( $array ) { |
| 2824 | - if( ! is_array( $array ) ) { | |
| 2825 | - return sanitize_text_field( $array ); | |
| 2826 | - } | |
| 2827 | 2474 | foreach ( $array as $key => &$value ) { |
| 2828 | 2475 | if ( is_array( $value ) ) { |
| 2829 | 2476 | $value = $this->recursive_sanitize_text_field( $value ); |
| 2830 | 2477 | } else { |
| @@ -2882,11 +2529,8 @@ | ||
| 2882 | 2529 | { |
| 2883 | 2530 | wp_register_script('wpdbbkp-admin-script', WPDB_PLUGIN_URL . '/assets/js/wpdbbkp-admin.js', array('jquery'), WPDB_VERSION, 'true' ); |
| 2884 | 2531 | wp_localize_script('wpdbbkp-admin-script', 'wpdbbkp_script_vars', array( |
| 2885 | 2532 | 'nonce' => wp_create_nonce( 'wpdbbkp-admin-nonce' ), |
| 2886 | - 'siteurl' => base64_encode(site_url( )), | |
| 2887 | - 'ud'=>wpdbbkp_get_current_user_name_email(), | |
| 2888 | - 'is_subscribed'=>wpdbbkp_if_remote_active(), | |
| 2889 | 2533 | )); |
| 2890 | 2534 | wp_enqueue_script('wpdbbkp-admin-script'); |
| 2891 | 2535 | |
| 2892 | 2536 | // Adding custom js |
| @@ -2913,12 +2557,10 @@ | ||
| 2913 | 2557 | $post_type = $current_screen->post_type; |
| 2914 | 2558 | } |
| 2915 | 2559 | |
| 2916 | 2560 | $post_id = get_the_ID(); |
| 2917 | - //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no form submission | |
| 2918 | 2561 | if(isset($_GET['tag_ID'])){ |
| 2919 | - //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no form submission | |
| 2920 | - $post_id = intval($_GET['tag_ID']); | |
| 2562 | + $post_id = intval($_GET['tag_ID']); | |
| 2921 | 2563 | } |
| 2922 | 2564 | |
| 2923 | 2565 | |
| 2924 | 2566 | |
| @@ -3040,10 +2682,10 @@ | ||
| 3040 | 2682 | public function wpdbbkp_update_backup_info($FileName, $logFile, $logMessage = '') { |
| 3041 | 2683 | $path_info = wp_upload_dir(); |
| 3042 | 2684 | $filename = $FileName . '.sql'; |
| 3043 | 2685 | $WPDBFileName = $FileName . '.zip'; |
| 3044 | - wp_delete_file($this->wp_db_backup_wp_config_path() . '/' . $filename); | |
| 3045 | - wp_delete_file($this->wp_db_backup_wp_config_path() . '/wp_installer.php'); | |
| 2686 | + @unlink($this->wp_db_backup_wp_config_path() . '/' . $filename); | |
| 2687 | + @unlink($this->wp_db_backup_wp_config_path() . '/wp_installer.php'); | |
| 3046 | 2688 | @$filesize = filesize($path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/' . $WPDBFileName); |
| 3047 | 2689 | |
| 3048 | 2690 | $upload_path = array( |
| 3049 | 2691 | 'filename' => ($WPDBFileName), |
| @@ -3067,16 +2709,18 @@ | ||
| 3067 | 2709 | } |
| 3068 | 2710 | |
| 3069 | 2711 | private function write_log($logFile, $logMessage) { |
| 3070 | 2712 | // Actually write the log file |
| 3071 | - global $wp_filesystem; | |
| 3072 | - if(!function_exists('WP_Filesystem')){ | |
| 3073 | - require_once ( ABSPATH . '/wp-admin/includes/file.php' ); | |
| 3074 | - } | |
| 3075 | - WP_Filesystem(); | |
| 2713 | + if (is_writable($logFile) || !file_exists($logFile)) { | |
| 3076 | 2714 | |
| 3077 | - if ($wp_filesystem && $wp_filesystem->is_writable($logFile) || !$wp_filesystem->exists($logFile)) { | |
| 3078 | - $wp_filesystem->put_contents( $logFile, $logMessage, FS_CHMOD_FILE ); | |
| 2715 | + if (!$handle = @fopen($logFile, 'a')) | |
| 2716 | + return; | |
| 2717 | + | |
| 2718 | + if (!fwrite($handle, $logMessage)) | |
| 2719 | + return; | |
| 2720 | + | |
| 2721 | + fclose($handle); | |
| 2722 | + | |
| 3079 | 2723 | return true; |
| 3080 | 2724 | } |
| 3081 | 2725 | } |
| 3082 | 2726 | |
| @@ -3158,9 +2802,9 @@ | ||
| 3158 | 2802 | |
| 3159 | 2803 | public function set_root($path) { |
| 3160 | 2804 | |
| 3161 | 2805 | if (empty($path) || !is_string($path) || !is_dir($path)) |
| 3162 | - throw new Exception('Invalid root path <code>' . esc_html($path) . '</code> must be a valid directory path'); | |
| 2806 | + throw new Exception('Invalid root path <code>' . $path . '</code> must be a valid directory path'); | |
| 3163 | 2807 | |
| 3164 | 2808 | $this->root = self::conform_dir($path); |
| 3165 | 2809 | } |
| 3166 | 2810 | |
| @@ -3209,59 +2853,56 @@ | ||
| 3209 | 2853 | $excludes = WPDB_BACKUPS_DIR . '|' . $wp_all_backup_exclude_dir; |
| 3210 | 2854 | } |
| 3211 | 2855 | |
| 3212 | 2856 | $excludes = explode("|", $excludes); |
| 3213 | - if(!empty($excludes) && is_array($excludes)){ | |
| 3214 | - foreach ($excludes as $key => &$rule) { | |
| 2857 | + foreach ($excludes as $key => &$rule) { | |
| 3215 | 2858 | |
| 3216 | - $file = $absolute = $fragment = false; | |
| 3217 | - | |
| 3218 | - // Files don't end with / | |
| 3219 | - if (!in_array(substr($rule, -1), array('\\', '/'))) | |
| 3220 | - $file = true; | |
| 3221 | - | |
| 3222 | - // If rule starts with a / then treat as absolute path | |
| 3223 | - elseif (in_array(substr($rule, 0, 1), array('\\', '/'))) | |
| 3224 | - $absolute = true; | |
| 3225 | - | |
| 3226 | - // Otherwise treat as dir fragment | |
| 3227 | - else | |
| 3228 | - $fragment = true; | |
| 3229 | - | |
| 3230 | - // Strip $this->root and conform | |
| 3231 | - $rule = str_ireplace($this->get_root(), '', untrailingslashit(self::conform_dir($rule))); | |
| 3232 | - | |
| 3233 | - // Strip the preceeding slash | |
| 3234 | - if (in_array(substr($rule, 0, 1), array('\\', '/'))) | |
| 3235 | - $rule = substr($rule, 1); | |
| 3236 | - | |
| 3237 | - // Escape string for regex | |
| 3238 | - if ($context === 'regex') | |
| 3239 | - $rule = str_replace('.', '\.', $rule); | |
| 3240 | - | |
| 3241 | - // Convert any existing wildcards | |
| 3242 | - if ($wildcard !== '*' && strpos($rule, '*') !== false) | |
| 3243 | - $rule = str_replace('*', $wildcard, $rule); | |
| 3244 | - | |
| 3245 | - // Wrap directory fragments and files in wildcards for zip | |
| 3246 | - if ($context === 'zip' && ( $fragment || $file )) | |
| 3247 | - $rule = $wildcard . $rule . $wildcard; | |
| 3248 | - | |
| 3249 | - // Add a wildcard to the end of absolute url for zips | |
| 3250 | - if ($context === 'zip' && $absolute) | |
| 3251 | - $rule .= $wildcard; | |
| 3252 | - | |
| 3253 | - // Add and end carrot to files for pclzip but only if it doesn't end in a wildcard | |
| 3254 | - if ($file && $context === 'regex') | |
| 3255 | - $rule .= '$'; | |
| 3256 | - | |
| 3257 | - // Add a start carrot to absolute urls for pclzip | |
| 3258 | - if ($absolute && $context === 'regex') | |
| 3259 | - $rule = '^' . $rule; | |
| 3260 | - } | |
| 3261 | - } | |
| 3262 | - | |
| 2859 | + $file = $absolute = $fragment = false; | |
| 3263 | 2860 | |
| 2861 | + // Files don't end with / | |
| 2862 | + if (!in_array(substr($rule, -1), array('\\', '/'))) | |
| 2863 | + $file = true; | |
| 2864 | + | |
| 2865 | + // If rule starts with a / then treat as absolute path | |
| 2866 | + elseif (in_array(substr($rule, 0, 1), array('\\', '/'))) | |
| 2867 | + $absolute = true; | |
| 2868 | + | |
| 2869 | + // Otherwise treat as dir fragment | |
| 2870 | + else | |
| 2871 | + $fragment = true; | |
| 2872 | + | |
| 2873 | + // Strip $this->root and conform | |
| 2874 | + $rule = str_ireplace($this->get_root(), '', untrailingslashit(self::conform_dir($rule))); | |
| 2875 | + | |
| 2876 | + // Strip the preceeding slash | |
| 2877 | + if (in_array(substr($rule, 0, 1), array('\\', '/'))) | |
| 2878 | + $rule = substr($rule, 1); | |
| 2879 | + | |
| 2880 | + // Escape string for regex | |
| 2881 | + if ($context === 'regex') | |
| 2882 | + $rule = str_replace('.', '\.', $rule); | |
| 2883 | + | |
| 2884 | + // Convert any existing wildcards | |
| 2885 | + if ($wildcard !== '*' && strpos($rule, '*') !== false) | |
| 2886 | + $rule = str_replace('*', $wildcard, $rule); | |
| 2887 | + | |
| 2888 | + // Wrap directory fragments and files in wildcards for zip | |
| 2889 | + if ($context === 'zip' && ( $fragment || $file )) | |
| 2890 | + $rule = $wildcard . $rule . $wildcard; | |
| 2891 | + | |
| 2892 | + // Add a wildcard to the end of absolute url for zips | |
| 2893 | + if ($context === 'zip' && $absolute) | |
| 2894 | + $rule .= $wildcard; | |
| 2895 | + | |
| 2896 | + // Add and end carrot to files for pclzip but only if it doesn't end in a wildcard | |
| 2897 | + if ($file && $context === 'regex') | |
| 2898 | + $rule .= '$'; | |
| 2899 | + | |
| 2900 | + // Add a start carrot to absolute urls for pclzip | |
| 2901 | + if ($absolute && $context === 'regex') | |
| 2902 | + $rule = '^' . $rule; | |
| 2903 | + } | |
| 2904 | + | |
| 3264 | 2905 | // Escape shell args for zip command |
| 3265 | 2906 | if ($context === 'zip') |
| 3266 | 2907 | $excludes = array_map('escapeshellarg', array_unique($excludes)); |
| 3267 | 2908 | |
| @@ -3278,9 +2919,9 @@ | ||
| 3278 | 2919 | return true; |
| 3279 | 2920 | |
| 3280 | 2921 | // If there are errors delete the backup file. |
| 3281 | 2922 | if ($this->get_errors($this->get_archive_method()) && file_exists($WPDBFileName)) |
| 3282 | - wp_delete_file($WPDBFileName); | |
| 2923 | + unlink($WPDBFileName); | |
| 3283 | 2924 | |
| 3284 | 2925 | // If the archive file still exists assume it's good |
| 3285 | 2926 | if (file_exists($WPDBFileName)) |
| 3286 | 2927 | return $this->archive_verified = true; |
| @@ -3315,10 +2956,8 @@ | ||
| 3315 | 2956 | } |
| 3316 | 2957 | |
| 3317 | 2958 | public function wpdbbkp_get_timeago( $time ) |
| 3318 | 2959 | { |
| 3319 | - $time = intval($time) > 0 ? intval($time) : time(); | |
| 3320 | - | |
| 3321 | 2960 | $time_difference = time() - $time; |
| 3322 | 2961 | |
| 3323 | 2962 | if( $time_difference < 1 ) { return 'less than 1 second ago'; } |
| 3324 | 2963 | $condition = array( 12 * 30 * 24 * 60 * 60 => 'year', |
| @@ -3338,43 +2977,8 @@ | ||
| 3338 | 2977 | $t = floor( $d ); |
| 3339 | 2978 | return 'About ' . $t . ' ' . $str . ( $t > 1 ? 's' : '' ) . ' ago'; |
| 3340 | 2979 | } |
| 3341 | 2980 | } |
| 3342 | - } | |
| 3343 | - | |
| 3344 | - private function wpdbbkp_append_to_file($file_path, $content_to_append){ | |
| 3345 | - global $wp_filesystem; | |
| 3346 | - | |
| 3347 | - if (!function_exists('WP_Filesystem')) { | |
| 3348 | - require_once ABSPATH . 'wp-admin/includes/file.php'; | |
| 3349 | - } | |
| 3350 | - | |
| 3351 | - | |
| 3352 | - if (empty($wp_filesystem)) { | |
| 3353 | - WP_Filesystem(); | |
| 3354 | - } | |
| 3355 | - | |
| 3356 | - if (!$wp_filesystem) { | |
| 3357 | - return false; | |
| 3358 | - } | |
| 3359 | - | |
| 3360 | - // Check if the file exists | |
| 3361 | - if ($wp_filesystem->exists($file_path)) { | |
| 3362 | - // Open the file in append mode | |
| 3363 | - $handle = $wp_filesystem->get_contents($file_path); | |
| 3364 | - | |
| 3365 | - if ($handle) { | |
| 3366 | - // Append the new content | |
| 3367 | - $result = $wp_filesystem->put_contents($file_path, $handle . $content_to_append, FS_CHMOD_FILE); | |
| 3368 | - return $result !== false; | |
| 3369 | - } | |
| 3370 | - } else { | |
| 3371 | - // If the file doesn't exist, create it with the initial content | |
| 3372 | - $result = $wp_filesystem->put_contents($file_path, $content_to_append, FS_CHMOD_FILE); | |
| 3373 | - return $result !== false; | |
| 3374 | - } | |
| 3375 | - | |
| 3376 | - return false; | |
| 3377 | 2981 | } |
| 3378 | 2982 | |
| 3379 | 2983 | } |
| 3380 | 2984 | |