1
0

index-full.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. $default_displayed=100;
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  4. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
  5. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  6. $default_date_shift='d';
  7. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datefilter.php");
  8. $default_sort='tin';
  9. $default_order='DESC';
  10. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");
  11. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
  12. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/gatefilter.php");
  13. print_reports_submenu($page_url);
  14. ?>
  15. <div id="cont">
  16. <form action="index-full.php" method="post">
  17. <?php echo WEB_cell_ou; ?>:&nbsp<?php print_ou_select($db_link,'ou',$rou); ?>
  18. <?php echo WEB_log_start_date; ?>:&nbsp<input type="date" name="date_start" value="<?php echo $date1; ?>" />
  19. <?php echo WEB_log_stop_date; ?>:&nbsp<input type="date" name="date_stop" value="<?php echo $date2; ?>" />
  20. <?php echo WEB_cell_gateway; ?>:&nbsp<?php print_gateway_select($db_link, 'gateway', $rgateway); ?>
  21. <?php print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?>
  22. <input id='btn_filter' name='btn_filter' type="submit" value="<?php echo WEB_btn_show; ?>">
  23. </form>
  24. <?php
  25. $sort_sql=" ORDER BY tin DESC";
  26. if (!empty($sort_field) and !empty($order)) { $sort_sql = " ORDER BY $sort_field $order"; }
  27. $gateway_list = get_gateways($db_link);
  28. $trafSQL = "SELECT
  29. User_list.login,User_list.ou_id,User_auth.user_id, User_auth.ip, User_stats_full.auth_id,
  30. User_stats_full.router_id, SUM( byte_in ) AS tin, SUM( byte_out ) AS tout, MAX(ROUND(`pkt_in`/`step`)) as pin, MAX(ROUND(`pkt_out`/`step`)) as pout
  31. FROM User_stats_full,User_auth,User_list WHERE User_list.id=User_auth.user_id
  32. AND User_stats_full.auth_id = User_auth.id
  33. AND User_stats_full.timestamp>='$date1'
  34. AND User_stats_full.timestamp<'$date2'
  35. ";
  36. if ($rou !== 0) {
  37. $trafSQL = $trafSQL . " AND User_list.ou_id=$rou";
  38. }
  39. if ($rgateway == 0) {
  40. $trafSQL = $trafSQL . " GROUP by User_auth.id,User_stats_full.router_id";
  41. } else {
  42. $trafSQL = $trafSQL . " AND User_stats_full.router_id=$rgateway GROUP by User_auth.id,User_stats_full.router_id";
  43. }
  44. $countSQL = "SELECT Count(*) FROM ($trafSQL) A";
  45. $res = mysqli_query($db_link, $countSQL);
  46. $count_records = mysqli_fetch_array($res);
  47. $total=ceil($count_records[0]/$displayed);
  48. if ($page>$total) { $page=$total; }
  49. if ($page<1) { $page=1; }
  50. $start = ($page * $displayed) - $displayed;
  51. #set sort
  52. $trafSQL=$trafSQL ." $sort_sql LIMIT $start,$displayed";
  53. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  54. print "<br><br>\n";
  55. print "<table class=\"data\" cellspacing=\"1\" cellpadding=\"4\">\n";
  56. print "<tr align=\"center\">\n";
  57. print "<td ><b><a href=index-full.php?sort=login&order=$new_order>".WEB_cell_login."</a></b></td>\n";
  58. print "<td ><b><a href=index-full.php?sort=ip&order=$new_order>".WEB_cell_ip."</a></b></td>\n";
  59. print "<td ><b>".WEB_cell_gateway."</b></td>\n";
  60. print "<td ><b><a href=index-full.php?sort=tin&order=$new_order>".WEB_title_input."</a></b></td>\n";
  61. print "<td ><b><a href=index-full.php?sort=tout&order=$new_order>".WEB_title_output."<a></b></td>\n";
  62. print "<td ><b><a href=index-full.php?sort=pin&order=$new_order>".WEB_title_maxpktin."</a></b></td>\n";
  63. print "<td ><b><a href=index-full.php?sort=pout&order=$new_order>".WEB_title_maxpktout."<a></b></td>\n";
  64. print "</tr>\n";
  65. $total_in = 0;
  66. $total_out = 0;
  67. $traf = mysqli_query($db_link, $trafSQL);
  68. while (list ($s_login,$s_ou_id,$u_id,$s_ip,$s_auth_id, $s_router_id, $traf_day_in, $traf_day_out, $p_in, $p_out) = mysqli_fetch_array($traf)) {
  69. if ($traf_day_in + $traf_day_out ==0) { continue; }
  70. $total_in += $traf_day_in;
  71. $total_out += $traf_day_out;
  72. if (!empty($gateway_list[$s_router_id])) { $s_router = $gateway_list[$s_router_id]; } else { $s_router=''; }
  73. $cl = "data";
  74. if ($traf_day_out > 2 * $traf_day_in) { $cl = "nb"; }
  75. print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  76. print "<td align=left class=\"$cl\">$s_login</td>\n";
  77. print "<td align=left class=\"$cl\"><a href=authday.php?id=$s_auth_id&date_start=$date1&date_stop=$date2>$s_ip</a></td>\n";
  78. print "<td align=left class=\"$cl\">$s_router</td>\n";
  79. print "<td class=\"$cl\">" . fbytes($traf_day_in) . "</td>\n";
  80. print "<td class=\"$cl\">" . fbytes($traf_day_out) . "</td>\n";
  81. print "<td class=\"$cl\">" . fpkts($p_in) . "</td>\n";
  82. print "<td class=\"$cl\">" . fpkts($p_out) . "</td>\n";
  83. print "</tr>\n";
  84. }
  85. print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  86. print "<td class=\"data\" colspan=2><b>".WEB_title_itog."</b></td>\n";
  87. print "<td class=\"data\"><b></b></td>\n";
  88. print "<td class=\"data\"><b>" . fbytes($total_in) . "</b></td>\n";
  89. print "<td class=\"data\"><b>" . fbytes($total_out) . "</b></td>\n";
  90. print "<td class=\"data\"><b></b></td>\n";
  91. print "<td class=\"data\"><b></b></td>\n";
  92. print "</tr>\n";
  93. ?>
  94. </table>
  95. <?php
  96. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  97. ?>
  98. <script>
  99. document.getElementById('ou').addEventListener('change', function(event) {
  100. const buttonApply = document.getElementById('btn_filter');
  101. buttonApply.click();
  102. });
  103. document.getElementById('rows').addEventListener('change', function(event) {
  104. const buttonApply = document.getElementById('btn_filter');
  105. buttonApply.click();
  106. });
  107. document.getElementById('gateway').addEventListener('change', function(event) {
  108. const buttonApply = document.getElementById('btn_filter');
  109. buttonApply.click();
  110. });
  111. </script>
  112. <?php
  113. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
  114. ?>