PluginProbe
WP Database Backup – Unlimited Database & Files Backup by Backup for WP / 7.4
WP Database Backup – Unlimited Database & Files Backup by Backup for WP v7.4
7.13 7.12 trunk 1.1 2.1.1 5.9 6.0 6.1 6.10 6.11 6.12 6.12.1 6.2 6.3 6.4 6.5 6.5.1 6.6 6.7 6.8 6.9 7.0 7.0.1 7.1 7.10 All 34 releases
← All changes | includes/admin/class-wpdb-admin.php +140 -139 7.07.4 View file →
@@ -29,9 +29,8 @@
29 29 add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 );
30 30 add_filter( 'cron_schedules', array( $this, 'wp_db_backup_cron_schedules' ) );
31 31 add_action( 'wpdbbkp_db_backup_event', array( $this, 'wp_db_backup_event_process' ) );
32 32 add_action( 'init', array( $this, 'wp_db_backup_scheduler_activation' ) );
33 - add_action( 'wp_logout', array( $this, 'wp_db_cookie_expiration' ) ); // Fixed Vulnerability 22-06-2016 for prevent direct download.
34 33 add_action( 'wp_db_backup_completed', array( $this, 'wp_db_backup_completed_local' ), 12 );
35 34 add_action('admin_enqueue_scripts', array( $this, 'wpdbbkp_admin_style'));
36 35 add_action('admin_enqueue_scripts', array( $this, 'wpdbbkp_admin_newsletter_script'));
37 36 add_action('wp_ajax_wpdbbkp_send_query_message', array( $this, 'wpdbbkp_send_query_message'));
@@ -36,8 +35,11 @@
36 35 add_action('admin_enqueue_scripts', array( $this, 'wpdbbkp_admin_newsletter_script'));
37 36 add_action('wp_ajax_wpdbbkp_send_query_message', array( $this, 'wpdbbkp_send_query_message'));
38 37 add_filter( 'plugin_action_links_' . plugin_basename( WP_BACKUP_PLUGIN_FILE ), array( $this, 'add_settings_plugin_action_wp' ), 10, 4 );
39 38 add_action( 'admin_notices', array($this, 'check_ziparchive_avalable_admin_notice' ));
39 + add_action( 'admin_notices', array($this, 'wpdbbkp_cloudbackup_notice' ) );
40 + add_action( 'wp_ajax_wpdbbkp_cloudbackup_dismiss_notice', array($this, 'wpdbbkp_cloudbackup_dismiss_notice' ) );
41 + add_action( 'admin_init', array($this, 'admin_backup_file_download' ));
40 42
41 43 }
42 44
43 45 /**
@@ -80,10 +82,10 @@
80 82 array($this, 'wp_db_backup_settings_page' ));
81 83
82 84 add_submenu_page(
83 85 'wp-database-backup',
84 - 'Remote Backups',
85 - 'Remote Backups',
86 + 'Cloud Backup',
87 + 'Cloud Backup',
86 88 'manage_options',
87 89 'wp-database-backup#tab_db_remotebackups',
88 90 array($this, 'wp_db_backup_settings_page' ));
89 91
@@ -110,49 +112,11 @@
110 112 'manage_options',
111 113 'wp-database-backup#tab_db_help',
112 114 array($this, 'wp_db_backup_settings_page' ));
113 115
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 - // }
139 -
140 -
141 -
142 116 }
143 117
144 118 /**
145 - * Start Fixed Vulnerability 22-06-2016 for prevent direct download.
146 - */
147 - public function wp_db_cookie_expiration() {
148 - setcookie( 'can_download', 0, time() - 300, COOKIEPATH, COOKIE_DOMAIN );
149 - if ( SITECOOKIEPATH !== COOKIEPATH ) {
150 - setcookie( 'can_download', 0, time() - 300, SITECOOKIEPATH, COOKIE_DOMAIN );
151 - }
152 - }
153 -
154 - /**
155 119 * If Checked then it will remove local backup after uploading to destination.
156 120 *
157 121 * @param array $args - backup details.
158 122 */
@@ -180,28 +144,15 @@
180 144
181 145 // Start Fixed Vulnerability 04-08-2016 for data save in options.
182 146 if ( isset( $_GET['page'] ) && 'wp-database-backup' === $_GET['page'] ) {
183 147 if ( ! empty( $_POST ) && ! ( isset( $_POST['option_page'] ) && 'wp_db_backup_options' === $_POST['option_page'] ) ) {
184 - if ( false === isset( $_REQUEST['_wpnonce'] ) || false === wp_verify_nonce( $_REQUEST['_wpnonce'] , 'wp-database-backup' ) ) {
148 + if ( false === isset( $_REQUEST['_wpnonce'] ) || false === wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ) , 'wp-database-backup' ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- using as nonce
185 149 wp_die( esc_html__('WPDB :: Invalid Access', 'wpdbbkp' ) );
186 150 }
187 151 }
188 -
189 - // End Fixed Vulnerability 04-08-2016 for data save in options.
190 - if ( isset( $_GET['page'] ) && 'wp-database-backup' === $_GET['page'] && current_user_can( 'manage_options' ) ) {
191 - setcookie( 'can_download', 1, 0, COOKIEPATH, COOKIE_DOMAIN );
192 - if ( SITECOOKIEPATH !== COOKIEPATH ) {
193 - setcookie( 'can_download', 1, 0, SITECOOKIEPATH, COOKIE_DOMAIN );
194 - }
195 - } else {
196 - setcookie( 'can_download', 0, time() - 300, COOKIEPATH, COOKIE_DOMAIN );
197 - if ( SITECOOKIEPATH !== COOKIEPATH ) {
198 - setcookie( 'can_download', 0, time() - 300, SITECOOKIEPATH, COOKIE_DOMAIN );
199 - }
200 - }
201 152 // End Fixed Vulnerability 22-06-2016 for prevent direct download.
202 153 if ( is_admin() && current_user_can( 'manage_options' ) ) {
203 - if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'] , 'wp-database-backup' ) ) {
154 + if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ) , 'wp-database-backup' ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- using as nonce
204 155 if ( isset( $_POST['wpsetting_search'] ) ) {
205 156 if ( isset( $_POST['wp_db_backup_search_text'] ) ) {
206 157 update_option( 'wp_db_backup_search_text', sanitize_text_field( wp_unslash( $_POST['wp_db_backup_search_text'] ) ), false );
207 158 }
@@ -224,13 +175,8 @@
224 175 update_option( 'wp_db_remove_on_uninstall', 1 , false);
225 176 } else {
226 177 update_option( 'wp_db_remove_on_uninstall', 0 , false);
227 178 }
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 179 if ( isset( $_POST['wp_db_remove_local_backup'] ) ) {
234 180 update_option( 'wp_db_remove_local_backup', 1 , false);
235 181 } else {
236 182 update_option( 'wp_db_remove_local_backup', 0 , false);
@@ -245,18 +191,8 @@
245 191 } else {
246 192 update_option( 'wp_db_backup_enable_auto_upgrade', 0 , false);
247 193 }
248 194
249 - if ( isset( $_POST['wp_db_backup_enable_htaccess'] ) ) {
250 - update_option( 'wp_db_backup_enable_htaccess', 1 , false);
251 - } else {
252 - update_option( 'wp_db_backup_enable_htaccess', 0 , false);
253 - $path_info = wp_upload_dir();
254 - if ( file_exists( $path_info['basedir'] . '/db-backup/.htaccess' ) ) {
255 - wp_delete_file( $path_info['basedir'] . '/db-backup/.htaccess' );
256 - }
257 - }
258 -
259 195 if ( isset( $_POST['wp_db_exclude_table'] ) ) {
260 196 update_option( 'wp_db_exclude_table', $this->recursive_sanitize_text_field( wp_unslash( $_POST['wp_db_exclude_table'] ) ) , false); // phpcs:ignore
261 197 } else {
262 198 update_option( 'wp_db_exclude_table', '', false );
@@ -333,19 +269,19 @@
333 269 update_option( 'bkpforwp_enable_exact_backup_time', 0 );
334 270 }
335 271
336 272 if ( isset( $_POST['anonymization_type'] ) ) {
337 - update_option( 'bkpforwp_anonymization_type', wp_db_filter_data( sanitize_text_field( $_POST['anonymization_type'] ) ) );
273 + update_option( 'bkpforwp_anonymization_type', wp_db_filter_data( sanitize_text_field( wp_unslash( $_POST['anonymization_type'] ) ) ) );
338 274
339 275 }
340 276
341 277 if ( isset( $_POST['anonymization_pass'] )) {
342 - update_option( 'bkpforwp_anonymization_pass', wp_db_filter_data( sanitize_text_field( $_POST['anonymization_pass'] ) ) );
278 + update_option( 'bkpforwp_anonymization_pass', wp_db_filter_data( sanitize_text_field( wp_unslash($_POST['anonymization_pass'] ) ) ) );
343 279
344 280 }
345 281
346 282 if ( isset( $_POST['backup_encryption_pass'] )) {
347 - update_option( 'bkpforwp_backup_encryption_pass', wp_db_filter_data( sanitize_text_field( $_POST['backup_encryption_pass'] ) ) );
283 + update_option( 'bkpforwp_backup_encryption_pass', wp_db_filter_data( sanitize_text_field( wp_unslash($_POST['backup_encryption_pass'] ) ) ) );
348 284
349 285 }
350 286 }
351 287
@@ -543,9 +479,9 @@
543 479 }
544 480 }
545 481
546 482 // End for extract zip file V.3.3.0.
547 - set_time_limit( 0 );
483 + set_time_limit( 0 ); // phpcs:ignore -- needed for long running process
548 484 ignore_user_abort(true);
549 485 if ('' !== trim($database_name) && '' !== trim($database_user) && '' !== trim($database_host)) {
550 486 $wpdb->db_connect();
551 487 $wpdb->select($database_name);
@@ -597,14 +533,10 @@
597 533 $wpdb->query($query);
598 534 }
599 535 }
600 536
601 - } else {
602 - error_log("Failed to Open file :".esc_html($database_file));
603 - }
604 - } else {
605 - error_log("Failed to initialize WP_Filesystem");
606 - }
537 + }
538 + }
607 539 }
608 540 }
609 541
610 542 if ( isset( $options[ $index ]['sqlfile'] ) && file_exists( $options[ $index ]['sqlfile'] ) ) { // Added for extract zip file V.3.3.0.
@@ -723,16 +655,8 @@
723 655 </div>
724 656 </div>
725 657 <?php
726 658 }
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 - &nbsp;<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
732 - <?php esc_html_e( 'Try Backup for WP Cloud Storage 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 659 ?>
736 660
737 661
738 662
@@ -758,9 +682,9 @@
758 682 </div>
759 683 <div class="panel-body">
760 684 <ul class="nav nav-tabs wbdbbkp_has_nav">
761 685 <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__('Remote Backups', 'wpdbbkp') ?></a></li>
686 + <li><a href="#db_remotebackups" data-toggle="tab"><?php echo esc_html__('Cloud Backup', 'wpdbbkp') ?></a></li>
763 687 <li><a href="#db_schedul" data-toggle="tab"><?php echo esc_html__('Auto Scheduler', 'wpdbbkp') ?></a></li>
764 688 <li><a href="#db_destination" data-toggle="tab"><?php echo esc_html__('Save Backups to', 'wpdbbkp') ?></a></li>
765 689 <li><a href="#db_setting" data-toggle="tab"><?php echo esc_html__('Settings', 'wpdbbkp') ?></a></li>
766 690 <li><a href="#searchreplace" style="display:none" data-toggle="tab"><?php echo esc_html__('Search and Replace', 'wpdbbkp') ?></a></li>
@@ -901,9 +825,9 @@
901 825 }else{
902 826 echo '<td>Database</td>';
903 827 }
904 828 echo '<td>';
905 - echo '<a class="btn btn-default" href="' . esc_url( $option['url'] ) . '" style="color: #21759B;border-color:#337ab7;">';
829 + echo '<a class="btn btn-default" href="' . esc_url( admin_url('?wpdbbkp_download='.basename($option['url'])) ) . '" style="color: #21759B;border-color:#337ab7;">';
906 830 echo '<span class="glyphicon glyphicon-download-alt"></span> Download</a></td>';
907 831 echo '<td>' . esc_attr( $this->wp_db_backup_format_bytes( $option['size'] ) ) . '</td>';
908 832 $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 833 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/> ';
@@ -1006,10 +930,10 @@
1006 930 <div class="modal-body">
1007 931 <button type="button" id="offer_close" class="close" data-dismiss="modal" aria-label="Close">
1008 932 <span aria-hidden="true">&times;</span>
1009 933 </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__('Remote Backups offers a secure, reliable and affordable solution to backup your WP site to the cloud.','wpdbbkp');?></p>
934 + <h3 class="modal-title" id="wpdbbkp_offer_modalLabel"><img src="<?php echo esc_attr( WPDB_PLUGIN_URL ); /* phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage */ ?>/assets/images/wp-database-backup.png" width="230px"></h3>
935 + <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 936 <div class="wpdbbkp_offer_container">
1013 937 <div class="wpdbbkp_server">
1014 938 <h4><?php echo esc_html__('Server Backup','wpdbbkp');?></h4>
1015 939 <p><?php echo esc_html__('Backup your site to server','wpdbbkp');?></p>
@@ -1021,9 +945,9 @@
1021 945 <h4><?php echo esc_html__('Free','wpdbbkp');?></h4>
1022 946 <button id="wpdbbkp_server_backup" class="btn btn-secondary"><?php echo esc_html__('Create a Backup on this Server','wpdbbkp');?></button>
1023 947 </div>
1024 948 <div class="wpdbbkp_remote">
1025 - <h4><?php echo esc_html__('Remote Backup','wpdbbkp');?></h4>
949 + <h4><?php echo esc_html__('Cloud Backup','wpdbbkp');?></h4>
1026 950 <p><?php echo esc_html__('Backup your site in the cloud','wpdbbkp');?></p>
1027 951 <ul>
1028 952 <li>&#10004; <?php echo esc_html__('Secure and reliable','wpdbbkp');?></li>
1029 953 <li>&#10004; <?php echo esc_html__('Only pay for what you use','wpdbbkp');?></li>
@@ -1029,9 +953,9 @@
1029 953 <li>&#10004; <?php echo esc_html__('Only pay for what you use','wpdbbkp');?></li>
1030 954 <li>&#10004; <?php echo esc_html__('High availability','wpdbbkp');?></li>
1031 955 </ul>
1032 956 <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 Remote Server','wpdbbkp');?></button>
957 + <button id="wpdbbkp_remote_backup" class="btn btn-primary"><?php echo esc_html__('Create a Backup on Cloud Server','wpdbbkp');?></button>
1034 958 </div>
1035 959
1036 960 </div>
1037 961 </div>
@@ -1049,25 +973,25 @@
1049 973 $anonymization_pass = get_option('bkpforwp_anonymization_pass','');
1050 974 $backup_encryption_pass = get_option('bkpforwp_encryption_pass','');
1051 975 $enable_exact_backup_time = get_option('bkpforwp_enable_exact_backup_time',false);
1052 976 ?>
1053 - <div class="row form-group"><label class="col-sm-3" for="enable_anonymization"><?php esc_html_e('Data Anonymization','backupforwp-pro'); ?></label>
977 + <div class="row form-group"><label class="col-sm-3" for="enable_anonymization"><?php esc_html_e('Data Anonymization','wpdbbkp'); ?></label>
1054 978 <div class="col-sm-9"><input type="checkbox" id="enable_anonymization"
1055 979 name="enable_anonymization" value="1" <?php checked($enable_anonymization,1,1); ?> />
1056 980
1057 981 <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>
982 + <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> <?php esc_html_e('Data anonymization is protecting private or sensitive information by erasing or encrypting identifiers that connect an individual to stored data.','wpdbbkp'); ?><a href="https://backupforwp.com/" target="_blank">Learn More</a></div>
1059 983 </div>
1060 984 </div>
1061 985 <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>
986 + <label class="col-sm-3" for="anonymization_type"><?php esc_html_e('Data Anonymization Type','wpdbbkp'); ?> </label>
1063 987 <div class="col-sm-9"><select id="anonymization_type" class="form-control"
1064 988 name="anonymization_type">
1065 - <option value="masked_data" <?php selected('masked_data', $anonymization_type, true) ?>> <?php esc_html_e('Masked Data','backupforwp-pro'); ?>
989 + <option value="masked_data" <?php selected('masked_data', $anonymization_type, true) ?>> <?php esc_html_e('Masked Data','wpdbbkp'); ?>
1066 990 </option>
1067 - <option value="fake_data" <?php selected('fake_data', $anonymization_type, true) ?>> <?php esc_html_e('Fake Data','backupforwp-pro'); ?>
991 + <option value="fake_data" <?php selected('fake_data', $anonymization_type, true) ?>> <?php esc_html_e('Fake Data','wpdbbkp'); ?>
1068 992 </option>
1069 - <option value="encrypted_data" <?php selected('encrypted_data', $anonymization_type, true) ?>> <?php esc_html_e('Encrypted Data','backupforwp-pro'); ?>
993 + <option value="encrypted_data" <?php selected('encrypted_data', $anonymization_type, true) ?>> <?php esc_html_e('Encrypted Data','wpdbbkp'); ?>
1070 994 </option>
1071 995 </select>
1072 996 <?php echo wp_kses_post('<table class="bkpforwp-infotable">
1073 997 <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>
@@ -1078,24 +1002,24 @@
1078 1002 </div>
1079 1003 </div>
1080 1004
1081 1005 <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>
1006 + <label class="col-sm-3" for="anonymization_pass"><?php esc_html_e('Encrypted Data','wpdbbkp'); ?> <?php esc_html_e('Anonymization Password','wpdbbkp'); ?></label>
1083 1007 <div class="col-sm-9">
1084 1008 <input type="password" name="anonymization_pass" id="anonymization_pass" class="form-control" value="<?php esc_attr($anonymization_pass);?>">
1085 1009 <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>
1010 + <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> <?php esc_html_e('Please enter the encryption password. If you lose this pass then you can not recover the encrypted data','wpdbbkp'); ?></div>
1087 1011 </div>
1088 1012
1089 1013 </div>
1090 1014
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>
1015 + <div class="row form-group" style="display:none"><label class="col-sm-3" for="enable_backup_encryption"><?php esc_html_e('Backup File Encrpytion','wpdbbkp'); ?></label>
1092 1016 <div class="col-sm-9"><input type="checkbox" id="enable_backup_encryption"
1093 1017 name="enable_backup_encryption" value="1" <?php checked($enable_backup_encryption,1,1); ?> /></div>
1094 1018 </div>
1095 1019
1096 1020 <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>
1021 + <label class="col-sm-3" for="backup_encryption_pass"><?php esc_html_e('Backup Password','wpdbbkp'); ?></label>
1098 1022 <div class="col-sm-9">
1099 1023 <input type="password" name="backup_encryption_pass" id="backup_encryption_pass" class="form-control" value="<?php esc_attr($backup_encryption_pass);?>">
1100 1024 </div>
1101 1025 </div>
@@ -1113,9 +1037,9 @@
1113 1037 // 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 1038 if ( ! isset( $_POST['wpdbbackup_update_cd_setting'] ) ) {
1115 1039 wp_die( esc_html__('Invalid form data. form request came from the somewhere else not current site!','wpdbbkp') );
1116 1040 }
1117 - if ( ! wp_verify_nonce( $_POST['wpdbbackup_update_cd_setting'] , 'wpdbbackup-update-cd-setting' ) ) {
1041 + if ( ! wp_verify_nonce( wp_unslash( $_POST['wpdbbackup_update_cd_setting'] ) , 'wpdbbackup-update-cd-setting' ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1118 1042 wp_die( esc_html__('Invalid form data. form request came from the somewhere else not current site!','wpdbbkp') );
1119 1043 }
1120 1044
1121 1045 if ( true === isset( $_POST['wpdb_clouddrive_token'] ) ) {
@@ -1122,9 +1046,9 @@
1122 1046 update_option( 'wpdb_clouddrive_token', wp_db_filter_data( sanitize_text_field( wp_unslash( $_POST['wpdb_clouddrive_token'] ) ) ), false );
1123 1047 }
1124 1048
1125 1049 // Put a "settings updated" message on the screen.
1126 - $update_msg = esc_html__('Your BackupforWP CloudDrive setting has been saved.' , 'wpdbbkp');
1050 + $update_msg = esc_html__('Your BackupforWP Cloud Backup setting has been saved.' , 'wpdbbkp');
1127 1051 }
1128 1052
1129 1053 $wpdb_clouddrive_token = get_option( 'wpdb_clouddrive_token',null);
1130 1054
@@ -1135,14 +1059,14 @@
1135 1059 $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 1060 }
1137 1061
1138 1062 ?>
1139 -<h2 align="center"><strong><?php echo esc_html__('Remote Cloud Backups by BackupforWP', 'wpdbbkp') ?></strong></h2>
1063 +<h2 align="center"><strong><?php echo esc_html__('Cloud Backup by BackupforWP', 'wpdbbkp') ?></strong></h2>
1140 1064 <div class="panel panel-default">
1141 1065 <div class="panel-heading">
1142 1066 <h4 class="panel-title">
1143 1067 <a data-toggle="collapse" data-parent="#accordion" href="#collapsebb">
1144 - <?php echo '<b>'.esc_html__('Remote Backups', 'wpdbbkp').'</b>'; ?> <?php echo wp_kses_post($wpdbbkp_bb_s3_status);?>
1068 + <?php echo '<b>'.esc_html__('Cloud Backup', 'wpdbbkp').'</b>'; ?> <?php echo wp_kses_post($wpdbbkp_bb_s3_status);?>
1145 1069
1146 1070 </a>
1147 1071 </h4>
1148 1072 </div>
@@ -1154,15 +1078,16 @@
1154 1078 ?>
1155 1079 <form class="form-group" name="Clouddrive3" method="post" action="">
1156 1080
1157 1081 <p style="padding:0 20px;">
1158 - <?php echo '<h2 style="padding:0 20px;">'.esc_html__('Getting started with our Remote backup service is simple.', 'wpdbbkp').'</h2>'; ?>
1082 + <?php echo '<h2 style="padding:0 20px;">'.esc_html__('Getting started with our Cloud Backup service is simple.', 'wpdbbkp').'</h2>'; ?>
1159 1083
1160 1084 <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__('Backup for WP CloudDrive', 'wpdbbkp');?> </a></li>
1085 + <li style="margin-left: 30px;"><?php echo esc_html__('Sign up for a free account at', 'wpdbbkp'); ?> <a href="https://backupforwp.com/register" target="_blank"><?php echo esc_html__(' Cloud Backup ', 'wpdbbkp');?> </a><?php echo esc_html__('by Backup for WP', 'wpdbbkp');?></li>
1162 1086 <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 1087 <li style="margin-left: 30px;"><?php echo esc_html__('API token will be generated on adding website.', 'wpdbbkp'); ?></li>
1164 1088 <li style="margin-left: 30px;"><?php echo esc_html__('Copy the token here and Click Save.', 'wpdbbkp'); ?></li>
1089 + <li style="margin-left: 30px;"><b><?php echo esc_html__('You can see your backup files from ', 'wpdbbkp'); ?><a href="https://app.backupforwp.com/dashboard/" target="_blank"><?php echo esc_html__('here', 'wpdbbkp');?> </a></b></li>
1165 1090 </ul>
1166 1091
1167 1092
1168 1093 <input type="hidden" name="wpdb_cd_s3" value="Y">
@@ -1179,9 +1104,8 @@
1179 1104
1180 1105 <p style="padding-left:20px"><input type="submit" name="Submit" class="btn btn-primary" value="<?php esc_attr_e( 'Save' , 'wpdbbkp' ); ?>" />&nbsp;
1181 1106 </p>
1182 1107 </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 1108 </div>
1185 1109 </div>
1186 1110
1187 1111
@@ -1232,9 +1156,9 @@
1232 1156 <div class="panel panel-group panel-default">
1233 1157 <div class="panel-heading">
1234 1158 <a class="toggle_anchor" data-toggle="collapse" data-parent="#accordion" href="#collapsedb">
1235 1159 <h4 class="panel-title">
1236 - <?php esc_attr_e( 'System Check', 'wpdbbk' ); ?>
1160 + <?php esc_attr_e( 'System Check', 'wpdbbkp' ); ?>
1237 1161 </h4>
1238 1162 </a>
1239 1163 </div>
1240 1164 <div id="collapsedb" class="panel-collapse collapse in">
@@ -1333,9 +1257,9 @@
1333 1257 <div class="row list-group-item">
1334 1258 <div class="col-md-1"><a href="" target="_blank" title="Help"><span
1335 1259 class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a>
1336 1260 </div>
1337 - <div class="col-md-3"><?php esc_attr_e( 'Upload directory URL', 'wpdbbk' ); ?></div>
1261 + <div class="col-md-3"><?php esc_attr_e( 'Upload directory URL', 'wpdbbkp' ); ?></div>
1338 1262 <div class="col-md-5">
1339 1263 <?php
1340 1264 $upload_dir = wp_upload_dir();
1341 1265 echo esc_url( $upload_dir['baseurl'] );
@@ -1352,9 +1276,9 @@
1352 1276 <div class="row list-group-item">
1353 1277 <div class="col-md-1"><a href="" target="_blank" title="Help"><span
1354 1278 class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a>
1355 1279 </div>
1356 - <div class="col-md-3"><?php esc_attr_e( 'Upload directory', 'wpdbbk' ); ?></div>
1280 + <div class="col-md-3"><?php esc_attr_e( 'Upload directory', 'wpdbbkp' ); ?></div>
1357 1281 <div class="col-md-5"><?php echo esc_attr( $upload_dir['basedir'] ); ?></div>
1358 1282 <div class="col-md-1">
1359 1283 <?php echo esc_attr( substr( sprintf( '%o', fileperms( $upload_dir['basedir'] ) ), -4 ) ); ?></div>
1360 1284 <div
@@ -1386,9 +1310,9 @@
1386 1310 <div class="row list-group-item">
1387 1311 <div class="col-md-1"><a href="" target="_blank" title="Help"><span
1388 1312 class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a>
1389 1313 </div>
1390 - <div class="col-md-3"><?php esc_attr_e( 'Max Execution Time', 'wpdbbk' ); ?></div>
1314 + <div class="col-md-3"><?php esc_attr_e( 'Max Execution Time', 'wpdbbkp' ); ?></div>
1391 1315 <div class="col-md-5"> <?php echo esc_attr( ini_get( 'max_execution_time' ) ); ?></div>
1392 1316 <div class="col-md-1"></div>
1393 1317 <div
1394 1318 class="col-md-2"><?php echo esc_attr( ini_get( 'max_execution_time' ) ) < 60 ? '<p class="text-danger" data-toggle="tooltip" data-placement="left" title="For large site set high"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Low </p>' : ''; ?></div>
@@ -1396,9 +1320,9 @@
1396 1320 <div class="row list-group-item">
1397 1321 <div class="col-md-1"><a href="" target="_blank" title="Help"><span
1398 1322 class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a>
1399 1323 </div>
1400 - <div class="col-md-3"><?php esc_attr_e( 'Database backup directory', 'wpdbbk' ); ?></div>
1324 + <div class="col-md-3"><?php esc_attr_e( 'Database backup directory', 'wpdbbkp' ); ?></div>
1401 1325 <div
1402 1326 class="col-md-5"> <?php echo esc_attr( $upload_dir['basedir'] . '/db-backup' ); ?></div>
1403 1327 <div
1404 1328 class="col-md-1"><?php echo esc_attr( substr( sprintf( '%o', @fileperms( esc_attr( $upload_dir['basedir'] ) . '/db-backup' ) ), -4 ) ); ?></div>
@@ -1409,9 +1333,9 @@
1409 1333 <div class="row list-group-item">
1410 1334 <div class="col-md-1"><a href="" target="_blank" title="Help"><span
1411 1335 class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a>
1412 1336 </div>
1413 - <div class="col-md-3"><?php esc_attr_e( 'Class ZipArchive Present : ', 'wpdbbk' ); ?></div>
1337 + <div class="col-md-3"><?php esc_attr_e( 'Class ZipArchive Present : ', 'wpdbbkp' ); ?></div>
1414 1338 <div class="col-md-5">
1415 1339 <?php
1416 1340 echo ( class_exists( 'ZipArchive' ) ) ? 'Yes </p>' : '<p class="">No</p>';
1417 1341 ?>
@@ -1422,9 +1346,9 @@
1422 1346 <div class="row list-group-item">
1423 1347 <div class="col-md-1"><a href="" target="_blank" title="Help"><span
1424 1348 class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a>
1425 1349 </div>
1426 - <div class="col-md-3"><?php esc_attr_e( 'mysqldump (cmd) Present : ', 'wpdbbk' ); ?></div>
1350 + <div class="col-md-3"><?php esc_attr_e( 'mysqldump (cmd) Present : ', 'wpdbbkp' ); ?></div>
1427 1351 <div class="col-md-5">
1428 1352 <?php
1429 1353 $wpdb_admin = new Wpdb_Admin();
1430 1354 echo ( $wpdb_admin->get_mysqldump_command_path() ) ? 'Yes </p>' : '<p class="">No</p>';
@@ -1867,9 +1791,9 @@
1867 1791 </p>
1868 1792 <br>
1869 1793 <div class="input-group">
1870 1794 <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">
1795 + <input type="text" name="wp_db_backup_search_text" value="<?php echo esc_html( $wp_db_backup_search_text ); ?>" class="form-control" placeholder="<?php esc_attr_e('https://example.com/wordpress','wpdbbkp'); ?>" aria-describedby="wp_db_backup_search_text">
1872 1796
1873 1797 </div>
1874 1798 <br>
1875 1799 <div class="input-group">
@@ -1882,9 +1806,9 @@
1882 1806 <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
1883 1807 <?php echo esc_html__("Leave blank those fields if you don't want use this feature and want only regular Database backup.", 'wpdbbkp') ?>
1884 1808 <br>
1885 1809 <?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 ?>
1810 + <br><?php echo esc_html__('Search For:', 'wpdbbkp') ?> <?php echo esc_url('http://example.com/wordpress/', 'wpdbbkp'); ?>
1887 1811 <br><?php echo esc_html__('Replace With:', 'wpdbbkp') ?> <?php echo esc_url('http://domain.com/', 'wpdbbkp') ?>
1888 1812
1889 1813 <br><br>
1890 1814 <?php echo esc_html__('Note - This is Search & Replace data in your WordPress Database Backup File not in current Database installation.', 'wpdbbkp') ?>
@@ -2460,9 +2384,8 @@
2460 2384 }
2461 2385 WP_Filesystem();
2462 2386
2463 2387 if(!$wp_filesystem){
2464 - error_log('Could not initialize WP_Filesystem');
2465 2388 return false;
2466 2389 }
2467 2390
2468 2391 wp_mkdir_p($path_info['basedir'] . '/' . WPDB_BACKUPS_DIR);
@@ -2475,22 +2398,22 @@
2475 2398
2476 2399
2477 2400 // Added htaccess file 08-05-2015 for prevent directory listing.
2478 2401 // Fixed Vulnerability 22-06-2016 for prevent direct download.
2479 - if ( 1 === (int) get_option( 'wp_db_backup_enable_htaccess' ) ) {
2480 - $htaccess_content = '#These next two lines will already exist in your .htaccess file
2481 - RewriteEngine On
2482 - RewriteBase /
2483 - # Add these lines right after the preceding two
2484 - RewriteCond %{REQUEST_FILENAME} ^.*(.zip)$
2485 - RewriteCond %{HTTP_COOKIE} !^.*can_download.*$ [NC]
2486 - RewriteRule . - [R=403,L]';
2402 +
2403 + $htaccess_content = '# Disable public access to this folder
2404 +<IfModule mod_authz_core.c>
2405 + Require all denied
2406 +</IfModule>
2407 +
2408 +<IfModule !mod_authz_core.c>
2409 + Deny from all
2410 +</IfModule>';
2487 2411 $wp_filesystem->put_contents( $path_info['basedir'] . '/db-backup/.htaccess', $htaccess_content, FS_CHMOD_FILE );
2488 2412
2489 - }
2490 2413 // Begin : Generate SQL DUMP and save to file database.sql.
2491 2414 $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';
2415 + $wp_db_file_name = $wp_site_name . '_' . gmdate( 'Y_m_d' ) . '_' . time() . '_' . substr( md5( wp_rand(100,9999999) ), 0, 9 ) . '_wpdb';
2493 2416 $sql_filename = $wp_db_file_name . '.sql';
2494 2417 $filename = $wp_db_file_name . '.zip';
2495 2418 $logname = $wp_db_file_name . '.txt';
2496 2419
@@ -2666,9 +2589,9 @@
2666 2589 if(wp_doing_cron() && !$cron_condition){
2667 2590 return false;
2668 2591 }
2669 2592
2670 - set_time_limit( 0 );
2593 + set_time_limit( 0 ); //phpcs:ignore -- increase time limit for backup process.
2671 2594 ignore_user_abort(true);
2672 2595
2673 2596 $details = $this->wp_db_backup_create_archive();
2674 2597 $options = get_option( 'wp_db_backup_backups' );
@@ -2979,9 +2902,9 @@
2979 2902
2980 2903 if ( ! isset( $_POST['wpdbbkp_security_nonce'] ) ){
2981 2904 return;
2982 2905 }
2983 - if ( !wp_verify_nonce( $_POST['wpdbbkp_security_nonce'], 'wpdbbkp-admin-nonce' ) ){
2906 + if ( !wp_verify_nonce( wp_unslash($_POST['wpdbbkp_security_nonce']), 'wpdbbkp-admin-nonce' ) ){ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- used as nonce
2984 2907 return;
2985 2908 }
2986 2909
2987 2910 if( ! current_user_can( 'manage_options' ) ) {
@@ -2987,10 +2910,10 @@
2987 2910 if( ! current_user_can( 'manage_options' ) ) {
2988 2911 return;
2989 2912 }
2990 2913
2991 - $message = $this->wpdbbkp_sanitize_textarea_field($_POST['message']);
2992 - $email = $this->wpdbbkp_sanitize_textarea_field($_POST['email']);
2914 + $message = isset($_POST['message']) ? $this->wpdbbkp_sanitize_textarea_field(wp_unslash($_POST['message'])) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitized using custom function
2915 + $email = isset($_POST['email']) ? $this->wpdbbkp_sanitize_textarea_field(wp_unslash($_POST['email'])) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitized using custom function
2993 2916
2994 2917 if(function_exists('wp_get_current_user')){
2995 2918
2996 2919 $user = wp_get_current_user();
@@ -3029,9 +2952,9 @@
3029 2952 wp_die();
3030 2953 }
3031 2954 public function add_settings_plugin_action_wp( $actions, $plugin_file, $plugin_data, $context ) {
3032 2955 $plugin_actions['settings'] = sprintf(
3033 - '<a href="%s">' . _x( 'Settings', 'wpdbbkp' ) . '</a>',
2956 + '<a href="%s">' . _x( 'Settings', 'Content translation' ,'wpdbbkp' ) . '</a>',
3034 2957 admin_url( 'options-general.php?page=wp-database-backup' )
3035 2958 );
3036 2959 $actions = array_merge( $actions, $plugin_actions );
3037 2960 return $actions;
@@ -3137,12 +3060,11 @@
3137 3060 }
3138 3061
3139 3062 // Zip up $this->root without excludes
3140 3063 else {
3141 - // error_log('without exclude rule');
3064 +
3142 3065 $stderr = shell_exec('cd ' . escapeshellarg($this->get_root()) . ' && ' . escapeshellcmd($this->get_zip_command_path()) . ' -rq ' . escapeshellarg($WPDBFileName) . ' ./' . ' 2>&1');
3143 3066 }
3144 - error_log($stderr);
3145 3067 if (!empty($stderr))
3146 3068 $this->warning($this->get_archive_method(), $stderr);
3147 3069
3148 3070 return $this->verify_archive($WPDBFileName);
@@ -3373,8 +3295,87 @@
3373 3295 return $result !== false;
3374 3296 }
3375 3297
3376 3298 return false;
3299 + }
3300 +
3301 + public function wpdbbkp_cloudbackup_notice(){
3302 + $user_id = get_current_user_id();
3303 + $wpdbbkp_cloudbackup_notice = get_option( 'wpdb_clouddrive_token', false );
3304 +
3305 + if( $wpdbbkp_cloudbackup_notice ){
3306 + return;
3307 + }
3308 + if ( ! current_user_can( 'manage_options' ) ) {
3309 + return;
3310 + }
3311 +
3312 + if ( get_user_meta( $user_id, 'wpdbbkp_cloudbackup_notice_dismissed', true ) ) {
3313 + return;
3314 + }
3315 +
3316 + $nonce = wp_create_nonce( 'wpdbbkp_cloudbackup_notice_dismissed' )
3317 + ?>
3318 + <div class="notice notice-info is-dismissible" id="wpdbbkp_cloudbackup_dismiss">
3319 + <p><?php echo esc_html__('Take a free 14-day trial of BackupforWP Cloud Backup.', 'wpdbbkp').'<a href="'.esc_url('https://backupforwp.com/register?from=plugin_notice').'" target="_blank">'.esc_html__('Get Started in 2 Minutes.', 'wpdbbkp'). '</a>';?></p>
3320 + </div>
3321 + <script type="text/javascript">
3322 + jQuery(document).ready(function($) {
3323 + // Handle dismiss action
3324 + $(document).on('click', '#wpdbbkp_cloudbackup_dismiss .notice-dismiss', function() {
3325 + var ajaxurl = "<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>";
3326 + $.post(ajaxurl, {
3327 + action: 'wpdbbkp_cloudbackup_dismiss_notice',
3328 + nonce: '<?php echo esc_js( $nonce ); ?>'
3329 + });
3330 + });
3331 + });
3332 + </script>
3333 + <?php
3334 + }
3335 + public function wpdbbkp_cloudbackup_dismiss_notice() {
3336 +
3337 +
3338 + if ( ! current_user_can( 'manage_options' ) ) {
3339 + wp_die( esc_html__( 'Permission denied', 'wpdbbkp' ), '', [ 'response' => 403 ] );
3340 + }
3341 +
3342 + // Verify the nonce
3343 + if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['nonce'] ), 'wpdbbkp_cloudbackup_notice_dismissed' ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- using as nonce
3344 + wp_die( esc_html__( 'Invalid nonce', 'wpdbbkp' ), '', [ 'response' => 403 ] );
3345 + }
3346 +
3347 + $user_id = get_current_user_id();
3348 + update_user_meta( $user_id, 'wpdbbkp_cloudbackup_notice_dismissed', 1 );
3349 + wp_die();
3350 + }
3351 +
3352 + public function admin_backup_file_download() {
3353 + if ( ! current_user_can( 'manage_options' ) ) {
3354 + return;
3355 + }
3356 +
3357 + // Check for a specific query parameter, e.g., ?download_backup=filename.zip
3358 + if ( isset( $_GET['wpdbbkp_download'] ) && ! empty( $_GET['wpdbbkp_download'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no form submission
3359 + $path_info = wp_upload_dir();
3360 + $backup_dir = $path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/';
3361 + $file_name = basename( sanitize_text_field( wp_unslash( $_GET['wpdbbkp_download'] ) ) ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no form submission
3362 + $file_path = trailingslashit( $backup_dir ) . $file_name;
3363 +
3364 +
3365 + // Check if file exists
3366 + if ( file_exists( $file_path ) ) {
3367 + // Serve the file
3368 + header( 'Content-Description: File Transfer' );
3369 + header( 'Content-Type: application/octet-stream' );
3370 + header( 'Content-Disposition: attachment; filename="' . $file_name . '"' );
3371 + header( 'Content-Length: ' . filesize( $file_path ) );
3372 + readfile( $file_path ); //phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_readfile -- readfile is used to read the file with buffer
3373 + exit;
3374 + } else {
3375 + wp_die( esc_html__( 'Backup file not found.', 'wpdbbkp' ) );
3376 + }
3377 + }
3377 3378 }
3378 3379
3379 3380 }
3380 3381