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 / Dropbox / dropboxupload.php

dropboxupload.php in WP Database Backup – Unlimited Database & Files Backup by Backup for WP 6.11, at includes/admin/Destination/Dropbox/dropboxupload.php

115 lines 5.0 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 ?>
9 <?php
10
11 require plugin_dir_path( __FILE__ ) . 'DropboxClient.php';
12 if ( isset( $_GET['action'] ) && 'deleteauth' === $_GET['action'] ) {
13 // disable token on dropbox.
14 try {
15 $dropbox = new WPDBBackup_Destination_Dropbox_API();
16 $dropbox->setOAuthTokens( maybe_unserialize( get_option( 'wpdb_dropboxtoken' ) ) );
17 $dropbox->authTokenRevoke();
18 } catch ( Exception $e ) {
19 echo '<div id="message" class="error"><p> Dropbox API: ' . esc_attr( $e->getMessage() ) . ' </p></div>';
20 }
21 update_option( 'wpdb_dropboxtoken', '' , false);
22 wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup&notification=deleteauth' );
23
24 }
25
26 $dropbox = new WPDBBackup_Destination_Dropbox_API( 'dropbox' );
27 $dropbox_auth_url = $dropbox->oAuthAuthorize();
28 if ( true === isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'] , 'wp-database-backup' ) ) {
29 if ( isset( $_POST['wpdb_dropbbox_code'] ) && ! empty( $_POST['wpdb_dropbbox_code'] ) ) {
30 $dropboxtoken = $dropbox->oAuthToken( sanitize_text_field( wp_unslash( $_POST['wpdb_dropbbox_code'] ) ) );
31 $dropboxtoken = update_option( 'wpdb_dropboxtoken', maybe_serialize( $dropboxtoken ) , false);
32 }
33
34 if ( isset( $_POST['wpdb_dropbbox_dir'] ) ) {
35 $dropboxtoken = update_option( 'wpdb_dropbbox_dir', sanitize_text_field( wp_unslash( $_POST['wpdb_dropbbox_dir'] ) ), false );
36 }
37 }
38
39 $wpdb_dropboxtoken = get_option( 'wpdb_dropboxtoken' );
40 $dropboxtoken = ! empty( $wpdb_dropboxtoken ) ? maybe_unserialize( $wpdb_dropboxtoken ) : array();
41
42
43 ?>
44 <form class="form-group" name="form2" method="post" action="">
45
46 <table class="form-table">
47 <tr>
48 <th scope="row"><?php esc_html_e( 'Authentication', 'wpdbbkp' ); ?></th>
49 <td><?php if ( empty( $dropboxtoken['access_token'] ) ) { ?>
50 <span style="color:red;"><?php esc_html_e( 'Not authenticated!', 'wpdbbkp' ); ?></span><br/>&nbsp;
51 <br/>
52 <a class="button secondary" href="http://db.tt/8irM1vQ0" target="_blank"><?php esc_html_e( 'Create Account', 'wpdbbkp' ); ?></a><br/><br/>
53 <?php } else { ?>
54 <span style="color:green;"><?php esc_html_e( 'Authenticated!', 'wpdbbkp' ); ?></span>
55 <?php
56 $dropbox->setOAuthTokens( $dropboxtoken );
57 $info = $dropbox->usersGetCurrentAccount();
58 if ( ! empty( $info['account_id'] ) ) {
59
60 $user = $info['name']['display_name'];
61
62 esc_attr_e( ' with Dropbox of user ', 'wpdbbkp' );
63 echo esc_attr( $user ) . '<br/>';
64 // Quota.
65 $quota = $dropbox->usersGetSpaceUsage();
66 $dropboxfreespase = $quota['allocation']['allocated'] - $quota['used'];
67 echo esc_attr( size_format( $dropboxfreespase, 2 ) );
68 esc_attr_e( ' available on your Dropbox', 'wpdbbkp' );
69
70 }
71 ?>
72 <br><br>
73 <a class="button secondary" href="<?php echo esc_url( site_url() . '/wp-admin/admin.php?page=wp-database-backup&action=deleteauth&_wpnonce=' . $nonce ); ?> " title="<?php esc_html_e( 'Unlink Dropbox Account', 'wpdbbkp' ); ?>"><?php esc_html_e( 'Unlink Dropbox Account', 'wpdbbkp' ); ?></a>
74 <p>Unlink Dropbox Account for local backups.</p>
75 <?php } ?>
76 </td>
77 </tr>
78
79 <?php if ( empty( $dropboxtoken['access_token'] ) ) { ?>
80 <tr>
81 <th scope="row"><label
82 for="id_dropbbox_code"><?php esc_html_e( 'Access to Dropbox', 'wpdbbkp' ); ?></label></th>
83 <td>
84 <input id="id_dropbbox_code" name="wpdb_dropbbox_code" type="text" value="" class="regular-text code"/>&nbsp;
85 <a class="button secondary" href="<?php echo esc_attr( $dropbox_auth_url ); ?>" target="_blank"><?php esc_html_e( 'Get Dropbox auth code ', 'wpdbbkp' ); ?></a>
86 <p>In order to use Dropbox destination you will need to Get Dropbox auth code with your Dropbox
87 account on click 'Get Dropbox auth code' button</p>
88 <p>Enter Dropbox auth code in text box and save changes</p>
89 <p>For local backup leave the setting as it is</p>
90 </td>
91 </tr>
92 <?php } ?>
93 </table>
94
95 <p></p>
96 <table class="form-table">
97 <tr>
98 <th scope="row"><label for="iddropboxdir"><?php esc_html_e( 'Destination Folder', 'wpdbbkp' ); ?></label></th>
99 <td>
100 <input id="wpdb_dropbbox_dir" name="wpdb_dropbbox_dir" type="text" value="<?php echo esc_html( get_option( 'wpdb_dropbbox_dir' ) ); ?>" class="regular-text"/>
101 <p class="description">
102 <?php esc_attr_e( 'Specify a subfolder where your backup archives will be stored. It will be created at the Apps › WP-Database-Backup of your Dropbox. Already exisiting folders with the same name will not be overriden.', 'wpdbbkp' ); ?>
103
104 </p>
105 <p>E.g. backup</p>
106 </td>
107 </tr>
108 </table>
109 <input type="hidden" name="<?php echo esc_html( $hidden_field_name ); ?>" value="Y">
110 <input name="wpdbbackup_update_setting" type="hidden" value="<?php echo esc_attr( wp_create_nonce( 'wpdbbackup-update-setting' ) ); ?>"/>
111 <?php wp_nonce_field( 'wp-database-backup' ); ?>
112
113 <input type="submit" name="Submit" class="btn btn-primary" value="<?php esc_attr_e( 'Save' , 'wpdbbkp' ); ?>"/>&nbsp;
114 </form>
115