PluginProbe ʕ •ᴥ•ʔ
Backup Migration / 2.1.2
Backup Migration v2.1.2
2.1.6 2.1.5.2 trunk 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.6.1 1.4.7 1.4.8 1.4.9 1.4.9.1 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.5.1
backup-backup / includes / bodies / storage / aws.php
backup-backup / includes / bodies / storage Last commit date
aws.php 3 months ago backupbliss.php 3 months ago dropbox.php 3 months ago ftp.php 3 months ago gdrive.php 3 months ago wasabi.php 3 months ago
aws.php
229 lines
1 <?php
2
3 // Namespace
4 namespace BMI\Plugin\Dashboard;
5
6 // use S3
7 use BMI\Plugin\External\BMI_External_S3 as S3;
8 // Exit on direct access
9 if (!defined('ABSPATH')) {
10 exit;
11 }
12
13 add_action('bmi_pro_aws_s3_template', function () {
14
15 require_once BMI_INCLUDES . '/external/s3.php';
16 //HERE
17 $s3 = new S3('aws');
18 $configs = $s3->retrieveS3Configs();
19 $accessKey = $configs['accessKey'];
20 $secretKey = $configs['secretKey'];
21 $bucket = $configs['bucket'];
22 $storageClass = $configs['storageClass'];
23 $region = $configs['region'];
24 $sse = $configs['sse'];
25 $path = $configs['path'];
26 $shouldBeConnected = false;
27 $s3_regions = $s3->getRegions();
28 $isEnabled = bmi_get_config('STORAGE::EXTERNAL::AWS');
29 if ($isEnabled === true || $isEnabled === 'true') {
30 $isEnabled = ' checked';
31 } else {
32 $isEnabled = '';
33 }
34
35 ?>
36 <!-- External: S3 -->
37 <div class="tab2-item d-flex jst-sb ia-center<?php echo (($isEnabled == ' checked') ? ' activeList' : ''); ?>">
38
39 <div class="d-flex ia-center">
40 <img src="<?php echo esc_url( $this->get_asset('images', 'Amazon.svg') ); ?>" alt="logo" class="tab2-img">
41 <span class="ml25 title_whereStored">Amazon S3</span>
42 </div>
43
44 <div class="ia-center">
45 <div class="b2 bmi-switch">
46 <input type="checkbox" class="checkbox storage-checkbox" <?php echo esc_attr( $isEnabled ); ?>
47 data-toggle="storage-s3-row" id="bmi-pro-storage-aws-toggle">
48 <div class="bmi-knobs"><span></span></div>
49 <div class="bmi-layer_str"></div>
50 </div>
51 </div>
52
53 </div>
54
55 <div class="bg_grey storage_target" id="storage-s3-row" <?php echo (($isEnabled == ' checked') ? '' : ' style="display: none;"'); ?>>
56 <?php
57
58 if (S3::hasRequiredExtensions()) {
59 ?>
60
61 <div class="container-40 lh30 pt30">
62
63 <!-- Backup Directory Path -->
64 <div class="d-flex">
65 <div class="w270" style="margin-top: 23px;"><span>Backup Directory Path:</span></div>
66 <div class="w100 pos-r">
67 <div class="w100 pos-r">
68 <input id="bmip-aws-path" class="input-ftpdrive_storage" type="text" autocomplete="off"
69 value="<?php echo esc_attr( sanitize_text_field($path) ); ?>"
70 <?php echo ($shouldBeConnected) ? ' readonly ' : ''; ?>
71 placeholder="backups/wordpress">
72 </div>
73 </div>
74 </div>
75
76 <!-- Access Key -->
77 <?php if (! $shouldBeConnected) { ?>
78 <div class="d-flex aws-access-key-container">
79 <div class="w270" style="margin-top: 23px;"><span>Access Key:</span></div>
80 <div style="width: 305px;">
81 <div class="w100 pos-r">
82 <input id="bmip-aws-access-key" class="input-ftpdrive_storage" type="text" autocomplete="off"
83 placeholder="Your S3 Access Key" required>
84 </div>
85 </div>
86 </div>
87
88 <!-- Secret Key -->
89 <div class="d-flex aws-secret-key-container">
90 <div class="w270" style="margin-top: 23px;"><span>Secret Key:</span></div>
91 <div style="width: 305px;">
92 <div class="w100 pos-r">
93 <input id="bmip-aws-secret-key" class="input-ftpdrive_storage" type="password" autocomplete="off"
94 placeholder="Your S3 Secret Key" required>
95 </div>
96 </div>
97 </div>
98 <?php } ?>
99
100 <!-- Bucket Name -->
101 <div class="d-flex">
102 <div class="w270" style="margin-top: 23px;"><span>Bucket Name:</span></div>
103 <div style="width: 305px;">
104 <div class="pos-r">
105 <input id="bmip-aws-bucket" class="input-ftpdrive_storage" type="text" autocomplete="off" <?php echo ($shouldBeConnected) ? 'readonly' : ''; ?>
106 value="<?php echo esc_attr( sanitize_text_field($bucket) ); ?>"
107 placeholder="my-backup-bucket" required>
108 </div>
109 </div>
110 </div>
111
112 <!-- Region -->
113 <?php if (! $shouldBeConnected) { ?>
114 <div class="d-flex region-container" style="margin-top: 8px;margin-bottom: 17px;">
115 <div class="w270" style="margin-top: 8px;"><span>Region:</span>
116 </div>
117 <div class="info-dropdown-container">
118 <select id="bmip-aws-region" class="input-ftpdrive_storage" required data-def="<?php echo esc_attr( sanitize_text_field($region) ); ?>" data-width="255" data-classes="pt-5 pb-5" data-readonly="<?php echo ($shouldBeConnected) ? 'true' : 'false'; ?>">
119 <?php
120 foreach ($s3_regions as $key => $value) {
121 $selected = ($key === $region) ? 'selected' : '';
122 echo '<option value="' . esc_attr( $key ) . '" ' . esc_attr( $selected ) . '>' . esc_html( $value ) . '</option>';
123 }
124 ?>
125 </select>
126 </div>
127 </div>
128 <?php } ?>
129
130 <!-- Storage Class -->
131 <div class="d-flex" style="margin-top: 8px;">
132 <div class="w270" style="margin-top:8px"><span>Storage Class:</span></div>
133 <div class="info-dropdown-container flex-here baseline" style="gap: 5px">
134 <div class="w100 pos-r">
135 <select id="bmip-aws-storage-class" class="input-ftpdrive_storage" required data-def="<?php echo esc_attr( sanitize_text_field($storageClass) ); ?>" data-width="255" data-classes="pt-5 pb-5" data-readonly="<?php echo ($shouldBeConnected) ? 'true' : 'false'; ?>">
136 <option value="STANDARD">Standard</option>
137 <option value="STANDARD_IA">Standard-IA</option>
138 <option value="REDUCED_REDUNDANCY">Reduced Redundancy</option>
139 </select>
140 </div>
141 <span class="bmi-info-icon tooltip" tooltip="<?php esc_attr_e('Storage classes are different levels of redundancy and availability for your data. Standard is the default class, while Standard-IA and Reduced Redundancy are lower-cost options with different availability and durability characteristics.', 'backup-backup'); ?>"></span>
142
143 </div>
144 </div>
145
146 <!-- Server-side Encryption -->
147 <div class="d-flex mb8 mt8 baseline" style="margin-top: 16px;">
148 <div class="w270" style="margin-top:8px"><span>Server-side Encryption:</span></div>
149 <div class="info-dropdown-container flex-here baseline" style="gap: 8px">
150 <div class="w100 pos-r">
151 <label class="checkbox-container" <?php echo ($shouldBeConnected) ? 'style="cursor: not-allowed;"' : ''; ?>>
152 <input type="checkbox" id="bmip-aws-sse" class="input-ftpdrive_storage" value="AES256" <?php echo ( $sse === 'AES256') ? 'checked' : ''; ?> <?php echo ($shouldBeConnected) ? 'disabled style="cursor: not-allowed;"' : ''; ?>>
153 <span class="checkmark"></span>
154 <span class="checkbox-label">Enable AES-256 encryption</span>
155 </label>
156 </div>
157 <span class="bmi-info-icon tooltip" tooltip="<?php esc_attr_e('Server-side encryption (SSE) is a feature that automatically encrypts data before it is written to disk. This feature helps protect your data at rest.', 'backup-backup'); ?>"></span>
158 </div>
159 </div>
160
161 </div>
162
163 <div id="aws-unauthenticated-box" class="container-40 lh30 pt30 pb30" <?php echo (($shouldBeConnected) ? 'style="display: none;"' : ''); ?>>
164 <div class="d-flex">
165 <div class="w270" style="margin-top: 11px;">
166 <span id="s3drive-not-authed-content-box" class="external-storage-not-authed-content">
167 Current status:&nbsp;<b>Inactive</b>
168 </span>
169 </div>
170 <div>
171 <div class="w100 pos-r">
172 <a href="#" id="aws-connect-btn" class="btn external-storage-btn-connection"><?php esc_html_e("Connect", 'backup-backup'); ?></a>
173 </div>
174 </div>
175 </div>
176
177 <div class="d-flex">
178 <blockquote class="bmi-ftpdrive-info">
179 Amazon S3 external storage provides a secure, durable, and scalable solution for storing your backup files.
180 With various storage classes and regions available, you can optimize for both cost and performance while
181 ensuring your backups are safely stored in the cloud.
182 </blockquote>
183 </div>
184 </div>
185
186 <div id="aws-authenticated-box" class="container-40 lh30 pt30 pb30" <?php echo (($shouldBeConnected) ? '' : 'style="display: none;"'); ?>>
187 <div class="d-flex">
188 <div class="w270" style="margin-top: 11px;">
189 <span id="s3drive-authed-content-box" class="external-storage-authed-content">
190 Current status:&nbsp;<b>Active</b>
191 </span>
192 </div>
193 <div>
194 <div class="w100 pos-r">
195 <a href="#" id="aws-disconnect-btn" class="btn external-storage-btn-connection"><?php esc_html_e("Disconnect", 'backup-backup'); ?></a>
196 </div>
197 </div>
198 </div>
199 </div>
200 <?php
201 } else {
202 ?>
203 <div class="container-40 lh30 pt30 pb30">
204 <div class="center">
205 <?php
206 $missing_extensions = S3::getExtensionRequirements()['errors']['missing_extensions'];
207 $count = \count($missing_extensions);
208 if ($count > 1) {
209 ?>
210 It seems like you don't have the following PHP extensions installed on your server: <b><?php echo esc_html( implode(', ', $missing_extensions) ); ?></b>.<br />
211 Without these modules, it's impossible to upload backups to Amazon S3.<br />
212 If you wish to use this feature, please enable the mentioned modules.
213 <?php
214 } elseif ($count === 1) {
215 ?>
216 It seems like you don't have the <b><?php echo esc_html( $missing_extensions[0] ); ?></b> extension installed on your server.<br />
217 Without this module, it's impossible to upload backups to Amazon S3.<br />
218 If you wish to use this feature, please enable this module.
219 <?php
220 }
221 ?>
222 </div>
223 </div>
224 <?php
225 }
226 ?>
227 </div>
228 <?php
229 });