Update common.php

check if SSL is being used and set/use a protocol constant instead of hardcoded http
This commit is contained in:
Luciano Fiore 2023-07-06 22:38:45 +01:00 committed by GitHub
parent b142975f43
commit c341d65a9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 3 deletions

View File

@ -6,15 +6,24 @@ $start = microtime();
$db_queries = 0;
if ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || ($_SERVER['SERVER_PORT'] == 443))
{
define('PROTOCOL', 'https://');
}
else
{
define('PROTOCOL', 'http://');
}
define('MAIN_SITE_URL', trim(SITE_URL, '/') . '/');
define('MAIN_SCRIPT_PATH', (SCRIPT_PATH ? trim(SCRIPT_PATH, '/') . '/' : ''));
define('VIEW_PATH', (FRIENDLY_URLS ? '' : 'view.php?id='));
define('VIEW_URL', 'http://' . MAIN_SITE_URL . MAIN_SCRIPT_PATH . VIEW_PATH);
define('VIEW_URL', PROTOCOL . MAIN_SITE_URL . MAIN_SCRIPT_PATH . VIEW_PATH);
define('IMAGES_URL', 'http://' . (FRIENDLY_URLS ? 'i.' : '') . MAIN_SITE_URL . (FRIENDLY_URLS ? '' : MAIN_SCRIPT_PATH . 'images/'));
define('IMAGES_URL', PROTOCOL . (FRIENDLY_URLS ? 'i.' : '') . MAIN_SITE_URL . (FRIENDLY_URLS ? '' : MAIN_SCRIPT_PATH . 'images/'));
define('IN_SCRIPT', true);
@ -81,4 +90,4 @@ function exit_message($message)
require('inc/message.php');
require('inc/footer.php');
exit;
}
}