function securepages_goto in Secure Pages 7
Same name and namespace in other branches
- 5 securepages.module \securepages_goto()
- 6.2 securepages.module \securepages_goto()
- 6 securepages.module \securepages_goto()
Redirects the current page to the secure or insecure version.
Parameters
$secure: Determines which version of the set to move to.
1 call to securepages_goto()
- securepages_redirect in ./
securepages.module - Checks the current page and see if we need to redirect to the secure or insecure version of the page.
File
- ./
securepages.module, line 183 - Allows certain pages to be viewable only via HTTPS.
Code
function securepages_goto($secure) {
$url['path'] = drupal_is_front_page() ? '' : $_GET['q'];
$url['query'] = $_GET;
unset($url['query']['q']);
$url['https'] = $secure;
$url['base_url'] = securepages_baseurl($secure);
$url['absolute'] = TRUE;
$url['external'] = FALSE;
// prevent an open redirect
// Check for the overlay. Attempting to switch protocols during an XHR
// isn't allowed by the browser's same-origin policy, so we must close the overlay.
if (module_exists('overlay') && overlay_get_mode() == 'child') {
overlay_close_dialog($url['path'], $url);
}
elseif (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
return;
}
else {
// Setting the redirect headers manually allows them to be cached.
drupal_add_http_header('Location', url($url['path'], $url));
drupal_add_http_header('Status', '302 Found');
print "302 Found";
// Store the response in the page cache.
if (variable_get('cache', 0) && ($cache = drupal_page_set_cache())) {
drupal_serve_page_from_cache($cache);
}
else {
ob_flush();
}
exit;
}
}