示例#1
0
 //If a network id is posted, it means a modification (update, split, host, or delete) is called
 if (isset($_POST['id'])) {
     //Get this network information from the database
     $ip_info = new IP_Database($_POST['id']);
     //if it's a split
     if (isset($_POST['ip_split_submit'])) {
         //do the split calculation first
         $ip_manager->set_IP($ip_info->get_address_ip(), $ip_info->get_family());
         $split = $ip_manager->split_IP($_POST['split']);
         //insert the split calculation into the database
         $add = true;
         foreach ($split as $id => $ip) {
             //GETTING RID OF DESCRIPTION
             $ip_manager = new Netblock($ip);
             $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_family($ip_info->get_family());
             //set the parent id to know who the parent is
             $n_ip->set_parent_id($ip_info->get_netblock_id());
             //if there are any inheritance of the information, inherit them into the new network
             if ($_POST['inh_loc'] == "on") {
                 $n_ip->set_location_id($ip_info->get_location_id());
             }
             if ($_POST['inh_owner'] == "on") {
                 $n_ip->set_owner_id($ip_info->get_owner_id());
             }
             if ($_POST['inh_assigned'] == "on") {
                 $n_ip->set_assigned_to_id($ip_info->get_assigned_to_id());
             }
             if ($_POST['inh_status'] == "on") {
示例#2
0
                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);