function httpbl_requirements in http:BL 8
Same name and namespace in other branches
- 5 httpbl.module \httpbl_requirements()
- 6.2 httpbl.module \httpbl_requirements()
- 6 httpbl.module \httpbl_requirements()
- 7 httpbl.module \httpbl_requirements()
Implements hook_requirements().
Shows some basic usage statistics for the module in the Status Report.
File
- ./
httpbl.install, line 13 - Install, update and uninstall functions for the httpbl module.
Code
function httpbl_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
// Checks for Access Key, and Comment or Page Checking enabled.
if (!\Drupal::state()
->get('httpbl.accesskey') ?: NULL || !\Drupal::state()
->get('httpbl.check') ?: HTTPBL_CHECK_NONE) {
// Make Config page link.
$config_link = \Drupal\Core\Link::fromTextAndUrl(t('Http:BL config'), \Drupal\Core\Url::fromRoute('httpbl.admin_config'))
->toString();
$requirements['httpbl'] = array(
'description' => t('IP blacklist lookups are currently disabled; enter your access key on the @settings page and enable checks to enable blacklist lookups.', array(
'@settings' => $config_link,
)),
'severity' => REQUIREMENT_WARNING,
'value' => t('Disabled'),
);
// Checks for page bottom honeypot links.
if (\Drupal::state()
->get('httpbl.footer') ?: FALSE) {
$requirements['httpbl']['severity'] = REQUIREMENT_INFO;
}
}
else {
// Gather the stats to be displayed.
$stat_black = \Drupal::state()
->get('httpbl.stat_black');
$stat_comment = \Drupal::state()
->get('httpbl.stat_comment');
$stat_grey = \Drupal::state()
->get('httpbl.stat_grey');
// Check of stats collecting/display is enabled.
if (!\Drupal::state()
->get('httpbl.stats') ?: FALSE) {
$requirements['httpbl'] = array(
'description' => t('Http:BL is enabled.'),
'severity' => REQUIREMENT_OK,
'value' => t('Enabled'),
);
}
elseif (\Drupal::state()
->get('httpbl.check') == HTTPBL_CHECK_COMMENTS) {
$requirements['httpbl'] = array(
'description' => t('Http:BL is enabled and has blocked @c comments.', array(
'@c' => $stat_comment,
)),
'severity' => REQUIREMENT_OK,
'value' => t('Enabled'),
);
}
elseif (\Drupal::state()
->get('httpbl.check') == HTTPBL_CHECK_ALL) {
$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'),
);
// Show a status error if core Internal Page Cache (page_cache) is enabled.
if (\Drupal::hasService('http_middleware.page_cache')) {
$requirements['httpbl'] = array(
'title' => t('Http:BL'),
'description' => t('Using HttpBL for evaluating page requests is allowed but NOT recommended when core extension Internal Page Cache (page_cache) enabled.', array()),
'severity' => REQUIREMENT_ERROR,
);
$requirements['httpbl']['description'] .= ' ' . t('Recommended action: Configure Http:BL for comment blocking only or uninstall page_cache. Note: Use with Internal Dynamic Page Cache (dynamic_page_cache) is ok.');
return $requirements;
}
// Checks if also auto-banning blacklisted IPs (via the Core Ban module).
if (\Drupal::state()
->get('httpbl.storage') == HTTPBL_DB_HH_DRUPAL) {
$requirements['httpbl']['severity'] = REQUIREMENT_INFO;
$requirements['httpbl']['description'] .= ' ' . t('Auto-banning of blacklisted IPs enabled.');
}
else {
$requirements['httpbl']['severity'] = REQUIREMENT_INFO;
$requirements['httpbl']['description'] .= ' ' . t('Auto-banning of blacklisted IPs DISABLED.');
}
}
// Checks if also using honeypot page bottom links.
if (!\Drupal::state()
->get('httpbl.footer') ?: FALSE) {
$requirements['httpbl']['severity'] = REQUIREMENT_INFO;
$requirements['httpbl']['description'] .= ' ' . t('Page bottom Honeypot links are DISABLED.');
}
else {
$requirements['httpbl']['severity'] = REQUIREMENT_INFO;
$requirements['httpbl']['description'] .= ' ' . t('Page bottom Honeypot links enabled.');
}
}
$requirements['httpbl']['title'] = t('Http:BL');
}
return $requirements;
}