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:
+9
-1
@@ -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"];
|
||||
|
||||
Reference in New Issue
Block a user