| Server IP : 193.86.120.172 / Your IP : 216.73.216.215 Web Server : Apache/2.4.63 (Unix) System : Linux JServices 3.10.108 #86003 SMP Wed Oct 22 13:20:46 CST 2025 x86_64 User : kubec ( 1026) PHP Version : 8.2.28 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /volume1/web/kadernictvidenisa_cz/api/ |
Upload File : |
<?php
// ============================================
// api/index.php
// Centrální API router
// ============================================
require_once __DIR__ . '/../includes/db.php';
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type, Authorization');
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { http_response_code(204); exit; }
$method = $_SERVER['REQUEST_METHOD'];
$path = trim($_GET['path'] ?? '', '/');
$parts = explode('/', $path);
$resource = $parts[0] ?? '';
$id = isset($parts[1]) && is_numeric($parts[1]) ? (int)$parts[1] : null;
$input = [];
if (in_array($method, ['POST', 'PUT', 'DELETE'])) {
$raw = file_get_contents('php://input');
$input = json_decode($raw, true) ?? [];
}
// Načteme auth.php až zde — $method a $parts jsou již definovány
require_once __DIR__ . '/auth.php';
match($resource) {
'sluzby' => require __DIR__ . '/sluzby.php',
'dostupnost'=> require __DIR__ . '/dostupnost.php',
'rezervace' => require __DIR__ . '/rezervace.php',
'token' => require __DIR__ . '/token.php',
'nastaveni' => require __DIR__ . '/nastaveni.php',
'admin' => require __DIR__ . '/admin.php',
'auth' => require __DIR__ . '/auth.php',
'heslo' => require __DIR__ . '/heslo.php',
'ics' => require __DIR__ . '/ics.php',
'zakaznici' => require __DIR__ . '/zakaznici.php',
'pracovni-doba' => require __DIR__ . '/pracovni-doba.php',
'pracovni-doba-public' => require __DIR__ . '/pracovni-doba-public.php',
'uzivatele' => require __DIR__ . '/uzivatele.php',
'doplnky' => require __DIR__ . '/doplnky.php',
default => json_error('Neznámý endpoint', 404),
};