blob: aa7a09ba750678e6497ef7740ddd6612dc8bd826 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<?php
include_once __DIR__ . '/../constants.php';
function call_handler(string $name) {
if (function_exists($name)) {
call_user_func($name);
}
}
$TOKEN = (array_key_exists('token', $_COOKIE)) ? ($_COOKIE['token'] ?? "") : ("");
$METHOD = null;
if (array_key_exists('method', $_POST)) {
$METHOD = $_POST;
}
else if (array_key_exists('method', $_GET)) {
$METHOD = $_GET;
}
if ($METHOD !== null) {
switch ($METHOD['method']) {
case 'PUT': call_handler('Controller\on_put'); break;
case 'DELETE': call_handler('Controller\on_delete'); break;
case 'PATCH': call_handler('Controller\on_patch'); break;
}
}
else if ($_SERVER['REQUEST_METHOD'] === 'POST') {
call_handler('Controller\on_post');
}
|