feat: v1.6.0 — fix service 500, search bar, modal redesign

- Fix 500 error: cast to string before preg_replace
- Search bar to filter services by name/description
- Redesigned service action modal with status badge + colored buttons
- Version 1.6.0
This commit is contained in:
2026-06-09 19:20:18 -04:00
parent c4277c937f
commit 3e13ac60f1
4 changed files with 112 additions and 36 deletions

View File

@@ -659,15 +659,18 @@ class ApiController
}
$input = json_decode(file_get_contents('php://input'), true) ?? $_POST;
$service = $input['service'] ?? '';
$action = $input['action'] ?? '';
$service = (string) ($input['service'] ?? '');
$action = (string) ($input['action'] ?? '');
$allowed = ['start', 'stop', 'restart', 'reload'];
if (empty($service) || !in_array($action, $allowed, true)) {
if ($service === '' || !in_array($action, $allowed, true)) {
$this->view->json(['error' => 'Invalid service or action'], 400);
}
$sanitized = preg_replace('/[^a-zA-Z0-9\-_]/', '', $service);
if ($sanitized === '') {
$this->view->json(['error' => 'Invalid service name'], 400);
}
try {
$ssh = new SSHService();
@@ -678,7 +681,7 @@ class ApiController
$result = $ssh->exec("sudo systemctl {$action} {$sanitized} 2>&1");
$ssh->disconnect();
$exitCode = (int) ($result['exit_status'] ?? -1);
$exitCode = isset($result['exit_status']) ? (int) $result['exit_status'] : -1;
$auditService = new AuditService();
$auditService->logServerAction($id, "service_{$action}", "{$sanitized} {$action}");
@@ -694,7 +697,7 @@ class ApiController
} else {
$this->view->json([
'success' => false,
'error' => "Failed to {$action} '{$sanitized}'.",
'error' => "Failed to {$action} '{$sanitized}'. Exit code: {$exitCode}",
'data' => ['output' => trim($result['output'] ?? '')],
], 500);
}