payfrit-api/api/beacon-sharding/get_shard_pool.php
John Mizerek 1f81d98c52 Initial PHP API migration from CFML
Complete port of all 163 API endpoints from Lucee/CFML to PHP 8.3.
Shared helpers in api/helpers.php (DB, auth, request/response, security).
PDO prepared statements throughout. Same JSON response shapes as CFML.
2026-03-14 14:26:59 -07:00

34 lines
822 B
PHP

<?php
require_once __DIR__ . '/../helpers.php';
runAuth();
try {
$sinceId = (int) ($_GET['since'] ?? 0);
$sql = "SELECT ID, UUID FROM BeaconShards WHERE IsActive = 1";
$params = [];
if ($sinceId > 0) {
$sql .= " AND ID > ?";
$params[] = $sinceId;
}
$sql .= " ORDER BY ID ASC";
$rows = queryTimed($sql, $params);
$shards = [];
$maxId = 0;
foreach ($rows as $r) {
$shards[] = ['ID' => (int) $r['ID'], 'UUID' => $r['UUID']];
if ((int) $r['ID'] > $maxId) $maxId = (int) $r['ID'];
}
jsonResponse([
'OK' => true,
'Version' => $maxId,
'Count' => count($shards),
'Shards' => $shards,
]);
} catch (Exception $e) {
jsonResponse(['OK' => false, 'ERROR' => 'server_error', 'MESSAGE' => $e->getMessage()]);
}