function securepages_redirect in Secure Pages 7
Same name and namespace in other branches
- 6.2 securepages.module \securepages_redirect()
- 6 securepages.module \securepages_redirect()
Checks the current page and see if we need to redirect to the secure or insecure version of the page.
1 call to securepages_redirect()
- securepages_init in ./
securepages.module - Implements hook_init().
File
- ./
securepages.module, line 148 - Allows certain pages to be viewable only via HTTPS.
Code
function securepages_redirect() {
global $base_url, $is_https, $user;
$path = isset($_GET['q']) ? $_GET['q'] : '';
$page_match = securepages_match($path);
$role_match = securepages_roles($user);
if ($_POST) {
// If something has been posted to here then ignore the rules.
}
elseif ($role_match && !$is_https) {
securepages_log('Switch User to secure', $path);
securepages_goto(TRUE);
}
elseif ($page_match && !$is_https) {
securepages_log('Switch Path to secure', $path);
securepages_goto(TRUE);
}
elseif ($page_match === 0 && $is_https && variable_get('securepages_switch', FALSE) && !$role_match) {
securepages_log('Switch Path to insecure (Path: "@path")', $path);
securepages_goto(FALSE);
}
// Correct the base_url so that everything comes from HTTPS.
if ($is_https) {
$base_url = securepages_baseurl();
}
}