function get_all_children($id, $family) { $all_child_ip = IP_Database::get_all_ip($id, $family); $ips_to_delete = array(); foreach ($all_child_ip as $a_id => $addr) { $temp_netblock = new IP_Database($a_id); $t_all_child = IP_Database::get_all_ip($temp_netblock->get_netblock_id(), $temp_netblock->get_family()); if (!empty($t_all_child)) { $ips_to_delete = array_merge($ips_to_delete, get_all_children($a_id, $family)); } $ips_to_delete = array_merge($ips_to_delete, array($a_id)); } return $ips_to_delete; }
function display_all_ip($arr, $ip_manager, $listType = "", $isID = "") { if ($isID) { print "\n<ul id='demo1' class='menu'>"; $isID = false; } else { print "\n<ul class='menu'>"; } foreach ($arr as $id => $name) { if (!IP_Database::is_parent($id)) { $listType = "leaf"; print "\n<li class='" . $listType . "'>"; //<form method='post'>"; $ip_2 = IP_Database::get_ip_by_id($id); $ip_manager->set_IP($ip_2['base_addr'] . "/" . $ip_2['subnet_size'], $ip_2['family']); print "\n<a style='cursor:default' class='tooltip' title='Subnet mask = " . $ip_manager->get_netmask() . " <br/> Wildcard = " . $ip_manager->get_wildcard() . " <br/> Network = " . $ip_manager->get_network() . " <br/> Broadcast = " . $ip_manager->get_broadcast() . " <br/> Hostmin = " . $ip_manager->get_hostmin() . " <br/> Hostmax = " . $ip_manager->get_hostmax() . "<br/>Host Per Net = " . $ip_manager->get_hostPerNet() . "'>" . $ip_manager->get_ip() . "</a><br/>"; /*echo "Split <select name='split'>"; if ($ip_manager->get_family()==4) { for ($i = $ip_manager->get_length(); $i<32; $i++) { echo "<option value='".($i+1)."'>".($i+1)."</option>"; } } else if ($ip_manager->get_family()==6) { for ($i = $ip_manager->get_length(); $i<128; $i++) { echo "<option value='".($i+1)."'>".($i+1)."</option>"; } } echo"</select> <input type='hidden' name='id' value='".$id."' />"; if($ip_2['stub'] == 0) { echo "<input type='submit' name='ip_split_submit' value='SPLIT NETWORK' />"; } else if ($ip_2['stub'] == 1) { echo "<input type='submit' disabled name='ip_split_submit' value='SPLIT NETWORK' />"; } echo "<input type='submit' name='ip_delete' value='DELETE NETWORK' /> <input type='text' name='ip_host' style='width:200px;'/> / <input type='text' name='ip_subnet' style='width:50px;'/> <input type='submit' name='ip_host' value='MAKE HOST' /> <input type='text' name='ip_status' style='width:200px;'/> <input type='submit' name='ip_assign' value='ASSIGN NETWORK' /> - ".$ip_2['status'].""; echo "</form>";*/ } else { $listType = "expanded"; print "\n<li class='" . $listType . "'>"; //<form method='post'>"; $ip_2 = IP_Database::get_ip_by_id($id); $ip_manager->set_IP($ip_2['base_addr'] . "/" . $ip_2['subnet_size'], $ip_2['family']); print "\n<a style='cursor:default' class='tooltip' title='Subnet mask = " . $ip_manager->get_netmask() . " <br/> Wildcard = " . $ip_manager->get_wildcard() . " <br/> Network = " . $ip_manager->get_network() . " <br/> Broadcast = " . $ip_manager->get_broadcast() . " <br/> Hostmin = " . $ip_manager->get_hostmin() . " <br/> Hostmax = " . $ip_manager->get_hostmax() . "<br/>Host Per Net = " . $ip_manager->get_hostPerNet() . "'>" . $ip_manager->get_ip() . "</a><br/>"; /*echo "<input type='hidden' name='id' value='".$id."' /> <input type='submit' name='ip_delete' value='DELETE NETWORK' /> <input type='text' name='ip_status' style='width:200px;'/> <input type='submit' name='ip_assign' value='ASSIGN NETWORK' /> - ".$ip_2['status']." </form>*/ echo "<br/>"; display_all_ip(IP_Database::get_all_ip($id), $ip_manager, $listType, $isID); } echo "</li>"; } echo "</ul>"; echo "<div style='border:1px solid green' id='thecurrent'> </div>"; }