You are here

function securepages_match in Secure Pages 5

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

securepages_match()

check 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()
securepages_form_alter in ./securepages.module
Implementation of hook_form_alter()
securepages_init in ./securepages.module
Implementation of hook_init()
securepages_link_alter in ./securepages.module
Implementation of hook_link_alter()

File

./securepages.module, line 208

Code

function securepages_match($path) {

  /**
   * Check to see if the current menu item has a preference and ignore the
   * secure pages settings
   */
  if (function_exists('menu_get_item')) {
    $item = menu_get_item(menu_get_active_item());
    if (isset($item['secure'])) {
      return $item['secure'];
    }
  }

  /**
   * Check to see if the page matches the current settings
   */
  $secure = variable_get('securepages_secure', 1);
  $pages = variable_get('securepages_pages', "node/add*\nnode/*/edit\nuser/*\nadmin*");
  $ignore = variable_get('securepages_ignore', "*/autocomplete/*\n*/ajax/*");
  if ($ignore) {
    $regexp = '/^(' . preg_replace(array(
      '/(\\r\\n?|\\n)/',
      '/\\\\\\*/',
      '/(^|\\|)\\\\<front\\\\>($|\\|)/',
    ), array(
      '|',
      '.*',
      '\\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\\2',
    ), preg_quote($ignore, '/')) . ')$/';
    if (preg_match($regexp, $path)) {
      return securepages_is_secure() ? 1 : 0;
    }
  }
  if ($pages) {
    $regexp = '/^(' . preg_replace(array(
      '/(\\r\\n?|\\n)/',
      '/\\\\\\*/',
      '/(^|\\|)\\\\<front\\\\>($|\\|)/',
    ), array(
      '|',
      '.*',
      '\\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\\2',
    ), preg_quote($pages, '/')) . ')$/';
    return !($secure xor preg_match($regexp, $path)) ? 1 : 0;
  }
  else {
    return;
  }
}