syslog.php 3.3 KB

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