|
|
@@ -23,14 +23,9 @@ print_reports_submenu($page_url);
|
|
|
</form>
|
|
|
|
|
|
<?php
|
|
|
-print "<br><br>\n";
|
|
|
-print "<table class=\"data\">\n";
|
|
|
-print "<tr class=\"info\">\n";
|
|
|
-print "<td ><b><a href=index.php?sort=login&order=$new_order>".WEB_cell_login."</a></b></td>\n";
|
|
|
-print "<td ><b>".WEB_cell_gateway."</b></td>\n";
|
|
|
-print "<td ><b><a href=index.php?sort=tin&order=$new_order>".WEB_title_input."</a></b></td>\n";
|
|
|
-print "<td ><b><a href=index.php?sort=tout&order=$new_order>".WEB_title_output."<a></b></td>\n";
|
|
|
-print "</tr>\n";
|
|
|
+
|
|
|
+$traffic_stat_table = 'user_stats_full';
|
|
|
+if ($days_shift >= $config["traffic_ipstat_history"]) { $traffic_stat_table = 'user_stats'; }
|
|
|
|
|
|
$sort_sql=" ORDER BY tin DESC";
|
|
|
|
|
|
@@ -38,30 +33,58 @@ if (!empty($sort_field) and !empty($order)) { $sort_sql = " ORDER BY $sort_field
|
|
|
|
|
|
$gateway_list = get_gateways($db_link);
|
|
|
|
|
|
-$trafSQL = "SELECT
|
|
|
-user_list.login,user_list.ou_id,user_auth.user_id, user_stats.auth_id,
|
|
|
-user_stats.router_id, SUM( byte_in ) AS tin, SUM( byte_out ) AS tout
|
|
|
-FROM user_stats,user_auth,user_list WHERE user_list.id=user_auth.user_id
|
|
|
-AND user_stats.auth_id = user_auth.id
|
|
|
-AND user_stats.ts>='$date1'
|
|
|
-AND user_stats.ts<'$date2'
|
|
|
-";
|
|
|
+$sql_params=[];
|
|
|
|
|
|
-if ($rou !== 0) { $trafSQL = $trafSQL . " AND user_list.ou_id=$rou"; }
|
|
|
+$trafSQL = "SELECT user_auth.user_id,".$traffic_stat_table.".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
|
|
|
+FROM ".$traffic_stat_table.",user_auth,user_list WHERE user_list.id=user_auth.user_id
|
|
|
+AND ".$traffic_stat_table.".auth_id = user_auth.id
|
|
|
+AND ".$traffic_stat_table.".ts>= ? AND ".$traffic_stat_table.".ts< ?";
|
|
|
|
|
|
-if ($rgateway == 0) {
|
|
|
- $trafSQL = $trafSQL . " GROUP by user_auth.user_id,user_stats.router_id";
|
|
|
- } else {
|
|
|
- $trafSQL = $trafSQL . " AND user_stats.router_id=$rgateway GROUP by user_auth.user_id,user_stats.router_id";
|
|
|
- }
|
|
|
+array_push($sql_params,$date1);
|
|
|
+array_push($sql_params,$date2);
|
|
|
+if ($rou !== 0) {
|
|
|
+ $trafSQL = $trafSQL . " AND user_list.ou_id=?";
|
|
|
+ array_push($sql_params,$rou);
|
|
|
+}
|
|
|
+
|
|
|
+if ($rgateway >0) {
|
|
|
+ $trafSQL = $trafSQL . " AND ".$traffic_stat_table.".router_id= ?";
|
|
|
+ array_push($sql_params,$rgateway);
|
|
|
+}
|
|
|
+
|
|
|
+$trafSQL = $trafSQL . " GROUP by user_auth.user_id,".$traffic_stat_table.".router_id";
|
|
|
+
|
|
|
+$countSQL = "SELECT Count(*) FROM ($trafSQL) A";
|
|
|
+$count_records = get_single_field($db_link,$countSQL,$sql_params);
|
|
|
+
|
|
|
+$total=ceil($count_records/$displayed);
|
|
|
+if ($page>$total) { $page=$total; }
|
|
|
+if ($page<1) { $page=1; }
|
|
|
+$start = ($page * $displayed) - $displayed;
|
|
|
|
|
|
#set sort
|
|
|
-$trafSQL=$trafSQL ." $sort_sql";
|
|
|
+$trafSQL=$trafSQL ." $sort_sql LIMIT ? OFFSET ?";
|
|
|
+array_push($sql_params,$displayed);
|
|
|
+array_push($sql_params,$start);
|
|
|
+
|
|
|
+print_navigation($page_url,$page,$displayed,$count_records,$total);
|
|
|
+
|
|
|
+print "<br><br>\n";
|
|
|
+print "<table class=\"data\">\n";
|
|
|
+print "<tr class=\"info\">\n";
|
|
|
+print "<td ><b><a href=index.php?sort=login&order=$new_order>".WEB_cell_login."</a></b></td>\n";
|
|
|
+print "<td ><b>".WEB_cell_gateway."</b></td>\n";
|
|
|
+print "<td ><b><a href=index.php?sort=tin&order=$new_order>".WEB_title_input."</a></b></td>\n";
|
|
|
+print "<td ><b><a href=index.php?sort=tout&order=$new_order>".WEB_title_output."<a></b></td>\n";
|
|
|
+print "<td ><b><a href=index.php?sort=pin&order=$new_order>".WEB_title_maxpktin."</a></b></td>\n";
|
|
|
+print "<td ><b><a href=index.php?sort=pout&order=$new_order>".WEB_title_maxpktout."<a></b></td>\n";
|
|
|
+print "</tr>\n";
|
|
|
|
|
|
$total_in = 0;
|
|
|
$total_out = 0;
|
|
|
|
|
|
-$traf = get_records_sql($db_link, $trafSQL);
|
|
|
+$traf = get_records_sql($db_link, $trafSQL,$sql_params);
|
|
|
|
|
|
foreach ($traf as $row) {
|
|
|
if ($row['tin'] + $row['tout'] == 0) { continue; }
|
|
|
@@ -69,12 +92,16 @@ foreach ($traf as $row) {
|
|
|
$total_out += $row['tout'];
|
|
|
$s_router = !empty($gateway_list[$row['router_id']]) ? $gateway_list[$row['router_id']] : '';
|
|
|
$cl = $row['tout'] > 2 * $row['tin'] ? "nb" : "data";
|
|
|
-
|
|
|
+
|
|
|
+ $u_SQL='SELECT * FROM user_list WHERE id=?';
|
|
|
+ $user_record = get_record_sql($db_link,$u_SQL,[$row['user_id']]);
|
|
|
print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
|
|
|
- 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";
|
|
|
+ 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";
|
|
|
print "<td align=left class=\"$cl\">$s_router</td>\n";
|
|
|
print "<td class=\"$cl\">" . fbytes($row['tin']) . "</td>\n";
|
|
|
print "<td class=\"$cl\">" . fbytes($row['tout']) . "</td>\n";
|
|
|
+ print "<td class=\"$cl\">" . fpkts($row['pin']) . "</td>\n";
|
|
|
+ print "<td class=\"$cl\">" . fpkts($row['pout']) . "</td>\n";
|
|
|
print "</tr>\n";
|
|
|
}
|
|
|
|
|
|
@@ -82,9 +109,34 @@ print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout
|
|
|
print "<td class=\"data\" colspan=2><b>".WEB_title_itog."</b></td>\n";
|
|
|
print "<td class=\"data\"><b>" . fbytes($total_in) . "</b></td>\n";
|
|
|
print "<td class=\"data\"><b>" . fbytes($total_out) . "</b></td>\n";
|
|
|
+print "<td class=\"data\"><b></b></td>\n";
|
|
|
+print "<td class=\"data\"><b></b></td>\n";
|
|
|
print "</tr>\n";
|
|
|
?>
|
|
|
- </table>
|
|
|
+</table>
|
|
|
+
|
|
|
+<?php
|
|
|
+print_navigation($page_url,$page,$displayed,$count_records,$total);
|
|
|
+?>
|
|
|
+
|
|
|
+<script>
|
|
|
+document.getElementById('ou').addEventListener('change', function(event) {
|
|
|
+ const buttonApply = document.getElementById('btn_filter');
|
|
|
+ buttonApply.click();
|
|
|
+});
|
|
|
+
|
|
|
+document.getElementById('rows').addEventListener('change', function(event) {
|
|
|
+ const buttonApply = document.getElementById('btn_filter');
|
|
|
+ buttonApply.click();
|
|
|
+});
|
|
|
+
|
|
|
+document.getElementById('gateway').addEventListener('change', function(event) {
|
|
|
+ const buttonApply = document.getElementById('btn_filter');
|
|
|
+ buttonApply.click();
|
|
|
+});
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
<?php
|
|
|
require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
|
|
|
?>
|