index.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. print "<br><br>\n";
  23. print "<table class=\"data\">\n";
  24. print "<tr class=\"info\">\n";
  25. print "<td ><b><a href=index.php?sort=login&order=$new_order>".WEB_cell_login."</a></b></td>\n";
  26. print "<td ><b>".WEB_cell_gateway."</b></td>\n";
  27. print "<td ><b><a href=index.php?sort=tin&order=$new_order>".WEB_title_input."</a></b></td>\n";
  28. print "<td ><b><a href=index.php?sort=tout&order=$new_order>".WEB_title_output."<a></b></td>\n";
  29. print "</tr>\n";
  30. $sort_sql=" ORDER BY tin DESC";
  31. if (!empty($sort_field) and !empty($order)) { $sort_sql = " ORDER BY $sort_field $order"; }
  32. $gateway_list = get_gateways($db_link);
  33. $trafSQL = "SELECT
  34. User_list.login,User_list.ou_id,User_auth.user_id, User_stats.auth_id,
  35. User_stats.router_id, SUM( byte_in ) AS tin, SUM( byte_out ) AS tout
  36. FROM User_stats,User_auth,User_list WHERE User_list.id=User_auth.user_id
  37. AND User_stats.auth_id = User_auth.id
  38. AND User_stats.timestamp>='$date1'
  39. AND User_stats.timestamp<'$date2'
  40. ";
  41. if ($rou !== 0) { $trafSQL = $trafSQL . " AND User_list.ou_id=$rou"; }
  42. if ($rgateway == 0) {
  43. $trafSQL = $trafSQL . " GROUP by User_auth.user_id,User_stats.router_id";
  44. } else {
  45. $trafSQL = $trafSQL . " AND User_stats.router_id=$rgateway GROUP by User_auth.user_id,User_stats.router_id";
  46. }
  47. #set sort
  48. $trafSQL=$trafSQL ." $sort_sql";
  49. $total_in = 0;
  50. $total_out = 0;
  51. $traf = get_records_sql($db_link, $trafSQL);
  52. foreach ($traf as $row) {
  53. if ($row['tin'] + $row['tout'] == 0) { continue; }
  54. $total_in += $row['tin'];
  55. $total_out += $row['tout'];
  56. $s_router = !empty($gateway_list[$row['router_id']]) ? $gateway_list[$row['router_id']] : '';
  57. $cl = $row['tout'] > 2 * $row['tin'] ? "nb" : "data";
  58. print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  59. print "<td align=left class=\"$cl\"><a href=userday.php?id=" . $row['user_id'] . "&date_start=$date1&date_stop=$date2>" . $row['login'] . "</a></td>\n";
  60. print "<td align=left class=\"$cl\">$s_router</td>\n";
  61. print "<td class=\"$cl\">" . fbytes($row['tin']) . "</td>\n";
  62. print "<td class=\"$cl\">" . fbytes($row['tout']) . "</td>\n";
  63. print "</tr>\n";
  64. }
  65. print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  66. print "<td class=\"data\" colspan=2><b>".WEB_title_itog."</b></td>\n";
  67. print "<td class=\"data\"><b>" . fbytes($total_in) . "</b></td>\n";
  68. print "<td class=\"data\"><b>" . fbytes($total_out) . "</b></td>\n";
  69. print "</tr>\n";
  70. ?>
  71. </table>
  72. <?php
  73. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  74. ?>