Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

FIxes to qualified_me suggested by Greg Barnett

  • Loading branch information...
commit f77c261e4d71caec30f0a4c1813670b1ed993988 1 parent d2481a4
moodler authored
Showing with 12 additions and 6 deletions.
  1. +12 −6 lib/weblib.php
View
18 lib/weblib.php
@@ -122,20 +122,26 @@ function me() {
function qualified_me() {
/// like me() but returns a full URL
- if (!empty($_SERVER["HTTP_HOST"])) {
- $hostname = $_SERVER["HTTP_HOST"];
- } else if (!empty($_ENV["HTTP_HOST"])) {
- $hostname = $_ENV["HTTP_HOST"];
- } else if (!empty($_SERVER["SERVER_NAME"])) {
+ 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 (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://';
+ }
- $protocol = (isset($_SERVER["HTTPS"]) and $_SERVER["HTTPS"] == "on") ? "https://" : "http://";
$url_prefix = $protocol.$hostname;
return $url_prefix . me();
}
Please sign in to comment.
Something went wrong with that request. Please try again.