PluginProbe
WP Database Backup – Unlimited Database & Files Backup by Backup for WP / 6.11
WP Database Backup – Unlimited Database & Files Backup by Backup for WP v6.11
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
wp-database-backup / includes / admin / Destination / FTP / ftp-form.php

ftp-form.php in WP Database Backup – Unlimited Database & Files Backup by Backup for WP 6.11, at includes/admin/Destination/FTP/ftp-form.php

242 lines 11.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Destination dropboxs
4 *
5 * @package wpdbbkp
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 if ( ! function_exists( 'add_action' ) ) {
13 header( 'Status: 403 Forbidden' );
14 header( 'HTTP/1.1 403 Forbidden' );
15 exit();
16 }
17
18 if ( ! current_user_can( 'manage_options' ) ) {
19 header( 'Status: 403 Forbidden' );
20 header( 'HTTP/1.1 403 Forbidden' );
21 exit();
22 }
23
24 // Variables for the field and option names.
25 $opt_name = 'backupbreeze_ftp_host';
26 $opt_name2 = 'backupbreeze_ftp_user';
27 $opt_name3 = 'backupbreeze_ftp_pass';
28 $opt_name4 = 'backupbreeze_ftp_subdir';
29 $opt_name5 = 'backupbreeze_ftp_prefix';
30 $opt_name6 = 'backupbreeze_add_dir1';
31 $opt_name7 = 'backupbreeze_auto_interval';
32 $opt_name8 = 'backupbreeze_auto_email';
33 $opt_name9 = 'backupbreeze_ftp_port';
34
35 $hidden_field_name = 'backupbreeze_ftp_hidden';
36 $hidden_field_name2 = 'backupbreeze_backup_hidden';
37 $hidden_field_name3 = 'backupbreeze_check_repo';
38 $data_field_name = 'backupbreeze_ftp_host';
39 $data_field_name2 = 'backupbreeze_ftp_user';
40 $data_field_name3 = 'backupbreeze_ftp_pass';
41 $data_field_name4 = 'backupbreeze_ftp_subdir';
42 $data_field_name5 = 'backupbreeze_ftp_prefix';
43 $data_field_name6 = 'backupbreeze_add_dir1';
44 $data_field_name7 = 'backupbreeze_auto_interval';
45 $data_field_name8 = 'backupbreeze_auto_email';
46 $data_field_name9 = 'backupbreeze_ftp_port';
47
48 // Read in existing option value from database.
49 $opt_val = wp_db_filter_data( get_option( $opt_name ) );
50 $opt_val2 = wp_db_filter_data( get_option( $opt_name2 ) );
51 $opt_val3 = wp_db_filter_data( get_option( $opt_name3 ) );
52 $opt_val4 = wp_db_filter_data( get_option( $opt_name4 ) );
53 $opt_val5 = wp_db_filter_data( get_option( $opt_name5 ) );
54 $opt_val6 = wp_db_filter_data( get_option( $opt_name6 ) );
55 $opt_val7 = wp_db_filter_data( get_option( $opt_name7 ) );
56 $opt_val8 = wp_db_filter_data( get_option( $opt_name8 ) );
57 $opt_val9 = wp_db_filter_data( get_option( $opt_name9 ) );
58 $wp_db_backup_destination_ftp = wp_db_filter_data( get_option( 'wp_db_backup_destination_FTP' ) );
59
60 // If user pressed this button, this hidden field will be set to 'Y'.
61 if ( true === isset( $_POST[ $hidden_field_name3 ] ) && 'Y' === $_POST[ $hidden_field_name3 ] ) {
62 // Validate that the contents of the form request came from the current site and not somewhere else added 21-08-15 V.3.4.
63 if ( ! isset( $_POST['wpdbbackup_update_setting'] ) ) {
64 wp_die( esc_html__('Invalid form data. form request came from the somewhere else not current site!','wpdbbkp') );
65 }
66 if ( ! wp_verify_nonce( $_POST['wpdbbackup_update_setting'] , 'wpdbbackup-update-setting' ) ) {
67 wp_die( esc_html__('Invalid form data. form request came from the somewhere else not current site!','wpdbbkp') );
68 }
69 // Read their posted value.
70 if ( true === isset( $_POST[ $data_field_name6 ] ) ) {
71 $opt_val6 = sanitize_text_field( wp_unslash( $_POST[ $data_field_name6 ] ) );
72 }
73 // Save the posted value in the database.
74 if ( true === isset( $_POST[ $opt_val6 ] ) ) {
75 update_option( $opt_name6, wp_db_filter_data( sanitize_text_field( $opt_val6 ) ) , false);
76 }
77 // Put a "settings updated" message on the screen.
78 ?>
79 <div class="updated"><p><strong><?php echo 'Your additional directory has been saved.'; ?></strong></p></div>
80 <?php
81 }
82
83 // If user pressed this button, this hidden field will be set to 'Y'.
84 if ( isset( $_POST[ $hidden_field_name ] ) && 'Y' === $_POST[ $hidden_field_name ] ) {
85 // Validate that the contents of the form request came from the current site and not somewhere else added 21-08-15 V.3.4.
86 if ( ! isset( $_POST['wpdbbackup_update_setting'] ) ) {
87 wp_die( esc_html__('Invalid form data. form request came from the somewhere else not current site!','wpdbbkp') );
88 }
89 if ( ! wp_verify_nonce( $_POST['wpdbbackup_update_setting'] , 'wpdbbackup-update-setting' ) ) {
90 wp_die( esc_html__('Invalid form data. form request came from the somewhere else not current site!','wpdbbkp') );
91 }
92 // Read their posted value.
93 if ( isset( $_POST[ $data_field_name ] ) ) {
94 $opt_val = sanitize_text_field( wp_unslash( $_POST[ $data_field_name ] ) );
95 }
96 if ( isset( $_POST[ $data_field_name2 ] ) ) {
97 $opt_val2 = sanitize_text_field( wp_unslash( $_POST[ $data_field_name2 ] ) );
98 }
99 if ( isset( $_POST[ $data_field_name3 ] ) ) {
100 $opt_val3 = sanitize_text_field( wp_unslash( $_POST[ $data_field_name3 ] ) );
101 }
102 if ( isset( $_POST[ $data_field_name4 ] ) ) {
103 $opt_val4 = sanitize_text_field( wp_unslash( $_POST[ $data_field_name4 ] ) );
104 }
105 if ( isset( $_POST[ $data_field_name5 ] ) ) {
106 $opt_val5 = sanitize_text_field( wp_unslash( $_POST[ $data_field_name5 ] ) );
107 }
108 if ( isset( $_POST[ $data_field_name9 ] ) ) {
109 $opt_val9 = sanitize_text_field( wp_unslash( $_POST[ $data_field_name9 ] ) );
110 }
111
112 // Save the posted value in the database.
113 update_option( $opt_name, wp_db_filter_data( sanitize_text_field( $opt_val ) ) , false);
114 update_option( $opt_name2, wp_db_filter_data( sanitize_text_field( $opt_val2 ) ) , false);
115 update_option( $opt_name3, wp_db_filter_data( sanitize_text_field( $opt_val3 ) ), false );
116 update_option( $opt_name4, wp_db_filter_data( sanitize_text_field( $opt_val4 ) ) , false);
117 if ( isset( $_POST['wp_db_backup_destination_FTP'] ) ) {
118 update_option( 'wp_db_backup_destination_FTP', 1 , false);
119 } else {
120 update_option( 'wp_db_backup_destination_FTP', 0, false );
121 }
122 $wp_db_backup_destination_ftp = wp_db_filter_data( get_option( 'wp_db_backup_destination_FTP' ) );
123 if ( isset( $_POST[ $data_field_name5 ] ) ) {
124 update_option( $opt_name5, wp_db_filter_data( sanitize_text_field( $opt_val5 ) ) , false);
125 }
126 update_option( $opt_name9, wp_db_filter_data( sanitize_text_field( $opt_val9 ) ) , false);
127
128 // Put a "settings updated" message on the screen.
129 ?>
130 <div class="updated"><p><strong><?php esc_html_e( 'Your FTP details have been saved.', 'wpdbbkp' ); ?></strong></p></div>
131 <?php
132 } // end if.
133
134 // If user pressed this button, this hidden field will be set to 'Y'.
135 if ( isset( $_POST[ $hidden_field_name ] ) && 'Test Connection' === $_POST[ $hidden_field_name ] ) {
136 // Validate that the contents of the form request came from the current site and not somewhere else added 21-08-15 V.3.4.
137 if ( ! isset( $_POST['wpdbbackup_update_setting'] ) ) {
138 wp_die( esc_html__('Invalid form data. form request came from the somewhere else not current site!','wpdbbkp') );
139 }
140 if ( ! wp_verify_nonce( $_POST['wpdbbackup_update_setting'] , 'wpdbbackup-update-setting' ) ) {
141 wp_die( esc_html__('Invalid form data. form request came from the somewhere else not current site!','wpdbbkp') );
142 }
143 include plugin_dir_path( __FILE__ ) . 'test-ftp.php';
144 // update all options while we're at it.
145 $opt_val = sanitize_text_field( wp_unslash( $_POST[ $data_field_name ] ) );
146 $opt_val2 = sanitize_text_field( wp_unslash( $_POST[ $data_field_name2 ] ) );
147 $opt_val3 = sanitize_text_field( wp_unslash( $_POST[ $data_field_name3 ] ) );
148 $opt_val4 = sanitize_text_field( wp_unslash( $_POST[ $data_field_name4 ] ) );
149 if ( isset( $_POST[ $data_field_name5 ] ) ) {
150 $opt_val5 = sanitize_text_field( wp_unslash( $_POST[ $data_field_name5 ] ) );
151 }
152 $opt_val9 = sanitize_text_field( wp_unslash( $_POST[ $data_field_name9 ] ) );
153
154 // Save the posted value in the database.
155 update_option( $opt_name, wp_db_filter_data( sanitize_text_field( $opt_val ) ) , false);
156 update_option( $opt_name2, wp_db_filter_data( sanitize_text_field( $opt_val2 ) ), false );
157 update_option( $opt_name3, wp_db_filter_data( sanitize_text_field( $opt_val3 ) ) , false);
158 update_option( $opt_name4, wp_db_filter_data( sanitize_text_field( $opt_val4 ) ) , false);
159 if ( isset( $_POST[ $data_field_name5 ] ) ) {
160 update_option( $opt_name5, wp_db_filter_data( sanitize_text_field( $opt_val5 ) ) , false);
161 }
162 update_option( $opt_name9, wp_db_filter_data( sanitize_text_field( $opt_val9 ) ) , false);
163 $result = backupbreeze_test_ftp();
164
165 if ( 'OK' !== $result ) {
166 ?>
167 <div class="error"><p><strong><?php echo esc_html__('connection has failed!', 'wpdbbkp') ?><br /></strong></p>
168 <?php echo esc_html( $result ) . '<br /><br />'; ?>
169 </div>
170 <?php } else { ?>
171
172 <div class="updated"><p><strong><?php echo esc_html__('Connected to ', 'wpdbbkp') ?><?php echo esc_attr( $opt_val ); ?>, <?php echo esc_html__('for user', 'wpdbbkp') ?> <?php echo esc_attr( $opt_val2 ); ?></strong></p></div>
173 <?php
174 } // end if.
175 } // end if.
176 ?>
177 <style>td, th {
178 padding: 5px;
179 }</style>
180 <p><?php echo esc_html__('Enter your FTP details for your offsite backup repository. Leave these blank for local backups or Disable FTP Destination.', 'wpdbbkp') ?></p>
181 <form class="form-group" name="form1" method="post" action="">
182 <input type="hidden" name="<?php echo esc_attr( $hidden_field_name ); ?>" value="Y">
183 <input name="wpdbbackup_update_setting" type="hidden" value="<?php echo esc_attr( wp_create_nonce( 'wpdbbackup-update-setting' ) ); ?>" />
184 <?php wp_nonce_field( 'wp-database-backup' ); ?>
185
186 <div class="row form-group">
187 <label class="col-sm-2" for="wp_db_backup_destination_FTP"><?php echo esc_html__('Enable FTP Destination:', 'wpdbbkp') ?></label>
188 <div class="col-sm-6">
189 <input type="checkbox" id="wp_db_backup_destination_FTP" <?php echo ( isset( $wp_db_backup_destination_ftp ) && 1 === (int) $wp_db_backup_destination_ftp ) ? 'checked' : ''; ?> name="wp_db_backup_destination_FTP">
190 </div>
191 </div>
192
193 <div class="row form-group">
194 <label class="col-sm-2" for="FTP_host"><?php echo esc_html__('FTP Host:', 'wpdbbkp') ?></label>
195 <div class="col-sm-6">
196 <input type="text" id="FTP_host" class="form-control" name="<?php echo esc_html( $data_field_name ); ?>" value="<?php echo esc_html( $opt_val ); ?>" size="25" placeholder="e.g. ftp.yoursite.com">
197 </div>
198 </div>
199
200 <div class="row form-group">
201 <label class="col-sm-2" for="FTP_port"><?php echo esc_html__('FTP Port:', 'wpdbbkp') ?></label>
202 <div class="col-sm-2">
203 <input type="text" id="FTP_port" class="form-control" name="<?php echo esc_html( $data_field_name9 ); ?>" value="<?php echo esc_html( $opt_val9 ); ?>" size="4">
204 </div>
205 <div class="col-sm-4">
206 <em><?php echo esc_html__('defaults to 21 if left blank', 'wpdbbkp') ?> </em>
207 </div>
208 </div>
209
210 <div class="row form-group">
211 <label class="col-sm-2" for="FTP_user"><?php echo esc_html__('FTP User:', 'wpdbbkp') ?></label>
212 <div class="col-sm-6">
213 <input type="text" id="FTP_user" class="form-control" name="<?php echo esc_html( $data_field_name2 ); ?>" value="<?php echo esc_html( $opt_val2 ); ?>" size="25">
214 </div>
215 </div>
216
217 <div class="row form-group">
218 <label class="col-sm-2" for="FTP_password"><?php echo esc_html__('FTP Password:', 'wpdbbkp') ?></label>
219 <div class="col-sm-6">
220 <input type="password" id="FTP_password" class="form-control" name="<?php echo esc_html( $data_field_name3 ); ?>" value="<?php echo esc_html( $opt_val3 ); ?>" size="25">
221 </div>
222 </div>
223
224 <div class="row form-group">
225 <label class="col-sm-2" for="FTP_dir"><?php echo esc_html__('Subdirectory:', 'wpdbbkp') ?></label>
226 <div class="col-sm-6">
227 <input type="text" id="FTP_dir" placeholder="e.g. /httpdocs/backups" class="form-control" name="<?php echo esc_html( $data_field_name4 ); ?>" value="<?php echo esc_html( $opt_val4 ); ?>" size="25">
228 </div>
229 <div class="col-sm-4">
230 <em><?php echo esc_html__('e.g. /httpdocs/backups or leave blank', 'wpdbbkp') ?></em>
231 </div>
232 </div>
233
234 <p><input type="submit" name="Submit" class="btn btn-primary" value="<?php esc_attr_e( 'Save' , 'wpdbbkp' ); ?>" />&nbsp;
235 <input type="submit" name="<?php echo esc_html( $hidden_field_name ); ?>" class="btn btn-secondary" value="Test Connection" />
236
237 <br />
238 </p>
239 </form>
240 <hr />
241 <br />
242