Files
server-manager/views/servers/logs.php
Agent 88f3c1f964 refactor: extract inline CSS/JS from views into separate asset files (20+ files)
Phase A — HTML removed from PHP files:
- RateLimitMiddleware.php: heredoc moved to views/errors/429.php
- public/index.php: inline HTML replaced with View::error()
- AuthMiddleware.php: <script> redirect replaced with <meta refresh>

Phase B — Inline CSS/JS extracted from views:
- CSS: landing.css (459 lines), legal.css (shared by terms+privacy)
- JS: 17 new files extracted from ~20 view files
  - main.js (layout sidebar + notifications)
  - dashboard-chart.js, server-show.js, server-services.js
  - nginx-manager.js, database-manager.js
  - terminal.js, team-show.js, team-index.js
  - server-list.js, server-permissions.js (shared by edit+create)
  - server-ssl.js, server-processes.js, system-users.js
  - admin-users.js, audit-log.js, admin-notifications.js, admin-security.js
  - notifications.js

Total: -3264 lines from views, +288 lines in new assets
2026-06-14 08:04:01 -04:00

77 lines
3.1 KiB
PHP

<?php
$server = $server ?? [];
$logOutput = $logOutput ?? '';
$logType = $logType ?? 'syslog';
$lines = $lines ?? 100;
$logFiles = $logFiles ?? [];
?>
<div class="page-header">
<div class="page-header-left">
<div class="back-link">
<a href="/servers/<?= $server['id'] ?>"><i class="fas fa-arrow-left"></i> Back to Server</a>
</div>
<h1 class="page-title">System Logs</h1>
<p class="page-subtitle"><?= htmlspecialchars($server['name']) ?></p>
</div>
</div>
<div class="card">
<div class="card-header">
<div class="card-filters">
<select id="logType" class="form-select" onchange="updateLog()">
<?php foreach ($logFiles as $file): ?>
<option value="<?= $file ?>" <?= $logType === $file ? 'selected' : '' ?>>
<?= ucfirst($file) ?>
</option>
<?php endforeach; ?>
</select>
<select id="logLines" class="form-select" onchange="updateLog()">
<option value="50" <?= $lines == 50 ? 'selected' : '' ?>>50 lines</option>
<option value="100" <?= $lines == 100 ? 'selected' : '' ?>>100 lines</option>
<option value="200" <?= $lines == 200 ? 'selected' : '' ?>>200 lines</option>
<option value="500" <?= $lines == 500 ? 'selected' : '' ?>>500 lines</option>
</select>
<button class="btn btn-secondary btn-sm" onclick="updateLog()">
<i class="fas fa-sync-alt"></i> Refresh
</button>
</div>
</div>
<div class="card-body">
<?php if (empty(trim($logOutput))): ?>
<div class="empty-state">
<i class="fas fa-file-alt empty-icon"></i>
<p>No log data available.</p>
</div>
<?php else: ?>
<div class="log-viewer">
<?php
$logLines = explode("\n", trim($logOutput));
foreach ($logLines as $line):
$lineClass = 'log-line';
$lower = mb_strtolower($line);
if (str_contains($lower, 'error') || str_contains($lower, 'critical') || str_contains($lower, 'emergency')) {
$lineClass .= ' log-line-error';
} elseif (str_contains($lower, 'warning') || str_contains($lower, 'warn')) {
$lineClass .= ' log-line-warning';
} elseif (str_contains($lower, 'notice') || str_contains($lower, 'info')) {
$lineClass .= ' log-line-info';
}
?>
<div class="<?= $lineClass ?>">
<code><?= htmlspecialchars($line) ?></code>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</div>
<script>
function updateLog() {
const type = document.getElementById('logType').value;
const lines = document.getElementById('logLines').value;
window.location.href = '/servers/<?= $server['id'] ?>/logs?type=' + type + '&lines=' + lines;
}
</script>