detaillog.php 5.9 KB

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