From edf446fae669f3370609f5a955c3d6c863a93524 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 26 Jan 2025 22:00:21 +0200 Subject: feat: Replace sessionStorage with (custom) cookieStorage --- controllers/meta.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'controllers/meta.php') diff --git a/controllers/meta.php b/controllers/meta.php index e20bbfc..91a8ade 100644 --- a/controllers/meta.php +++ b/controllers/meta.php @@ -6,8 +6,18 @@ function call_handler(string $name) { } } -switch ($_SERVER['REQUEST_METHOD']) { - case 'POST': call_handler('Controller\on_post'); break; - case 'PUT': call_handler('Controller\on_put'); break; - case 'DELETE': call_handler('Controller\on_delete'); break; -}; +$TOKEN = (array_key_exists('token', $_COOKIE)) ? ($_COOKIE['token'] ?? "") : (""); + +function request_handler() { + if ($_SERVER['REQUEST_METHOD'] === 'POST') { + if (array_key_exists('method', $_POST)) { + switch ($_POST['method']) { + case 'PUT': call_handler('Controller\on_put'); return; + case 'DELETE': call_handler('Controller\on_delete'); return; + case 'PATCH': call_handler('Controller\on_patch'); return; + } + } + call_handler('Controller\on_post'); + } +} +request_handler(); -- cgit v1.2.3