<?php include_once '../../plugins/IP Manager/Netblock.php'; if (isset($_POST['net']) && isset($_POST['length']) && is_numeric($_POST['length']) && $_POST['net'] != '') { $net = $_POST['net']; $length = $_POST['length']; $netblock = new Netblock("{$net}/{$length}"); if ($netblock->get_family() != 4 && $netblock->get_family() != 6) { //print "Invalid address<br>"; return; } else { echo "<p><hr>"; echo $netblock->print_all(); } }
if ($ip == "/") { echo Form::warning("Enter an IP!"); exit; } //create a new manager to do the calculation $ip_manager = new Netblock($ip); //if it's adding a new network if (isset($_POST['add'])) { //check if the ip is valid if ($ip_manager->get_IP() != "INVALID") { //set all the values if it's valid $n_ip = new IP_Database(); $n_ip->set_address_int($ip_manager->get_long()); $n_ip->set_subnet_size($ip_manager->get_length()); $n_ip->set_description(""); $n_ip->set_family($ip_manager->get_family()); $n_ip->set_title($_POST['title']); //IAM HERE TRYING TO INSTALL SEARCH AND ADD IP $i_match = explode("/", $ip_manager->get_IP()); //check if the ip and subnet are valid combinations if ($ip_manager->get_long_ip() != $ip_manager->get_long()) { echo Form::warning("Your IP is invalid, the IP is changed from " . $i_match[0] . " to " . $ip_manager->get_network()); } //inserting the IP, if it fails show the error if (!$n_ip->insert()) { echo Form::error($n_ip->get_error()); } } else { //If IP info is invalid this message shows echo Form::warning("INVALID INFO TRY AGAIN"); exit;
$ip_2->set_stub($stub); } $ip_2->set_tags($tags); if (!$ip_2->update()) { return false; } } if (isset($_GET['stub'])) { $stub_id = explode("@", $_GET['stub']); $ip_db = new IP_Database($stub_id[1]); $ip_db->set_stub($stub_id[0]); $ip_manager = new Netblock(); $ip_manager->set_IP($ip_db->get_address_int() . "/" . $ip_db->get_subnet_size(), $ip_db->get_family()); if ($ip_db->update()) { if ($ip_db->is_stub() == 0) { if ($ip_manager->get_family() == 4) { if ($ip_db->get_subnet_size() != 32) { echo "Split <select name='split'>"; for ($i = $ip_manager->get_length(); $i < 32; $i++) { echo "<option value='" . ($i + 1) . "'>" . ($i + 1) . "</option>"; } echo "</select>"; echo " <input type='submit' name='ip_split_submit' value='SPLIT NETWORK' />"; } else { echo "<span style='color:red; font-size:14px'>NO MORE SPLITS</span>"; } } else { if ($ip_manager->get_family() == 6) { if ($ip_db->get_subnet_size() != 128) { echo "Split <select name='split'>"; for ($i = $ip_manager->get_length(); $i < 128; $i++) {
IP_Database::add_ip_to_db($ip_manager->get_long(), $ip_manager->get_length(), $ip_manager->get_desc(), $ip_manager->get_family()); } else { echo "INVALID INFO TRY AGAIN"; exit; } } } } echo "<hr/>"; if (isset($_POST['ip_split_submit'])) { $ip_info = IP_Database::get_ip_by_id($_POST['id']); $ip_manager->set_IP($ip_info->get_address_ip() . "/" . $ip_info['subnet_size'], $ip_info['family']); $split = $ip_manager->split_IP($_POST['split']); foreach ($split as $id => $ip) { $ip_manager = new Netblock($ip, $ip_info['description']); IP_Database::add_split_to_db($ip_manager->get_long(), $ip_manager->get_length(), $ip_info['description'], $ip_manager->get_family(), $ip_info['base_index']); } } else { if (isset($_POST['ip_delete'])) { IP_Database::remove_ip_by_id($_POST['id']); } else { if (isset($_POST['ip_assign'])) { IP_Database::assign_ip_by_id($_POST['id'], $_POST['ip_status']); } } } $arr = array(); $arr = IP_Database::get_all_ip(); $listType = "expanded"; $isID = true; display_all_ip($arr, $ip_manager, $listType, $isID);