Content Security Policy (CSP) compatibility beta.
This commit is contained in:
24
pub/api/v1/frontend/breadcrumbs/index.php
Normal file
24
pub/api/v1/frontend/breadcrumbs/index.php
Normal 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;
|
||||
}
|
||||
21
pub/api/v1/frontend/locale/index.php
Normal file
21
pub/api/v1/frontend/locale/index.php
Normal 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);
|
||||
|
||||
}
|
||||
18
pub/api/v1/frontend/response/index.php
Normal file
18
pub/api/v1/frontend/response/index.php
Normal 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 '[]';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user