Пример #1
0
 function add_interface_form()
 {
     // This function will be the wizard that allows the user
     // to add interfaces to an accounting profile
     // First check if Device ID is set, if not then render device menu
     if (isset($_POST['device_id'])) {
         $device = new Device($_POST['device_id']);
         $all_interfaces = $device->get_interfaces();
         $data = array();
         $title = array();
         foreach ($all_interfaces as $id => $value) {
             array_push($title, "<input type='checkbox' class='check_pref' name='if_add[]' value='" . $id . "' />");
             array_push($data, $value->get_name());
             array_push($data, $value->get_alias());
             array_push($data, $value->get_oper_status());
         }
         $form = new Form("auto", 4);
         $heading = array("Select All<input name='all' type='checkbox' value='Select All' onclick=\"checkAll(document.dataForm['if_add[]'],this)\"", "Interface name", "Description", "Status");
         $form->setSortable(true);
         // or false for not sortable
         $form->setHeadings($heading);
         $form->setTitles($title);
         $form->setTitleWidth("50px");
         $form->setData($data);
         $form->setTableWidth("500px");
         $content .= "<form action='' id='dataForm' method='POST' name='dataForm'>";
         $content .= $form->showForm();
         $content .= "<div style='clear:both'></div>\n                                        <INPUT TYPE=SUBMIT VALUE='Add Selected Interfaces' name='addInterfacesToProfile'>\n                                        <INPUT TYPE=hidden NAME=action VALUE='add_device_interface_to_profile'>\n                                        <INPUT TYPE=hidden NAME=tab VALUE='" . $_GET['tab'] . "'>\n                                        <INPUT TYPE=hidden NAME=name VALUE='" . $_POST['name'] . "'>\n                                        <INPUT TYPE=hidden NAME=pluginID VALUE='" . $_GET['pluginID'] . "'>\n                                        <INPUT TYPE=hidden NAME=device_id VALUE='" . $_POST['device_id'] . "'>\n                                </form>";
         $content .= $form->showForm();
         print_r($_POST);
         return $content;
     } elseif (isset($_POST['addInterfacesToProfile'])) {
         print "adding ifs!!<br>";
         print_r($_POST);
     } else {
         // Render device menu
         $heading = array("Select Device");
         $titles = array("Device");
         $keys = array("device_id");
         $all_devices = Device::get_devices();
         $myDropDownListener = "alert('Your gender is '+this.value)";
         $fieldType = array("drop_down");
         $form = new Form("auto", 2);
         $form->setHeadings($heading);
         $form->setTitles($titles);
         $form->setDatabase($keys);
         $form->setType($all_devices);
         $form->setFieldType($fieldType);
         $form->setUpdateText("Continue to select Interface");
         $form->setUpdateValue("select_if");
         //$form->setMethod("GET") ;
         echo $form->editForm();
     }
     return;
 }
