- Patch #97538 by edkwh and imagine: fixed throttle settings not being validated properly.

5.x
Dries Buytaert 2006-12-04 10:56:21 +00:00
parent 33ed764421
commit 225ebf38fe
1 changed files with 9 additions and 10 deletions

View File

@ -108,14 +108,6 @@ function throttle_exit() {
}
}
function _throttle_validate($value, $form) {
if ($value != NULL) {
if (!is_numeric($value) || $value < 0) {
form_set_error($form, t("%value is not a valid auto-throttle setting. Please enter a positive numeric value.", array('%value' => $value)));
}
}
}
/**
* Implementation of hook_help().
*/
@ -132,8 +124,6 @@ function throttle_help($section) {
}
function throttle_admin_settings() {
_throttle_validate(variable_get('throttle_anonymous', ''), 'throttle_anonymous');
_throttle_validate(variable_get('throttle_user', ''), 'throttle_user');
$probabilities = array(0 => '100%', 1 => '50%', 2 => '33.3%', 3 => '25%', 4 => '20%', 5 => '16.6%', 7 => '12.5%', 9 => '10%', 19 => '5%', 99 => '1%', 199 => '.5%', 399 => '.25%', 989 => '.1%');
$form['throttle_anonymous'] = array(
@ -162,3 +152,12 @@ function throttle_admin_settings() {
return system_settings_form($form);
}
function throttle_admin_settings_validate($form_id, $form_values) {
if (!is_numeric($form_values['throttle_anonymous']) || $form_values['throttle_anonymous'] < 0) {
form_set_error('throttle_anonymous', t("%value is not a valid auto-throttle setting. Please enter a positive numeric value.", array('%value' => $form_values['throttle_anonymous'])));
}
if (!is_numeric($form_values['throttle_user']) || $form_values['throttle_user'] < 0) {
form_set_error('throttle_user', t("%value is not a valid auto-throttle setting. Please enter a positive numeric value.", array('%value' => $form_values['throttle_user'])));
}
}