function require_login_authcheck in Require Login 7
Checks current user authentication.
Return value
bool Returns TRUE if authenticated and FALSE otherwise.
1 call to require_login_authcheck()
- require_login_init in ./
require_login.module - Implements hook_init().
File
- ./
require_login.module, line 99 - require_login.module
Code
function require_login_authcheck() {
global $base_path, $base_url;
$path = '/' . drupal_get_path_alias($_GET['q']);
// Isolate request path from subdirectory when present.
$raw_uri = request_uri();
if ($base_path != '/') {
$current_uri = '/' . str_replace($base_path, '', $raw_uri);
}
else {
$current_uri = $raw_uri;
}
// Detect PHP script running Drupal bootstrap.
if (preg_match('/^.*\\.php$/i', $raw_uri)) {
$path = $base_path . trim($current_uri, '/');
}
// Compare current path with configured exclude paths. Returns TRUE when
// at least one excluded path matches the current path.
$exclude_paths = explode(PHP_EOL, variable_get('require_login_excluded_paths', ''));
foreach ($exclude_paths as $key => $exclude_path) {
$exclude_paths[$key] = trim($exclude_path);
if ($exclude_paths[$key] == '<front>') {
$exclude_paths[$key] = '/' . drupal_get_path_alias(variable_get('site_frontpage', 'node'));
}
}
if ($auth_path = filter_xss_admin(trim(variable_get('require_login_auth_path', '')))) {
$auth_path = drupal_parse_url($auth_path);
$exclude_paths[] = trim($auth_path['path']);
}
if (drupal_match_path($path, implode(PHP_EOL, $exclude_paths))) {
return TRUE;
}
// Various checks to determine exceptions for current page. Returns TRUE
// when at least one check has evaluated as TRUE.
$checks = array(
// Check user authentication.
user_is_logged_in(),
// Check maintenance mode.
variable_get('maintenance_mode', 0),
// Check cron.php file.
preg_match('/^\\/cron.php/i', $current_uri),
// Check update.php file.
preg_match('/\\/update.php/i', request_uri()),
// Check install.php file.
preg_match('/\\/install.php/i', request_uri()),
// Check OpenID integration.
isset($_SESSION['openid']),
// Check user pages.
arg(0) == 'user' && (!arg(1) || !is_numeric(arg(1))),
// Check drush command.
function_exists('drupal_is_cli') && drupal_is_cli(),
);
foreach ($checks as $check) {
if ($check) {
return TRUE;
}
}
return FALSE;
}