You are here

function securepages_goto in Secure Pages 6.2

Same name and namespace in other branches
  1. 5 securepages.module \securepages_goto()
  2. 6 securepages.module \securepages_goto()
  3. 7 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 145
Provide method of creating allowing certain pages to only viewable from https pages

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
  if (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_set_header('Location: ' . url($url['path'], $url));
    drupal_set_header('Status: ' . '302 Found');

    // Store the response in the page cache.
    drupal_page_footer();
    exit;
  }
}