give https urls if in a https context

This commit is contained in:
freya 2024-09-25 16:18:23 +00:00
parent 184b4162d6
commit 6702a8586c

View file

@ -36,13 +36,17 @@ abstract class Core {
*/ */
public static function get_url(string $path, bool $timestamp = FALSE): string public static function get_url(string $path, bool $timestamp = FALSE): string
{ {
$scheme = 'http';
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']))
$scheme = $_SERVER['HTTP_X_FORWARDED_PROTO'];
$host = $_SERVER['HTTP_HOST']; $host = $_SERVER['HTTP_HOST'];
if (ENVIRONMENT == 'production') if (ENVIRONMENT == 'production')
$host = lang('domain'); $host = lang('domain');
$base = lang('base_path'); $base = lang('base_path');
$url = "http://{$host}{$base}{$path}"; $url = "{$scheme}://{$host}{$base}{$path}";
if ($timestamp) { if ($timestamp) {
$time = @filemtime(PHP_ROOT . '/' . $path); $time = @filemtime(PHP_ROOT . '/' . $path);
$url .= "?timestamp={$time}"; $url .= "?timestamp={$time}";