Skip to content

Commit

Permalink
Refs #78, updates WEB_ROOT to include port number.
Browse files Browse the repository at this point in the history
(cherry picked from commit 364578b)
  • Loading branch information
zerocrates committed Sep 26, 2011
1 parent cd0c270 commit ddc630c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion paths.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ function _define_web_root()
// As $_SERVER['HTTP_HOST'] is user input, ensure it only contains
// characters allowed in hostnames.
$base_url = $base_root .= '://' . preg_replace('/[^a-z0-9-:._]/i', '', $_SERVER['HTTP_HOST']);

// Handle non-standard ports
$port = $_SERVER['SERVER_PORT'];
if (($base_root == 'http' && $port != '80') || ($base_root == 'https' && $port != '443')) {
$base_url .= ":$port";
}

// $_SERVER['SCRIPT_NAME'] can, in contrast to $_SERVER['PHP_SELF'], not
// be modified by a visitor.
Expand Down Expand Up @@ -187,4 +193,4 @@ function _define_web_root()
assert_options(ASSERT_ACTIVE, 0);
} else {
assert_options(ASSERT_ACTIVE, 1);
}
}

0 comments on commit ddc630c

Please sign in to comment.