detaillog.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".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>Детализация для <a href=/admin/users/editauth.php?id=$id>$fip</a></b> ::&nbsp"); */
  30. ?>
  31. <div id="cont">
  32. <form action="<?php print $page_url; ?>" method="post">
  33. <input type="hidden" name="id" value=<?php echo $id; ?>>
  34. 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])$"
  35. Начало:&nbsp<input type="datetime-local" name="date_start" value="<?php echo $date1; ?>" />
  36. Конец:&nbsp<input type="datetime-local" name="date_stop" value="<?php echo $date2; ?>" />
  37. Шлюз:&nbsp <?php print_gateway_select($db_link, 'gateway', $rgateway); ?>
  38. DNS:&nbsp <input type=checkbox name=dns value="1" <?php print $dns_checked; ?>>
  39. Отображать:<?php print_row_at_pages('rows',$displayed); ?>
  40. <input type="submit" value="OK">
  41. </form>
  42. <b>Полный лог</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. $res = mysqli_query($db_link, $countSQL);
  50. $count_records = mysqli_fetch_array($res);
  51. $total=ceil($count_records[0]/$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[0],$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>Юзер</b></td>
  63. <td class="data" width=150><b><?php $url = $sort_url.'&sort=timestamp&order='.$new_order."'>Дата</a>"; print $url; ?></b></td>
  64. <td class="data" width=30><b>Роутер</b></td>
  65. <td class="data" width=30><b>Протокол</b></td>
  66. <td class="data" width=150><b><?php $url = $sort_url.'&sort=src_ip&order='.$new_order."'>Откуда</a>"; print $url; ?></b></td>
  67. <td class="data"><b>DNS</b></td>
  68. <td class="data" width=50><b>Порт</b></td>
  69. <td class="data" width=150><b><?php $url = $sort_url.'&sort=dst_ip&order='.$new_order."'>Куда</a>"; print $url; ?></b></td>
  70. <td class="data"><b>DNS</b></td>
  71. <td class="data" width=50><b>Порт</b></td>
  72. <td class="data" width=80><b><?php $url = $sort_url.'&sort=bytes&order='.$new_order."'>Байт</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.`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
  77. WHERE $gateway_filter $ip_where `timestamp`>='$date1' AND `timestamp`<'$date2'
  78. ORDER BY `timestamp` ASC LIMIT $start,$displayed) as T ON A.id = T.id ORDER BY $sort_table.$sort_field $order";
  79. $userdata = mysqli_query($db_link, $fsql);
  80. while (list ($uid, $auth_id, $udata, $urouter, $uproto, $sip, $sport,$dip, $dport, $ubytes, $upkt) = mysqli_fetch_array($userdata)) {
  81. print "<tr align=center align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  82. print "<td class=\"data\">$uid</td>\n";
  83. print "<td class=\"data\">"; print_auth_simple($db_link,$auth_id); print "</td>\n";
  84. print "<td class=\"data\">$udata</td>\n";
  85. print "<td class=\"data\">$gateway_list[$urouter]</td>\n";
  86. if ($uproto==='6') { $uproto = 'tcp'; }
  87. if ($uproto==='17') { $uproto = 'udp'; }
  88. print "<td class=\"data\">" . $uproto . "</td>\n";
  89. print "<td class=\"data\" align=left>" . long2ip($sip) . "</td>\n";
  90. $ip_name = '-';
  91. if ($rdns) { $ip_name = ResolveIP($db_link,$sip); }
  92. print "<td class=\"data\" align=left>" . $ip_name . "</td>\n";
  93. print "<td class=\"data\">" .$sport . "</td>\n";
  94. print "<td class=\"data\" align=left>" . long2ip($dip) . "</td>\n";
  95. $ip_name = '-';
  96. if ($rdns) { $ip_name = ResolveIP($db_link,$dip); }
  97. print "<td class=\"data\" align=left>" . $ip_name . "</td>\n";
  98. print "<td class=\"data\">" . $dport . "</td>\n";
  99. print "<td class=\"data\" align=right>" . fbytes($ubytes) . "</td>\n";
  100. print "<td class=\"data\" align=right>" . $upkt . "</td>\n";
  101. print "</tr>\n";
  102. }
  103. ?>
  104. </table>
  105. <?php print_navigation($page_url,$page,$displayed,$count_records[0],$total); ?>
  106. <br>
  107. <?php
  108. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  109. ?>