function hosting_ssl_nodeapi_site_validate in Hostmaster (Aegir) 6
File
- modules/
hosting/ web_server/ ssl/ hosting_ssl.nodeapi.inc, line 152
Code
function hosting_ssl_nodeapi_site_validate($node, &$form) {
if ($node->ssl_enabled) {
// TODO: find a way to avoid calling this function multiple times in hook_validate
$valid_options = hosting_site_available_options($node);
if ($node->ssl_key == HOSTING_SSL_CUSTOM_KEY) {
if (!strlen($node->ssl_key_new)) {
form_set_error('ssl_key_new', t("The encryption key field is required to enable us to generate a new SSL certificate for your site."));
}
else {
$key = hosting_ssl_filter_key($node->ssl_key_new);
if ($node->ssl_key_new != $key || !strlen($key)) {
form_set_error('ssl_key_new', t("The encryption key field should only contain lower case alpha-numeric and '_', '-' or '.' characters."));
}
if (!ctype_alnum($key[0])) {
form_set_error('ssl_key_new', t("The encryption key field must start with an alpha-numeric character."));
}
if ($key == HOSTING_SSL_CUSTOM_KEY) {
form_set_error('ssl_key_new', t("This encryption key value is reserved for internal use, please choose another"));
}
}
}
else {
if (!in_array($node->ssl_key, $valid_options['ssl_key'])) {
form_set_error('ssl_key', t("You have chosen an invalid SSL key"));
}
}
}
}