retrieve_show_message('updraftcentral_connection', true); ?>
retrieve_show_message('updraftcentral_connection_successful', true);
} else {
?>
retrieve_show_message('updraftcentral_connection_failed', true); ?>
retrieve_show_message('unknown_key', true);
break;
case 'not_logged_in':
echo esc_html($updraftcentral_host_plugin->retrieve_show_message('not_logged_in')).' ';
$updraftcentral_host_plugin->retrieve_show_message('must_visit_url', true);
break;
case 'nonce_failure':
$updraftcentral_host_plugin->retrieve_show_message('security_check', true);
$updraftcentral_host_plugin->retrieve_show_message('must_visit_link', true);
break;
case 'already_have':
$updraftcentral_host_plugin->retrieve_show_message('connection_already_made', true);
break;
case 'insufficient_privilege':
$updraftcentral_host_plugin->retrieve_show_message('insufficient_privilege', true);
break;
default:
echo esc_html(print_r($result, true));
break;
}
}
?>
retrieve_show_message('close', true); ?>
'error', 'code' => 'not_logged_in');
}
$global_get_wp_nonce = UpdraftPlus_Manipulation_Functions::fetch_superglobal('get', '_wpnonce');
if (empty($global_get_wp_nonce) || !wp_verify_nonce($global_get_wp_nonce, 'updraftcentral_receivepublickey')) return array('responsetype' => 'error', 'code' => 'nonce_failure');
$updraft_key_index = UpdraftPlus_Manipulation_Functions::fetch_superglobal('get', 'updraft_key_index');
$our_keys = $this->get_central_localkeys();
if (!is_array($our_keys)) $our_keys = array();
if ('' === $updraft_key_index || is_null($updraft_key_index) || !isset($our_keys[$updraft_key_index])) {
return array('responsetype' => 'error', 'code' => 'unknown_key');
}
if (!empty($our_keys[$updraft_key_index]['publickey_remote'])) {
return array('responsetype' => 'error', 'code' => 'already_have');
}
$public_key = UpdraftPlus_Manipulation_Functions::fetch_superglobal('get', 'public_key');
$our_keys[$updraft_key_index]['publickey_remote'] = base64_decode(UpdraftPlus_Manipulation_Functions::wp_unslash($public_key));
$this->update_central_localkeys($our_keys, true, 'no');
return array('responsetype' => 'ok', 'code' => 'ok');
}
/**
* Action parameters, from udrpc: $message, $level, $this->key_name_indicator, $this->debug, $this
*
* @param string $message The log message
* @param string $level Log level
* @param string $key_name_indicator This indicates the key name
*/
public function udrpc_log($message, $level, $key_name_indicator) {
$udrpc_log = get_site_option('updraftcentral_client_log');
if (!is_array($udrpc_log)) $udrpc_log = array();
$new_item = array(
'time' => time(),
'level' => $level,
'message' => $message,
'key_name_indicator' => $key_name_indicator
);
$server_remote_addr = UpdraftPlus_Manipulation_Functions::fetch_superglobal('server', 'REMOTE_ADDR');
$server_http_user_agent = UpdraftPlus_Manipulation_Functions::fetch_superglobal('server', 'HTTP_USER_AGENT');
$server_http_x_secondary_user_agent = UpdraftPlus_Manipulation_Functions::fetch_superglobal('server', 'HTTP_X_SECONDARY_USER_AGENT');
if (!empty($server_remote_addr)) {
$new_item['remote_ip'] = $server_remote_addr;
}
if (!empty($server_http_user_agent)) {
$new_item['http_user_agent'] = $server_http_user_agent;
}
if (!empty($server_http_x_secondary_user_agent)) {
$new_item['http_secondary_user_agent'] = $server_http_x_secondary_user_agent;
}
$udrpc_log[] = $new_item;
if (count($udrpc_log) > 50) array_shift($udrpc_log);
update_site_option('updraftcentral_client_log', $udrpc_log);
}
/**
* Delete UpdraftCentral Key
*
* @param array $key_id key_id of UpdraftCentral
*
* @return array which contains deleted flag and key table. If error, Returns array which contains fatal_error flag and fatal_error_message
*/
public function delete_key($key_id) {
$our_keys = $this->get_central_localkeys();
if (is_array($key_id) && isset($key_id['key_id'])) {
$key_id = $key_id['key_id'];
}
if (!is_array($our_keys)) $our_keys = array();
if (isset($our_keys[$key_id])) {
unset($our_keys[$key_id]);
$this->update_central_localkeys($our_keys);
}
return array('deleted' => 1, 'keys_table' => $this->get_keys_table());
}
/**
* Get UpdraftCentral Log
*
* @return array which contains log_contents. If error, Returns array which contains fatal_error flag and fatal_error_message
*/
public function get_log() {
global $updraftcentral_host_plugin;
$udrpc_log = get_site_option('updraftcentral_client_log');
if (!is_array($udrpc_log)) $udrpc_log = array();
$log_contents = '';
// Events are appended to the array in the order they happen. So, reversing the order gets them into most-recent-first order.
rsort($udrpc_log);
if (empty($udrpc_log)) {
$log_contents = ''.sprintf($updraftcentral_host_plugin->retrieve_show_message('need_to_copy_key'), 'UpdraftCentral dashboard').'
'.$updraftcentral_host_plugin->retrieve_show_message('press_add_site_button').'
'.sprintf($updraftcentral_host_plugin->retrieve_show_message('detailed_instructions'), 'teamupdraft.com').'
';
} else {
$created['keys_guide'] .= '