You are here

function securepages_can_alter_url in Secure Pages 6

Same name and namespace in other branches
  1. 5 securepages.module \securepages_can_alter_url()
  2. 6.2 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.

2 calls to securepages_can_alter_url()
securepages_form_alter in ./securepages.module
Implementation of hook_form_alter().
securepages_link_alter in ./securepages.module
Implementation of hook_link_alter().

File

./securepages.module, line 465
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;
  $path = '';
  @extract(@parse_url($url));

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

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