portmactable.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. $port_id = $id;
  6. $sSQL = "SELECT DP.device_id, DP.port, DP.snmp_index, D.device_name, D.ip, D.snmp_version, D.community, D.fdb_snmp_index, D.vendor_id FROM `device_ports` AS DP, devices AS D WHERE D.id = DP.device_id AND DP.id=$port_id";
  7. $port_info = get_record_sql($db_link, $sSQL);
  8. $device_id = $port_info["device_id"];
  9. $device=get_record($db_link,'devices',"id=".$device_id);
  10. $user_info = get_record_sql($db_link,"SELECT * FROM User_list WHERE id=".$device['user_id']);
  11. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  12. print_device_submenu($page_url);
  13. print_editdevice_submenu($page_url,$device_id,$device['device_type'],$user_info['login']);
  14. ?>
  15. <div id="contsubmenu">
  16. <?php
  17. $display_name = " ".$port_info['port']." свича ".$port_info['device_name'];
  18. print "<b>".$port_info['device_name']." [".$port_info['port']."] </b><br>\n";
  19. $sw_auth=NULL;
  20. $sw_mac=NULL;
  21. if ($port_info['vendor_id'] == 9) {
  22. $sw_auth = get_record_sql($db_link,"SELECT mac FROM User_auth WHERE deleted=0 and ip='".$port_info['ip']."'");
  23. $sw_mac = mac_simplify($sw_auth['mac']);
  24. $sw_mac = preg_replace("/.{2}$/","",$sw_mac);
  25. }
  26. if ($port_info['snmp_index'] > 0) {
  27. print "<table class=\"data\" cellspacing=\"1\" cellpadding=\"4\">\n";
  28. print "<tr><td colspan=2><b>".WEB_device_port_mac_table_show."</b></td></tr>\n";
  29. if (! $port_info['fdb_snmp_index']) { $port_info['snmp_index'] = $port_info['port']; }
  30. $fdb = get_fdb_port_table($port_info['ip'], $port_info['snmp_index'], $port_info['community'], $port_info['snmp_version']);
  31. foreach ($fdb as $a_mac => $a_port) {
  32. $a_mac = dec_to_hex($a_mac);
  33. if (!empty($sw_mac) and preg_match('/^'.$sw_mac.'/',mac_simplify($a_mac))) { continue; }
  34. print "<tr>";
  35. $auth = get_auth_by_mac($db_link, $a_mac);
  36. print "<td class=\"data\">" .$auth['auth'] . "</td><td class=\"data\">". $auth['mac']."</td>\n";
  37. print "</tr>";
  38. }
  39. print "</table>\n";
  40. }
  41. ?>
  42. <table class="data">
  43. <tr>
  44. <td><?php echo WEB_cell_mac; ?></td>
  45. <td><?php echo WEB_cell_login; ?></td>
  46. <td><?php echo WEB_cell_last_found; ?></td>
  47. </tr>
  48. <?php
  49. print "<b>".WEB_device_port_mac_table_history."</b><br>\n";
  50. $d_sql = "select A.ip,A.ip_int,A.mac,A.id,A.dns_name,A.last_found from User_auth as A, connections as C where C.port_id=$port_id and A.id=C.auth_id order by A.ip_int";
  51. $t_device = mysqli_query($db_link, $d_sql);
  52. while (list ($f_ip, $f_int, $f_mac, $f_auth_id, $f_dns, $f_last) = mysqli_fetch_array($t_device)) {
  53. $name = $f_ip;
  54. if (isset($f_dns) and $f_dns != '') {
  55. $name = $f_dns;
  56. }
  57. print "<tr>";
  58. print "<td class=\"data\">" . expand_mac($db_link,$f_mac) . "</td>\n";
  59. print "<td class=\"data\"><a href=\"/admin/users/editauth.php?id=$f_auth_id\">" . $name . "</a></td>\n";
  60. print "<td class=\"data\">$f_last</td>\n";
  61. print "</tr>";
  62. }
  63. $maclist = mysqli_query($db_link, "SELECT mac,timestamp from Unknown_mac where port_id=$port_id order by timestamp desc");
  64. while (list ($fmac, $f_last) = mysqli_fetch_array($maclist)) {
  65. print "<tr>";
  66. print "<td class=\"data\">" . expand_mac($db_link,$fmac) . "</td>\n";
  67. print "<td class=\"data\">Unknown</td>\n";
  68. print "<td class=\"data\">$f_last</td>\n";
  69. print "</tr>";
  70. }
  71. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  72. ?>