2
0

server-logs.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. session_start();
  3. require_once "../env.inc.php";
  4. require_once "../access.inc.php";
  5. require_once "../conf.inc.php";
  6. require_once DIR_PHP_LAYOUTS . "header.php";
  7. require_once DIR_PHP_LAYOUTS . "cms.session.php";
  8. if (!is_readable(SERVER_LOGS)) {
  9. echo "Le fichier n'est pas accessible en lecture.";
  10. exit();
  11. }
  12. $lines = file(SERVER_LOGS);
  13. $search = strtolower($_GET['search'] ?? '');
  14. if ($search) {
  15. $lines = array_filter($lines, fn($line) => stripos($line, $search) !== false);
  16. }
  17. $lines = array_reverse($lines);
  18. ?>
  19. <!DOCTYPE html>
  20. <html lang="fr">
  21. <head>
  22. <meta charset="UTF-8">
  23. <title>Visualiseur de logs</title>
  24. <style>
  25. body { font-family: monospace; background: #f4f4f4; padding: 20px; }
  26. .error { color: red; }
  27. .warning { color: orange; }
  28. .notice { color: blue; }
  29. pre { background: #fff; padding: 10px; border: 1px solid #ccc; overflow-x: auto; }
  30. </style>
  31. <link rel="stylesheet" href="<?php cache::printFileWithTime("libs/bootstrap/assets/dist/css/bootstrap.min.css") ?>">
  32. <script src="<?php cache::printFileWithTime("libs/bootstrap/js/bootstrap.min.js") ?>"></script>
  33. <script>
  34. setInterval(() => {
  35. location.reload();
  36. }, 5000);
  37. </script>
  38. </head>
  39. <body>
  40. <?php
  41. foreach (array_slice($lines, 0, 100) as $line) {
  42. serverLog::filtreLog($line);
  43. }
  44. ?>
  45. </body>
  46. </html>