27 lines
1.2 KiB
PHP
27 lines
1.2 KiB
PHP
<?php
|
|
// public/index.php — tiny router
|
|
require __DIR__.'/../app/bootstrap.php';
|
|
require __DIR__.'/../app/helpers/cors.php';
|
|
|
|
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) ?: '/';
|
|
|
|
// CORS preflight
|
|
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { cors_preflight(); exit; }
|
|
|
|
// Routes (v1)
|
|
if ($path === '/v1/emojis') { require __DIR__.'/../app/controllers/Emojis.php'; exit; }
|
|
if (preg_match('#^/v1/emoji/([^/]+)$#', $path)) { $_GET['slug'] = urldecode($GLOBALS['matches'][1] ?? $GLOBALS['1'] ?? ''); require __DIR__.'/../app/controllers/Emojis.php'; exit; }
|
|
if ($path === '/v1/license/activate') { require __DIR__.'/../app/controllers/License.php'; exit; }
|
|
if ($path === '/v1/license/verify') { require __DIR__.'/../app/controllers/License.php'; exit; }
|
|
if ($path === '/v1/license/deactivate') { require __DIR__.'/../app/controllers/License.php'; exit; }
|
|
|
|
// Health
|
|
if ($path === '/v1/health') {
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
echo json_encode(['ok'=>true,'time'=>gmdate('c')]);
|
|
exit;
|
|
}
|
|
|
|
http_response_code(404);
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
echo json_encode(['error'=>'not_found','path'=>$path]); |