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.
32 lines
1 KiB
PHP
32 lines
1 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../helpers.php';
|
|
runAuth();
|
|
|
|
try {
|
|
$data = readJsonBody();
|
|
|
|
$userID = (int) ($data['UserID'] ?? 0);
|
|
$businessID = (int) ($data['BusinessID'] ?? 0);
|
|
$servicePointID = (int) ($data['ServicePointID'] ?? 0);
|
|
|
|
if ($userID === 0) apiAbort(['OK' => false, 'ERROR' => 'missing_UserID']);
|
|
if ($businessID === 0) apiAbort(['OK' => false, 'ERROR' => 'missing_BusinessID']);
|
|
|
|
$params = [$userID, $businessID];
|
|
$spVal = $servicePointID > 0 ? '?' : 'NULL';
|
|
if ($servicePointID > 0) $params[] = $servicePointID;
|
|
|
|
queryTimed("
|
|
INSERT INTO UserPresence (UserID, BusinessID, ServicePointID, LastSeenOn)
|
|
VALUES (?, ?, $spVal, NOW())
|
|
ON DUPLICATE KEY UPDATE
|
|
BusinessID = VALUES(BusinessID),
|
|
ServicePointID = VALUES(ServicePointID),
|
|
LastSeenOn = NOW()
|
|
", $params);
|
|
|
|
jsonResponse(['OK' => true]);
|
|
|
|
} catch (Exception $e) {
|
|
jsonResponse(['OK' => false, 'ERROR' => 'server_error', 'MESSAGE' => $e->getMessage()]);
|
|
}
|