You are here

function securepages_match in Secure Pages 7

Same name and namespace in other branches
  1. 5 securepages.module \securepages_match()
  2. 6.2 securepages.module \securepages_match()
  3. 6 securepages.module \securepages_match()

Checks the page past and see if it should be secure or insecure.

Parameters

$path: The page of the page to check.

Return value

  • 0: Page should be insecure.
  • 1: Page should be secure.
  • NULL: Do not change page.
4 calls to securepages_match()
SecurePagesTestCase::_testMatch in ./securepages.test
Tests the securepages_match() function.
securepages_drupal_goto_alter in ./securepages.module
Implements hook_drupal_goto_alter().
securepages_form_alter in ./securepages.module
Implements hook_form_alter().
securepages_redirect in ./securepages.module
Checks the current page and see if we need to redirect to the secure or insecure version of the page.

File

./securepages.module, line 229
Allows certain pages to be viewable only via HTTPS.

Code

function securepages_match($path) {
  global $is_https;
  $secure = variable_get('securepages_secure', 1);
  $pages = drupal_strtolower(variable_get('securepages_pages', SECUREPAGES_PAGES));
  $ignore = drupal_strtolower(variable_get('securepages_ignore', SECUREPAGES_IGNORE));
  $path = drupal_strtolower(trim($path, '/'));
  $path_alias = NULL;

  // Checks to see if the page matches the current settings.
  if ($ignore) {
    $result = drupal_match_path($path, $ignore);
    if (!$result && function_exists('drupal_get_path_alias')) {
      $path_alias = drupal_get_path_alias($path);
      $result = drupal_match_path($path_alias, $ignore);
    }
    if ($result) {
      securepages_log('Ignored path (Path: "@path", Line: @line, Pattern: "@pattern")', $path, $ignore);
      return $is_https ? 1 : 0;
    }
  }
  if ($pages) {
    $result = drupal_match_path($path, $pages);
    if (!$result && function_exists('drupal_get_path_alias')) {
      $path_alias = isset($path_alias) ? drupal_get_path_alias($path) : $path_alias;
      $result = drupal_match_path($path_alias, $pages);
    }
    if (!($secure xor $result)) {
      securepages_log('Secure path (Path: "@path", Line: @line, Pattern: "@pattern")', $path, $pages);
    }
    return !($secure xor $result) ? 1 : 0;
  }
  else {
    return;
  }
}