function hosting_ssl_save_key in Hosting 6.2
Same name and namespace in other branches
- 7.4 web_server/ssl/hosting_ssl.nodeapi.inc \hosting_ssl_save_key()
- 7.3 web_server/ssl/hosting_ssl.nodeapi.inc \hosting_ssl_save_key()
Store the SSL Cert key in the database.
1 call to hosting_ssl_save_key()
- hosting_ssl_nodeapi_site_presave in web_server/
ssl/ hosting_ssl.nodeapi.inc
File
- web_server/
ssl/ hosting_ssl.nodeapi.inc, line 245
Code
function hosting_ssl_save_key($node) {
if (empty($node->ssl_enabled)) {
return 0;
}
$client = hosting_get_client($node->client);
if (!empty($node->ssl_key_new)) {
$ssl_key = $node->ssl_key_new;
$result = db_query("SELECT * FROM {hosting_ssl_cert} WHERE ssl_key = '%s'", $ssl_key);
if ($obj = db_fetch_object($result)) {
// update
if ($node->client != null) {
$obj->client = $client->nid;
}
drupal_write_record("hosting_ssl_cert", $obj, 'cid');
$node->ssl_key = $obj->cid;
}
else {
// insert
$obj = new stdClass();
$obj->ssl_key = $ssl_key;
$obj->client = $client->nid;
$obj->status = 0;
drupal_write_record("hosting_ssl_cert", $obj);
if (!hosting_ip_allocate($obj, $node)) {
form_set_error('ssl_key_new', t("Unable to allocate IP address for certificate, disabling SSL. Allocate more IP addresses to this server then try to enable SSL again."));
db_query("DELETE FROM {hosting_ssl_cert} WHERE cid = %d", $obj->cid);
$obj->cid = FALSE;
$node->ssl_enabled = HOSTING_SSL_DISABLED;
}
$node->ssl_key = $obj->cid;
}
return $obj->cid;
}
return $node->ssl_key;
}