1
0

index.php 5.3 KB

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