You are here

function httpbl_requirements in http:BL 5

Same name and namespace in other branches
  1. 8 httpbl.install \httpbl_requirements()
  2. 6.2 httpbl.module \httpbl_requirements()
  3. 6 httpbl.module \httpbl_requirements()
  4. 7 httpbl.module \httpbl_requirements()

Implementation of hook_requirements().

Shows some basic usage statistics for the module.

File

./httpbl.module, line 271
Implementation of http:BL for Drupal. It provides IP-based blacklisting through http:BL and allows linking to a honeypot.

Code

function httpbl_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {
    if (!variable_get('httpbl_accesskey', NULL) || !variable_get('httpbl_check', 0)) {
      $requirements['httpbl'] = array(
        'description' => t('IP blacklist lookups are currently disabled; enter your access key <a href="@settings">on the settings page</a> and enable checks to enable blacklist lookups.', array(
          '@settings' => url('admin/settings/httpbl'),
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => t('Disabled'),
      );
      if (variable_get('httpbl_footer', FALSE)) {
        $requirements['httpbl']['severity'] = REQUIREMENT_WARNING;
      }
    }
    else {
      $stat_black = variable_get('httpbl_stat_black', 0);
      $stat_comment = variable_get('httpbl_stat_comment', 0);
      $stat_grey = variable_get('httpbl_stat_grey', 0);
      if (!variable_get('httpbl_stats', TRUE)) {
        $requirements['httpbl'] = array(
          'description' => t('http:BL is enabled.'),
          'severity' => REQUIREMENT_OK,
          'value' => t('Enabled'),
        );
      }
      else {
        if (variable_get('httpbl_check', 0) == 1) {
          $requirements['httpbl'] = array(
            'description' => t('http:BL is enabled and has blocked %c comments.', array(
              '%c' => $stat_comment,
            )),
            'severity' => REQUIREMENT_OK,
            'value' => t('Enabled'),
          );
        }
        else {
          if (variable_get('httpbl_check', 0)) {
            $requirements['httpbl'] = array(
              'description' => t('http:BL is enabled and has blocked %t visits (%b blacklisted and %g greylisted).', array(
                '%t' => $stat_grey + $stat_black,
                '%b' => $stat_black,
                '%g' => $stat_grey,
              )),
              'severity' => REQUIREMENT_OK,
              'value' => t('Enabled'),
            );
          }
        }
      }
    }
    $requirements['httpbl']['title'] = t('http:BL');
  }
  return $requirements;
}