Content Security Policy (CSP) compatibility beta.

This commit is contained in:
2026-06-20 00:21:19 +02:00
parent 0b76255cfa
commit 8b742d997c
68 changed files with 1632 additions and 1421 deletions

View File

@@ -33,12 +33,41 @@ class API_office_stompjes extends API
$this->apiOutput(200, ['success' => 'Stomp removed.']);
}
public function getStomp()
public function getStomp($frontend = false)
{
list($query, $types, $params) = $this->buildDynamicQuery('office_stompjes');
if (!$frontend) {
list($query, $types, $params) = $this->buildDynamicQuery('office_stompjes');
$items = $this->generalGetFunction($query, $types, $params, false, 'Stompjes');
$items = $this->generalGetFunction($query, $types, $params, false, 'Stompjes');
return ($items);
return ($items);
} else {
if (!isset($_GET['fd'])) {
$SelectFromDate = strtotime(date('Y-m-01'));
} else {
$date = str_replace('/', '-', htmlspecialchars($_GET['fd'], ENT_QUOTES, 'UTF-8'));
$SelectFromDate = strtotime($date . ' 00:00:00');
}
if (!isset($_GET['td'])) {
$SelectTillDate = time();
} else {
$date = str_replace('/', '-', htmlspecialchars($_GET['td'], ENT_QUOTES, 'UTF-8'));
$SelectTillDate = strtotime($date . ' 23:59:59');
}
$stompjes = [];
$stmt = $this->conn->query("SELECT stomp_uuid, office_stompjes.user_uuid, user_full_name, user_first_name, stomp_timestamp
FROM office_stompjes
INNER JOIN system_users ON office_stompjes.user_uuid = system_users.user_uuid
WHERE stomp_timestamp BETWEEN '$SelectFromDate' AND '$SelectTillDate'
AND user_stompable = '1'
ORDER BY stomp_timestamp DESC");
while ($row = $stmt->fetch_assoc()) {
$stompjes[] = $row;
}
return $stompjes;
}
}
}

View File

@@ -0,0 +1,24 @@
<?php
use api\classes\API;
session_start();
require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API.php";
$API = new API();
if ($API->request_method === 'GET') {
$breadcrumbJson = '[]';
if (isset($_SESSION['breadCrumbArray'])) {
try {
$breadcrumbJson = json_encode($_SESSION['breadCrumbArray'] ?? [], JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
error_log($e->getMessage());
$breadcrumbJson = '[]';
}
$_SESSION['breadCrumbArray'] = [];
}
echo $breadcrumbJson;
}

View File

@@ -0,0 +1,21 @@
<?php
use api\classes\API;
session_start();
require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API.php";
$API = new API();
if ($API->request_method === 'GET') {
# this is used by js scripts to get the locale of the user
$locale = getPreferredLocale();
$translations = require $_SERVER['DOCUMENT_ROOT'] . "/bin/locales/{$locale}.php";
header("Cache-Control: public, max-age=3600");
header('Content-Type: application/json; charset=utf-8');
echo json_encode($translations, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}

View File

@@ -0,0 +1,18 @@
<?php
use api\classes\API;
session_start();
require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API.php";
$API = new API();
if ($API->request_method === 'GET') {
ini_set('display_errors', 1);
if (isset($_SESSION['response'])) {
echo $_SESSION['response'];
unset($_SESSION['response']);
} else {
echo '[]';
}
}

View File

@@ -15,7 +15,12 @@ if (!$GLOBALS['modules_enabled']['office']) {
if ($API_office_stompjes->request_method === 'GET') {
$API_office_stompjes->checkPermissions('office-stompjes', 'RO');
$stompjes = $API_office_stompjes->getStomp();
if (isset($_GET['frontend'])) {
# This one is used by the frontend and is filtered by date.
$stompjes = $API_office_stompjes->getStomp(true);
} else {
$stompjes = $API_office_stompjes->getStomp();
}
$API_office_stompjes->apiOutput($code = 200, ['success' => $stompjes]);