You are here

function securepages_match in Secure Pages 6.2

Same name and namespace in other branches
  1. 5 securepages.module \securepages_match()
  2. 6 securepages.module \securepages_match()
  3. 7 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.
3 calls to securepages_match()
SecurePagesTestCase::_testMatch in ./securepages.test
Tests the securepages_match() function.
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 180
Provide method of creating allowing certain pages to only viewable from https pages

Code

function securepages_match($path) {
  $is_https = securepages_is_secure();
  $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 = securepages_strtolower(trim($path, '/'));

  // Checks to see if the page matches the current settings.
  if ($ignore) {
    if (drupal_match_path($path, $ignore)) {
      return $is_https ? 1 : 0;
    }
  }
  if ($pages) {
    $result = drupal_match_path($path, $pages);
    if (function_exists('drupal_get_path_alias')) {
      $path_alias = drupal_get_path_alias($path);
      $result |= drupal_match_path($path_alias, $pages);
    }
    return !($secure xor $result) ? 1 : 0;
  }
  else {
    return;
  }
}