portmactable.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
  4. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
  5. ?>
  6. <html>
  7. <head>
  8. <title>Панель администратора</title>
  9. <link rel="stylesheet" type="text/css" href=<?php echo "\"/$style.css\""; ?>>
  10. <meta http-equiv="content-type" content="application/xhtml+xml">
  11. <meta charset="UTF-8">
  12. </head>
  13. <body>
  14. <div id="cont">
  15. <?php
  16. $port_id = $id;
  17. $sSQL = "SELECT 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";
  18. $port_info = get_record_sql($db_link, $sSQL);
  19. $display_name = " ".$port_info['port']." свича ".$port_info['device_name'];
  20. print "<b>".$port_info['device_name']." [".$port_info['port']."] </b><br>\n";
  21. $sw_auth=NULL;
  22. $sw_mac=NULL;
  23. if ($port_info['vendor_id'] == 9) {
  24. $sw_auth = get_record_sql($db_link,"SELECT mac FROM User_auth WHERE deleted=0 and ip='".$port_info['ip']."'");
  25. $sw_mac = mac_simplify($sw_auth['mac']);
  26. $sw_mac = preg_replace("/.{2}$/","",$sw_mac);
  27. }
  28. if ($port_info['snmp_index'] > 0) {
  29. print "<table class=\"data\" cellspacing=\"1\" cellpadding=\"4\">\n";
  30. print "<tr><td><b>Список маков активных на порту</b></td></tr>\n";
  31. if (! $port_info['fdb_snmp_index']) { $port_info['snmp_index'] = $port_info['port']; }
  32. $fdb = get_fdb_port_table($port_info['ip'], $port_info['snmp_index'], $port_info['community'], $port_info['snmp_version']);
  33. foreach ($fdb as $a_mac => $a_port) {
  34. $a_mac = dec_to_hex($a_mac);
  35. if (!empty($sw_mac) and preg_match('/^'.$sw_mac.'/',mac_simplify($a_mac))) { continue; }
  36. print "<tr>";
  37. $auth = get_auth_by_mac($db_link, $a_mac);
  38. print "<td class=\"data\">" .$auth['auth'] . "</td><td class=\"data\">". $auth['mac']."</td>\n";
  39. print "</tr>";
  40. }
  41. print "</table>\n";
  42. }
  43. ?>
  44. <table class="data">
  45. <tr>
  46. <td>Mac</td>
  47. <td>User</td>
  48. <td>Last found</td>
  49. </tr>
  50. <?php
  51. print "<b>Список маков когда-либо обнаруженных на порту</b><br>\n";
  52. $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";
  53. $t_device = mysqli_query($db_link, $d_sql);
  54. while (list ($f_ip, $f_int, $f_mac, $f_auth_id, $f_dns, $f_last) = mysqli_fetch_array($t_device)) {
  55. $name = $f_ip;
  56. if (isset($f_dns) and $f_dns != '') {
  57. $name = $f_dns;
  58. }
  59. print "<tr>";
  60. print "<td class=\"data\">" . expand_mac($db_link,$f_mac) . "</td>\n";
  61. print "<td class=\"data\"><a href=\"/admin/users/editauth.php?id=$f_auth_id\">" . $name . "</a></td>\n";
  62. print "<td class=\"data\">$f_last</td>\n";
  63. print "</tr>";
  64. }
  65. $maclist = mysqli_query($db_link, "SELECT mac,timestamp from Unknown_mac where port_id=$port_id order by timestamp desc");
  66. while (list ($fmac, $f_last) = mysqli_fetch_array($maclist)) {
  67. print "<tr>";
  68. print "<td class=\"data\">" . expand_mac($db_link,$fmac) . "</td>\n";
  69. print "<td class=\"data\">Unknown</td>\n";
  70. print "<td class=\"data\">$f_last</td>\n";
  71. print "</tr>";
  72. }
  73. ?>
  74. </table>
  75. </body>
  76. </html>