function httprl_admin_settings_form_validate in HTTP Parallel Request & Threading Library 7
Same name and namespace in other branches
- 6 httprl.admin.inc \httprl_admin_settings_form_validate()
Validate form values.
File
- ./
httprl.admin.inc, line 117 - Administrative page callbacks for the httprl module.
Code
function httprl_admin_settings_form_validate($form, &$form_state) {
// Skip validation if we are resting to defaults.
if (isset($form_state['clicked_button']['#post']['op']) && $form_state['clicked_button']['#post']['op'] == 'Reset to defaults') {
return;
}
// Get form values.
$values =& $form_state['values'];
// If the IP field is not blank, check that it is a valid address.
if (!empty($values['httprl_server_addr']) && $values['httprl_server_addr'] != -1 && ip2long($values['httprl_server_addr']) === FALSE) {
form_set_error('httprl_server_addr', t('Must be a valid IP address.'));
}
if (!empty($values['httprl_non_blocking_fclose_delay'])) {
if (!is_numeric($values['httprl_non_blocking_fclose_delay'])) {
form_set_error('httprl_non_blocking_fclose_delay', t('Must be a numeric value.'));
}
if ((int) $values['httprl_non_blocking_fclose_delay'] != $values['httprl_non_blocking_fclose_delay']) {
form_set_error('httprl_non_blocking_fclose_delay', t('Must be an interger.'));
}
elseif ($values['httprl_non_blocking_fclose_delay'] < 0) {
form_set_error('httprl_non_blocking_fclose_delay', t('Must be a positive value.'));
}
else {
$values['httprl_non_blocking_fclose_delay'] = (int) $values['httprl_non_blocking_fclose_delay'];
}
}
// Make sure the timeouts are positive numbers.
$positive_values = array(
'httprl_dns_timeout',
'httprl_connect_timeout',
'httprl_ttfb_timeout',
'httprl_timeout',
'httprl_global_timeout',
);
foreach ($positive_values as $name) {
if (empty($values[$name])) {
form_set_error($name, t('Must not be empty or zero.'));
continue;
}
if (!is_numeric($values[$name])) {
form_set_error($name, t('Must be numeric.'));
continue;
}
if ($values[$name] <= 0) {
form_set_error($name, t('Must be a positive number.'));
continue;
}
}
// Change checkbox value to string.
if (!empty($values['drupal_http_request_function'])) {
$values['drupal_http_request_function'] = 'httprl_override_core';
}
}