Dropbox2
2 years ago
Google
2 years ago
blockui
1 year ago
checkout-embed
1 year ago
cloudfiles
2 years ago
handlebars
2 years ago
images
9 years ago
jquery-ui.dialog.extended
1 year ago
jquery.serializeJSON
5 years ago
jstree
1 year ago
labelauty
1 year ago
pcloud
2 years ago
tether
6 years ago
tether-shepherd
7 years ago
updraftclone
2 years ago
S3.php
2 years ago
S3compat.php
1 year ago
cacert.pem
2 years ago
class-backup-history.php
1 year ago
class-commands.php
1 year ago
class-database-utility.php
2 years ago
class-filesystem-functions.php
1 year ago
class-http-error-descriptions.php
2 years ago
class-job-scheduler.php
3 years ago
class-manipulation-functions.php
2 years ago
class-partialfileservlet.php
5 years ago
class-remote-send.php
2 years ago
class-search-replace.php
3 years ago
class-semaphore.php
3 years ago
class-storage-methods-interface.php
2 years ago
class-updraft-dashboard-news.php
2 years ago
class-updraft-semaphore.php
4 years ago
class-updraftcentral-updraftplus-commands.php
3 years ago
class-updraftplus-encryption.php
2 years ago
class-wpadmin-commands.php
1 year ago
class-zip.php
2 years ago
ftp.class.php
2 years ago
get-cpanel-quota-usage.pl
12 years ago
google-extensions.php
3 years ago
jquery-ui.custom-v1.11.4-1-24-10.min.css
1 year ago
jquery-ui.custom-v1.11.4-1-24-10.min.css.map
1 year ago
jquery-ui.custom-v1.11.4.css
3 years ago
jquery-ui.custom-v1.12.1-1-24-10.min.css
1 year ago
jquery-ui.custom-v1.12.1-1-24-10.min.css.map
1 year ago
jquery-ui.custom-v1.12.1.css
3 years ago
migrator-lite.php
1 year ago
updraft-admin-common-1-24-10.min.js
1 year ago
updraft-admin-common.js
1 year ago
updraft-restorer-skin-compatibility.php
6 years ago
updraft-restorer-skin.php
3 years ago
updraftcentral.php
2 years ago
updraftplus-clone.php
2 years ago
updraftplus-login.php
7 years ago
updraftplus-notices.php
2 years ago
updraftplus-tour.php
2 years ago
updraftvault.php
3 years ago
updraftcentral.php
75 lines
| 1 | <?php |
| 2 | |
| 3 | if (!defined('UPDRAFTPLUS_DIR')) die('No direct access allowed.'); |
| 4 | |
| 5 | if (!class_exists('UpdraftPlus_Login')) require_once('updraftplus-login.php'); |
| 6 | |
| 7 | class UpdraftPlus_UpdraftCentral_Cloud extends UpdraftPlus_Login { |
| 8 | |
| 9 | /** |
| 10 | * Pulls the appropriate message for the given code and translate it before |
| 11 | * returning it to the caller |
| 12 | * |
| 13 | * @internal |
| 14 | * @param string $code The code of the message to pull |
| 15 | * @return string - The translated message |
| 16 | */ |
| 17 | protected function translate_message($code) { |
| 18 | switch ($code) { |
| 19 | case 'generic': |
| 20 | default: |
| 21 | return __('An error has occurred while processing your request.', 'updraftplus').' '.__('The server might be busy or you have lost your connection to the internet at the time of the request.', 'updraftplus').' '.__('Please try again later.', 'updraftplus'); |
| 22 | break; |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Executes login or registration process. Connects and sends request to the UpdraftCentral Cloud |
| 28 | * and returns the response coming from the server |
| 29 | * |
| 30 | * @internal |
| 31 | * @param array $data The submitted form data |
| 32 | * @param boolean $register Indicates whether the current call is for a registration process or not. Defaults to false. |
| 33 | * @return array - The response from the request |
| 34 | */ |
| 35 | protected function login_or_register($data, $register = false) { |
| 36 | global $updraftplus, $updraftcentral_main; |
| 37 | |
| 38 | $action = ($register) ? 'updraftcentral_cloud_register' : 'updraftcentral_cloud_login'; |
| 39 | if (empty($data['site_url'])) $data['site_url'] = trailingslashit(network_site_url()); |
| 40 | |
| 41 | $response = $this->send_remote_request($data, $action); |
| 42 | if (is_wp_error($response)) { |
| 43 | $response = array('error' => true, 'code' => $response->get_error_code(), 'message' => $response->get_error_message()); |
| 44 | } else { |
| 45 | if (isset($response['status'])) { |
| 46 | if (in_array($response['status'], array('authenticated', 'registered'))) { |
| 47 | $response['redirect_url'] = $updraftplus->get_url('mothership').'/?udm_action=updraftcentral_cloud_redirect'; |
| 48 | |
| 49 | if (is_a($updraftcentral_main, 'UpdraftCentral_Main')) { |
| 50 | $response['keys_table'] = $updraftcentral_main->get_keys_table(); |
| 51 | } |
| 52 | |
| 53 | if (!empty($data['addons_options_connect']) && class_exists('UpdraftPlus_Options')) { |
| 54 | UpdraftPlus_Options::update_updraft_option('updraftplus_com_and_udc_connection_success', 1, false); |
| 55 | } |
| 56 | |
| 57 | } else { |
| 58 | if ('error' === $response['status']) { |
| 59 | $response = array( |
| 60 | 'error' => true, |
| 61 | 'code' => isset($response['code']) ? $response['code'] : -1, |
| 62 | 'message' => isset($response['message']) ? $response['message'] : $this->translate_message('generic'), |
| 63 | 'response' => $response |
| 64 | ); |
| 65 | } |
| 66 | } |
| 67 | } else { |
| 68 | $response = array('error' => true, 'message' => $this->translate_message('generic')); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | return $response; |
| 73 | } |
| 74 | } |
| 75 |