Import current PCAT application

This commit is contained in:
ZeroIchiro
2026-09-15 10:47:36 +00:00
commit 1b532b937f
18 changed files with 1059 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/inc/admin_bootstrap.php';
requireAdmin();
$token = $_SERVER['HTTP_X_CSRF_TOKEN'] ?? '';
if (!is_string($token) || !hash_equals(csrf(), $token)) {
http_response_code(403);
exit;
}
$query = trim((string) ($_GET['q'] ?? ''));
if (mb_strlen($query) < 2 || mb_strlen($query) > 100) {
header('Content-Type: application/json; charset=utf-8');
echo '[]';
exit;
}
$statement = $pdo->prepare('SELECT id, name FROM authors WHERE name LIKE :query ORDER BY name LIMIT 10');
$statement->execute([':query' => '%' . $query . '%']);
header('Content-Type: application/json; charset=utf-8');
echo json_encode($statement->fetchAll(PDO::FETCH_ASSOC), JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE);