index.php 3.5 KB

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