You are here

function _securesite_filter_check in Secure Site 5

Same name and namespace in other branches
  1. 6 securesite.module \_securesite_filter_check()

Check if pages should bypass Secure Site

Parameters

$path: String containing the path to be filtered

Return value

TRUE if Secure Site should be bypassed

2 calls to _securesite_filter_check()
SecureSiteTest::testFilterCheck in tests/securesite.test
Tests for _securesite_filter_check()
securesite_init in ./securesite.module
Implementation of hook_init()

File

./securesite.module, line 429
Secure Site contrib module

Code

function _securesite_filter_check($path) {

  // Don't allow empty paths
  if (empty($path)) {
    return FALSE;
  }

  // Fetch paths to ignore
  $pages = variable_get('securesite_filter_pages', '');

  // Check if the current path matches the list defined by the admin
  $alias = drupal_get_path_alias($path);
  $regexp = '/^(' . preg_replace(array(
    '/(\\r\\n?|\\n)/',
    '/\\\\\\*/',
    '/(^|\\|)\\\\<front\\\\>($|\\|)/',
  ), array(
    '|',
    '.*',
    '\\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\\2',
  ), preg_quote($pages, '/')) . ')$/';
  $page_match = preg_match($regexp, $alias);

  // Check normal paths if the alias lookup fails to match
  if (!$page_match) {
    $alias = drupal_get_normal_path($path);
    $page_match = preg_match($regexp, $alias);
  }

  // Whitelist or blacklist?
  if (variable_get('securesite_filter_pages_type', SECURESITE_WHITELIST) == !$page_match) {
    return TRUE;
  }
  return FALSE;
}