Skip to content

Commit 7df8d55

Browse files
committed
marge changes from pro
1 parent 80f54c1 commit 7df8d55

File tree

8 files changed

+1672
-1701
lines changed

8 files changed

+1672
-1701
lines changed

backwpup.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Description: WordPress Backup Plugin
66
* Author: Inpsyde GmbH
77
* Author URI: http://inpsyde.com
8-
* Version: 3.3.3
8+
* Version: 3.3.4
99
* Text Domain: backwpup
1010
* Domain Path: /languages/
1111
* Network: true
@@ -33,8 +33,8 @@
3333

3434
if ( ! class_exists( 'BackWPup' ) ) {
3535

36-
// Don't activate on anything less than PHP 5.2.7 or WordPress 3.8
37-
if ( version_compare( PHP_VERSION, '5.2.7', '<' ) || version_compare( get_bloginfo( 'version' ), '3.8', '<' ) || ! function_exists( 'spl_autoload_register' ) ) {
36+
// Don't activate on anything less than PHP 5.2.7 or WordPress 3.9
37+
if ( version_compare( PHP_VERSION, '5.2.7', '<' ) || version_compare( get_bloginfo( 'version' ), '3.9', '<' ) || ! function_exists( 'spl_autoload_register' ) ) {
3838
require_once ABSPATH . 'wp-admin/includes/plugin.php';
3939
deactivate_plugins( __FILE__ );
4040
die( 'BackWPup requires PHP version 5.2.7 with spl extension or greater and WordPress 3.8 or greater.' );
@@ -73,6 +73,10 @@ private function __construct() {
7373
if ( get_site_option( 'backwpup_version' ) !== self::get_plugin_data( 'Version' ) || ! wp_next_scheduled( 'backwpup_check_cleanup' ) ) {
7474
BackWPup_Install::activate();
7575
}
76+
//load pro features
77+
if ( class_exists( 'BackWPup_Pro' ) ) {
78+
BackWPup_Pro::get_instance();
79+
}
7680
//WP-Cron
7781
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
7882
if ( ! empty( $_GET[ 'backwpup_run' ] ) && class_exists( 'BackWPup_Job' ) ) {

inc/class-destination-s3.php

Lines changed: 128 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,14 @@
22
// Amazon S3 SDK v2.8.27
33
// http://aws.amazon.com/de/sdkforphp2/
44
// https://github.com/aws/aws-sdk-php
5+
// http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
56

67
/**
78
* Documentation: http://docs.amazonwebservices.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html
89
*/
910
class BackWPup_Destination_S3 extends BackWPup_Destinations {
1011

1112

12-
/**
13-
* @param $s3region
14-
* @param string $s3base_url
15-
* @return string
16-
*/
17-
protected function get_s3_base_url( $s3region, $s3base_url = '' ) {
18-
19-
if ( ! empty( $s3base_url ) )
20-
return $s3base_url;
21-
22-
switch ( $s3region ) {
23-
case 'us-east-1':
24-
return 'https://s3.amazonaws.com';
25-
case 'us-west-1':
26-
return 'https://s3-us-west-1.amazonaws.com';
27-
case 'us-west-2':
28-
return 'https://s3-us-west-2.amazonaws.com';
29-
case 'eu-west-1':
30-
return 'https://s3-eu-west-1.amazonaws.com';
31-
case 'eu-central-1':
32-
return 'https://s3-eu-central-1.amazonaws.com';
33-
case 'ap-northeast-1':
34-
return 'https://s3-ap-northeast-1.amazonaws.com';
35-
case 'ap-northeast-2':
36-
return 'https://s3-ap-northeast-2.amazonaws.com';
37-
case 'ap-southeast-1':
38-
return 'https://s3-ap-southeast-1.amazonaws.com';
39-
case 'ap-southeast-2':
40-
return 'https://s3-ap-southeast-2.amazonaws.com';
41-
case 'sa-east-1':
42-
return 'https://s3-sa-east-1.amazonaws.com';
43-
case 'cn-north-1':
44-
return 'https:/cn-north-1.amazonaws.com';
45-
case 'google-storage':
46-
return 'https://storage.googleapis.com';
47-
case 'google-storage-us':
48-
return 'https://storage.googleapis.com';
49-
case 'google-storage-asia':
50-
return 'https://storage.googleapis.com';
51-
case 'dreamhost':
52-
return 'https://objects-us-west-1.dream.io';
53-
case 'greenqloud':
54-
return 'http://s.greenqloud.com';
55-
default:
56-
return '';
57-
}
58-
59-
}
60-
6113
/**
6214
* @return array
6315
*/
@@ -66,7 +18,6 @@ public function option_defaults() {
6618
return array( 's3accesskey' => '', 's3secretkey' => '', 's3bucket' => '', 's3region' => 'us-east-1', 's3base_url' => '', 's3ssencrypt' => '', 's3storageclass' => '', 's3dir' => trailingslashit( sanitize_file_name( get_bloginfo( 'name' ) ) ), 's3maxbackups' => 15, 's3syncnodelete' => TRUE, 's3multipart' => TRUE );
6719
}
6820

69-
7021
/**
7122
* @param $jobid
7223
*/
@@ -85,6 +36,7 @@ public function edit_tab( $jobid ) {
8536
<option value="us-west-2" <?php selected( 'us-west-2', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php esc_html_e( 'Amazon S3: US West (Oregon)', 'backwpup' ); ?></option>
8637
<option value="eu-west-1" <?php selected( 'eu-west-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php esc_html_e( 'Amazon S3: EU (Ireland)', 'backwpup' ); ?></option>
8738
<option value="eu-central-1" <?php selected( 'eu-central-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php esc_html_e( 'Amazon S3: EU (Germany)', 'backwpup' ); ?></option>
39+
<option value="ap-south-1" <?php selected( 'ap-south-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php esc_html_e( 'Amazon S3: Asia Pacific (Mumbai)', 'backwpup' ); ?></option>
8840
<option value="ap-northeast-1" <?php selected( 'ap-northeast-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php esc_html_e( 'Amazon S3: Asia Pacific (Tokyo)', 'backwpup' ); ?></option>
8941
<option value="ap-northeast-2" <?php selected( 'ap-northeast-2', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php esc_html_e( 'Amazon S3: Asia Pacific (Seoul)', 'backwpup' ); ?></option>
9042
<option value="ap-southeast-1" <?php selected( 'ap-southeast-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php esc_html_e( 'Amazon S3: Asia Pacific (Singapore)', 'backwpup' ); ?></option>
@@ -214,6 +166,132 @@ public function edit_tab( $jobid ) {
214166
<?php
215167
}
216168

169+
/**
170+
* @param string $args
171+
*/
172+
public function edit_ajax( $args = '' ) {
173+
174+
$error = '';
175+
$buckets_list = array();
176+
177+
if ( is_array( $args ) ) {
178+
$ajax = FALSE;
179+
}
180+
else {
181+
if ( ! current_user_can( 'backwpup_jobs_edit' ) ) {
182+
wp_die( -1 );
183+
}
184+
check_ajax_referer( 'backwpup_ajax_nonce' );
185+
$args[ 's3accesskey' ] = sanitize_text_field( $_POST[ 's3accesskey' ] );
186+
$args[ 's3secretkey' ] = sanitize_text_field( $_POST[ 's3secretkey' ] );
187+
$args[ 's3bucketselected' ] = sanitize_text_field( $_POST[ 's3bucketselected' ] );
188+
$args[ 's3base_url' ] = esc_url_raw( $_POST[ 's3base_url' ] );
189+
$args[ 's3region' ] = sanitize_text_field( $_POST[ 's3region' ] );
190+
$ajax = TRUE;
191+
}
192+
echo '<span id="s3bucketerror" style="color:red;">';
193+
194+
if ( ! empty( $args[ 's3accesskey' ] ) && ! empty( $args[ 's3secretkey' ] ) ) {
195+
try {
196+
$s3 = Aws\S3\S3Client::factory( array( 'key' => $args[ 's3accesskey' ],
197+
'secret' => BackWPup_Encryption::decrypt( $args[ 's3secretkey' ] ),
198+
'region' => $args[ 's3region' ],
199+
'base_url' => $this->get_s3_base_url( $args[ 's3region' ], $args[ 's3base_url' ]),
200+
'scheme' => 'https',
201+
'ssl.certificate_authority' => BackWPup::get_plugin_data( 'cacert' )
202+
) );
203+
204+
$buckets = $s3->listBuckets();
205+
if ( ! empty( $buckets['Buckets'] ) ) {
206+
$buckets_list = $buckets['Buckets'];
207+
}
208+
while ( ! empty( $vaults['Marker'] ) ) {
209+
$buckets = $s3->listBuckets( array( 'marker' => $buckets['Marker'] ) );
210+
if ( ! empty( $buckets['Buckets'] ) ) {
211+
$buckets_list = array_merge( $buckets_list, $buckets['Buckets'] );
212+
}
213+
}
214+
}
215+
catch ( Exception $e ) {
216+
$error = $e->getMessage();
217+
}
218+
}
219+
220+
if ( empty( $args[ 's3accesskey' ] ) )
221+
_e( 'Missing access key!', 'backwpup' );
222+
elseif ( empty( $args[ 's3secretkey' ] ) )
223+
_e( 'Missing secret access key!', 'backwpup' );
224+
elseif ( ! empty( $error ) && $error == 'Access Denied' )
225+
echo '<input type="text" name="s3bucket" id="s3bucket" value="' . esc_attr( $args[ 's3bucketselected' ] ) . '" >';
226+
elseif ( ! empty( $error ) )
227+
echo esc_html( $error );
228+
elseif ( ! isset( $buckets ) || count( $buckets['Buckets'] ) < 1 )
229+
_e( 'No bucket found!', 'backwpup' );
230+
echo '</span>';
231+
232+
if ( !empty( $buckets_list ) ) {
233+
echo '<select name="s3bucket" id="s3bucket">';
234+
foreach ( $buckets_list as $bucket ) {
235+
echo "<option " . selected( $args[ 's3bucketselected' ], esc_attr( $bucket['Name'] ), FALSE ) . ">" . esc_attr( $bucket['Name'] ) . "</option>";
236+
}
237+
echo '</select>';
238+
}
239+
240+
if ( $ajax ) {
241+
die();
242+
}
243+
}
244+
245+
/**
246+
* @param $s3region
247+
* @param string $s3base_url
248+
* @return string
249+
*/
250+
protected function get_s3_base_url( $s3region, $s3base_url = '' ) {
251+
252+
if ( ! empty( $s3base_url ) )
253+
return $s3base_url;
254+
255+
switch ( $s3region ) {
256+
case 'us-east-1':
257+
return 'https://s3.amazonaws.com';
258+
case 'us-west-1':
259+
return 'https://s3-us-west-1.amazonaws.com';
260+
case 'us-west-2':
261+
return 'https://s3-us-west-2.amazonaws.com';
262+
case 'eu-west-1':
263+
return 'https://s3-eu-west-1.amazonaws.com';
264+
case 'eu-central-1':
265+
return 'https://s3-eu-central-1.amazonaws.com';
266+
case 'ap-south-1':
267+
return 'https://s3-ap-south-1.amazonaws.com';
268+
case 'ap-northeast-1':
269+
return 'https://s3-ap-northeast-1.amazonaws.com';
270+
case 'ap-northeast-2':
271+
return 'https://s3-ap-northeast-2.amazonaws.com';
272+
case 'ap-southeast-1':
273+
return 'https://s3-ap-southeast-1.amazonaws.com';
274+
case 'ap-southeast-2':
275+
return 'https://s3-ap-southeast-2.amazonaws.com';
276+
case 'sa-east-1':
277+
return 'https://s3-sa-east-1.amazonaws.com';
278+
case 'cn-north-1':
279+
return 'https://cn-north-1.amazonaws.com';
280+
case 'google-storage':
281+
return 'https://storage.googleapis.com';
282+
case 'google-storage-us':
283+
return 'https://storage.googleapis.com';
284+
case 'google-storage-asia':
285+
return 'https://storage.googleapis.com';
286+
case 'dreamhost':
287+
return 'https://objects-us-west-1.dream.io';
288+
case 'greenqloud':
289+
return 'http://s.greenqloud.com';
290+
default:
291+
return '';
292+
}
293+
294+
}
217295

218296
/**
219297
* @param $jobid
@@ -599,7 +677,6 @@ public function job_run_archive( BackWPup_Job $job_object ) {
599677
return TRUE;
600678
}
601679

602-
603680
/**
604681
* @param $job_settings array
605682
* @return bool
@@ -658,80 +735,4 @@ function awsgetbucket() {
658735
</script>
659736
<?php
660737
}
661-
662-
/**
663-
* @param string $args
664-
*/
665-
public function edit_ajax( $args = '' ) {
666-
667-
$error = '';
668-
$buckets_list = array();
669-
670-
if ( is_array( $args ) ) {
671-
$ajax = FALSE;
672-
}
673-
else {
674-
if ( ! current_user_can( 'backwpup_jobs_edit' ) ) {
675-
wp_die( -1 );
676-
}
677-
check_ajax_referer( 'backwpup_ajax_nonce' );
678-
$args[ 's3accesskey' ] = sanitize_text_field( $_POST[ 's3accesskey' ] );
679-
$args[ 's3secretkey' ] = sanitize_text_field( $_POST[ 's3secretkey' ] );
680-
$args[ 's3bucketselected' ] = sanitize_text_field( $_POST[ 's3bucketselected' ] );
681-
$args[ 's3base_url' ] = esc_url_raw( $_POST[ 's3base_url' ] );
682-
$args[ 's3region' ] = sanitize_text_field( $_POST[ 's3region' ] );
683-
$ajax = TRUE;
684-
}
685-
echo '<span id="s3bucketerror" style="color:red;">';
686-
687-
if ( ! empty( $args[ 's3accesskey' ] ) && ! empty( $args[ 's3secretkey' ] ) ) {
688-
try {
689-
$s3 = Aws\S3\S3Client::factory( array( 'key' => $args[ 's3accesskey' ],
690-
'secret' => BackWPup_Encryption::decrypt( $args[ 's3secretkey' ] ),
691-
'region' => $args[ 's3region' ],
692-
'base_url' => $this->get_s3_base_url( $args[ 's3region' ], $args[ 's3base_url' ]),
693-
'scheme' => 'https',
694-
'ssl.certificate_authority' => BackWPup::get_plugin_data( 'cacert' )
695-
) );
696-
697-
$buckets = $s3->listBuckets();
698-
if ( ! empty( $buckets['Buckets'] ) ) {
699-
$buckets_list = $buckets['Buckets'];
700-
}
701-
while ( ! empty( $vaults['Marker'] ) ) {
702-
$buckets = $s3->listBuckets( array( 'marker' => $buckets['Marker'] ) );
703-
if ( ! empty( $buckets['Buckets'] ) ) {
704-
$buckets_list = array_merge( $buckets_list, $buckets['Buckets'] );
705-
}
706-
}
707-
}
708-
catch ( Exception $e ) {
709-
$error = $e->getMessage();
710-
}
711-
}
712-
713-
if ( empty( $args[ 's3accesskey' ] ) )
714-
_e( 'Missing access key!', 'backwpup' );
715-
elseif ( empty( $args[ 's3secretkey' ] ) )
716-
_e( 'Missing secret access key!', 'backwpup' );
717-
elseif ( ! empty( $error ) && $error == 'Access Denied' )
718-
echo '<input type="text" name="s3bucket" id="s3bucket" value="' . esc_attr( $args[ 's3bucketselected' ] ) . '" >';
719-
elseif ( ! empty( $error ) )
720-
echo esc_html( $error );
721-
elseif ( ! isset( $buckets ) || count( $buckets['Buckets'] ) < 1 )
722-
_e( 'No bucket found!', 'backwpup' );
723-
echo '</span>';
724-
725-
if ( !empty( $buckets_list ) ) {
726-
echo '<select name="s3bucket" id="s3bucket">';
727-
foreach ( $buckets_list as $bucket ) {
728-
echo "<option " . selected( $args[ 's3bucketselected' ], esc_attr( $bucket['Name'] ), FALSE ) . ">" . esc_attr( $bucket['Name'] ) . "</option>";
729-
}
730-
echo '</select>';
731-
}
732-
733-
if ( $ajax ) {
734-
die();
735-
}
736-
}
737738
}

0 commit comments

Comments
 (0)