adad
This commit is contained in:
@@ -11,17 +11,19 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$label = trim((string)($_POST['label'] ?? ''));
|
||||
$command = trim((string)($_POST['command'] ?? ''));
|
||||
$adminOnly = !empty($_POST['admin_only']) ? 1 : 0;
|
||||
$timeoutSec = (int)($_POST['timeout_sec'] ?? 0);
|
||||
|
||||
if ($label === '' || $command === '') {
|
||||
$error = 'Bitte Label und Command angeben.';
|
||||
} else {
|
||||
$stmt = $pdo->prepare(
|
||||
'INSERT INTO ' . $table('commands') . ' (label, command, admin_only) VALUES (:label, :command, :admin_only)'
|
||||
'INSERT INTO ' . $table('commands') . ' (label, command, admin_only, timeout_sec) VALUES (:label, :command, :admin_only, :timeout_sec)'
|
||||
);
|
||||
$stmt->execute([
|
||||
'label' => $label,
|
||||
'command' => $command,
|
||||
'admin_only' => $adminOnly,
|
||||
'timeout_sec' => $timeoutSec > 0 ? $timeoutSec : null,
|
||||
]);
|
||||
$notice = 'Befehl gespeichert.';
|
||||
}
|
||||
@@ -47,9 +49,10 @@ $commands = $pdo->query('SELECT * FROM ' . $table('commands') . ' ORDER BY id DE
|
||||
<div class="grid" style="margin-top:1rem;">
|
||||
<div class="card" style="background:var(--panel-2);">
|
||||
<strong>Neuer Befehl</strong>
|
||||
<form method="post" style="display:grid; gap:10px; margin-top:.75rem;">
|
||||
<form method="post" class="form-grid" style="margin-top:.75rem;">
|
||||
<input type="text" name="label" placeholder="Label" required>
|
||||
<textarea name="command" rows="4" placeholder="Command" required></textarea>
|
||||
<input type="number" name="timeout_sec" placeholder="Timeout (Sek., optional)">
|
||||
<label class="muted" style="display:flex; gap:8px; align-items:center;">
|
||||
<input type="checkbox" name="admin_only" value="1">
|
||||
Nur Admin
|
||||
@@ -66,12 +69,13 @@ $commands = $pdo->query('SELECT * FROM ' . $table('commands') . ' ORDER BY id DE
|
||||
<tr>
|
||||
<th>Label</th>
|
||||
<th>Command</th>
|
||||
<th>Timeout</th>
|
||||
<th>Admin</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (!$commands): ?>
|
||||
<tr><td colspan="3" class="muted">Keine Befehle vorhanden.</td></tr>
|
||||
<tr><td colspan="4" class="muted">Keine Befehle vorhanden.</td></tr>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($commands as $c): ?>
|
||||
<tr>
|
||||
@@ -79,6 +83,7 @@ $commands = $pdo->query('SELECT * FROM ' . $table('commands') . ' ORDER BY id DE
|
||||
<td class="muted" style="max-width:360px;">
|
||||
<code><?= e($c['command'] ?? '') ?></code>
|
||||
</td>
|
||||
<td><?= !empty($c['timeout_sec']) ? e((string)$c['timeout_sec']) . 's' : 'default' ?></td>
|
||||
<td><?= !empty($c['admin_only']) ? 'ja' : 'nein' ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
Reference in New Issue
Block a user