PluginProbe
UpdraftPlus: WP Backup & Migration Plugin / 1.16.43
UpdraftPlus: WP Backup & Migration Plugin v1.16.43
1.26.7 1.26.6 1.26.5 1.26.4 1.26.3 1.9.19 1.9.25 1.9.26 1.9.30 1.9.31 1.9.32 1.9.4 1.9.40 1.9.41 1.9.42 1.9.43 1.9.44 1.9.45 1.9.46 1.9.5 1.9.50 1.9.51 1.9.60 1.9.62 1.9.63 All 371 releases
updraftplus / includes / updraftcentral.php

updraftcentral.php in UpdraftPlus: WP Backup & Migration Plugin 1.16.43, at includes/updraftcentral.php

75 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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. The server might be busy or you have lost your connection to the internet at the time of the request. 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