function imageinfo_cache_admin_form_validate in Imageinfo Cache 6.2
Same name and namespace in other branches
- 6 imageinfo_cache.admin.inc \imageinfo_cache_admin_form_validate()
validate imageinfo_cache_admin_form submissions.
File
- ./
imageinfo_cache.admin.inc, line 89 - Configuration page for imageinfo cache module.
Code
function imageinfo_cache_admin_form_validate($form, &$form_state) {
$values = $form_state['values'];
// Check that imageinfo_cache_async_max is a positive interger.
if (empty($values['imageinfo_cache_async_max']) || !is_numeric($values['imageinfo_cache_async_max']) || $values['imageinfo_cache_async_max'] < 1) {
form_set_error('imageinfo_cache_async_max', t('Number must be a positive interger.'));
}
// If the IP field is not blank, check that its a valid address.
if (!empty($values['imageinfo_cache_server_addr'])) {
// Not an IP address
if (ip2long($values['imageinfo_cache_server_addr']) === FALSE) {
// Not a valid hostname
if (ip2long(gethostbyname($values['imageinfo_cache_server_addr'])) === FALSE) {
form_set_error('imageinfo_cache_server_addr', t('Must be a valid IP address OR server name.') . gethostbyname($values['imageinfo_cache_server_addr']));
}
}
}
if (empty($values['imageinfo_cache_url_key']) || !preg_match('/^[a-f0-9]{32}$/', $values['imageinfo_cache_url_key'])) {
form_set_error('imageinfo_cache_url_key', t('Value must be a valid md5 hash. Recommended md5 hash on this server: %value', array(
'%value' => md5(drupal_get_private_key()),
)));
}
// Do no set certian variables.
unset($form_state['values']['list']);
}