Correct SERVER_NAME to HTTP_HOST to get a valid host url

This commit is contained in:
shtse8 2017-09-28 11:44:33 +00:00
parent e2a3536d7e
commit 6c1aa15879
6 changed files with 8 additions and 8 deletions

View File

@ -666,7 +666,7 @@ class User extends Base {
// Enforce a page reload and point towards login with referrer included, if supplied // Enforce a page reload and point towards login with referrer included, if supplied
$port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]); $port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]);
$pushto = $_SERVER['SCRIPT_NAME'].'?page=login'; $pushto = $_SERVER['SCRIPT_NAME'].'?page=login';
$location = (@$_SERVER['HTTPS'] == 'on') ? 'https://' . $_SERVER['SERVER_NAME'] . $port . $pushto : 'http://' . $_SERVER['SERVER_NAME'] . $port . $pushto; $location = (@$_SERVER['HTTPS'] == 'on') ? 'https://' . $_SERVER['HTTP_HOST'] . $port . $pushto : 'http://' . $_SERVER['HTTP_HOST'] . $port . $pushto;
if (!headers_sent()) header('Location: ' . $location); if (!headers_sent()) header('Location: ' . $location);
exit('<meta http-equiv="refresh" content="0; url=' . $location . '"/>'); exit('<meta http-equiv="refresh" content="0; url=' . $location . '"/>');
} }

View File

@ -687,7 +687,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
protected function getRandomId() protected function getRandomId()
{ {
$idLeft = md5(getmypid() . '.' . time() . '.' . uniqid(mt_rand(), true)); $idLeft = md5(getmypid() . '.' . time() . '.' . uniqid(mt_rand(), true));
$idRight = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'swift.generated'; $idRight = !empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'swift.generated';
$id = $idLeft . '@' . $idRight; $id = $idLeft . '@' . $idRight;
try { try {

View File

@ -477,10 +477,10 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
/** Try to determine the hostname of the server this is run on */ /** Try to determine the hostname of the server this is run on */
private function _lookupHostname() private function _lookupHostname()
{ {
if (!empty($_SERVER['SERVER_NAME']) if (!empty($_SERVER['HTTP_HOST'])
&& $this->_isFqdn($_SERVER['SERVER_NAME'])) && $this->_isFqdn($_SERVER['HTTP_HOST']))
{ {
$this->_domain = $_SERVER['SERVER_NAME']; $this->_domain = $_SERVER['HTTP_HOST'];
} elseif (!empty($_SERVER['SERVER_ADDR'])) { } elseif (!empty($_SERVER['SERVER_ADDR'])) {
$this->_domain = sprintf('[%s]', $_SERVER['SERVER_ADDR']); $this->_domain = sprintf('[%s]', $_SERVER['SERVER_ADDR']);
} }

View File

@ -6,7 +6,7 @@ if ($user->isAuthenticated()) {
$user->setUserFailed($_SESSION['USERDATA']['id'], 0); $user->setUserFailed($_SESSION['USERDATA']['id'], 0);
$port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]); $port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]);
$pushto = $_SERVER['SCRIPT_NAME'].'?page=dashboard'; $pushto = $_SERVER['SCRIPT_NAME'].'?page=dashboard';
$location = (@$_SERVER['HTTPS'] == 'on') ? 'https://' . $_SERVER['SERVER_NAME'] . $port . $pushto : 'http://' . $_SERVER['SERVER_NAME'] . $port . $pushto; $location = (@$_SERVER['HTTPS'] == 'on') ? 'https://' . $_SERVER['HTTP_HOST'] . $port . $pushto : 'http://' . $_SERVER['HTTP_HOST'] . $port . $pushto;
header("Location: " . $location); header("Location: " . $location);
} }
// Somehow we still need to load this empty template // Somehow we still need to load this empty template

View File

@ -29,7 +29,7 @@ if (!empty($_POST['username']) && !empty($_POST['password'])) {
if ($user->checkLogin(@$_POST['username'], @$_POST['password']) ) { if ($user->checkLogin(@$_POST['username'], @$_POST['password']) ) {
$port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]); $port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]);
$location = (@$_SERVER['HTTPS'] == "on") ? 'https://' : 'http://'; $location = (@$_SERVER['HTTPS'] == "on") ? 'https://' : 'http://';
$location .= $_SERVER['SERVER_NAME'] . $port . $_SERVER['SCRIPT_NAME']; $location .= $_SERVER['HTTP_HOST'] . $port . $_SERVER['SCRIPT_NAME'];
$location.= '?page=dashboard'; $location.= '?page=dashboard';
if (!headers_sent()) header('Location: ' . $location); if (!headers_sent()) header('Location: ' . $location);
exit('<meta http-equiv="refresh" content="0; url=' . htmlspecialchars($location) . '"/>'); exit('<meta http-equiv="refresh" content="0; url=' . htmlspecialchars($location) . '"/>');

View File

@ -40,7 +40,7 @@ define("BASEPATH", dirname(__FILE__) . "/");
include_once(BASEPATH . '../include/bootstrap.php'); include_once(BASEPATH . '../include/bootstrap.php');
// switch to https if config option is enabled // switch to https if config option is enabled
$hts = ($config['https_only'] && (!empty($_SERVER['QUERY_STRING']))) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']."?".$_SERVER['QUERY_STRING'] : "https://".$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']; $hts = ($config['https_only'] && (!empty($_SERVER['QUERY_STRING']))) ? "https://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']."?".$_SERVER['QUERY_STRING'] : "https://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
($config['https_only'] && @!$_SERVER['HTTPS']) ? exit(header("Location: ".$hts)):0; ($config['https_only'] && @!$_SERVER['HTTPS']) ? exit(header("Location: ".$hts)):0;
// Rate limiting, we use our initilized memcache from bootstrap/autoloader // Rate limiting, we use our initilized memcache from bootstrap/autoloader