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
gdrive.php
112 lines
| 1 | <?php |
| 2 | |
| 3 | // Namespace |
| 4 | namespace BMI\Plugin; |
| 5 | use BMI\Plugin\Dashboard as Dashboard; |
| 6 | |
| 7 | // Exit on direct access |
| 8 | if (!defined('ABSPATH')) { |
| 9 | exit; |
| 10 | } |
| 11 | |
| 12 | // Google drive template |
| 13 | add_action('bmi_pro_google_drive_template', function () { |
| 14 | $clinet_token = get_option('bmi_pro_gd_client_id', false); |
| 15 | $site_token = get_option('bmi_pro_gd_token', false); |
| 16 | $shouldBeConnected = false; |
| 17 | if (is_string($site_token) && is_string($clinet_token)) { |
| 18 | $shouldBeConnected = true; |
| 19 | } |
| 20 | |
| 21 | $isEnabled = Dashboard\bmi_get_config('STORAGE::EXTERNAL::GDRIVE'); |
| 22 | if ($isEnabled === true || $isEnabled === 'true') { |
| 23 | $isEnabled = ' checked'; |
| 24 | } else $isEnabled = ''; |
| 25 | |
| 26 | ?> |
| 27 | <!-- External: Google drive --> |
| 28 | <div class="tab2-item d-flex jst-sb ia-center<?php echo (($isEnabled == ' checked') ? ' activeList' : ''); ?>"> |
| 29 | <div class="d-flex ia-center"> |
| 30 | <img src="<?php echo esc_url( $this->get_asset('images', 'google-drive.svg') ); ?>" alt="logo" class="tab2-img"> |
| 31 | <span class="ml25 d-flex ia-center"> |
| 32 | <span class="title_whereStored"><?php esc_html_e("Google Drive", 'backup-backup'); ?></span> |
| 33 | </span> |
| 34 | </div> |
| 35 | <div class="ia-center"> |
| 36 | <div class="b2 bmi-switch"><input type="checkbox" class="checkbox storage-checkbox"<?php echo esc_attr( $isEnabled ); ?> data-toggle="storage-gdrive-row" id="bmi-pro-storage-gdrive-toggle"> |
| 37 | <div class="bmi-knobs"><span></span></div> |
| 38 | <div class="bmi-layer_str"></div> |
| 39 | </div> |
| 40 | </div> |
| 41 | </div> |
| 42 | <div class="bg_grey storage_target" id="storage-gdrive-row"<?php echo (($isEnabled == ' checked') ? '' : ' style="display: none;"'); ?>> |
| 43 | <?php |
| 44 | $disabled_functions = explode(',', ini_get('disable_functions')); |
| 45 | $vA = !in_array('curl_exec', $disabled_functions); |
| 46 | $vB = !in_array('curl_init', $disabled_functions); |
| 47 | |
| 48 | if (function_exists('curl_version') && function_exists('curl_exec') && function_exists('curl_init') && $vA && $vB) { |
| 49 | ?> |
| 50 | |
| 51 | <div class="container-40 lh30 pt30"> |
| 52 | <div class="d-flex"> |
| 53 | <div class="w270" style="margin-top: 23px;"><span>Backup directory path:</span></div> |
| 54 | <div> |
| 55 | <div class="w100 pos-r"> |
| 56 | <input id="bmip-googledrive-path" class="input-googledrive_storage" type="text" value="<?php echo esc_attr( sanitize_text_field(Dashboard\bmi_get_config('STORAGE::EXTERNAL::GDRIVE::DIRNAME')) ); ?>" placeholder="Directory_Name_Of_My_Backups_In_GDrive" autocomplete="off"> |
| 57 | </div> |
| 58 | <div class="mt10"> |
| 59 | <span> |
| 60 | <?php esc_html_e('You can set individual directory name for this website. Allowed characters: 0-9, A-z, _, -', 'backup-backup'); ?><br /> |
| 61 | <?php esc_html_e('If you have any existing backups, will not be moved automatically, they will require you to move them manually or upload once again.', 'backup-backup'); ?><br /> |
| 62 | <?php esc_html_e('You have to allow our plugin to create the directory, otherwise our plugin cannot access files within that directory.', 'backup-backup'); ?> |
| 63 | </span> |
| 64 | </div> |
| 65 | </div> |
| 66 | </div> |
| 67 | </div> |
| 68 | |
| 69 | <div id="gdrive-unauthenticated-box" class="container-40 lh30 pt30 pb30" <?php echo (($shouldBeConnected) ? 'style="display: none;"' : ''); ?>> |
| 70 | <div class="d-flex"> |
| 71 | <div class="w270" style="margin-top: 11px;"><span id="gdrive-not-authed-content-box">Current status: <b>Inactive</b></span></div> |
| 72 | <div> |
| 73 | <div class="w100 pos-r"> |
| 74 | <a href="#" id="gdrive-connect-btn" class="btn"><?php esc_html_e("Connect", 'backup-backup'); ?></a> |
| 75 | </div> |
| 76 | </div> |
| 77 | </div> |
| 78 | <div class="d-flex"> |
| 79 | <blockquote class="bmi-gdrive-info"> |
| 80 | The plugin only asks for the permissions it <i>really</i> needs in order for the feature to work. It can only see or edit the files itself created, <b>no other</b>. If that doesn’t put your mind at ease, you can also always set up a new (empty) Google account (<a href="https://accounts.google.com/signup" target="_blank">here</a>) and then provide access to that. |
| 81 | </blockquote> |
| 82 | </div> |
| 83 | </div> |
| 84 | <div id="gdrive-authenticated-box" class="container-40 lh30 pt30 pb30" <?php echo ((!$shouldBeConnected) ? 'style="display: none;"' : ''); ?>> |
| 85 | |
| 86 | <div class="d-flex"> |
| 87 | <div class="w270" style="margin-top: 11px;"><span id="gdrive-authed-content-box">Current status: <b>Active</b></span></div> |
| 88 | <div> |
| 89 | <div class="w100 pos-r"> |
| 90 | <a href="#" id="gdrive-disconnect-btn" class="btn"><?php esc_html_e("Disconnect", 'backup-backup'); ?></a> |
| 91 | </div> |
| 92 | </div> |
| 93 | </div> |
| 94 | |
| 95 | </div> |
| 96 | <?php |
| 97 | } else { |
| 98 | ?> |
| 99 | <div class="container-40 lh30 pt30 pb30"> |
| 100 | <div class="center"> |
| 101 | It seem like you don't have cURL extension (PHP module) installed on your server.<br /> |
| 102 | Without this module it's impossible to upload backups to Google Drive.<br /> |
| 103 | If you wish to use this feature, please enable cURL module. |
| 104 | </div> |
| 105 | </div> |
| 106 | <?php |
| 107 | } |
| 108 | ?> |
| 109 | </div> |
| 110 | <?php |
| 111 | }); |
| 112 |