function fast_404_ext_check in Fast 404 7
Same name and namespace in other branches
- 6 fast_404.inc \fast_404_ext_check()
1 call to fast_404_ext_check()
- fast_404_boot in ./fast_404.module
- Implements hook_boot().
File
- ./fast_404.inc, line 3
Code
function fast_404_ext_check() {
if (!variable_get('fast_404_extension_check', TRUE)) {
return TRUE;
}
if (drupal_is_cli()) {
return TRUE;
}
$uri = request_uri();
$path = parse_url('http://example.com' . $uri, PHP_URL_PATH);
if ($path == '/') {
return TRUE;
}
if (strpos($path, 'styles/')) {
if (!variable_get('fast_404_allow_anon_imagecache', TRUE)) {
$found_session = FALSE;
foreach ($_COOKIE as $k => $v) {
if (stristr($k, 'SESS')) {
$found_session = TRUE;
break;
}
}
if ($found_session) {
return TRUE;
}
}
else {
return TRUE;
}
}
if (variable_get('fast_404_url_whitelisting', FALSE)) {
$allowed = variable_get('fast_404_whitelist', array());
if (in_array($path, $allowed)) {
return TRUE;
}
}
if (is_array(variable_get('fast_404_string_whitelisting', FALSE))) {
foreach (variable_get('fast_404_string_whitelisting', array()) as $str) {
if (strstr($path, $str) !== FALSE) {
return TRUE;
}
}
}
$exts = variable_get('fast_404_exts', '/^(?!robots).*\\.(txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i');
if ($exts && preg_match($exts, $path, $m)) {
fast_404_error_return(FALSE, variable_get('fast_404_return_gone', FALSE));
}
define('FAST_404_EXT_CHECKED', TRUE);
}