You are here

function securepages_can_alter_url in Secure Pages 6.2

Same name and namespace in other branches
  1. 5 securepages.module \securepages_can_alter_url()
  2. 6 securepages.module \securepages_can_alter_url()
  3. 7 securepages.module \securepages_can_alter_url()

Check the url and make sure that it is a url that you can alter this url.

Parameters

$url: URL to check.

1 call to securepages_can_alter_url()
securepages_form_alter in ./securepages.module
Implements hook_form_alter().

File

./securepages.module, line 310
Provide method of creating allowing certain pages to only viewable from https pages

Code

function securepages_can_alter_url($url) {
  global $base_path, $base_url;
  $url = @parse_url($url);

  // If there is no scheme then it is a relative url and can be altered
  if (!isset($url['scheme']) && $base_path == '/') {
    return TRUE;
  }

  // If the host names are not the same then don't allow altering of the path.
  if (isset($url['host']) && strtolower($url['host']) != strtolower($_SERVER['HTTP_HOST'])) {
    return FALSE;
  }
  if (strlen($base_path) > 1 && substr($base_url, -1) != substr($url['path'], 1, strlen($base_path))) {
    return FALSE;
  }
  return TRUE;
}