--- weblib.php 2008-07-26 18:17:56.000000000 -0600 +++ weblib.php.new 2008-08-12 15:59:12.000000000 -0600 @@ -244,57 +244,21 @@ } /** - * Like {@link me()} but returns a full URL - * @see me() - * @return string - */ -function qualified_me() { + * This solves the problem described in MDL-11061 http://tracker.moodle.org/browse/MDL-11061. + * i jus't can't get why was this function constructing the url prefix + * from within the server environment variables with so much exceptions + * when we have $CFG->wwwroot defined in config.php + * + * Like {@link me()} but returns a full URL + * @see me() + * @return string + */ +function qualified_me() { global $CFG; - - if (!empty($CFG->wwwroot)) { - $url = parse_url($CFG->wwwroot); - } - - if (!empty($url['host'])) { - $hostname = $url['host']; - } else if (!empty($_SERVER['SERVER_NAME'])) { - $hostname = $_SERVER['SERVER_NAME']; - } else if (!empty($_ENV['SERVER_NAME'])) { - $hostname = $_ENV['SERVER_NAME']; - } else if (!empty($_SERVER['HTTP_HOST'])) { - $hostname = $_SERVER['HTTP_HOST']; - } else if (!empty($_ENV['HTTP_HOST'])) { - $hostname = $_ENV['HTTP_HOST']; - } else { - notify('Warning: could not find the name of this server!'); - return false; - } - - if (!empty($url['port'])) { - $hostname .= ':'.$url['port']; - } else if (!empty($_SERVER['SERVER_PORT'])) { - if ($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) { - $hostname .= ':'.$_SERVER['SERVER_PORT']; - } - } - - // TODO, this does not work in the situation described in MDL-11061, but - // I don't know how to fix it. Possibly believe $CFG->wwwroot ahead of what - // the server reports. - if (isset($_SERVER['HTTPS'])) { - $protocol = ($_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'; - } else if (isset($_SERVER['SERVER_PORT'])) { # Apache2 does not export $_SERVER['HTTPS'] - $protocol = ($_SERVER['SERVER_PORT'] == '443') ? 'https://' : 'http://'; - } else { - $protocol = 'http://'; - } - - $url_prefix = $protocol.$hostname; - return $url_prefix . me(); + return $CFG->wwwroot . me(); } - /** * Class for creating and manipulating urls. *