diff --git a/html/pages/ports.inc.php b/html/pages/ports.inc.php
index aa1f2023c..cd0cfabcf 100644
--- a/html/pages/ports.inc.php
+++ b/html/pages/ports.inc.php
@@ -119,6 +119,18 @@ foreach (dbFetchRows("SELECT `port_descr_type` FROM `ports` GROUP BY `port_descr
> Deleted
+
+
+
@@ -206,12 +218,6 @@ echo('');
print_optionbar_end();
-#if ($_SESSION['userlevel'] >= '5') {
-# $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id ORDER BY D.hostname, I.ifDescr";
-#} else {
-# $sql = "SELECT * FROM `ports` AS I, `devices` AS D, `devices_perms` AS P WHERE I.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, I.ifDescr";
-#}
-
$param = array();
# FIXME block below is not totally used, at least the iftype stuff is bogus?
@@ -288,7 +294,34 @@ foreach($vars as $var => $value)
}
}
-$query = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id ".$where." ORDER BY D.hostname, I.ifIndex";
+switch ($vars['sort'])
+{
+ case 'traffic':
+ $query_sort = " ORDER BY (I.ifInOctets_rate+I.ifOutOctets_rate)";
+ break;
+ case 'traffic_in':
+ $query_sort = " ORDER BY I.ifInOctets_rate";
+ break;
+ case 'traffic_out':
+ $query_sort = " ORDER BY I.ifOutOctets_rate";
+ break;
+ case 'packets':
+ $query_sort = " ORDER BY (I.ifInUcastPkts_rate+I.ifOutUcastPkts_rate)";
+ break;
+ case 'packets_in':
+ $query_sort = " ORDER BY I.ifInUcastPkts_rate";
+ break;
+ case 'packets_out':
+ $query_sort = " ORDER BY I.ifOutUcastPkts_rate";
+ break;
+ case 'errors':
+ $query_sort = " ORDER BY (I.ifInErrors + I.ifOutErrors)";
+ break;
+ default:
+ $query_sort = " ORDER BY D.hostname, I.ifIndex";
+}
+
+$query = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id ".$where." ".$query_sort." DESC";
$row = 1;
@@ -296,6 +329,8 @@ list($format, $subformat) = explode("_", $vars['format']);
$ports = dbFetchRows($query, $param);
+echo(count($ports));
+
if(file_exists('pages/ports/'.$format.'.inc.php'))
{
include('pages/ports/'.$format.'.inc.php');