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