Skip to content
Snippets Groups Projects
Commit 6351efb2 authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

Improved handling of getting its own hostname and port and so on... this may...

Improved handling of getting its own hostname and port and so on... this may cause that people that have included https://foo:443 may now have to remove :443 from their metadata

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@54 44740490-163a-0410-bde0-09ae8108e29a
parent d32577a9
Branches
Tags
No related merge requests found
......@@ -19,20 +19,39 @@ require_once('SimpleSAML/Configuration.php');
class SimpleSAML_Utilities {
public static function selfURLhost() {
public static function getSelfHost() {
$currenthost = $_SERVER['HTTP_HOST'];
if(strstr($currenthost, ":")) {
$currenthostdecomposed = explode(":", $currenthost);
$currenthost = $currenthostdecomposed[0];
}
return $currenthost;
}
public static function selfURLhost() {
$currenthost = self::getSelfHost();
$s = empty($_SERVER["HTTPS"]) ? ''
: ($_SERVER["HTTPS"] == "on") ? "s"
: "";
$protocol = self::strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? ""
: (":".$_SERVER["SERVER_PORT"]);
$portnumber = $_SERVER["SERVER_PORT"];
$port = ':' . $portnumber;
if ($protocol == 'http') {
if ($portnumber == '80') $port = '';
} elseif ($protocol == 'https') {
if ($portnumber == '443') $port = '';
}
$querystring = '';
return $protocol."://" . $currenthost . $port;
......@@ -40,41 +59,14 @@ class SimpleSAML_Utilities {
public static function selfURLNoQuery() {
$currenthost = $_SERVER['HTTP_HOST'];
if(strstr($currenthost, ":")) {
$currenthostdecomposed = explode(":", $currenthost);
$currenthost = $currenthostdecomposed[0];
}
$s = empty($_SERVER["HTTPS"]) ? ''
: ($_SERVER["HTTPS"] == "on") ? "s"
: "";
$protocol = self::strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? ""
: (":".$_SERVER["SERVER_PORT"]);
$querystring = '';
return $protocol."://" . $currenthost . $port . $_SERVER['SCRIPT_NAME'];
$selfURLhost = self::selfURLhost();
return $selfURLhost . $_SERVER['SCRIPT_NAME'];
}
public static function selfURL() {
$currenthost = $_SERVER['HTTP_HOST'];
if(strstr($currenthost, ":")) {
$currenthostdecomposed = explode(":", $currenthost);
$currenthost = $currenthostdecomposed[0];
}
$s = empty($_SERVER["HTTPS"]) ? ''
: ($_SERVER["HTTPS"] == "on") ? "s"
: "";
$protocol = self::strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? ""
: (":".$_SERVER["SERVER_PORT"]);
$querystring = '';
return $protocol . "://" . $currenthost . $port . $_SERVER['REQUEST_URI'];
$selfURLhost = self::selfURLhost();
return $selfURLhost . $_SERVER['REQUEST_URI'];
}
public static function addURLparameter($url, $parameter) {
......
......@@ -71,7 +71,7 @@ if (!isset($session) || !$session->isValid() ) {
$et->data['e'] = $exception;
$et->show();
exit(0);
}
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment