| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- session_start();
- require_once "../env.inc.php";
- require_once "../access.inc.php";
- require_once "../conf.inc.php";
- require_once DIR_PHP_LAYOUTS . "header.php";
- require_once DIR_PHP_LAYOUTS . "cms.session.php";
- if (!is_readable(SERVER_LOGS)) {
- echo "Le fichier n'est pas accessible en lecture.";
- exit();
- }
- $lines = file(SERVER_LOGS);
- $search = strtolower($_GET['search'] ?? '');
- if ($search) {
- $lines = array_filter($lines, fn($line) => stripos($line, $search) !== false);
- }
- ?>
- <!DOCTYPE html>
- <html lang="fr">
- <head>
- <meta charset="UTF-8">
- <title>Visualiseur de logs</title>
- <style>
- body { font-family: monospace; background: #f4f4f4; padding: 20px; }
- .error { color: red; }
- .warning { color: orange; }
- .notice { color: blue; }
- pre { background: #fff; padding: 10px; border: 1px solid #ccc; overflow-x: auto; }
- </style>
- <script>
-
- setInterval(() => {
- location.reload();
- }, 5000);
- </script>
- </head>
- <body>
- <form method="get">
- <label for="search">Filtrer par mot-clé :</label>
- <input type="text" name="search" value="<?= htmlspecialchars($search) ?>">
- <button type="submit">Filtrer</button>
- </form>
- <hr>
- <pre>
- <?php foreach (array_slice($lines, -50) as $line) {
- if(stripos($line, DOCUMENT_ROOT) !== false OR stripos($line, "/var/www/") === false){
- if (stripos($line, 'error') !== false) {
- echo '<div class="error">' . $line . '</div>';
- } elseif (stripos($line, 'warn') !== false) {
- echo '<div class="warning">' . $line . '</div>';
- } elseif (stripos($line, 'notice') !== false) {
- echo '<div class="notice">' . $line . '</div>';
- }
- }
- } ?>
- </pre>
- </body>
- </html>
|