diff options
author | Stefan Giehl <stefan@matomo.org> | 2020-12-08 00:54:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-08 00:54:17 +0300 |
commit | 0d979018ce23e8e0187dd435cc8de99fcf3c3585 (patch) | |
tree | e06eb15fc0754475077fef3ad3e4da15232334cb /plugins/ScheduledReports | |
parent | 28efeafae6c9540060f39a5e1f76b4da3ad6c8bc (diff) |
Host detection: use HTTP_HOST as default, but provide a setting to use SERVER_NAME instead (#16899)
Diffstat (limited to 'plugins/ScheduledReports')
-rw-r--r-- | plugins/ScheduledReports/config/tcpdf_config.php | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/plugins/ScheduledReports/config/tcpdf_config.php b/plugins/ScheduledReports/config/tcpdf_config.php index 77f74ae9ef..aecb3296ba 100644 --- a/plugins/ScheduledReports/config/tcpdf_config.php +++ b/plugins/ScheduledReports/config/tcpdf_config.php @@ -53,21 +53,16 @@ if (!defined('K_TCPDF_EXTERNAL_CONFIG')) { if (!defined('K_PATH_URL')) { // Automatic calculation for the following K_PATH_URL constant $k_path_url = K_PATH_MAIN; // default value for console mode - if (isset($_SERVER['SERVER_NAME']) AND (!empty($_SERVER['SERVER_NAME']))) { - if (isset($_SERVER['HTTPS']) AND (!empty($_SERVER['HTTPS'])) AND strtolower($_SERVER['HTTPS']) != 'off') { - $k_path_url = 'https://'; - } else { - $k_path_url = 'http://'; - } - $k_path_url .= \Piwik\Url::getHostFromServerNameVar(); - $k_path_url .= str_replace('\\', '/', substr(K_PATH_MAIN, (strlen($_SERVER['DOCUMENT_ROOT']) - 1))); - } elseif (isset($_SERVER['HTTP_HOST']) AND (!empty($_SERVER['HTTP_HOST']))) { - if (isset($_SERVER['HTTPS']) AND (!empty($_SERVER['HTTPS'])) AND strtolower($_SERVER['HTTPS']) != 'off') { + + $host = \Piwik\Url::getHost(false); + + if ($host) { + if (isset($_SERVER['HTTPS']) and (!empty($_SERVER['HTTPS'])) and strtolower($_SERVER['HTTPS']) != 'off') { $k_path_url = 'https://'; } else { $k_path_url = 'http://'; } - $k_path_url .= $_SERVER['HTTP_HOST']; + $k_path_url .= $host; $k_path_url .= str_replace('\\', '/', substr(K_PATH_MAIN, (strlen($_SERVER['DOCUMENT_ROOT']) - 1))); } |