mactable.php 2.3 KB

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