Location: PHPKode > projects > Network Asset Management Archive > nama/arptable.php
<?php
$now = date("m/j/y h:i:s",time());
include "connect.php";
$stmt = "Select * FROM routers order by IP_ADDRESS;";
$sth = ibase_query($dbh, $stmt);
while ($row = ibase_fetch_object($sth)) {
$interface = snmpwalk($row->IP_ADDRESS, "nonpub",".1.3.6.1.2.1.4.22.1.1");
$macaddress = snmpwalk($row->IP_ADDRESS, "nonpub",".1.3.6.1.2.1.4.22.1.2");
$ipaddress = snmpwalk($row->IP_ADDRESS, "nonpub",".1.3.6.1.2.1.4.22.1.3");

$host = $row->IP_ADDRESS;
$community = "nonpub";
$sysDescr = snmpget("$host","$community","system.sysDescr.0");
print '<body bgcolor="#F9F3E0" text="#000000">';                                         
print "<table border=1 bgcolor=#ECD99E><tr><td><b>$row->ROUTER</b></td><td>$host</td>";
print "<td>$sysDescr</td></tr></table> ";
print "<table border=1 bgcolor=#F9F3E0>";
print "<tr> 
       <td>ifIndex</td>
       <td>IP Address</td>
       <td>MAC Address</td>
       <td>IP Integer</td>
       </tr>";
            
for ($i=0; $i<count($ipaddress); $i++) {
       print "<tr>";
       list ($junk, $interf) = split(": ", $interface[$i]);	
       print "<td>$interf</td>";
       list ($junk, $ip) = split("IpAddress: ", $ipaddress[$i]);	
       print "<td>$ip</td>";
       list ($junk, $mac) = split("STRING: ",$macaddress[$i]);
       $mac = split(":", $mac);
       $mymac = "";
       for ($j=0; $j<count($mac); $j++) {
	   if (strlen($mac[$j]) == 1) {
	   	$mymac = $mymac . "0" . $mac[$j];
	   } 
	   else {
		$mymac = $mymac . $mac[$j];
	   }
       }	
       print "<td>$mymac</td>";
       print "<td>";
       printf("%u",ip2long($ip));
       print "</td>";
       print "</tr>";
}            
print "</table>";

}
?>

Return current item: Network Asset Management Archive