ban.module 1.7 KB
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Allows to ban individual IP addresses.
6 7 8 9 10 11 12 13 14 15
 */

/**
 * Implements hook_help().
 */
function ban_help($path, $arg) {
  switch ($path) {
    case 'admin/help#ban':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
16
      $output .= '<p>' . t('The Ban module allows administrators to ban visits to their site from individual IP addresses. For more information, see <a href="@url">the online documentation for the Ban module</a>.', array('@url' => 'https://drupal.org/documentation/modules/ban')) . '</p>';
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
      $output .= '<h3>' . t('Uses') . '</h3>';
      $output .= '<dl>';
      $output .= '<dt>' . t('Banning IP addresses') . '</dt>';
      $output .= '<dd>' . t('Administrators can enter IP addresses to ban on the <a href="@bans">IP address bans</a> page.', array('@bans' => url('admin/config/people/ban'))) . '</dd>';
      $output .= '</dl>';
      return $output;

    case 'admin/config/people/ban':
      return '<p>' . t('IP addresses listed here are banned from your site. Banned addresses are completely forbidden from accessing the site and instead see a brief message explaining the situation.') . '</p>';
  }
}

/**
 * Implements hook_permission().
 */
function ban_permission() {
  return array(
    'ban IP addresses' => array(
      'title' => t('Ban IP addresses'),
    ),
  );
}

/**
 * Implements hook_menu().
 */
function ban_menu() {
  $items['admin/config/people/ban'] = array(
    'title' => 'IP address bans',
    'description' => 'Manage banned IP addresses.',
47
    'route_name' => 'ban.admin_page',
48 49
    'weight' => 10,
  );
50
  $items['admin/config/people/ban/delete/%'] = array(
51
    'title' => 'Delete IP address',
52
    'route_name' => 'ban.delete',
53 54 55
  );
  return $items;
}