Skip to content

Commit

Permalink
Merge pull request pressflow#8 from davidstrauss/master
Browse files Browse the repository at this point in the history
This backports blocked_ips to D6
  • Loading branch information
elliotttf committed Feb 22, 2012
2 parents 386b20a + 53feef8 commit fc46cb9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions includes/bootstrap.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1360,8 +1360,16 @@ function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
* TRUE if access is denied, FALSE if access is allowed.
*/
function drupal_is_denied($type, $mask) {
// Because this function is called for every page request, both cached
// and non-cached pages, we tried to optimize it as much as possible.
if ($type == 'host') {
// Because this function is called with $type == 'host' on every page
// request, we first check for an array of IP addresses in settings.php
// before querying the database. In the former case there is no wildcard
// support.
$blocked_ips = variable_get('blocked_ips', NULL);
if (isset($blocked_ips) && is_array($blocked_ips)) {
return in_array($mask, $blocked_ips);
}
}
// We deny access if the only matching records in the {access} table have
// status 0 (deny). If any have status 1 (allow), or if there are no
// matching records, we allow access.
Expand Down

0 comments on commit fc46cb9

Please sign in to comment.