detaillog.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");
  6. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/gatefilter.php");
  7. $default_sort='id';
  8. $sort_table = 'A';
  9. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
  10. $f_ip = getParam('ip', $page_url, '127.0.0.1');
  11. $_SESSION[$page_url]['ip'] = $f_ip;
  12. $ip_where = '';
  13. $params=[];
  14. if (!empty($f_ip)) {
  15. if (checkValidIp($f_ip)) {
  16. $ip_where = " (src_ip=? or dst_ip=?) AND ";
  17. $params[]=ip2long($f_ip);
  18. $params[]=ip2long($f_ip);
  19. }
  20. }
  21. $rdns = getPOST('dns', $page_url, 0, FILTER_VALIDATE_INT);
  22. $_SESSION[$page_url]['dns'] = $rdns;
  23. $dns_checked = $rdns ? 'checked="checked"' : '';
  24. $dns_cache=NULL;
  25. print_log_submenu($page_url);
  26. ?>
  27. <div id="contsubmenu">
  28. <form action="<?php print $page_url; ?>" method="post">
  29. <input type="hidden" name="id" value="<?php echo $id; ?>">
  30. <?php print_date_fields($date1,$date2,$date_shift); ?>
  31. <?php echo WEB_cell_gateway; ?>:&nbsp <?php print_gateway_select($db_link, 'gateway', $rgateway); ?>
  32. DNS:&nbsp <input type=checkbox name=dns value="1" <?php print $dns_checked; ?>>
  33. <?php print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?>
  34. <div><br>
  35. <?php echo WEB_cell_ip; ?>:&nbsp<input type="text" name="ip" value="<?php echo $f_ip; ?>" pattern="^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$">
  36. <input type="submit" value="<?php echo WEB_btn_show; ?>">
  37. </form>
  38. <div><br>
  39. <b><?php echo WEB_log_full; ?></b>
  40. <?php
  41. $sort_url = "<a href='detaillog.php?date_start=\"".$date1.'"&date_stop="'.$date2.'"';
  42. if (!empty($f_ip)) { $sort_url .='&f_ip="'.$f_ip.'"'; }
  43. $gateway_filter='';
  44. if (!empty($rgateway) and $rgateway>0) {
  45. $gateway_filter="(router_id=?) AND"; $params[]=$rgateway;
  46. }
  47. $countSQL="SELECT Count(*) FROM traffic_detail as A WHERE $gateway_filter $ip_where ts>=? AND ts< ? ";
  48. $params[]=$date1;
  49. $params[]=$date2;
  50. $count_records = get_single_field($db_link,$countSQL, $params);
  51. $total=ceil($count_records/$displayed);
  52. if ($page>$total) { $page=$total; }
  53. if ($page<1) { $page=1; }
  54. $start = ($page * $displayed) - $displayed;
  55. print_navigation($page_url,$page,$displayed,$count_records,$total);
  56. $gateway_list = get_gateways($db_link);
  57. ?>
  58. <br>
  59. <table class="data">
  60. <tr align="center">
  61. <td class="data" width=20><b><?php $url = $sort_url.'&sort=id&order='.$new_order."'>id</a>"; print $url; ?></b></td>
  62. <td class="data" width=20><b><?php echo WEB_cell_login; ?></b></td>
  63. <td class="data" width=150><b><?php $url = $sort_url.'&sort=ts&order='.$new_order."'>".WEB_date."</a>"; print $url; ?></b></td>
  64. <td class="data" width=30><b><?php echo WEB_cell_gateway; ?></b></td>
  65. <td class="data" width=30><b><?php echo WEB_traffic_proto; ?></b></td>
  66. <td class="data" width=150><b><?php $url = $sort_url.'&sort=src_ip&order='.$new_order."'>".WEB_traffic_source_address."</a>"; print $url; ?></b></td>
  67. <td class="data"><b>DNS</b></td>
  68. <td class="data" width=50><b><?php echo WEB_traffic_src_port; ?></b></td>
  69. <td class="data" width=150><b><?php $url = $sort_url.'&sort=dst_ip&order='.$new_order."'>".WEB_traffic_dest_address."</a>"; print $url; ?></b></td>
  70. <td class="data"><b>DNS</b></td>
  71. <td class="data" width=50><b><?php echo WEB_traffic_dst_port; ?></b></td>
  72. <td class="data" width=80><b><?php $url = $sort_url.'&sort=bytes&order='.$new_order."'>".WEB_bytes."</a>"; print $url; ?></b></td>
  73. <td class="data" width=80><b><?php $url = $sort_url.'&sort=pkt&order='.$new_order."'>Pkt</a>"; print $url; ?></b></td>
  74. </tr>
  75. <?php
  76. $fsql = "SELECT A.id, A.auth_id, A.ts, A.router_id, A.proto, A.src_ip, A.src_port, A.dst_ip, A.dst_port, A.bytes, A.pkt FROM traffic_detail as A JOIN (SELECT id FROM traffic_detail
  77. WHERE $gateway_filter $ip_where ts>= ? AND ts< ?
  78. ORDER BY ts ASC LIMIT ? OFFSET ?) as T ON A.id = T.id ORDER BY $sort_table.$sort_field $order";
  79. $params[]=$displayed;
  80. $params[]=$start;
  81. $userdata = get_records_sql($db_link, $fsql, $params);
  82. foreach ($userdata as $row) {
  83. print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  84. print "<td class=\"data\">" . $row['id'] . "</td>\n";
  85. print "<td class=\"data\">"; print_auth_simple($db_link, $row['auth_id']); print "</td>\n";
  86. print "<td class=\"data\">" . get_datetime_display($row['ts']) . "</td>\n";
  87. print "<td class=\"data\">" . $gateway_list[$row['router_id']] . "</td>\n";
  88. $proto_name = getprotobynumber($row['proto']);
  89. if (!$proto_name) { $proto_name = $row['proto']; }
  90. print "<td class=\"data\">" . $proto_name . "</td>\n";
  91. print "<td class=\"data\" align=left>" . long2ip($row['src_ip']) . "</td>\n";
  92. $ip_name = '-';
  93. if ($rdns) { $ip_name = ResolveIP($db_link, $row['src_ip']); }
  94. print "<td class=\"data\" align=left>" . $ip_name . "</td>\n";
  95. print "<td class=\"data\">" . $row['src_port'] . "</td>\n";
  96. print "<td class=\"data\" align=left>" . long2ip($row['dst_ip']) . "</td>\n";
  97. $ip_name = '-';
  98. if ($rdns) { $ip_name = ResolveIP($db_link, $row['dst_ip']); }
  99. print "<td class=\"data\" align=left>" . $ip_name . "</td>\n";
  100. print "<td class=\"data\">" . $row['dst_port'] . "</td>\n";
  101. print "<td class=\"data\" align=right>" . fbytes($row['bytes']) . "</td>\n";
  102. print "<td class=\"data\" align=right>" . $row['pkt'] . "</td>\n";
  103. print "</tr>\n";
  104. }
  105. ?>
  106. </table>
  107. <?php print_navigation($page_url,$page,$displayed,$count_records,$total); ?>
  108. <?php
  109. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  110. ?>