diff --git a/cleanup.php b/cleanup.php index bfb678946..b4266540e 100755 --- a/cleanup.php +++ b/cleanup.php @@ -6,19 +6,19 @@ include("config.php"); include("includes/functions.php"); -$query = "SELECT *,A.id as id FROM ipaddr AS A, interfaces as I, devices as D +$query = "SELECT *,A.id as id FROM ipv4_addresses AS A, interfaces as I, devices as D WHERE A.interface_id = I.interface_id AND I.device_id = D.device_id AND D.status = '1'"; $data = mysql_query($query); while($row = mysql_fetch_array($data)) { - $mask = trim(shell_exec($config['ipcalc'] . " ".$row['addr']."/".$row['cidr']." | grep Netmask: | cut -d \" \" -f 4")); - $response = trim(`snmpget -v2c -Osq -c $row[community] $row[hostname]:$row[port] ipAdEntIfIndex.$row[addr] | cut -d " " -f 2`); - $maskcheck = trim(`snmpget -v2c -Osq -c $row[community] $row[hostname]:$row[port] ipAdEntNetMask.$row[addr] | cut -d " " -f 2`); + $mask = trim(shell_exec($config['ipcalc'] . " ".$row['ipv4_address']."/".$row['ipv4_prefixlen']." | grep Netmask: | cut -d \" \" -f 4")); + $response = trim(`snmpget -v2c -Osq -c $row[community] $row[hostname]:$row[port] ipAdEntIfIndex.".$row['ipv4_address']." | cut -d " " -f 2`); + $maskcheck = trim(`snmpget -v2c -Osq -c $row[community] $row[hostname]:$row[port] ipAdEntNetMask.".$row['ipv4_address']." | cut -d " " -f 2`); if($response == $row['ifIndex'] && $mask == $maskcheck) { } else { - mysql_query("delete from ipaddr where id = '$row[id]'"); - echo("Deleted $row[addr] from $row[hostname]\n"); + mysql_query("delete from ipv4_address where id = '".$row['ipv4_address_id']."'"); + echo("Deleted ".$row['ipv4_address']." from $row[hostname]\n"); } } diff --git a/html/pages/ipv4.php b/html/pages/ipv4.php index 426852f26..195be1f66 100644 --- a/html/pages/ipv4.php +++ b/html/pages/ipv4.php @@ -51,7 +51,7 @@ while($interface = mysql_fetch_array($query)) { if($_POST['address']) { list($addy, $mask) = explode("/", $_POST['address']); - if(!$mask) { $mask = "/32"; } + if(!$mask) { $mask = "32"; } if (!match_network($addy . "/" . $mask, $interface['ipv4_address'] )) { $ignore = 1; } }