server-logs.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. $limit = strtolower($_GET['limit'] ?? 50); // A défaut les 50 derniers logs
  15. if ($search) {
  16. $lines = array_filter($lines, fn($line) => stripos($line, $search) !== false);
  17. }
  18. $lines = array_reverse($lines);
  19. ?>
  20. <!DOCTYPE html>
  21. <html lang="fr">
  22. <head>
  23. <meta charset="UTF-8">
  24. <title>Visualiseur de logs</title>
  25. <style>
  26. body { font-family: monospace; background: black !important; padding: 20px; }
  27. div { font-size: 0.8em; }
  28. .error { color: salmon; }
  29. .warning { color: orange; }
  30. .notice { color: white; }
  31. .grey { color: grey; }
  32. pre { background: #fff; padding: 10px; border: 1px solid #ccc; overflow-x: auto; }
  33. </style>
  34. <link rel="stylesheet" href="<?php cache::printFileWithTime("libs/bootstrap/assets/dist/css/bootstrap.min.css") ?>">
  35. <script src="<?php cache::printFileWithTime("libs/bootstrap/js/bootstrap.min.js") ?>"></script>
  36. </head>
  37. <body>
  38. <?php
  39. foreach (array_slice($lines, 0, $limit) as $line) {
  40. serverLog::filtreLog($line);
  41. }
  42. ?>
  43. </body>
  44. </html>