Unsupported scripts and control panel web app for a hosting company
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

editsite.errors.php 1.0KB

123456789101112131415161718192021222324252627282930313233343536
  1. <div class="block">
  2. <h2>Recent errors</h2>
  3. <table class="innerblock">
  4. <tr>
  5. <th>Time</th>
  6. <th>Type</th>
  7. <th>Client</th>
  8. <th>Message</th>
  9. </tr>
  10. <?PHP
  11. $file = '/usr/local/apache/logs/'.str_pad(SITE_ID,3,'0',STR_PAD_LEFT).'-error_log';
  12. if (file_exists($file) && ($size = filesize($file)) > 0) {
  13. $fh = fopen($file,'r');
  14. if ($size < 1024*50) { $size = 1024*50; }
  15. fseek($fh, $size - 1024*50);
  16. $lines = array();
  17. while (!feof($fh)) {
  18. $lines[] = fgets($fh);
  19. }
  20. array_shift($lines); // Could be incomplete
  21. $lines = array_reverse($lines);
  22. $lines = array_slice($lines, 0, 10);
  23. $i = 0;
  24. foreach ($lines as $line) {
  25. if (preg_match('/^\[(.*?)\] \[(.*?)\]( \[client (.*?)\])? (.*)$/', $line, $matches)) {
  26. echo '<tr'.(($i == 1)?' class="odd"':'').'><td>'.$matches[1].'</td><td>'.$matches[2].'</td><td>'.$matches[4].'</td><td>'.$matches[5].'</td></tr>';
  27. $i = 1 - $i;
  28. }
  29. }
  30. fclose($fh);
  31. } else {
  32. echo '<tr><td colspan="4" style="font-style: italic; text-align: center;">No errors</td></tr>';
  33. }
  34. ?>
  35. </table>
  36. </div>