You are here

function tokenauth_allowed_pages in Token authentication 5

Same name and namespace in other branches
  1. 6.2 tokenauth.inc \tokenauth_allowed_pages()
  2. 6 tokenauth.inc \tokenauth_allowed_pages()
  3. 7 tokenauth.inc \tokenauth_allowed_pages()

Return TRUE if current page may be viewed using only a token

1 call to tokenauth_allowed_pages()
tokenauth_init in ./tokenauth.module
Implementation of hook_init().

File

./tokenauth.module, line 257

Code

function tokenauth_allowed_pages($path) {

  // Code from the block_list funtion in block.module.
  // If the path doesn't match any of the exeptions, return TRUE.
  $pathalias = 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(variable_get('tokenauth_pages', "rss.xml\n*/feed\n*/opml"), '/')) . ')$/';

  // Compare with the internal and path alias (if any).
  $page_match = preg_match($regexp, $pathalias);
  if ($pathalias != $path) {
    $page_match = $page_match || preg_match($regexp, $path);
  }
  if ($page_match) {
    return TRUE;
  }
  else {
    return FALSE;
  }
}