|
@@ -116,8 +116,18 @@ if (in_array(SERVICE, ['reg', 'ns', 'ht']) AND CONF[SERVICE]['enabled'] !== true
|
|
|
output(403, 'Ce service est désactivé.');
|
|
|
|
|
|
// Protect against cross-site request forgery if a POST request is received
|
|
|
-if (empty($_POST) === false AND (isset($_SERVER['HTTP_SEC_FETCH_SITE']) !== true OR $_SERVER['HTTP_SEC_FETCH_SITE'] !== 'same-origin'))
|
|
|
- output(403, 'Anti-<abbr title="Cross-Site Request Forgery">CSRF</abbr> verification failed ! (Wrong or unset <code>Sec-Fetch-Site</code> HTTP header)');
|
|
|
+if ($_POST !== []) {
|
|
|
+ if (isset($_SERVER['HTTP_SEC_FETCH_SITE']) !== true)
|
|
|
+ output(403, 'The <code>Sec-Fetch-Site</code> HTTP header is required when submitting a POST request to prevent Cross-Site Request Forgery (<abbr>CSRF</abbr>).');
|
|
|
+ if ($_SERVER['HTTP_SEC_FETCH_SITE'] !== 'same-origin')
|
|
|
+ output(403, 'The <code>Sec-Fetch-Site</code> HTTP header must be <code>same-origin</code> when submitting a POST request to prevent Cross-Site Request Forgery (<abbr>CSRF</abbr>).');
|
|
|
+}
|
|
|
+
|
|
|
+if (isset($_SERVER['SERVER_NAME']) !== true)
|
|
|
+ output(500, 'Missing $_SERVER[\'SERVER_NAME\']');
|
|
|
+if (in_array($_SERVER['SERVER_NAME'], CONF['common']['public_domains'], true) !== true)
|
|
|
+ output(500, 'The current server name is not allowed in configuration.');
|
|
|
+define('SERVER_NAME', $_SERVER['SERVER_NAME']);
|
|
|
|
|
|
function displayFinalMessage() {
|
|
|
global $final_message;
|