27 lines
671 B
PHP
27 lines
671 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/admin_bootstrap.php';
|
|
|
|
$pdo = admin_get_pdo();
|
|
admin_require_auth($pdo);
|
|
|
|
$method = $_SERVER['REQUEST_METHOD'] ?? 'GET';
|
|
if ($method !== 'GET') {
|
|
admin_json_error('Metoda niedozwolona', 405);
|
|
}
|
|
|
|
try {
|
|
$stmt = $pdo->prepare("SELECT id, username FROM users WHERE role = 'admin' ORDER BY username ASC");
|
|
$stmt->execute();
|
|
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
admin_json_response([
|
|
'success' => true,
|
|
'data' => $rows,
|
|
'count' => count($rows),
|
|
]);
|
|
} catch (Throwable $e) {
|
|
admin_json_error('Błąd pobierania listy adminów', 500);
|
|
}
|