syslog.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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/logfilter.php");
  7. if (isset($_POST['device_show'])) { $f_id = $_POST['device_show']*1; }
  8. if (isset($_GET['device_show'])) { $f_id = $_GET['device_show']*1; }
  9. if (!isset($f_id) and isset($_SESSION[$page_url]['device_show'])) { $f_id=$_SESSION[$page_url]['device_show']*1; }
  10. if (!isset($f_id)) { $f_id=0; }
  11. $_SESSION[$page_url]['device_show']=$f_id;
  12. print_log_submenu($page_url);
  13. $log_filter = "";
  14. if ($f_id>0) {
  15. $dev_ips=get_device_ips($db_link,$f_id);
  16. $log_filter=' and `ip` IN (';
  17. foreach ($dev_ips as $index => $ip) {
  18. $log_filter=$log_filter."'".$ip."',";
  19. }
  20. $log_filter = preg_replace('/\,$/', '',$log_filter);
  21. $log_filter = $log_filter .")";
  22. }
  23. ?>
  24. <div id="cont">
  25. <br>
  26. <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
  27. Начало:&nbsp<input type="date" name="date_start" value="<?php echo $date1; ?>" />
  28. Конец:&nbsp<input type="date" name="date_stop" value="<?php echo $date2; ?>" />
  29. Отчёт по устройству&nbsp <?php print_device_select($db_link, "device_show", $f_id); ?>
  30. Отображать:<?php print_row_at_pages('rows',$displayed); ?>
  31. <input type="submit" value="OK"><br><br>
  32. Фильтр - сообщение:<input name="message" value="<?php echo $fmessage; ?>" />
  33. </form>
  34. <?php
  35. if (isset($fmessage)) {
  36. if (isset($log_filter)) { $log_filter = $log_filter." and message LIKE '%".$fmessage."%'"; } else { $log_filter = " message LIKE '%".$fmessage."%'"; }
  37. }
  38. $countSQL="SELECT Count(*) FROM `remote_syslog` WHERE `date`>='$date1' AND `date`<'$date2' $log_filter";
  39. $res = mysqli_query($db_link, $countSQL);
  40. $count_records = mysqli_fetch_array($res);
  41. $total=ceil($count_records[0]/$displayed);
  42. if ($page>$total) { $page=$total; }
  43. if ($page<1) { $page=1; }
  44. $start = ($page * $displayed) - $displayed;
  45. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  46. ?>
  47. <br>
  48. <table class="data" width="90%">
  49. <tr align="center">
  50. <td class="data" width=150><b>Дата</b></td>
  51. <td class="data"><b>IP </b></td>
  52. <td class="data"><b>Сообщение</b></td>
  53. </tr>
  54. <?php
  55. #speedup pageing
  56. $sSQL = "SELECT
  57. `date`, `ip`, `message`
  58. FROM `remote_syslog` as R
  59. JOIN
  60. (SELECT id FROM `remote_syslog` WHERE `date`>='$date1' AND `date`<'$date2' $log_filter ORDER BY `id` DESC LIMIT $start,$displayed) as I
  61. ON R.id = I.id";
  62. $syslog = get_records_sql($db_link, $sSQL);
  63. if (!empty($syslog)) {
  64. foreach ($syslog as $row) {
  65. print "<tr align=center align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  66. print "<td class=\"data\">" . $row['date'] . "</td>\n";
  67. print "<td class=\"data\">" . $row['ip'] . "</td>\n";
  68. print "<td class=\"data\">" . $row['message'] . "</td>\n";
  69. print "</tr>\n";
  70. }
  71. }
  72. print "</table>\n";
  73. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  74. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  75. ?>