index.php 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
  4. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  5. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datefilter.php");
  6. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/loglevelfilter.php");
  7. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/logfilter.php");
  8. print_log_submenu($page_url);
  9. ?>
  10. <div id="cont">
  11. <br>
  12. <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
  13. Начало:<input type="date" name="date_start" value="<?php echo $date1; ?>" />
  14. Конец:<input type="date" name="date_stop" value="<?php echo $date2; ?>" />
  15. Отображать:<?php print_row_at_pages('rows',$displayed); ?>
  16. Уровень логов:<?php print_loglevel_select('log_level',$log_level); ?>
  17. <input type="submit" value="OK"><br><br>
  18. Фильтр Источник:<input name="customer" value="<?php echo $fcustomer; ?>" />
  19. Сообщение:<input name="message" value="<?php echo $fmessage; ?>" />
  20. </form>
  21. <?php
  22. $log_filter ='';
  23. global $L_ERROR;
  24. global $L_WARNING;
  25. global $L_INFO;
  26. global $L_VERBOSE;
  27. global $L_DEBUG;
  28. if ($log_level === $L_ERROR) { $log_filter = " and `level`=$L_ERROR "; }
  29. if ($log_level === $L_WARNING) { $log_filter = " and `level`<=$L_WARNING "; }
  30. if ($log_level === $L_INFO) { $log_filter = " and `level`<=$L_INFO "; }
  31. if ($log_level === $L_VERBOSE) { $log_filter = " and `level`<=$L_VERBOSE "; }
  32. if ($log_level === $L_DEBUG) { $log_filter = ""; }
  33. if (isset($fcustomer)) { $log_filter = $log_filter." and customer LIKE '%".$fcustomer."%'"; }
  34. if (isset($fmessage)) { $log_filter = $log_filter." and message LIKE '%".$fmessage."%'"; }
  35. $countSQL="SELECT Count(*) FROM syslog WHERE date(timestamp)>='$date1' AND date(timestamp)<'$date2' $log_filter";
  36. $res = mysqli_query($db_link, $countSQL);
  37. $count_records = mysqli_fetch_array($res);
  38. $total=ceil($count_records[0]/$displayed);
  39. if ($page>$total) { $page=$total; }
  40. if ($page<1) { $page=1; }
  41. $start = ($page * $displayed) - $displayed;
  42. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  43. ?>
  44. <br>
  45. <table class="data" width="90%">
  46. <tr align="center">
  47. <td class="data" width=150><b>Время</b></td>
  48. <td class="data"><b>Менеджер</b></td>
  49. <td class="data"><b>Level</b></td>
  50. <td class="data"><b>Лог</b></td>
  51. </tr>
  52. <?php
  53. #speedup paging
  54. $sSQL = "SELECT timestamp,customer,message,level FROM syslog as S JOIN (SELECT id FROM syslog WHERE date(timestamp)>='$date1' AND date(timestamp)<'$date2' $log_filter ORDER BY id DESC LIMIT $start,$displayed) AS I ON S.id = I.id";
  55. $userlog = get_records_sql($db_link, $sSQL);
  56. foreach ($userlog as $row) {
  57. print "<tr align=center align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  58. print "<td class=\"data\">" . $row['timestamp'] . "</td>\n";
  59. print "<td class=\"data\">" . $row['customer'] . "</td>\n";
  60. $msg_level = 'INFO';
  61. if ($row['level'] == $L_ERROR) { $msg_level='ERROR'; }
  62. if ($row['level'] == $L_WARNING) { $msg_level='WARNING'; }
  63. if ($row['level'] == $L_DEBUG) { $msg_level='DEBUG'; }
  64. if ($row['level'] == $L_VERBOSE) { $msg_level='VERBOSE'; }
  65. print "<td class=\"data\">" . $msg_level . "</td>\n";
  66. $print_msg = expand_log_str($db_link, $row['message']);
  67. print "<td class=\"data\" align=left>" . $print_msg . "</td>\n";
  68. print "</tr>\n";
  69. }
  70. print "</table>\n";
  71. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  72. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  73. ?>