New way to get the server name from wwwroot instead of

using such SERVER_NAME and HTTP_HOST variables.

It should help in servers having wrong Apache configurations, being
the cause of bad logins, referer problems....making Moodle a bit less
demanding.

Semi-merged from MOODLE_HEAD (it has been working there from some days ago
with possitive resuts).

SEMI because I've retroffited from HEAD only the WWWROOT part. The rest are
quite different but I haven't modified it. Perhaps we shoul retroffit the
function completely?
This commit is contained in:
stronk7
2005-03-07 18:08:30 +00:00
parent 64afd5f7f4
commit 067ce31750
+9 -1
View File
@@ -124,7 +124,15 @@ function me() {
function qualified_me() {
/// like me() but returns a full URL
if (!empty($_SERVER["HTTP_HOST"])) {
global $CFG;
if (!empty($CFG->wwwroot)) {
$url = parse_url($CFG->wwwroot);
}
if (!empty($url['host'])) {
$hostname = $url['host'];
} else if (!empty($_SERVER["HTTP_HOST"])) {
$hostname = $_SERVER["HTTP_HOST"];
} else if (!empty($_ENV["HTTP_HOST"])) {
$hostname = $_ENV["HTTP_HOST"];