$stub = $_POST['stub']; $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'>";
function display_search_results($s_results, $ip_manager) { if (empty($s_results)) { echo Form::warning("NO IP!"); return false; } echo "<style>"; foreach ($s_results as $id => $name) { echo "#modalBox #dialog" . $id; echo "{\n\t\t\twidth:auto;\n\t\t\tmax-width: 80%;\n\t\t\tmin-width:40%;\n \t\t\theight:auto;\n\t\t\tpadding:10px;\n\t\t\tpadding-top:10px;\n\t\t}\n\t\t"; echo "#modalBox #dialog_calc" . $id; echo "{\n\t\t\twidth:auto;\n\t\t\tmax-width: 80%;\n\t\t\tmin-width:40%;\n \t\t\theight:auto;\n\t\t\tpadding:10px;\n\t\t\tpadding-top:10px;\n\t\t}"; } echo "</style>"; //set the default column $form = new Form("auto", 6); //create the headings for these $heading = array("Netblock", "Name", "Location", "Owner", "Assigned To", "Status"); $data = array(); // Loop through all vlans and set the name and status foreach ($s_results as $id => $n_name) { $my_netblock = new IP_Database($id); $color = "black"; $status = $my_netblock->get_status(); switch ($status) { case "FREE": $color = "green"; break; case "RESERVED": $color = "blue"; break; case "ASSIGNED": $color = "red"; break; case "PARENT": $color = "grey; font-style:italic;"; break; } array_push($data, "<a name='modal' href='#dialog" . $id . "' style='cursor:default; color:" . $color . "' class='ipdesc' rel='" . $my_netblock->get_address_ip() . "@" . $id . "'>" . $my_netblock->get_address_ip() . " </a><a name='modal' href='#dialog_calc" . $id . "' style='cursor:default; color:" . $color . "' class='ipcalc' rel='" . $my_netblock->get_address_ip() . "@" . $id . "'><img src='icons/calculator.png' /></a><input type='hidden' name='id' value='" . $id . "' />"); array_push($data, $my_netblock->get_title()); array_push($data, $my_netblock->get_location_name()); array_push($data, $my_netblock->get_owner_name()); array_push($data, $my_netblock->get_assigned_to_name()); array_push($data, $my_netblock->get_status()); echo "<div id='modalBox'>\n\t\t\t<div id='dialog" . $id . "' class='window'>\n\t\t\t<div style='clear:both;'></div>\n\t\t\t<form method='post'>"; echo "<a href='#'class='close' /><img src='icons/close.png'></a>"; echo "<input type='hidden' name='id' value='" . $id . "' />"; echo "<font class='header2'>" . $my_netblock->get_address_ip() . "</font><hr /><br/><font class='header'>Name</font>"; echo "</select> "; echo "<input type='text' name='title' style='width:100%; margin-bottom:10px;' maxchar='100' value='" . $my_netblock->get_title() . "' />"; echo "<font class='header'>Comment</font><textArea name='description' style='width:100%; margin-bottom:10px;' rows='5' >" . $my_netblock->get_description() . "</textArea>"; echo "Location: <select name='location'>"; if ($my_netblock->get_location_id() === NULL) { echo "<option selected value='NULL'>No Location</option>"; } else { echo "<option value='NULL'>No Location</option>"; } foreach (Location::get_locations() as $lid => $lname) { if ($lid == $my_netblock->get_location_id()) { echo "<option selected value='" . $lid . "'>" . $lname . "</option>"; } else { echo "<option value='" . $lid . "'>" . $lname . "</option>"; } } echo "</select> "; echo "Owner: <select name='owner'>"; if ($my_netblock->get_owner_id() === NULL) { echo "<option selected value='NULL'>No Owner</option>"; } else { echo "<option value='NULL'>No Owner</option>"; } foreach (Contact::get_groups() as $g_id => $g_name) { if ($g_id == $my_netblock->get_owner_id()) { echo "<option selected value='" . $g_id . "'>" . $g_name . "</option>"; } else { echo "<option value='" . $g_id . "'>" . $g_name . "</option>"; } } echo "</select> "; echo "Assigned To: <select name='assigned'>"; if ($my_netblock->get_owner_id() === NULL) { echo "<option selected value='NULL'>No Assigned To</option>"; } else { echo "<option value='NULL'>No Assigned To</option>"; } foreach (Contact::get_groups() as $g_id => $g_name) { if ($g_id == $my_netblock->get_assigned_to_id()) { echo "<option selected value='" . $g_id . "'>" . $g_name . "</option>"; } else { echo "<option value='" . $g_id . "'>" . $g_name . "</option>"; } } echo "</select> "; if (!IP_Database::is_parent($id)) { echo "Status: <select name='status'>"; $all_status = array("FREE", "RESERVED", "ASSIGNED"); foreach ($all_status as $s_id => $s_name) { if ($my_netblock->get_status() == $s_name) { echo "<option selected value='" . $s_name . "'>" . $s_name . "</option>"; } else { echo "<option value='" . $s_name . "'>" . $s_name . "</option>"; } } echo "</select> "; } if (!IP_Database::is_parent($id)) { echo "Stub: <select name='stub' id='stub" . $id . "'>"; if ($my_netblock->is_stub() == 0) { echo "<option value='0' selected >not stub</option>\n\t\t\t\t\t<option value='1' >stub</option>"; } else { echo "<option value='0' >not stub</option>\n\t\t\t\t\t<option value='1' selected >stub</option>"; } echo "</select>"; } echo "<br /><font class='header'>Tags</font><input type='text' name='tags' class='tags_input' style='width:100%; margin-bottom:10px;' value='"; foreach ($my_netblock->get_tags() as $t_id => $t_name) { echo $t_name . ", "; } echo "' />"; echo " <input type='submit' id='ip_update' name='ip_update' value='UPDATE' />\n\t\t\t<input type='submit' id='ip_delete' name='ip_delete' onclick='return confirmSubmit()' value='DELETE NETWORK' />\n\t\t\t</form>"; echo "</div>\n\t\t\t\t<div id='mask'></div>\n\t\t\t\t</div>"; $ip_manager->set_ip($my_netblock->get_address_ip()); echo "<div id='modalBox'>\n\t\t\t<div id='dialog_calc" . $id . "' class='window'>\n\t\t\t<div style='clear:both;'></div>"; echo "<a href='#'class='close' /><img src='icons/close.png'></a>"; echo $ip_manager->print_all($my_netblock->get_title()); echo "</div>\n\t\t\t\t<div id='mask'></div>\n\t\t\t\t</div>"; } $form->setSortable(true); // or false for not sortable $form->setHeadings($heading); $form->setData($data); //set the table size $form->setTableWidth("1024px"); echo "<div id='csv_block' style='clear:both; float:left; margin-bottom:5px; margin-top:10px;'><input type='button' onclick='csv_report(\"plugins/IP%20Manager/export_csv.php?report_name=ip_report&title=" . $_GET['title'] . "&location=" . $_GET['location'] . "&owner=" . $_GET['owner'] . "&assigned=" . $_GET['assigned'] . "&status=" . $_GET['status'] . "&tags=" . $_GET['tags'] . "\")' value='Export to CSV' /></div>"; //$_GET['title'] $_GET['tags'] $_GET['location'] $_GET['owner'] $_GET['assigned'] $_GET['status']; //title=$_GET['title']&location=$_GET['location']&owner=$_GET['owner']&assigned=$_GET['assigned']&status=$_GET['status']&tags=$_GET['tags'] echo $form->showForm(); }