Пример #2
0
function displayIP()
{
    //global all variables
    global $deviceKey, $deviceForm, $tool;
    $deviceForm->setCols(2);
    $deviceForm->setTableWidth('200px');
    //create the toolbar
    /*$toolNames = array("All Devices", "All Archived Device");
    	$toolIcons = array("devices", "devices");
    	$toolHandlers = array("handleEvent('devices.php')", "handleEvent('devices.php?action=showArchived')");
    	
    	echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers);*/
    //make place holder arrays for the ips
    $devices = Device::get_devices();
    $info = array();
    $info2 = array();
    $title = array();
    $title2 = array();
    $headings = array();
    $handlers = array();
    $isTitle = true;
    //push the ip addresses to the corresponding devices
    foreach ($devices as $id => $value) {
        $curDevices = new Device($id);
        $interfaces = $curDevices->get_interfaces();
        array_push($headings, $curDevices->get_name());
        array_push($headings, "*<break>*");
        foreach ($interfaces as $iId => $iValue) {
            $ipv4 = $iValue->get_ipv4_addresses();
            $ipv6 = $iValue->get_ipv6_addresses();
            foreach ($ipv4 as $ipID => $ipValue) {
                $actualIP = explode("/", $ipID, 2);
                $hostname = gethostbyaddr($actualIP[0]);
                if (preg_match('/^(192\\.168|10\\.|172\\.[1-3]|127\\.0\\.0\\.1)/', $ipID)) {
                    if ($hostname == $actualIP[0] || $hostname == '') {
                        $hostname = "<b class='DNS RFC' style='color:#CCC; filter:alpha(opacity=30);'>No DNS entry for this IP</b>";
                    } else {
                        $hostname = "<span class='DNS RFC'>" . $hostname . "</span>";
                    }
                    $rfcIP = "<span class='RFC'>" . $ipID . "</span>";
                    array_push($title, $rfcIP);
                } else {
                    if ($hostname == $actualIP[0] || $hostname == '') {
                        $hostname = "<b class='DNS' style='color:#CCC; filter:alpha(opacity=30);'>No DNS entry for this IP</b>";
                    } else {
                        $hostname = "<span class='DNS'>" . $hostname . "</span>";
                    }
                    array_push($title, $ipID);
                }
                array_push($info, $hostname);
            }
            foreach ($ipv6 as $ipID => $ipValue) {
                $actualIP = explode("/", $ipID, 2);
                $hostname = gethostbyaddr($actualIP[0]);
                if (preg_match('/^(192\\.168|10\\.|172\\.[1-3]|127\\.0\\.0\\.1)/', $ipID)) {
                    if ($hostname == $actualIP[0] || $hostname == '') {
                        $hostname = "<b class='DNS RFC' style='color:#CCC; filter:alpha(opacity=30);'>No DNS entry for this IP</b>";
                    } else {
                        $hostname = "<span class='DNS RFC'>" . $hostname . "</span>";
                    }
                    $rfcIP = "<span class='RFC'>" . $ipID . "</span>";
                    array_push($title2, $rfcIP);
                } else {
                    if ($hostname == $actualIP[0] || $hostname == '') {
                        $hostname = "<b class='DNS' style='color:#CCC; filter:alpha(opacity=30);'>No DNS entry for this IP</b>";
                    } else {
                        $hostname = "<span class='DNS'>" . $hostname . "</span>";
                    }
                    array_push($title2, $ipID);
                }
                array_push($info2, $hostname);
            }
        }
        array_push($title, "*<break>*");
        array_push($title2, "*<break>*");
    }
    echo "<input type='checkbox' id='hideDNS'>Disable DNS Resolving</input>";
    echo " | <input type='checkbox' id='hideRFC'>Suppress RFC1918 and link Local addresses</input>";
    //show all the IPv4 and IPv6 addresses
    $deviceForm->setFirst(true);
    echo $deviceForm->showAll($headings, $title, $info, $handlers);
    $deviceForm->setFirst(false);
    echo $deviceForm->showAll($headings, $title2, $info2, $handlers);
}
Пример #3
0
function displayGraphListResult($keyword)
{
    //global the tool and make a tool bar for adding a client
    global $tool, $deviceForm;
    $interfaces = array();
    $allDevices = Device::get_devices();
    foreach ($allDevices as $id => $value) {
        $device = new Device($id);
        $interfaceStorage = $device->get_interfaces();
        foreach ($interfaceStorage as $iID => $iValue) {
            array_push($interfaces, $iValue);
        }
    }
    $numInterface = count($interfaces);
    if (!isset($_GET['mode'])) {
        $searchAction = "statistics.php?action=showGraphListResult";
        echo $tool->createSearchBar($searchAction);
    }
    echo "<div id='filteredResult' style='width:1024px; text-align:left;'>";
    echo "<form name='listForm' method='post' action='statistics.php?action=showGraphResult&ID=" . $_GET['ID'] . "&pageNum=1'>\r\n\t\t<input type='submit' name='returnResults' value='Display Checked Graphs' style='float:right; margin-bottom:5px;'></input>\r\n\t\t<table id=\"dataTable\" cellspacing=\"0\" cellpadding=\"0\" border=\"1\" style='width:100%; clear:left;'>\r\n\t\t<thead><tr><th colspan='4'>\r\n\t\t<input type='checkbox' name='all' onclick=\"checkAll(document.listForm['list[]'], all)\">Select All</input> | Statistics\r\n\t\t</th></tr></thead>";
    #"<select name='interfaces' onchange=\"return LoadPage('statistics.php?action=showCurGraph&mode=graphTime'+this.value, 'statGraphs')\">";
    if (isset($interfaces)) {
        foreach ($interfaces as $id => $value) {
            $device = new Device($value->get_device_id());
            $deviceName = $device->get_name();
            $link = "statistics.php?action=showGraphDetail&ID=" . $value->get_device_id() . "&interID=" . $value->get_interface_id() . "&active=" . $value->get_oper_status() . "&type=";
            $all = "statistics.php?action=showGraphResult&ID=" . $value->get_device_id() . "&interID=" . $value->get_interface_id() . "&pageNum=1&active=yes";
            $specialChars = array('/', '(', ')', '>', '<', '[', ']');
            $newKey = $keyword;
            foreach ($specialChars as $sid => $svalue) {
                $newKey = str_replace($svalue, "\\" . $svalue, $newKey);
            }
            if (preg_match("/" . $newKey . "/i", $value->get_name()) || preg_match("/" . $newKey . "/i", $value->get_descr()) || preg_match("/" . $newKey . "/i", $value->get_alias())) {
                echo "<tr><td style='width:20%; border-bottom:solid thin;'><input type='checkbox' name='list[]' value='" . $value->get_interface_id() . "//" . $value->get_device_id() . "'>" . $value->get_name() . "</input></td>\r\n\t\t\t\t<td style='border-bottom:solid thin;'>" . $value->get_descr() . " | " . $value->get_alias() . "</td>\r\n\t\t\t\t<td style='border-bottom:solid thin;'>" . $deviceName . "</td>\r\n\t\t\t\t<td style='border-bottom:solid thin; width:35%'>\r\n\t\t\t\t<input type='button' onclick=\"handleEvent('" . $link . "traffic')\" value='Traffic' />\r\n\t\t\t\t<input type='button' onclick=\"handleEvent('" . $link . "errors')\" value='Error' />\r\n\t\t\t\t<input type='button' onclick=\"handleEvent('" . $link . "unicastpkts')\" value='Unicast' />\r\n\t\t\t\t<input type='button' onclick=\"handleEvent('" . $link . "nonunicastpkts')\" value='Nonunicast' />\r\n\t\t\t\t<input type='button' onclick=\"handleEvent('" . $all . "')\" value='All' />\r\n\t\t\t\t</td></tr>";
            }
        }
    } else {
        $deviceForm->warning("No interfaces for this device");
    }
    echo "</table>\r\n\t<input type='submit' name='returnResults' value='Display Checked Graphs' style='float:right; margin-bottom:5px;'></input>\r\n\t</form>\r\n\t</div>";
}