index-full.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");
  7. $default_sort='tin';
  8. $default_order='DESC';
  9. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");
  10. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
  11. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/gatefilter.php");
  12. print_reports_submenu($page_url);
  13. ?>
  14. <div id="cont">
  15. <form action="index-full.php" method="post">
  16. <?php echo WEB_cell_ou; ?>:&nbsp<?php print_ou_select($db_link,'ou',$rou); ?>
  17. <?php print_date_fields($date1,$date2,$date_shift); ?>
  18. <?php echo WEB_cell_gateway; ?>:&nbsp<?php print_gateway_select($db_link, 'gateway', $rgateway); ?>
  19. <?php print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?>
  20. <input id='btn_filter' name='btn_filter' type="submit" value="<?php echo WEB_btn_show; ?>">
  21. </form>
  22. <?php
  23. $traffic_stat_table = 'user_stats_full';
  24. if ($days_shift >= $config["traffic_ipstat_history"]) { $traffic_stat_table = 'user_stats'; }
  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. $sql_params=[];
  29. $trafSQL = "SELECT user_auth.id, ".$traffic_stat_table.".router_id,
  30. 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 ".$traffic_stat_table.",user_auth,user_list WHERE user_list.id=user_auth.user_id
  32. AND ".$traffic_stat_table.".auth_id = user_auth.id
  33. AND ".$traffic_stat_table.".ts>= ? AND ".$traffic_stat_table.".ts< ?";
  34. array_push($sql_params,$date1);
  35. array_push($sql_params,$date2);
  36. if ($rou !== 0) {
  37. $trafSQL = $trafSQL . " AND user_list.ou_id=?";
  38. array_push($sql_params,$rou);
  39. }
  40. if ($rgateway >0) {
  41. $trafSQL = $trafSQL . " AND ".$traffic_stat_table.".router_id= ?";
  42. array_push($sql_params,$rgateway);
  43. }
  44. $trafSQL = $trafSQL . " GROUP by user_auth.id,".$traffic_stat_table.".router_id";
  45. $countSQL = "SELECT Count(*) FROM ($trafSQL) A";
  46. $count_records = get_single_field($db_link,$countSQL,$sql_params);
  47. $total=ceil($count_records/$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 ? OFFSET ?";
  53. array_push($sql_params,$displayed);
  54. array_push($sql_params,$start);
  55. print_navigation($page_url,$page,$displayed,$count_records,$total);
  56. print "<br><br>\n";
  57. print "<table class=\"data\" cellspacing=\"1\" cellpadding=\"4\">\n";
  58. print "<tr align=\"center\">\n";
  59. print "<td ><b><a href=index-full.php?sort=login&order=$new_order>".WEB_cell_login."</a></b></td>\n";
  60. print "<td ><b><a href=index-full.php?sort=ip&order=$new_order>".WEB_cell_ip."</a></b></td>\n";
  61. print "<td ><b>".WEB_cell_gateway."</b></td>\n";
  62. print "<td ><b><a href=index-full.php?sort=tin&order=$new_order>".WEB_title_input."</a></b></td>\n";
  63. print "<td ><b><a href=index-full.php?sort=tout&order=$new_order>".WEB_title_output."<a></b></td>\n";
  64. print "<td ><b><a href=index-full.php?sort=pin&order=$new_order>".WEB_title_maxpktin."</a></b></td>\n";
  65. print "<td ><b><a href=index-full.php?sort=pout&order=$new_order>".WEB_title_maxpktout."<a></b></td>\n";
  66. print "</tr>\n";
  67. $total_in = 0;
  68. $total_out = 0;
  69. $traf = get_records_sql($db_link, $trafSQL, $sql_params);
  70. foreach ($traf as $row) {
  71. if ($row['tin'] + $row['tout'] == 0) { continue; }
  72. $total_in += $row['tin'];
  73. $total_out += $row['tout'];
  74. $s_router = !empty($gateway_list[$row['router_id']]) ? $gateway_list[$row['router_id']] : '';
  75. $cl = $row['tout'] > 2 * $row['tin'] ? "nb" : "data";
  76. $a_SQL='SELECT ip,U.login FROM user_auth, user_list as U where user_auth.user_id=U.id and user_auth.id=?';
  77. $auth_record = get_record_sql($db_link,$a_SQL,[$row['id']]);
  78. print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  79. print "<td align=left class=\"$cl\">" . $auth_record['login'] . "</td>\n";
  80. print "<td align=left class=\"$cl\"><a href=authday.php?id=" . $row['id'] . "&date_start=$date1&date_stop=$date2>" . $auth_record['ip'] . "</a></td>\n";
  81. print "<td align=left class=\"$cl\">$s_router</td>\n";
  82. print "<td class=\"$cl\">" . fbytes($row['tin']) . "</td>\n";
  83. print "<td class=\"$cl\">" . fbytes($row['tout']) . "</td>\n";
  84. print "<td class=\"$cl\">" . fpkts($row['pin']) . "</td>\n";
  85. print "<td class=\"$cl\">" . fpkts($row['pout']) . "</td>\n";
  86. print "</tr>\n";
  87. }
  88. print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  89. print "<td class=\"data\" colspan=2><b>".WEB_title_itog."</b></td>\n";
  90. print "<td class=\"data\"><b></b></td>\n";
  91. print "<td class=\"data\"><b>" . fbytes($total_in) . "</b></td>\n";
  92. print "<td class=\"data\"><b>" . fbytes($total_out) . "</b></td>\n";
  93. print "<td class=\"data\"><b></b></td>\n";
  94. print "<td class=\"data\"><b></b></td>\n";
  95. print "</tr>\n";
  96. ?>
  97. </table>
  98. <?php
  99. print_navigation($page_url,$page,$displayed,$count_records,$total);
  100. ?>
  101. <script>
  102. document.getElementById('ou').addEventListener('change', function(event) {
  103. const buttonApply = document.getElementById('btn_filter');
  104. buttonApply.click();
  105. });
  106. document.getElementById('rows').addEventListener('change', function(event) {
  107. const buttonApply = document.getElementById('btn_filter');
  108. buttonApply.click();
  109. });
  110. document.getElementById('gateway').addEventListener('change', function(event) {
  111. const buttonApply = document.getElementById('btn_filter');
  112. buttonApply.click();
  113. });
  114. </script>
  115. <?php
  116. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
  117. ?>