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.
40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../helpers.php';
|
|
runAuth();
|
|
|
|
/**
|
|
* Clear ALL menu data (all businesses)
|
|
*
|
|
* POST body: { "confirm": "NUKE_EVERYTHING" }
|
|
*/
|
|
|
|
$data = readJsonBody();
|
|
$confirm = $data['confirm'] ?? '';
|
|
|
|
if ($confirm !== 'NUKE_EVERYTHING') {
|
|
jsonResponse(['OK' => false, 'ERROR' => "Must pass confirm: 'NUKE_EVERYTHING' to proceed"]);
|
|
}
|
|
|
|
try {
|
|
// Get counts before deletion
|
|
$itemCount = queryOne("SELECT COUNT(*) as cnt FROM Items");
|
|
$catCount = queryOne("SELECT COUNT(*) as cnt FROM Categories");
|
|
$linkCount = queryOne("SELECT COUNT(*) as cnt FROM lt_ItemID_TemplateItemID");
|
|
|
|
// Delete in correct order (foreign key constraints)
|
|
queryTimed("DELETE FROM lt_ItemID_TemplateItemID");
|
|
queryTimed("DELETE FROM Items");
|
|
queryTimed("DELETE FROM Categories");
|
|
|
|
jsonResponse([
|
|
'OK' => true,
|
|
'deleted' => [
|
|
'items' => (int) $itemCount['cnt'],
|
|
'categories' => (int) $catCount['cnt'],
|
|
'templateLinks' => (int) $linkCount['cnt'],
|
|
],
|
|
]);
|
|
|
|
} catch (Exception $e) {
|
|
jsonResponse(['OK' => false, 'ERROR' => $e->getMessage(), 'DETAIL' => '']);
|
|
}
|