PluginProbe
WP Database Backup – Unlimited Database & Files Backup by Backup for WP / 5.9
WP Database Backup – Unlimited Database & Files Backup by Backup for WP v5.9
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 / S3 / s3-form.php

s3-form.php in WP Database Backup – Unlimited Database & Files Backup by Backup for WP 5.9, at includes/admin/Destination/S3/s3-form.php

133 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Destination form.
4 *
5 * @package wpdbbkp
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11 $update_msg = '';
12 if ( true === isset( $_POST['wpdb_amazon_s3'] ) && 'Y' === $_POST['wpdb_amazon_s3'] ) {
13 // Validate that the contents of the form request came from the current site and not somewhere else added 21-08-15 V.3.4.
14 if ( ! isset( $_POST['wpdbbackup_update_amazon_setting'] ) ) {
15 die( '<br><br>Invalid form data. form request came from the somewhere else not current site!' );
16 }
17 if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['wpdbbackup_update_amazon_setting'] ) ), 'wpdbbackup-update-amazon-setting' ) ) {
18 die( '<br><br>Invalid form data. form request came from the somewhere else not current site! ' );
19 }
20
21 // Save the posted value in the database.
22 if ( true === isset( $_POST['wpdb_dest_amazon_s3_bucket'] ) ) {
23 update_option( 'wpdb_dest_amazon_s3_bucket', wp_db_filter_data( sanitize_text_field( wp_unslash( $_POST['wpdb_dest_amazon_s3_bucket'] ) ) ) );
24 }
25 if ( true === isset( $_POST['wpdb_dest_amazon_s3_bucket_key'] ) ) {
26 update_option( 'wpdb_dest_amazon_s3_bucket_key', wp_db_filter_data( sanitize_text_field( wp_unslash( $_POST['wpdb_dest_amazon_s3_bucket_key'] ) ) ) );
27 }
28 if ( true === isset( $_POST['wpdb_dest_amazon_s3_bucket_secret'] ) ) {
29 update_option( 'wpdb_dest_amazon_s3_bucket_secret', wp_db_filter_data( sanitize_text_field( wp_unslash( $_POST['wpdb_dest_amazon_s3_bucket_secret'] ) ) ) );
30 }
31 if ( isset( $_POST['wp_db_backup_destination_s3'] ) ) {
32 update_option( 'wp_db_backup_destination_s3', 1 );
33 } else {
34 update_option( 'wp_db_backup_destination_s3', 0 );
35 }
36 // Put a "settings updated" message on the screen.
37 $update_msg = '<div class="updated"><p><strong>Your amazon s3 setting has been saved.</strong></p></div>';
38 }
39 $wp_db_backup_destination_s3 = get_option( 'wp_db_backup_destination_s3' );
40 ?>
41 <div class="panel panel-default">
42 <div class="panel-heading">
43 <h4 class="panel-title">
44 <a data-toggle="collapse" data-parent="#accordion" href="#collapseAmazon">
45 <h2>Amazon S3</h2>
46
47 </a>
48 </h4>
49 </div>
50 <div id="collapseAmazon" class="panel-collapse collapse in">
51 <div class="panel-body">
52 <?php
53 echo esc_html( $update_msg );
54
55 if ( get_option( 'wpdb_dest_amazon_s3_bucket_key' ) && get_option( 'wpdb_dest_amazon_s3_bucket_secret' ) ) {
56
57 try {
58 if ( ! class_exists( 'S3' ) ) {
59 require_once 'S3.php';
60 }
61
62 // AWS access info.
63 if ( ! defined( 'AWSACCESSKEY' ) ) {
64 define( 'AWSACCESSKEY', get_option( 'wpdb_dest_amazon_s3_bucket_key' ) );
65 }
66 if ( ! defined( 'AWSSECRETKEY' ) ) {
67 define( 'AWSSECRETKEY', get_option( 'wpdb_dest_amazon_s3_bucket_secret' ) );
68 }
69
70 // Check for CURL.
71 if ( ! extension_loaded( 'curl' ) && ! @dl( 'so' === PHP_SHLIB_SUFFIX ? 'curl.so' : 'php_curl.dll' ) ) { // phpcs:ignore
72 echo "ERROR: CURL extension not loaded\n\n";
73 }
74
75 $s3 = new S3( AWSACCESSKEY, AWSSECRETKEY );
76 $result = $s3->listBuckets();
77 if ( get_option( 'wpdb_dest_amazon_s3_bucket' ) ) {
78 if ( false === in_array( get_option( 'wpdb_dest_amazon_s3_bucket' ), $result, true ) ) {
79 echo '<span class="label label-warning">Invalid bucket name or AWS details</span>';
80 }
81 }
82 } catch ( Exception $e ) {
83 echo '<span class="label label-warning">Invalid AWS details</span>';
84 }
85 }
86 ?>
87 <p><a href="http://www.wpseeds.com/wp-database-backup/#amazon" target="_blank"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> Back up WordPress database to Amazon S3.</p>
88 <p>Enter your Amazon S3 details for your offsite backup. Leave these blank for local backups OR Disable Amazon S3 Destination</p>
89 <form class="form-group" name="amazons3" method="post" action="">
90
91 <div class="row form-group">
92 <label class="col-sm-2" for="wp_db_backup_destination_s3">Enable Amazon S3 Destination:</label>
93 <div class="col-sm-6">
94 <input type="checkbox" id="wp_db_backup_destination_s3" <?php echo ( true === isset( $wp_db_backup_destination_s3 ) && 1 === $wp_db_backup_destination_s3 ) ? 'checked' : ''; ?> name="wp_db_backup_destination_s3">
95 </div>
96
97 </div>
98 <input type="hidden" name="wpdb_amazon_s3" value="Y">
99 <input name="wpdbbackup_update_amazon_setting" type="hidden" value="<?php echo esc_attr( wp_create_nonce( 'wpdbbackup-update-amazon-setting' ) ); ?>" />
100 <?php wp_nonce_field( 'wp-database-backup' ); ?>
101 <div class="row form-group">
102 <label class="col-sm-2" for="wpdb_dest_amazon_s3_bucket">Bucket Name:</label>
103 <div class="col-sm-6">
104
105 <input type="text" id="wpdb_dest_amazon_s3_bucket" class="form-control" name="wpdb_dest_amazon_s3_bucket" value="<?php echo esc_html( get_option( 'wpdb_dest_amazon_s3_bucket' ) ); ?>" size="25" placeholder="Buket name">
106 <a href="http://docs.aws.amazon.com/AmazonS3/latest/gsg/CreatingABucket.html" target="_blank"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a>
107 </div>
108 </div>
109
110 <div class="row form-group">
111 <label class="col-sm-2" for="wpdb_dest_amazon_s3_bucket_key">Key:</label>
112 <div class="col-sm-6">
113 <input type="text" id="wpdb_dest_amazon_s3_bucket_key" class="form-control" name="wpdb_dest_amazon_s3_bucket_key" value="<?php echo esc_html( get_option( 'wpdb_dest_amazon_s3_bucket_key' ) ); ?>" size="25" placeholder="your access key id">
114 <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/AWSCredentials.html" target="_blank"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a>
115 </div>
116 </div>
117
118 <div class="row form-group">
119 <label class="col-sm-2" for="wpdb_dest_amazon_s3_bucket_secret">Secret:</label>
120 <div class="col-sm-6">
121 <input type="text" id="wpdb_dest_amazon_s3_bucket_secret" class="form-control" name="wpdb_dest_amazon_s3_bucket_secret" value="<?php echo esc_html( get_option( 'wpdb_dest_amazon_s3_bucket_secret' ) ); ?>" size="25" placeholder="your secret access key">
122 <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/AWSCredentials.html" target="_blank"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a>
123 </div>
124 </div>
125
126 <p><input type="submit" name="Submit" class="btn btn-primary" value="<?php esc_attr_e( 'Save' ); ?>" />&nbsp;
127 </p>
128 </form>
129
130 </div>
131 </div>
132 </div>
133