fix: remove duplicate old() function causing 500 on create page

- Removed the local old() function definition from views/servers/create.php
  which conflicted with the global old() in src/Helpers/functions.php:37
- Replaced all old() calls with direct htmlspecialchars([...]) lookups
This commit is contained in:
2026-06-13 11:31:52 -04:00
parent e99615c162
commit 1e01961462

View File

@@ -1,9 +1,6 @@
<?php
$groups = $groups ?? [];
$old = $oldInput ?? [];
function old(string $key, string $default = ''): string {
return htmlspecialchars($GLOBALS['old'][$key] ?? $default);
}
?>
<div class="page-header">
@@ -23,13 +20,13 @@ function old(string $key, string $default = ''): string {
<label for="name">Server Name *</label>
<input type="text" id="name" name="name" class="form-input"
placeholder="e.g., Production Web Server" required
value="<?= old('name') ?>">
value="<?= htmlspecialchars($old['name'] ?? '') ?>">
</div>
<div class="form-group">
<label for="group_name">Group / Category</label>
<input type="text" id="group_name" name="group_name" class="form-input"
placeholder="e.g., Production, Staging"
list="groupList" value="<?= old('group_name') ?>">
list="groupList" value="<?= htmlspecialchars($old['group_name'] ?? '') ?>">
<datalist id="groupList">
<?php foreach ($groups as $group): ?>
<option value="<?= htmlspecialchars($group) ?>">
@@ -40,7 +37,7 @@ function old(string $key, string $default = ''): string {
<div class="form-group">
<label for="description">Description</label>
<textarea id="description" name="description" class="form-input" rows="3"
placeholder="Optional description of the server"><?= old('description') ?></textarea>
placeholder="Optional description of the server"><?= htmlspecialchars($old['description'] ?? '') ?></textarea>
</div>
</div>
@@ -51,18 +48,18 @@ function old(string $key, string $default = ''): string {
<label for="ip_address">IP Address / Hostname *</label>
<input type="text" id="ip_address" name="ip_address" class="form-input"
placeholder="e.g., 192.168.1.100 or server.example.com" required
value="<?= old('ip_address') ?>">
value="<?= htmlspecialchars($old['ip_address'] ?? '') ?>">
</div>
<div class="form-group">
<label for="ssh_port">SSH Port *</label>
<input type="number" id="ssh_port" name="ssh_port" class="form-input"
value="<?= old('ssh_port', '22') ?>" min="1" max="65535" required>
value="<?= htmlspecialchars($old['ssh_port'] ?? '22') ?>" min="1" max="65535" required>
</div>
<div class="form-group">
<label for="ssh_user">SSH User *</label>
<input type="text" id="ssh_user" name="ssh_user" class="form-input"
placeholder="e.g., root or admin" required
value="<?= old('ssh_user') ?>">
value="<?= htmlspecialchars($old['ssh_user'] ?? '') ?>">
</div>
</div>
</div>