Browse Source

The address and port comments are combined in the output of the switch ports

Roman Dmitriev 1 year ago
parent
commit
73160f2
3 changed files with 18 additions and 4 deletions
  1. 1 1
      html/admin/devices/switchport.php
  2. 1 1
      html/admin/devices/switchstatus.php
  3. 16 2
      html/inc/common.php

+ 1 - 1
html/admin/devices/switchport.php

@@ -104,7 +104,7 @@ foreach ($ports as $row) {
             print_auth_port($db_link, $row['id'],FALSE);
         }
         print "</td>\n";
-        print "<td class='".$cl."'>" . $row['comment'] . "</td>\n";
+        print "<td class='".$cl."'>" . get_port_comment($db_link, $row['id'],$row['comment']) . "</td>\n";
         print "<td class='".$cl."' >" . get_qa($row['uplink']) . "</td>\n";
         print "<td class='".$cl."' >" . get_qa($row['nagios']) . "</td>\n";
         print "<td class='".$cl."' >" . get_qa($row['skip']) . "</td>\n";

+ 1 - 1
html/admin/devices/switchstatus.php

@@ -186,7 +186,7 @@ print_editdevice_submenu($page_url, $id, $device['device_type'], $user_info['log
                 print_auth_port($db_link, $row['id'], TRUE);
             }
             print "</td>\n";
-            print "<td class='" . $cl . "'>" . $row['comment'] . "</td>\n";
+            print "<td class='" . $cl . "' >" . get_port_comment($db_link, $row['id'],$row['comment']) . "</td>\n";
             print "<td class='" . $cl . "' >" . get_qa($row['uplink']) . "</td>\n";
             print "<td class='" . $cl . "' >" . get_qa($row['nagios']) . "</td>\n";
             print "<td class='" . $cl . "' >" . get_qa($row['skip']) . "</td>\n";

+ 16 - 2
html/inc/common.php

@@ -1418,8 +1418,8 @@ function get_device_by_auth($db, $id)
 function print_auth_port($db, $port_id, $new_window = FALSE)
 {
     $d_sql = "SELECT A.ip,A.ip_int,A.mac,A.id,A.dns_name,A.comments,A.user_id FROM User_auth as A, connections as C WHERE C.port_id=$port_id and A.id=C.auth_id and A.deleted=0 order by A.ip_int";
-    $t_device = mysqli_query($db, $d_sql);
-    while (list($f_ip, $f_int, $f_mac, $f_auth_id, $f_dns, $f_comment, $f_user_id) = mysqli_fetch_array($t_device)) {
+    $t_auth = mysqli_query($db, $d_sql);
+    while (list($f_ip, $f_int, $f_mac, $f_auth_id, $f_dns, $f_comment, $f_user_id) = mysqli_fetch_array($t_auth)) {
         $name = $f_ip;
         if (isset($f_dns) and $f_dns != '') {
             $name = $f_dns;
@@ -1435,6 +1435,20 @@ function print_auth_port($db, $port_id, $new_window = FALSE)
     }
 }
 
+function get_port_comment($db, $port_id, $port_comment)
+{
+    $d_sql = "SELECT A.ip_int,A.comments FROM User_auth as A, connections as C WHERE C.port_id=$port_id and A.id=C.auth_id and A.deleted=0 order by A.ip_int";
+    $t_auth = mysqli_query($db, $d_sql);
+    $comment_found = 0;
+    $result = '';
+    while (list($f_int, $f_comment) = mysqli_fetch_array($t_auth)) {
+        if (!empty($f_comment)) { $comment_found = 1; } else { $f_comment = ''; }
+        $result .=$f_comment.'<br>';
+    }
+    if (!$comment_found) { return $port_comment; }
+    return $result;
+}
+
 function print_auth_simple($db, $auth_id)
 {
     $auth = get_record($db, "User_auth", "id=$auth_id");