mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 23:35:12 +00:00
server_name issue
This commit is contained in:
parent
0e5994863e
commit
d59916e9a1
2 changed files with 41 additions and 20 deletions
30
boot.php
30
boot.php
|
@ -848,7 +848,6 @@ class App {
|
||||||
|
|
||||||
self::$query_string = '';
|
self::$query_string = '';
|
||||||
|
|
||||||
|
|
||||||
startup();
|
startup();
|
||||||
|
|
||||||
set_include_path(
|
set_include_path(
|
||||||
|
@ -857,17 +856,21 @@ class App {
|
||||||
. '.'
|
. '.'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// normally self::$hostname (also scheme and port) will be filled in during startup.
|
||||||
|
// Set it manually from $_SERVER variables only if it wasn't.
|
||||||
|
|
||||||
|
if (! self::$hostname) {
|
||||||
|
self::$hostname = punify(get_host());
|
||||||
self::$scheme = 'http';
|
self::$scheme = 'http';
|
||||||
|
|
||||||
if(x($_SERVER,'HTTPS') && $_SERVER['HTTPS'])
|
if(x($_SERVER,'HTTPS') && $_SERVER['HTTPS'])
|
||||||
self::$scheme = 'https';
|
self::$scheme = 'https';
|
||||||
elseif(x($_SERVER,'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443))
|
elseif(x($_SERVER,'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443))
|
||||||
self::$scheme = 'https';
|
self::$scheme = 'https';
|
||||||
|
|
||||||
if(x($_SERVER,'SERVER_NAME')) {
|
|
||||||
self::$hostname = punify($_SERVER['SERVER_NAME']);
|
|
||||||
|
|
||||||
if(x($_SERVER,'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443)
|
if(x($_SERVER,'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443)
|
||||||
self::$hostname .= ':' . $_SERVER['SERVER_PORT'];
|
self::$hostname .= ':' . $_SERVER['SERVER_PORT'];
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Figure out if we are running at the top of a domain
|
* Figure out if we are running at the top of a domain
|
||||||
|
@ -876,7 +879,6 @@ class App {
|
||||||
$path = trim(dirname($_SERVER['SCRIPT_NAME']),'/\\');
|
$path = trim(dirname($_SERVER['SCRIPT_NAME']),'/\\');
|
||||||
if(isset($path) && strlen($path) && ($path != self::$path))
|
if(isset($path) && strlen($path) && ($path != self::$path))
|
||||||
self::$path = $path;
|
self::$path = $path;
|
||||||
}
|
|
||||||
|
|
||||||
if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 4) === "req=") {
|
if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 4) === "req=") {
|
||||||
self::$query_string = str_replace(['<','>'],['<','>'],substr($_SERVER['QUERY_STRING'], 4));
|
self::$query_string = str_replace(['<','>'],['<','>'],substr($_SERVER['QUERY_STRING'], 4));
|
||||||
|
@ -2505,3 +2507,21 @@ function get_safemode() {
|
||||||
function supported_imagetype($x) {
|
function supported_imagetype($x) {
|
||||||
return in_array($x, [ IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_WEBP ]);
|
return in_array($x, [ IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_WEBP ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_host() {
|
||||||
|
if ($host = $_SERVER['HTTP_X_FORWARDED_HOST']) {
|
||||||
|
$elements = explode(',', $host);
|
||||||
|
$host = trim(end($elements));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (! $host = $_SERVER['HTTP_HOST']) {
|
||||||
|
if (! $host = $_SERVER['SERVER_NAME']) {
|
||||||
|
$host = ((! empty($_SERVER['SERVER_ADDR'])) ? $_SERVER['SERVER_ADDR'] : '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove port number from host
|
||||||
|
$host = preg_replace('/:\d+$/', '', $host);
|
||||||
|
return trim($host);
|
||||||
|
}
|
||||||
|
|
|
@ -228,11 +228,12 @@ abstract class dba_driver {
|
||||||
// Procedural functions
|
// Procedural functions
|
||||||
//
|
//
|
||||||
|
|
||||||
function printable($s) {
|
function printable($s, $escape = true) {
|
||||||
$s = preg_replace("~([\x01-\x08\x0E-\x0F\x10-\x1F\x7F-\xFF])~",".", $s);
|
$s = preg_replace("~([\x01-\x08\x0E-\x0F\x10-\x1F\x7F-\xFF])~",".", $s);
|
||||||
$s = str_replace("\x00",'.',$s);
|
$s = str_replace("\x00",'.',$s);
|
||||||
if(x($_SERVER,'SERVER_NAME'))
|
if ($escape) {
|
||||||
$s = escape_tags($s);
|
$s = escape_tags($s);
|
||||||
|
}
|
||||||
|
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue