diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-05-10 07:32:02 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-05-10 07:32:02 +0000 |
commit | 0a31af3ed2d12e40ec62b907bc24f33c11b0ab1e (patch) | |
tree | fbad80a1bc236515732ae7d55ca7638e504235cd /modules/system/system.admin.inc | |
parent | ccef07e59e9f5197452b2fdf54ce0818ea8a5ae1 (diff) | |
download | brdo-0a31af3ed2d12e40ec62b907bc24f33c11b0ab1e.tar.gz brdo-0a31af3ed2d12e40ec62b907bc24f33c11b0ab1e.tar.bz2 |
- Patch #256152 by catch: added additional tests for the IP address blocking and added a small usability improvement.
Diffstat (limited to 'modules/system/system.admin.inc')
-rw-r--r-- | modules/system/system.admin.inc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc index 7ebac6c37..87ef36dd9 100644 --- a/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -1137,17 +1137,20 @@ function system_ip_blocking_form($form_state) { } function system_ip_blocking_form_validate($form, &$form_state) { - $ip = $form_state['values']['ip']; + $ip = trim($form_state['values']['ip']); if (db_result(db_query("SELECT * FROM {blocked_ips} WHERE ip = '%s'", $ip))) { form_set_error('ip', t('This IP address is already blocked.')); } + else if ($ip == ip_address()) { + form_set_error('ip', t('You may not block your own IP address.')); + } else if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) == FALSE) { form_set_error('ip', t('Please enter a valid IP address.')); } } function system_ip_blocking_form_submit($form, &$form_state) { - $ip = $form_state['values']['ip']; + $ip = trim($form_state['values']['ip']); db_query("INSERT INTO {blocked_ips} (ip) VALUES ('%s')", $ip); drupal_set_message(t('The IP address %ip has been blocked.', array('%ip' => $ip))); $form_state['redirect'] = 'admin/settings/ip-blocking'; @@ -2260,4 +2263,4 @@ function theme_system_themes_form($form) { $output = theme('table', $header, $rows); $output .= drupal_render($form); return $output; -} +}
\ No newline at end of file |