Commit 9e0af44f authored by Dries's avatar Dries

- Patch #523286 by aspilicious, Bojhan, anarcat, aaronbauman: cleanup IP blocking.

parent f363c920
...@@ -217,7 +217,7 @@ class StatisticsBlockVisitorsTestCase extends StatisticsTestCase { ...@@ -217,7 +217,7 @@ class StatisticsBlockVisitorsTestCase extends StatisticsTestCase {
$this->assertText(t('IP address blocking'), t('IP blocking page displayed.')); $this->assertText(t('IP address blocking'), t('IP blocking page displayed.'));
$edit = array(); $edit = array();
$edit['ip'] = $test_ip_address; $edit['ip'] = $test_ip_address;
$this->drupalPost('admin/config/people/ip-blocking', $edit, t('Save')); $this->drupalPost('admin/config/people/ip-blocking', $edit, t('Add'));
$ip = db_query("SELECT iid from {blocked_ips} WHERE ip = :ip", array(':ip' => $edit['ip']))->fetchField(); $ip = db_query("SELECT iid from {blocked_ips} WHERE ip = :ip", array(':ip' => $edit['ip']))->fetchField();
$this->assertNotEqual($ip, FALSE, t('IP address found in database')); $this->assertNotEqual($ip, FALSE, t('IP address found in database'));
$this->assertRaw(t('The IP address %ip has been blocked.', array('%ip' => $edit['ip'])), t('IP address was blocked.')); $this->assertRaw(t('The IP address %ip has been blocked.', array('%ip' => $edit['ip'])), t('IP address was blocked.'));
......
...@@ -1405,7 +1405,7 @@ function system_modules_uninstall_submit($form, &$form_state) { ...@@ -1405,7 +1405,7 @@ function system_modules_uninstall_submit($form, &$form_state) {
function system_ip_blocking($default_ip = '') { function system_ip_blocking($default_ip = '') {
$output = ''; $output = '';
$rows = array(); $rows = array();
$header = array(t('IP address'), t('Operations')); $header = array(t('Blocked IP addresses'), t('Operations'));
$result = db_query('SELECT * FROM {blocked_ips}'); $result = db_query('SELECT * FROM {blocked_ips}');
foreach ($result as $ip) { foreach ($result as $ip) {
$rows[] = array( $rows[] = array(
...@@ -1436,15 +1436,15 @@ function system_ip_blocking_form($form, $form_state, $default_ip) { ...@@ -1436,15 +1436,15 @@ function system_ip_blocking_form($form, $form_state, $default_ip) {
$form['ip'] = array( $form['ip'] = array(
'#title' => t('IP address'), '#title' => t('IP address'),
'#type' => 'textfield', '#type' => 'textfield',
'#size' => 64, '#size' => 48,
'#maxlength' => 32, '#maxlength' => 40,
'#default_value' => $default_ip, '#default_value' => $default_ip,
'#description' => t('Enter a valid IP address.'), '#description' => t('Enter a valid IP address.'),
); );
$form['actions'] = array('#type' => 'actions'); $form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array( $form['actions']['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Save'), '#value' => t('Add'),
); );
$form['#submit'][] = 'system_ip_blocking_form_submit'; $form['#submit'][] = 'system_ip_blocking_form_submit';
$form['#validate'][] = 'system_ip_blocking_form_validate'; $form['#validate'][] = 'system_ip_blocking_form_validate';
......
...@@ -135,7 +135,7 @@ function system_help($path, $arg) { ...@@ -135,7 +135,7 @@ function system_help($path, $arg) {
case 'admin/config/system/actions/configure': case 'admin/config/system/actions/configure':
return t('An advanced action offers additional configuration options which may be filled out below. Changing the <em>Description</em> field is recommended, in order to better identify the precise action taking place. This description will be displayed in modules such as the Trigger module when assigning actions to system events, so it is best if it is as descriptive as possible (for example, "Send e-mail to Moderation Team" rather than simply "Send e-mail").'); return t('An advanced action offers additional configuration options which may be filled out below. Changing the <em>Description</em> field is recommended, in order to better identify the precise action taking place. This description will be displayed in modules such as the Trigger module when assigning actions to system events, so it is best if it is as descriptive as possible (for example, "Send e-mail to Moderation Team" rather than simply "Send e-mail").');
case 'admin/config/people/ip-blocking': case 'admin/config/people/ip-blocking':
return '<p>' . t('IP addresses listed here are blocked from your site before any modules are loaded. You may add IP addresses to the list, or delete existing entries.') . '</p>'; return '<p>' . t('IP addresses listed here are blocked from your site. Blocked addresses are completely forbidden from accessing the site and instead see a brief message explaining the situation.') . '</p>';
case 'admin/reports/status': case 'admin/reports/status':
return '<p>' . t("Here you can find a short overview of your site's parameters as well as any problems detected with your installation. It may be useful to copy and paste this information into support requests filed on drupal.org's support forums and project issue queues.") . '</p>'; return '<p>' . t("Here you can find a short overview of your site's parameters as well as any problems detected with your installation. It may be useful to copy and paste this information into support requests filed on drupal.org's support forums and project issue queues.") . '</p>';
} }
......
...@@ -416,7 +416,7 @@ class IPAddressBlockingTestCase extends DrupalWebTestCase { ...@@ -416,7 +416,7 @@ class IPAddressBlockingTestCase extends DrupalWebTestCase {
// Block a valid IP address. // Block a valid IP address.
$edit = array(); $edit = array();
$edit['ip'] = '192.168.1.1'; $edit['ip'] = '192.168.1.1';
$this->drupalPost('admin/config/people/ip-blocking', $edit, t('Save')); $this->drupalPost('admin/config/people/ip-blocking', $edit, t('Add'));
$ip = db_query("SELECT iid from {blocked_ips} WHERE ip = :ip", array(':ip' => $edit['ip']))->fetchField(); $ip = db_query("SELECT iid from {blocked_ips} WHERE ip = :ip", array(':ip' => $edit['ip']))->fetchField();
$this->assertTrue($ip, t('IP address found in database.')); $this->assertTrue($ip, t('IP address found in database.'));
$this->assertRaw(t('The IP address %ip has been blocked.', array('%ip' => $edit['ip'])), t('IP address was blocked.')); $this->assertRaw(t('The IP address %ip has been blocked.', array('%ip' => $edit['ip'])), t('IP address was blocked.'));
...@@ -424,30 +424,30 @@ class IPAddressBlockingTestCase extends DrupalWebTestCase { ...@@ -424,30 +424,30 @@ class IPAddressBlockingTestCase extends DrupalWebTestCase {
// Try to block an IP address that's already blocked. // Try to block an IP address that's already blocked.
$edit = array(); $edit = array();
$edit['ip'] = '192.168.1.1'; $edit['ip'] = '192.168.1.1';
$this->drupalPost('admin/config/people/ip-blocking', $edit, t('Save')); $this->drupalPost('admin/config/people/ip-blocking', $edit, t('Add'));
$this->assertText(t('This IP address is already blocked.')); $this->assertText(t('This IP address is already blocked.'));
// Try to block a reserved IP address. // Try to block a reserved IP address.
$edit = array(); $edit = array();
$edit['ip'] = '255.255.255.255'; $edit['ip'] = '255.255.255.255';
$this->drupalPost('admin/config/people/ip-blocking', $edit, t('Save')); $this->drupalPost('admin/config/people/ip-blocking', $edit, t('Add'));
$this->assertText(t('Enter a valid IP address.')); $this->assertText(t('Enter a valid IP address.'));
// Try to block a reserved IP address. // Try to block a reserved IP address.
$edit = array(); $edit = array();
$edit['ip'] = 'test.example.com'; $edit['ip'] = 'test.example.com';
$this->drupalPost('admin/config/people/ip-blocking', $edit, t('Save')); $this->drupalPost('admin/config/people/ip-blocking', $edit, t('Add'));
$this->assertText(t('Enter a valid IP address.')); $this->assertText(t('Enter a valid IP address.'));
// Submit an empty form. // Submit an empty form.
$edit = array(); $edit = array();
$edit['ip'] = ''; $edit['ip'] = '';
$this->drupalPost('admin/config/people/ip-blocking', $edit, t('Save')); $this->drupalPost('admin/config/people/ip-blocking', $edit, t('Add'));
$this->assertText(t('Enter a valid IP address.')); $this->assertText(t('Enter a valid IP address.'));
// Pass an IP address as a URL parameter and submit it. // Pass an IP address as a URL parameter and submit it.
$submit_ip = '1.2.3.4'; $submit_ip = '1.2.3.4';
$this->drupalPost('admin/config/people/ip-blocking/' . $submit_ip, NULL, t('Save')); $this->drupalPost('admin/config/people/ip-blocking/' . $submit_ip, NULL, t('Add'));
$ip = db_query("SELECT iid from {blocked_ips} WHERE ip = :ip", array(':ip' => $submit_ip))->fetchField(); $ip = db_query("SELECT iid from {blocked_ips} WHERE ip = :ip", array(':ip' => $submit_ip))->fetchField();
$this->assertTrue($ip, t('IP address found in database')); $this->assertTrue($ip, t('IP address found in database'));
$this->assertRaw(t('The IP address %ip has been blocked.', array('%ip' => $submit_ip)), t('IP address was blocked.')); $this->assertRaw(t('The IP address %ip has been blocked.', array('%ip' => $submit_ip)), t('IP address was blocked.'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment