function drd_server_key in Drupal Remote Dashboard Server 6.2
Same name and namespace in other branches
- 7.2 drd_server.module \drd_server_key()
This is called to update the excryption keys for this server and all it's domains hosted in the same Drupal installation.
Parameters
string $api:
int $timestamp:
string $langcode:
bool $debug:
string $domainurl:
string $aes_key:
string $aes_cipher:
string $aes_iv:
string $aes_impl:
string $cluster_token:
Return value
string
1 string reference to 'drd_server_key'
- drd_server_xmlrpc in ./
drd_server.module - Implementation of hook_xmlrpc().
File
- ./
drd_server.module, line 292
Code
function drd_server_key($api, $timestamp, $langcode, $debug, $domainurl, $aes_key = '', $aes_cipher = '', $aes_iv = '', $aes_impl = '', $cluster_token = '') {
global $language;
$language->language = $langcode;
_drd_server_debug_mode($debug);
_drd_server_watchdog('AES key change request.');
$allowed = variable_get('drd_allowed_referer', '');
$referer = empty($cluster_token) ? ip_address() : $cluster_token;
if (empty($allowed)) {
_drd_server_watchdog('AES key change request not allowed from anywhere.', array(), WATCHDOG_ALERT);
return drd_server_error(t('Referer (' . $referer . ') not allowed, nothing configured yet.'), DRD_SERVER_ERROR_NO_REFERER);
}
if (strpos($allowed, $referer) === FALSE) {
_drd_server_watchdog('AES key change request unauthorized.', array(), WATCHDOG_ALERT);
return drd_server_error(t('Referer (' . $referer . ') not allowed.'), DRD_SERVER_ERROR_WRONG_REFERER);
}
$aes_keys = variable_get('drd_aes_keys', array());
if (!empty($cluster_token)) {
if (empty($aes_keys[$cluster_token]['cluster_mode']) || empty($aes_keys[$cluster_token]['cluster_ips']) || strpos($aes_keys[$cluster_token]['cluster_ips'], ip_address()) === FALSE) {
_drd_server_watchdog('AES key change request unauthorized due to ip address mismatch.', array(), WATCHDOG_ALERT);
return drd_server_error(t('Referer (' . $referer . ') not allowed from ' . ip_address() . '.'), DRD_SERVER_ERROR_WRONG_REFERER);
}
}
if ($api !== DRD_SERVER_API_VERSION) {
_drd_server_watchdog('Wrong API: %api.', array(
'%api' => $api,
), WATCHDOG_ALERT);
return drd_server_error(t('Wrong API.'), DRD_SERVER_ERROR_WRONG_API);
}
$sites = drd_server_read_sites();
_drd_server_watchdog('AES key change, available domains:<pre>@domains</pre>', array(
'@domains' => print_r($sites, TRUE),
), WATCHDOG_INFO);
if (empty($domainurl)) {
$aes_keys[$referer] = array(
'key' => $aes_key,
'cipher' => $aes_cipher,
'iv' => $aes_iv,
'impl' => $aes_impl,
'cluster_mode' => !empty($cluster_token),
'cluster_ips' => empty($aes_keys[$cluster_token]['cluster_ips']) ? ip_address() : $aes_keys[$cluster_token]['cluster_ips'],
);
variable_set('drd_aes_keys', $aes_keys);
$domainurls = $sites;
}
else {
$domainurls = array(
$domainurl => $sites[$domainurl],
);
}
_drd_server_watchdog('AES key change for the following domains:<pre>@domains</pre>', array(
'@domains' => print_r($domainurls, TRUE),
), WATCHDOG_INFO);
drd_server_key_remote($domainurls, $aes_keys);
return drd_server_result('drd.key', TRUE);
}