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
wasabi.php
197 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_wasabi_template', function () { |
| 14 | |
| 15 | require_once BMI_INCLUDES . '/external/s3.php'; |
| 16 | |
| 17 | $s3 = new S3('wasabi'); |
| 18 | $configs = $s3->retrieveS3Configs(); |
| 19 | $accessKey = $configs['accessKey']; |
| 20 | $secretKey = $configs['secretKey']; |
| 21 | $bucket = $configs['bucket']; |
| 22 | $region = $configs['region']; |
| 23 | $path = $configs['path']; |
| 24 | $shouldBeConnected = false; |
| 25 | $wasabi_regions = $s3->getRegions(); |
| 26 | |
| 27 | |
| 28 | $isEnabled = bmi_get_config('STORAGE::EXTERNAL::WASABI'); |
| 29 | if ($isEnabled === true || $isEnabled === 'true') { |
| 30 | $isEnabled = ' checked'; |
| 31 | } else { |
| 32 | $isEnabled = ''; |
| 33 | } |
| 34 | |
| 35 | ?> |
| 36 | <!-- External: Wasabi --> |
| 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', 'wasabi.svg') ); ?>" alt="logo" class="tab2-img"> |
| 41 | <span class="ml25 title_whereStored">Wasabi</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-wasabi-row" id="bmi-pro-storage-wasabi-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-wasabi-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-wasabi-path" class="input-ftpdrive_storage" type="text" autocomplete="off" |
| 69 | value="<?php echo esc_attr( sanitize_text_field($path) ); ?>" |
| 70 | placeholder="backups/wordpress"> |
| 71 | </div> |
| 72 | </div> |
| 73 | </div> |
| 74 | |
| 75 | <!-- Bucket Name --> |
| 76 | <div class="d-flex"> |
| 77 | <div class="w270" style="margin-top: 23px;"><span>Bucket Name:</span></div> |
| 78 | <div style="width: 305px;"> |
| 79 | <div class="pos-r"> |
| 80 | <input id="bmip-wasabi-bucket" class="input-ftpdrive_storage" type="text" autocomplete="off" |
| 81 | value="<?php echo esc_attr( sanitize_text_field($bucket) ); ?>" |
| 82 | placeholder="my-backup-bucket" required> |
| 83 | </div> |
| 84 | </div> |
| 85 | </div> |
| 86 | |
| 87 | |
| 88 | <!-- Region --> |
| 89 | <div class="d-flex region-container" style="margin-top: 8px;margin-bottom: 6px;"> |
| 90 | <div class="w270" style="margin-top: 12px;"><span>Region:</span> |
| 91 | </div> |
| 92 | <div class="info-dropdown-container"> |
| 93 | <select id="bmip-wasabi-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'; ?>"> |
| 94 | <?php |
| 95 | foreach ($wasabi_regions as $key => $value) { |
| 96 | $selected = ($key === $region) ? 'selected' : ''; |
| 97 | echo '<option value="' . esc_attr( $key ) . '" ' . esc_attr( $selected ) . '>' . esc_html( $value ) . '</option>'; |
| 98 | } |
| 99 | ?> |
| 100 | </select> |
| 101 | </div> |
| 102 | </div> |
| 103 | |
| 104 | <!-- Access Key --> |
| 105 | <div class="d-flex wasabi-access-key-container"> |
| 106 | <div class="w270" style="margin-top: 23px;"><span>Access Key:</span></div> |
| 107 | <div style="width: 305px;"> |
| 108 | <div class="w100 pos-r"> |
| 109 | <input id="bmip-wasabi-access-key" class="input-ftpdrive_storage" type="text" autocomplete="off" |
| 110 | placeholder="Your Wasabi Access Key" required> |
| 111 | </div> |
| 112 | </div> |
| 113 | </div> |
| 114 | |
| 115 | <!-- Secret Key --> |
| 116 | <div class="d-flex wasabi-secret-key-container"> |
| 117 | <div class="w270" style="margin-top: 23px;"><span>Secret Key:</span></div> |
| 118 | <div style="width: 305px;"> |
| 119 | <div class="w100 pos-r"> |
| 120 | <input id="bmip-wasabi-secret-key" class="input-ftpdrive_storage" type="password" autocomplete="off" |
| 121 | placeholder="Your Wasabi Secret Key" required> |
| 122 | </div> |
| 123 | </div> |
| 124 | </div> |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | </div> |
| 130 | |
| 131 | <div id="wasabi-unauthenticated-box" class="container-40 lh30 pt30 pb30"> |
| 132 | <div class="d-flex"> |
| 133 | <div class="w270" style="margin-top: 11px;"> |
| 134 | <span id="wasabi-not-authed-content-box" class="external-storage-not-authed-content"> |
| 135 | Current status: <b>Inactive</b> |
| 136 | </span> |
| 137 | </div> |
| 138 | <div> |
| 139 | <div class="w100 pos-r"> |
| 140 | <a href="#" id="wasabi-connect-btn" class="btn external-storage-btn-connection"><?php esc_html_e("Connect", 'backup-backup'); ?></a> |
| 141 | </div> |
| 142 | </div> |
| 143 | </div> |
| 144 | |
| 145 | <div class="d-flex"> |
| 146 | <blockquote class="bmi-ftpdrive-info"> |
| 147 | Wasabi external storage provides a secure, high-performance, and cost-effective solution for storing your backup files. |
| 148 | With no egress fees or API request charges, Wasabi offers a predictable pricing model with performance that meets or |
| 149 | exceeds comparable S3 storage services. |
| 150 | </blockquote> |
| 151 | </div> |
| 152 | </div> |
| 153 | |
| 154 | <div id="wasabi-authenticated-box" class="container-40 lh30 pt30 pb30"> |
| 155 | <div class="d-flex"> |
| 156 | <div class="w270" style="margin-top: 11px;"> |
| 157 | <span id="wasabi-authed-content-box" class="external-storage-authed-content"> |
| 158 | Current status: <b>Active</b> |
| 159 | </span> |
| 160 | </div> |
| 161 | <div> |
| 162 | <div class="w100 pos-r"> |
| 163 | <a href="#" id="wasabi-disconnect-btn" class="btn external-storage-btn-connection"><?php esc_html_e("Disconnect", 'backup-backup'); ?></a> |
| 164 | </div> |
| 165 | </div> |
| 166 | </div> |
| 167 | </div> |
| 168 | <?php |
| 169 | } else { |
| 170 | ?> |
| 171 | <div class="container-40 lh30 pt30 pb30"> |
| 172 | <div class="center"> |
| 173 | <?php |
| 174 | $missing_extensions = S3::getExtensionRequirements()['errors']['missing_extensions']; |
| 175 | $count = \count($missing_extensions); |
| 176 | if ($count > 1) { |
| 177 | ?> |
| 178 | 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 /> |
| 179 | Without these modules, it's impossible to upload backups to Wasabi.<br /> |
| 180 | If you wish to use this feature, please enable the mentioned modules. |
| 181 | <?php |
| 182 | } elseif ($count === 1) { |
| 183 | ?> |
| 184 | It seems like you don't have the <b><?php echo esc_html( $missing_extensions[0] ); ?></b> extension installed on your server.<br /> |
| 185 | Without this module, it's impossible to upload backups to Wasabi.<br /> |
| 186 | If you wish to use this feature, please enable this module. |
| 187 | <?php |
| 188 | } |
| 189 | ?> |
| 190 | </div> |
| 191 | </div> |
| 192 | <?php |
| 193 | } |
| 194 | ?> |
| 195 | </div> |
| 196 | <?php |
| 197 | }); |