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(); }
print "<span id='head' style='color:" . $color . ";'>" . $netblock->get_IP() . "</span><br / > "; print "<div class = 'box'>Subnet mask = <span id='sub'>" . $netblock->get_netmask() . "</span></div>"; print "<div class = 'box'>Wildcard = <span id='sub'>" . $netblock->get_wildcard() . "</span></div>"; print "<div class = 'box'>Network = <span id='sub'>" . $netblock->get_network() . "</span></div>"; print "<div class = 'box'>Broadcast = <span id='sub'>" . $netblock->get_broadcast() . "</span></div>"; print "<div class = 'box'>Hostmin = <span id='sub'>" . $netblock->get_hostmin() . "</span></div>"; print "<div class = 'box'>Hostmax = <span id='sub'>" . $netblock->get_hostmax() . "</span></div>"; print "<div class = 'box'>Host Per Net = <span id='sub'>" . $netblock->get_hostPerNet(); } else { if ($_GET['action'] == 'desc') { $name = "NO OWNER"; if ($ip_db->get_owner_name() != "") { $name = $ip_db->get_owner_name(); } $assigned = "NO ASSIGNED TO"; if ($ip_db->get_assigned_to_name() != "") { $assigned = $ip_db->get_assigned_to_name(); } $location = "NO LOCATION"; if ($ip_db->get_location_name() != "") { $location = $ip_db->get_location_name(); } print "<span id='head' style='color:" . $color . ";'>" . $netblock->get_IP() . "</span> - " . $ip_db->get_title() . "<br / > "; print "<div id='left'>"; print "<img src='icons/location.png' /> " . $location . "<br /> \n\t\t\t\t\t<img src='icons/Person.png' /> " . $name . " <br />\n\t\t\t\t\t<img src='icons/People.png' /> " . $assigned . "<br />"; print "</div>"; print "<div id='right'>"; print "<div class = 'desc'>Comment: <span id='sub'>" . nl2br($ip_db->get_description()) . "</span></div>"; print "<div class = 'desc'>Tags: <span id='sub'>"; foreach ($ip_db->get_tags() as $t_id => $t_name) { $tag_str .= $t_name . ", ";
function export_csv() { if (isset($_GET['report_name']) && $_GET['report_name'] != '') { $name = $_GET['report_name']; } else { return "<b>Sorry invalid report name " . $_GET['report_name'] . "</b>"; } if (isset($_GET['vlan_id'])) { if ($_GET['vlan_id'] == 'showALL') { $vlan_manager = new Vlan_database(); $all_vlans = $vlan_manager->get_all_vlans(); $num_max = 4096; $heading = array("VLAN ID", "Name", "Status", "Location", "Assigned To", "VLAN Distinguisher"); $content = implode(",", $heading); $content .= "\n"; $arr = array(); foreach ($all_vlans as $id => $v_id) { $arr[$v_id] = $id; } for ($i = 1; $i < $num_max; $i++) { $data = array(); if (in_array($i, $all_vlans)) { foreach ($all_vlans as $id => $v_id) { if ($v_id == $i) { $my_vlan = new Vlan_database($id); if ($my_vlan->get_id() !== NULL) { $data = array(); array_push($data, $my_vlan->get_vlan_id()); array_push($data, $my_vlan->get_name()); array_push($data, $my_vlan->get_status()); array_push($data, $my_vlan->get_location_name()); array_push($data, $my_vlan->get_assigned_to_name()); array_push($data, $my_vlan->get_vlan_distinguisher()); $content .= stripslashes(implode(",", $data)); $content .= "\n"; } } } } else { //if it doesn't create a free vlan array_push($data, $i); array_push($data, ""); array_push($data, "FREE"); array_push($data, ""); array_push($data, ""); array_push($data, ""); $content .= stripslashes(implode(",", $data)); $content .= "\n"; } } } else { $results = Vlan_database::Search($_GET['vlan_id'], $_GET['name'], $_GET['status'], $_GET['location'], $_GET['assign'], $_GET['distinguish'], $_GET['notes']); $heading = array("VLAN ID", "Name", "Status", "Location", "Assigned To", "VLAN Distinguisher"); $content = implode(",", $heading); $content .= "\n"; foreach ($results as $v_id => $vlan_id) { $data = array(); $my_vlan = new Vlan_database($v_id); array_push($data, $my_vlan->get_vlan_id()); array_push($data, $my_vlan->get_name()); array_push($data, $my_vlan->get_status()); array_push($data, $my_vlan->get_location_name()); array_push($data, $my_vlan->get_assigned_to_name()); array_push($data, $my_vlan->get_vlan_distinguisher()); $content .= stripslashes(implode(",", $data)); $content .= "\n"; } } } else { $title = $_GET['title']; $str_tag = $_GET['tags']; while (strpos($str_tag, ", ")) { $str_tag = str_replace(", ", ",", $str_tag); } $tags = explode(",", $str_tag); if (count($tags) == 1 && $tags[0] == "") { $tags = array(); } $location = $_GET['location']; $owner = $_GET['owner']; $assigned_to = $_GET['assigned']; $status = $_GET['status']; $IP_Search = new IP_Database(); $s_results = $IP_Search->search($title, $tags, $location, $owner, $assigned_to, $status); $heading = array("Master Block", "Prefix", "Length", "Family", "Status", "Location", "Owner", "Assigned To", "Tags"); $content = implode(",", $heading); $content .= "\n"; foreach ($s_results as $id => $n_name) { $data = array(); $my_netblock = new IP_Database($id); $master_id = IP_Database::get_master($id); $master_block = new IP_Database($master_id); $ip = explode("/", $my_netblock->get_address_ip()); array_push($data, $master_block->get_address_ip()); array_push($data, $ip[0]); array_push($data, $my_netblock->get_subnet_size()); array_push($data, $my_netblock->get_family()); array_push($data, $my_netblock->get_status()); 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()); $tags = $my_netblock->get_tags(); $n_tags = stripslashes(implode(" ", $tags)); array_push($data, $n_tags); $content .= stripslashes(implode(",", $data)); $content .= "\n"; } } return $content; }