1
0

mactable.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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/idfilter.php");
  5. $device=get_record($db_link,'devices',"id=".$id);
  6. $user_info = get_record_sql($db_link,"SELECT * FROM User_list WHERE id=".$device['user_id']);
  7. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  8. print_device_submenu($page_url);
  9. print_editdevice_submenu($page_url,$id,$device['device_type'],$user_info['login']);
  10. $sSQL = "SELECT port, snmp_index FROM `device_ports` WHERE device_id=".$id;
  11. $ports_info = get_records_sql($db_link, $sSQL);
  12. $ports_by_snmp_index=NULL;
  13. foreach ($ports_info as &$row) { $ports_by_snmp_index[$row["snmp_index"]]=$row["port"]; }
  14. if (!apply_device_lock($db_link,$id)) {
  15. header("Location: /admin/devices/editdevice.php?id=".$id."&status=locked");
  16. exit;
  17. }
  18. ?>
  19. <div id="contsubmenu">
  20. <?php
  21. $ports = get_records($db_link,'device_ports',"device_id=$id AND uplink=0 ORDER BY port");
  22. print "<b>".WEB_device_mac_table_show."&nbsp".$device['device_name']." (".$device['ip']."):</b>\n";
  23. $snmp_ok = 0;
  24. if (!empty($device['ip']) and $device['snmp_version'] > 0) {
  25. $snmp_ok = check_snmp_access($device['ip'], $device['community'], $device['snmp_version']);
  26. }
  27. if ($snmp_ok) {
  28. $fdb = get_fdb_table($device['ip'], $device['community'], $device['snmp_version']);
  29. $port_by_snmp = 0;
  30. foreach ($fdb as $a_mac => $a_port) {
  31. if (!empty($ports_by_snmp_index[$a_port])) { $port_by_snmp=1; break; }
  32. }
  33. print "<table class=\"data\" cellspacing=\"1\" cellpadding=\"4\">\n";
  34. print "<tr>";
  35. print "<td>Port</td>\n";
  36. print "<td>User</td>\n";
  37. print "<td>Mac</td>\n";
  38. print "</tr>";
  39. foreach ($ports as $port) {
  40. foreach ($fdb as $a_mac => $a_port) {
  41. if ($port_by_snmp) { $f_port =$port['snmp_index']; } else { $f_port = $port['port']; }
  42. if ($a_port == $f_port) {
  43. print "<tr>";
  44. print "<td class=\"data\">" . $port['port'] . "</td>\n";
  45. $auth = get_auth_by_mac($db_link, dec_to_hex($a_mac));
  46. print "<td class=\"data\">" .$auth['auth'] . "</td><td class=\"data\">". $auth['mac']."</td>\n";
  47. print "</tr>";
  48. }
  49. }
  50. }
  51. print "</table>\n";
  52. } else {
  53. print "No SNMP access!";
  54. }
  55. unset_lock_discovery($db_link,$id);
  56. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.small.php");
  57. ?>