Files
phpsite/cancel.php
alex d629689473 Redesign as VM webshop with NetBox virtualization integration
- Split single-page into 3 pages:
  - index.php: product catalog with VM size cards
  - create.php: order form (name, domain, description)
  - requests.php: request history with pagination
- Rewrite NetBox integration to create Virtual Machines
  (/virtualization/virtual-machines/) instead of DCIM devices
- Add netbox_integration/netbox_api.php: NetBoxClient with
  createVirtualMachine(), findCluster(), findTag(), getList()
- Generate new sleek product-card images (420x280) with
  aligned spec boxes (vcpus/ram/disk)
- Add webshop CSS: product cards, nav links, hero section,
  order layout, responsive grid
- Update redirects: send.php -> requests.php, cancel.php -> requests.php
- Update E2E test for new page structure
- Add .gitignore, deploy-local.sh, setup_database.sql to repo
2026-05-09 23:49:02 +02:00

49 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
require __DIR__ . '/config.php';
require_login();
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
echo 'Method not allowed.';
exit;
}
if (!verify_csrf($_POST['csrf_token'] ?? null)) {
http_response_code(419);
echo 'Invalid CSRF token.';
exit;
}
$id = filter_var($_POST['id'] ?? '', FILTER_VALIDATE_INT);
if ($id === false || $id === null) {
header('Location: /requests.php?error=Invalid+request+ID.');
exit;
}
$stmt = db()->prepare('SELECT id, status FROM vm_requests WHERE id = ?');
$stmt->execute([$id]);
$request = $stmt->fetch();
if (!$request) {
header('Location: /requests.php?error=Request+not+found.');
exit;
}
if ($request['status'] !== 'queued') {
header('Location: /requests.php?error=Only+queued+requests+can+be+cancelled.');
exit;
}
try {
$stmt = db()->prepare('UPDATE vm_requests SET status = ? WHERE id = ?');
$stmt->execute(['cancelled', $id]);
} catch (PDOException $e) {
header('Location: /requests.php?error=Failed+to+cancel+request.');
exit;
}
header('Location: /requests.php?cancelled=1');
exit;