get_url('mothership').'/?udm_action='.$action, array( 'timeout' => 20, 'headers' => apply_filters('updraftplus_auth_headers', ''), 'body' => $data ) ); // If we got an error then we return the WP_Error object itself // and let the caller handle it. if (is_wp_error($result)) return $result; $response = json_decode(wp_remote_retrieve_body($result), true); if (!is_array($response) || !isset($response['mothership']) || !isset($response['status'])) { if (preg_match('/has banned your IP address \(([\.:0-9a-f]+)\)/', $result['body'], $matches)) { return new WP_Error('banned_ip', sprintf(__("UpdraftPlus.com has responded with 'Access Denied'.", 'updraftplus').'
'.__("It appears that your web server's IP Address (%s) is blocked.", 'updraftplus').' '.__('This most likely means that you share a webserver with a hacked website that has been used in previous attacks.', 'updraftplus').'
'.__('To remove the block, please go here.', 'updraftplus').' ', $matches[1])); } else { return new WP_Error('unknown_response', sprintf(__('UpdraftPlus.Com returned a response which we could not understand (data: %s)', 'updraftplus'), wp_remote_retrieve_body($result))); } } return $response; } /** * The ajax based request point of entry for the login process * * @param array $data - The submitted form data * @param boolean $echo_results - Whether to echo/display the results directly to the user or assign it to a variable * @return array - Response of the process */ public function ajax_process_login($data = array(), $echo_results = true) { try { if (isset($data['form_data'])) { if (is_string($data['form_data'])) { parse_str($data['form_data'], $form_data); } elseif (is_array($data['form_data'])) { $form_data = $data['form_data']; } } $response = $this->login_or_register($form_data); } catch (Exception $e) { $response = array('error' => true, 'message' => $e->getMessage()); } if ($echo_results) { echo json_encode($response); } else { return $response; } } /** * The ajax based request point of entry for the registration process * * @param array $data - The submitted form data * @param boolean $echo_results - Whether to echo/display the results directly to the user or assign it to a variable * @return array - Response of the process */ public function ajax_process_registration($data = array(), $echo_results = true) { try { if (isset($data['form_data'])) parse_str($data['form_data'], $form_data); $response = $this->login_or_register($form_data, true); } catch (Exception $e) { $response = array('error' => true, 'message' => $e->getMessage()); } if ($echo_results) { echo json_encode($response); } else { return $response; } } }