syslog.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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)) { $log_filter .= " AND `message` LIKE '%" . addslashes($fmessage) . "%'"; }
  37. $countSQL="SELECT Count(*) FROM `remote_syslog` WHERE `date`>='$date1' AND `date`<'$date2' $log_filter";
  38. $res = mysqli_query($db_link, $countSQL);
  39. $count_records = mysqli_fetch_array($res);
  40. $total=ceil($count_records[0]/$displayed);
  41. if ($page>$total) { $page=$total; }
  42. if ($page<1) { $page=1; }
  43. $start = ($page * $displayed) - $displayed;
  44. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  45. #speedup pageing
  46. $sSQL = "SELECT * FROM (SELECT * FROM `remote_syslog` WHERE `date`>='$date1' AND `date`<'$date2' $log_filter) as R ORDER BY `date` DESC LIMIT $start,$displayed";
  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. $syslog = get_records_sql($db_link, $sSQL);
  57. if (!empty($syslog)) {
  58. foreach ($syslog as $row) {
  59. print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  60. print "<td class=\"data\">" . $row['date'] . "</td>\n";
  61. print "<td class=\"data\">" . $row['ip'] . "</td>\n";
  62. print "<td class=\"data\">" . $row['message'] . "</td>\n";
  63. print "</tr>\n";
  64. }
  65. }
  66. print "</table>\n";
  67. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  68. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  69. ?>