Exemple #1
0
/*if (!$vlan_manager->reset()) {
       print "failed to reset vlan manager ";
       print $vlan_manager->get_error() . "\n";
}*/
$all_vlans = $vlan_manager->get_all_vlans();
//set the default column
$form = new Form("auto", 5);
//create the headings for these
$heading = array("VLAN ID", "Name", "Status", "Location", "Assigned To");
//all the food
$titles = array();
//their calories and locations correspondingly
$data = array();
// Loop through all vlans and set the name and status
foreach ($all_vlans as $vlan_id => $vlan_name) {
    $my_vlan = new Vlan_database($vlan_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());
    /*print "vlan info for vlanid ". $my_vlan->get_vlan_id() ;
      print " vlan name ". $my_vlan->get_name() ;
      print " vlan location ". $my_vlan->get_location_name() ."\n";
      print "Asssinged to " . $my_vlan->get_assigned_to() ." name is ". $my_vlan->get_assigned_to_name()  ."\n";
      print "these are the tags: ";
      foreach ( $my_vlan->get_tags() as $tag) {
              print "$tag ";
      }
      #print "\n Now just dump the object\n";
      #print_r($my_vlan);
Exemple #2
0
                 // or false for not sortable
                 $form->setHeadings($heading);
                 $form->setData($data);
                 $form->setEventHandler($handlers);
                 $form->setFilter($filters);
                 //set the table size
                 $form->setTableWidth("1024px");
                 $form->setTitleWidth("20%");
                 //export the search result into csv
                 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=vlan_report&vlan_id=showALL\")' value='Export to CSV' /></div>";
                 echo $form->showForm();
             }
         }
         //update VLAN information when the update is called
         if (isset($_POST['updateInfo'])) {
             $my_vlan = new Vlan_database($v_id);
             $my_vlan->set_name($_POST["name"]);
             $my_vlan->set_status($_POST["status"]);
             $my_vlan->set_location($_POST["location"]);
             $my_vlan->set_assigned_to($_POST["assign"]);
             $my_vlan->set_notes($_POST["notes"]);
             $my_vlan->set_vlan_distinguisher($_POST['distinguish']);
             if ($my_vlan->update()) {
                 echo "<meta http-equiv=\"REFRESH\" content=\"0;url=" . $_SERVER['SCRIPT_NAME'] . "?tab=" . $_GET['tab'] . "&pluginID=" . $_GET['pluginID'] . "&className=" . $_GET['className'] . "&family=vlan&v_id=" . $v_id . "&success=update\">";
             }
         }
     }
 } else {
     echo "<div id='report'>";
     //create a button to toggle advance searches
     echo "<div id='toggle'><a onclick='toggle_search()'><p><input type='button' value='Open Advance Report'></p><p style='display:none'><input type='button' value='Close Advance Report'></p></a></div>";
Exemple #3
0
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;
}