Beispiel #1
0
 function get_config($id = '')
 {
     // MUST HAVE<input type='hidden' name='id' value=".$id."></input>
     // the name of the property must follow the conventions plugin_<Classname>_<propertyName>
     // have the form post and make sure the submit button is named widget_update
     // make sure there is also a hidden value giving the name of this Class file
     // Get defaults
     $subquery = "select device_id, enabled FROM plugin_SNMPPoller_devices";
     $result2 = mysql_query($subquery);
     if (!$result2) {
         return "<b>Oops something went wrong, unable to read plugin_SNMPPoller_devices SQL table </b>";
     }
     $devices = array();
     while ($obj = mysql_fetch_object($result2)) {
         $devices[$obj->device_id] = $obj->enabled;
     }
     // Now we have the defaults in $devices;
     $content .= "<h1>Please select the Devices you would like to Monitor with the SNMP poller</h1>";
     $content .= "<form id='configForm' method='post' name='edit_devices'>\r\n\t\t\t<input type='hidden' name='class' value='SNMPPoller'></input>\r\n\t\t\t<input type='hidden' name='id' value=" . $id . "></input> ";
     $select_all = "<input name='all' type='checkbox' value='Select All' onclick=\"checkAll(document.edit_devices['devices[]'],this)\"";
     #$content .= "<table border=1><tr><th>$select_all</th><th>Device</th><th>Device Type</th><th>Location</th></tr>";
     $form = new Form("auto", 4);
     $keyHandlers = array();
     $keyData = array();
     $keyTitle = array();
     foreach (Device::get_devices() as $id => $name) {
         if (array_key_exists($id, $devices) && $devices[$id] == 1) {
             $checked = "checked='yes'";
         } else {
             $checked = "";
         }
         $deviceInfo = new Device($id);
         array_push($keyData, "<input type=checkbox name=devices[] value='{$id}' {$checked} >");
         array_push($keyData, $name);
         array_push($keyData, $deviceInfo->get_type_name());
         array_push($keyData, $deviceInfo->get_location_name());
         #$content .= "<tr><td><input type=checkbox name=devices[] value='$id' $checked ></td>";
         #$content .= "<td>$name</td><td>". $deviceInfo->get_type_name() ."</td>";
         #$content .= "<td>". $deviceInfo->get_location_name() ."</td></tr>";
     }
     #$content .= "</table> <br>";
     //get all the device and display them all in the 3 sections "Device Name", "Device Type", "Location".
     $heading = array($select_all, "Device Name", "Device Type", "Location ");
     $form->setSortable(true);
     // or false for not sortable
     $form->setHeadings($heading);
     $form->setEventHandler($handler);
     $form->setData($keyData);
     $form->setTableWidth("auto");
     $content .= $form->showForm();
     $content .= "<div style='clear:both;'></div><input type='submit' class='submitBut' name='plugin_update' value='Update configuration'/>\r\n\t\t\t</form> ";
     return "{$content}";
 }
Beispiel #2
0
 function get_content()
 {
     include_once "classes/Contact.php";
     include_once "classes/Device.php";
     include_once "classes/Service.php";
     $clients = new Contact();
     $allClients = $clients->get_groups();
     $numClients = count($allClients);
     $devices = Device::get_devices();
     $numDevices = count($devices);
     $services = Service::get_services(0);
     $numLay2 = 0;
     $numOran = 0;
     $numComm = 0;
     $numCU = 0;
     $numIx = 0;
     foreach ($services as $id => $value) {
         $curService = new Service($id);
         switch ($curService->get_service_type()) {
             case 0:
                 $numComm++;
                 break;
             case 1:
                 $numOran++;
                 break;
             case 2:
                 $numIx++;
                 break;
             case 4:
                 $numLay2++;
                 break;
             case 7:
                 $numCU++;
                 break;
         }
     }
     $content = "<ul>";
     $content .= "<li>" . $numClients . " clients</li>" . "<li>" . $numDevices . " devices</li>" . "<li>" . $numCU . " customer logical router (CU_ALL) Service</li>" . "<li>" . $numComm . " internet IP Transit (commodity) Service</li>" . "<li>" . $numLay2 . " layer 2 vlan service (l2_vlan) Service</li>" . "<li>" . $numOran . " oran IP service (oran) Service</li>" . "<li>" . $numIx . " transit Exchange Peering (ix) Service</li>";
     $content .= "</ul>";
     return $content;
 }
Beispiel #3
0
function addDeviceForm($devices)
{
    //global all variables and make the tool bar
    global $tool, $deviceForm, $headings, $titles, $deviceKey, $deviceTypes, $location;
    /*Taken out for user interface issues
    	$toolNames = array("All Devices", "All Archived Devices");
    	$toolIcons = array("devices", "devices");
    	$toolHandlers = array("handleEvent('devices.php')", "handleEvent('devices.php?action=showArchived')");
    	echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers);*/
    $deviceForm->setCols(2);
    if ($_GET['item'] == mPort) {
        $devices = new Device($_GET['ID']);
        $deviceForm->setCols(2);
        $name = $devices->get_name();
        $deviceKey = array("pType", "description", "physicalPort", "portName", "portType", "controlledDevice");
        $headings = array("Port Info for " . $name);
        $titles = array("pType", "Description.tip.A descriptive name for this connection, i.e. \"console connection for router1, routing engine 2\" or \"Remote power cycle group for router1\"", "Physical port.tip.Which port is this device physically connected to", "Port name.tip.Name of port. This will also be the name used for scripts", "Port type", "Control device");
        $dropDownAction = "LoadPage('devices.php?action=changeControlledPort&mode='+this.value, 'controlledPort');";
        $types = array("power_control" => "Power Port", "console_server" => "Console Port");
        $fieldType = array("hidden", "", "", "", "drop_down.handler:" . $dropDownAction, "custom");
        $fieldInfo = array("mport", "", "", "", "", "<div id='controlledPort'></div>");
        $deviceForm->setFieldType($fieldType);
        $deviceForm->setData($fieldInfo);
        echo $deviceForm->newPortForm($headings, $titles, $deviceKey, $types);
    } else {
        if ($_GET['item'] == cPort) {
            $devices = new Device($_GET['ID']);
            $deviceForm->setCols(2);
            $name = $devices->get_name();
            $deviceKey = array("pType", "description", "physicalPort", "portName", "portType", "managedDevice");
            $headings = array("Port Info for " . $name);
            $titles = array("pType", "Description.tip.A descriptive name for this connection, i.e. \"console connection for router1, routing engine 2\" or \"Remote power cycle group for router1\"", "Physical port.tip.Which port is this device physically connected to", "Port name.tip.Name of port. This will also be the name used for scripts", "Port type", "Managed device.tip.Select a device or select \"Other Device\" if you want to manage a device that is not in the database. If you select \"Other Device\" please make sure to have a good port description.");
            $titles = array("pType", "Description", "Physical port", "Port name", "Port type", "Managed device");
            $types = $devices->get_devices();
            $fieldType = array("hidden", "", "", "", "static", "drop_down");
            if ($_GET['deviceClass'] == "console_server") {
                $port = "console";
            } else {
                $port = "power";
            }
            $fieldInfo = array("cport", "", "", "", $port, "");
            $deviceForm->setData($fieldInfo);
            $deviceForm->setFieldType($fieldType);
            echo $deviceForm->newPortForm($headings, $titles, $deviceKey, $types);
        } else {
            //create a new client form
            $fieldType = array("", "", "drop_down", "drop_down", "", "text_area", "", "", "", "", "");
            $type = array($location, $deviceTypes);
            $deviceForm->setFieldType($fieldType);
            echo $deviceForm->newDeviceForm($headings, $titles, $deviceKey, $type);
        }
    }
}
Beispiel #4
0
 private function renderFirewallCounterForm()
 {
     $content = '<h2>Firewall Counters</h2>';
     $allDevices = Device::get_devices();
     //$allDevices = array();
     asort($allDevices);
     $getdeviceID = "";
     if (isset($_GET['deviceID'])) {
         $getdeviceID = $_GET['deviceID'];
     }
     $getFrom = "-1d";
     if (isset($_GET['From'])) {
         $getFrom = $_GET['From'];
     }
     $form = new Form("auto", 2);
     $values = array();
     $handler = array();
     $titles = array("Device", "Time Frame", "tab", "pluginID");
     $postKeys = array("deviceID", "From", "tab", "pluginID");
     array_push($values, $getdeviceID, $getFrom, $_GET['tab'], $_GET['pluginID']);
     $heading = array("Select location");
     $fieldType[0] = "drop_down";
     $fieldType[1] = "drop_down";
     $fieldType[2] = "hidden";
     $fieldType[3] = "hidden";
     $form->setType($allDevices);
     $allFrom = array();
     $allFrom["-1h"] = "Past 1 Hour";
     $allFrom["-1d"] = "Past 1 Day";
     $allFrom["-1w"] = "Past 1 Week";
     $allFrom["-1y"] = "Past 1 Year";
     $form->setType($allFrom);
     $form->setFieldType($fieldType);
     $form->setSortable(false);
     $form->setHeadings($heading);
     $form->setTitles($titles);
     $form->setData($values);
     $form->setDatabase($postKeys);
     //set the table size
     $form->setTableWidth("100");
     $form->setTitleWidth("20%");
     $form->setUpdateValue("GetCounters");
     $form->setUpdateText("Get Counters");
     $form->setMethod("GET");
     $content .= $form->EditForm(1);
     $content .= "<div style=\"clear:both;\"></div> </p>";
     return $content;
 }
Beispiel #5
0
function addCheck()
{
    //global the tool and make a tool bar for adding a device and display all the archived device, and displaying the IP Report
    global $tool, $form;
    $keyHandlers = array();
    $keyData = array();
    $keyTitle = array();
    $allDevices = Device::get_devices();
    $keyHandlers = array();
    $keyData = array();
    $keyData[3] = "5";
    $keyTitle = array();
    $postKeys = array();
    $allTemplates = CheckTemplate::get_templates();
    $check = new Check();
    $form->setType($allDevices);
    // Drop down
    $form->setType($allTemplates);
    // Drop down
    $key1 = "Key1<br><small><i>Depends on selected Template</i></small>";
    $key2 = "Key2<br><small><i>Depends on selected Template</i></small>";
    $headings = array("New Check ");
    $postKeys = array("check_name", "hostname", "check_desc", "check_interval", "check_template", "check_args", "check_key1", "check_key2", "check_notes");
    $keyTitle = array("Name.tip.descriptive name for this chesk", "Hostname", "Description.tip.A usefull description", "Interval.tip.Check interval in Minutes", "Template", "Arguments", "{$key1}", "{$key2}", "Notes");
    $form->setCols(2);
    $form->setData($keyData);
    $form->setTitles($keyTitle);
    $form->setDatabase($postKeys);
    $form->setCols(2);
    $form->setTableWidth("500px");
    $form->setData($keyData);
    $form->setTitles($keyTitle);
    $form->setDatabase($postKeys);
    $fieldType[1] = "drop_down";
    $fieldType[4] = "drop_down";
    $fieldType[8] = "text_area";
    $form->setFieldType($fieldType);
    $form->setHeadings($headings);
    $form->setSortable(false);
    $form->setUpdateValue("insertCheck");
    $form->setUpdateText("Add new Check");
    echo $form->editForm();
}
Beispiel #6
0
function addServiceForm($services)
{
    //global all variables and make the tool bar
    global $tool, $serviceForm, $headings, $titles, $serviceKey, $serviceTypes, $location, $status_array;
    //create the tools if this is not in Ajax mode
    /*Taken out for usability issues
    	if (!isset($_GET['mode']))
    	{
    		$toolNames = array("All Services", "All Archived Services");
    		$toolIcons = array("services", "services");
    		$toolHandlers = array("handleEvent('services.php')", "handleEvent('services.php?action=showArchived')");
    		echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers);
    	}*/
    $serviceForm->setCols(2);
    $serviceType;
    $value = $_GET['mode'];
    /*switch ($value)
    	{
    		case 0: $serviceType = 'commodity'; break;
    		case 1: $serviceType = 'oran'; break;
    		case 2: $serviceType = 'ix'; break;
    		case 3: $serviceType = 'undefined'; break;
    		case 4: $serviceType = 'l2_vlan'; break;
    		case 5: $serviceType = 'l2_transparant_p2p'; break;
    		case 6: $serviceType = 'l2_tranparant_multipoint'; break;
    		case 7: $serviceType = 'CU_ALL'; break;
    	}*/
    //gives the headings titles and service keyes to the corresponding layer
    if ($_GET['layer'] == 3) {
        $headings = array("Service Information", "*<break>*", "Port Specific Information", "*<break>*", "Routing Specific Information", "*<break>*", "IPv4 Information", "*<break>*", "IPv6 Information");
        $titles = array("Customer name", "Service type", "Include statistics in portal?.tip.If YES is selected the user will be able to see the statistics for this particular service in the wiki portal. If this is not selected, traffic stats for this service will not be available in the wiki portal", "Service description (name).tip.A useful description for this service", "Notes.tip.Here you can add generic notes for this service, for example: This is a tempory backup connection.", "Status.tip.Specify the production status of this Service", "In production date", "Out of production date", "*<break>*", "Device for Service", "Interface.tip.Name of the physical interface, for example ge-2/0/1<br>Do not use subinterface format no ge-2/0/1.10", "Interface MTU Size.tip.Default for ORAN and CU_ALL is 9000 bytes, the commodity and IX instance use 1500", "Interface tagged", "Vlan number.tip.Please enter a vlan number. If this is an untagged routed port and has no vlan, than please use 0. This means no vlan configuration", "*<break>*", "Logical router", "Routing type", "AS number", "Traffic Policing", "*<break>*", "IPv4 unicast", "IPv4 multicast", "BCNET router address.tip.IPv4 address of the BCNET side of this link. Please include masklenght. Format: x.x.x.x/30", "Customer router address.tip.IPv4 address of the Customer side of this link. Please include masklenght. Format: x.x.x.x/30", "IPv4 prefix", "*<break>*", "IPv6 unicast", "IPv6 multicast", "BCNET router address", "Customer router address", "IPv6 prefix");
        $serviceKey = array("cusName", "serviceType", "stats", "description", "notes", "status", "in_production", "out_production", "device", "interface", "interfaceMTU", "tagged", "vlanNum", "logiRout", "routType", "ASNum", "trafPolice", "ipv4Uni", "ipv4Multi", "pRoutAd4", "cRoutAd4", "prefix4", "ipv6Uni", "ipv6Multi", "pRoutAd6", "cRoutAd6", "prefix6");
        $layer3Service = new Layer3_service($services->get_service_id());
        $fieldType = array("drop_down", "drop_down", "radio", "", "text_area", "drop_down", "date_picker", "date_picker", "drop_down", "", "drop_down", "radio", "", "", "drop_down", "", "", "radio", "radio", "custom", "custom", "text_area.width:150px.height:100px", "radio", "radio", "custom", "custom", "text_area.width:200px.height:100px");
        $customKeys = array("pRoutAd4", "cRoutAd4", "pRoutAd6", "cRoutAd6");
        $custom = array();
        foreach ($customKeys as $id => $value) {
            $custom[$id] = "<input name=\"" . $customKeys[$id] . "\" id=\"" . $customKeys[$id] . "\" value=\"\" type=\"text\" maxChar=\"250\" style='width: 30%;'> / <input name=\"" . $customKeys[$id] . "-length\" id=\"" . $customKeys[$id] . "-length\" value=\"\" type=\"text\" maxChar=\"2\" style='width: 2%;'>";
        }
        //store the values in the info
        $fieldInfo = array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", $custom[0], $custom[1], "", "", "", $custom[2], $custom[3], "");
        $contact = new Contact();
        $customers = $contact->get_groups();
        $MTU = array(1500 => '1500', 9000 => '9000');
        $routingType = array('BGP' => 'BGP', 'Static' => 'Static');
        $allServiceTypes = ServiceType::get_service_types();
        $lay3Types = array();
        foreach ($allServiceTypes as $id => $value) {
            $curServiceType = new ServiceType($id);
            if ($curServiceType->get_service_layer() == 3) {
                $lay3Types[$id] = $curServiceType->get_name();
            }
        }
        $types = array($customers, $lay3Types, $status_array, Device::get_devices(), $MTU, $routingType);
        $serviceForm->setData($fieldInfo);
        $serviceForm->setFieldType($fieldType);
        //WEIRD BUG THAT I DUN GET BCNET ROUTER ADDRESS NOT WORKING
        //store all the contact information values into an array
        echo $serviceForm->newServiceForm($headings, $titles, $serviceKey, $types);
    } else {
        if ($_GET['layer'] == 2) {
            $serviceKey = array("cusName", "serviceType", "stats", "description", "notes", "status", "in_production", "out_production", "vlanNum");
            $headings = array("Service Information", "*<break>*", "Layer 2 Specific Information");
            $titles = array("Customer name", "Service type", "Include statistics in portal?.tip.If YES is selected the user will be able to see the statistics for this particular service in the wiki portal. If this is not selected, traffic stats for this service will not be available in the wiki portal", "Service description (name).tip.A useful description for this service", "Notes.tip.Here you can add generic notes for this service, for example: This is a tempory backup connection.", "Status.tip.Specify the production status of this Service", "In production date", "Out of production date", "*<break>*", "Vlan number.tip.Please enter a vlan number. If this is an untagged routed port and has no vlan, than please use 0. This means no vlan configuration");
            $types = "";
            $contact = new Contact();
            $allServiceTypes = ServiceType::get_service_types();
            $lay2Types = array();
            foreach ($allServiceTypes as $id => $value) {
                $curServiceType = new ServiceType($id);
                if ($curServiceType->get_service_layer() == 2) {
                    $lay2Types[$id] = $curServiceType->get_name();
                }
            }
            $customers = $contact->get_groups();
            $types = array($customers, $lay2Types, $status_array);
            $fieldType = array("drop_down", "drop_down", "radio", "", "text_area", "drop_down", "date_picker", "date_picker", "");
            //$fieldInfo = array("", $serviceType, "", "", "", "");
            $serviceForm->setFieldType($fieldType);
            //$serviceForm->setData($fieldInfo);
            //store all the service information values into an array
            echo $serviceForm->newServiceForm($headings, $titles, $serviceKey, $types);
        } else {
            $handler2 = "return LoadPage('services.php?action=add&layer=2&mode='+this.value, 'addLayerForm');";
            $handler3 = "return LoadPage('services.php?action=add&layer=3&mode='+this.value, 'addLayerForm');";
            // Change that... for some reason the above doesn't load the ajax scripts properly....
            // Specificaly the datepicker scripts.
            $handler2 = "window.location='services.php?action=add&layer=2';";
            $handler3 = "window.location='services.php?action=add&layer=3';";
            echo "\r\n\t\t<div style='margin-bottom:10px; clear:left;'>\r\n\t\t<form method='post'>\r\n\t\t<input type='radio' name='serviceType' value='2' onclick=\"{$handler2}\">Layer 2</input>\r\n\t\t<input type='radio' name='serviceType' value='3' onclick=\"{$handler3}\">Layer 3</input>\r\n\t\t</form></div>\r\n\t\t<div id='addLayerForm'></div>";
        }
    }
}
Beispiel #7
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;
 }
Beispiel #8
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>";
}
Beispiel #9
0
 function render_edit_change()
 {
     // First determine change id
     if (isset($_GET[cid]) && is_numeric($_GET[cid])) {
         $cid = $_GET[cid];
     } else {
         return "<b>Sorry change not found<br></b>";
     }
     //$content = "<h1>Change Details (#$cid) </h1>";
     $contentH .= "<div><p><a href='{$this->url}&action=edit_change&cid={$cid}&add_device#new_device'>\n<img src='icons/Add.png'>Add Device Component</a><br></p></div>";
     if (isset($_GET['add_device'])) {
         $add_device = 1;
     } else {
         $add_device = 0;
     }
     // Get all users
     $allUsers_real = User::get_users_by_fullname();
     $allUsers = User::get_users_by_fullname();
     // Do not show Administrator account in changed by dropdown
     unset($allUsers[1]);
     array_push($allUsers, "  ");
     asort($allUsers);
     /*
     	First Generic change info
     */
     $query = "SELECT change_id, title, notes, record_date, \n\t\t\t\t\tUNIX_TIMESTAMP(change_date) as change_date,\n\t\t\t\t\tUNIX_TIMESTAMP(planned_change_date) as planned_change_date,\n\t\t\t\t\tchange_contact_1, change_contact_2, impact, status\n\t\t\t\t\tFROM plugin_ChangeManager_Changes\n\t\t\t\t\tWHERE change_id = '{$cid}'";
     $result = mysql_query($query);
     if (!$result) {
         return "<b>Oops something went wrong, unable to select changes 'Error, query failed. '" . mysql_error() . "</b>";
     }
     $values = array();
     $form = new Form("auto", 2);
     // Need to count the number of sections in this form
     // Used by editForm($numHead)  later
     $form_sections = 1;
     while ($obj = mysql_fetch_object($result)) {
         // First initialized with correct date
         if (is_null($obj->change_date)) {
             $custom_date = '';
         } else {
             $year = date("Y", $obj->change_date);
             $month = date("m", $obj->change_date);
             $day = date("d", $obj->change_date);
             $hour = date("H", $obj->change_date);
             $minute = date("i", $obj->change_date);
             $sql_time = "{$hour}:{$minute}";
             $custom_date = "{$year}-{$month}-{$day}";
         }
         // First initialized with correct date
         if (is_null($obj->planned_change_date)) {
             $custom_planned_date = '';
         } else {
             $planned_year = date("Y", $obj->planned_change_date);
             $planned_month = date("m", $obj->planned_change_date);
             $planned_day = date("d", $obj->planned_change_date);
             $planned_hour = date("H", $obj->planned_change_date);
             $planned_minute = date("i", $obj->planned_change_date);
             $planned_sql_time = "{$planned_hour}:{$planned_minute}";
             $custom_planned_date = "{$planned_year}-{$planned_month}-{$planned_day}";
         }
         // Create status array
         /**
         $status_arr= array();
         $status_arr = $this->status_values;
         if ($obj->status == 1) {
         	$status_arr = array();
         	//$status_arr[0] = $this->status_values[0];
         	$status_arr[1] = $this->status_values[1];
         	$status_arr[2] = $this->status_values[2];
         }
         elseif ($obj->status == 2) {
         	//unset($status_arr[0]);
         	unset($status_arr[1]);
         }
         else {
         	unset($status_arr[0]);
         	unset($status_arr[1]);
         	unset($status_arr[2]);
         }
         */
         $status_arr = array();
         $status_arr = $this->status_values;
         // date and time for planned change date
         $fieldType[1] = "date_picker";
         $fieldType[2] = "drop_down";
         $form->setType($this->timetable);
         // Drop down
         // date and time for actual (completion)change date
         $custom_date = "{$year}-{$month}-{$day}";
         $fieldType[3] = "date_picker";
         $fieldType[4] = "drop_down";
         $form->setType($this->timetable);
         // Drop down
         $notes = $obj->notes;
         $user1 = new User($obj->change_contact_1);
         $contact_name1 = $user1->get_full_name();
         $user2 = new User($obj->change_contact_2);
         $contact_name2 = $user2->get_full_name();
         $fieldType[5] = "drop_down";
         $form->setType($allUsers);
         // Drop down
         $fieldType[6] = "drop_down";
         $form->setType($allUsers);
         // Drop down
         $fieldType[7] = "drop_down";
         $impact_name = "";
         if ($obj->impact == "0") {
             // Make it none of the existing drop down selected options if none were previously chosen
             $impact_name = "  ";
         } else {
             $impact_name = $this->impact_values[$obj->impact];
         }
         $form->setType($this->impact_values);
         // Drop down
         $fieldType[8] = "drop_down";
         $status_name = "";
         if ($obj->status == "0") {
             // Make it none of the existing drop down selected options if none were previously chosen
             $status_name = "  ";
         } else {
             $status_name = $this->status_values[$obj->status];
         }
         $form->setType($status_arr);
         // Drop down
         // End Custom field
         $title = $obj->title;
         $fieldType[9] = "text_area";
         array_push($values, $obj->title, $custom_planned_date, $planned_sql_time, $custom_date, $sql_time, $contact_name1, $contact_name2, $impact_name, $status_name, $notes);
     }
     $content = "<hr align=\"left\" style=\"width:94%;border:1px solid #C0C0C0;\">\n\t\t\t\t\t<h2>CHANGE (#{$cid}): {$title}</h2>\n\t\t\t\t\t<hr align=\"left\" style=\"width:94%;border:1px solid #C0C0C0;\">" . $contentH;
     $javascriptFormValidation = "\n\t\t<script language=\"javascript\">\n\t\tfunction validateForm()\n\t\t{\n\t\t\t// Parse Date and then check if change date is before planned date\n\t\t\tvar PlannedChangeDateStr = document.forms[\"MyClassForm\"][\"PlannedChangeDate\"].value;\n\t\t\tvar PlannedChangeDateStringArray = PlannedChangeDateStr.split(\"-\",3);\t\t\t\n\t\t\tvar PlannedYear = PlannedChangeDateStringArray[0];\n\t\t\tvar PlannedMonth = PlannedChangeDateStringArray[1];\n\t\t\tvar PlannedDay = PlannedChangeDateStringArray[2];\t\t\t\t\t\t\n\t\t\tvar PlannedChangeTimeStr = document.forms[\"MyClassForm\"][\"PlannedChangeTime\"].value;\n\t\t\tvar PlannedChangeTimeStringArray = PlannedChangeTimeStr.split(\":\",2);\t\t\t\n\t\t\tvar PlannedHour = PlannedChangeTimeStringArray[0];\n\t\t\tvar PlannedMinute = PlannedChangeTimeStringArray[1];\n\t\t\t\n\t\t\tvar PlannedChangeDateTime = new Date(PlannedYear,PlannedMonth,PlannedDay,PlannedHour,PlannedMinute);\n\t\t\t\n\t\t\t// alert('Date: ' + PlannedChangeDateTime.getDate());\n\t\t\t// alert('Month: ' + PlannedChangeDateTime.getMonth());\n\t\t\t// alert('Year: ' + PlannedChangeDateTime.getFullYear());\n\t\t\t// alert('Hour: ' + PlannedChangeDateTime.getHours());\n\t\t\t// alert('Minute: ' + PlannedChangeDateTime.getMinutes());\n\t\t\t\n\t\t\t// alert('PlannedChangeDate ' + document.forms[\"MyClassForm\"][\"PlannedChangeDate\"].value + ' was chosen.');\n\t\t\t// alert('PlannedChangeTime ' + document.forms[\"MyClassForm\"][\"PlannedChangeTime\"].value + ' was chosen.');\n\t\t\t\n\t\t\tif (document.forms[\"MyClassForm\"][\"PlannedChangeDate\"].value == \"\")\n\t\t\t{\n\t\t\t\talert('No Planned Change Date or Time entered!');\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\n\t\t\tvar CompletionChangeDateStr = document.forms[\"MyClassForm\"][\"ChangeDate\"].value;\n\t\t\tvar CompletionChangeTimeStr = document.forms[\"MyClassForm\"][\"ChangeTime\"].value;\n\n\t\t\tif (\n\t\t\t\t(\n\t\t\t\t\t(\n\t\t\t\t\t\t(CompletionChangeDateStr != \"\")\n\t\t\t\t\t\t && \n\t\t\t\t\t\t(CompletionChangeTimeStr == \"Pick an option\")\n\t\t\t\t\t)\n\t\t\t\t) \n\t\t\t\t||\t\t\n\t\t\t\t(\n\t\t\t\t\t(\n\t\t\t\t\t\t(CompletionChangeDateStr == \"\")\n\t\t\t\t\t\t&&\n\t\t\t\t\t\t(CompletionChangeTimeStr != \"Pick an option\")\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t\t{\n\t\t\t\talert('Ensure both Completion Date and Completion Time entered!');\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\n\t\t\tif(CompletionChangeDateStr != \"\" && CompletionChangeTimeStr != \"Pick an option\")\n\t\t\t{\t\t\t\n\t\t\t\tvar CompletionChangeDateStringArray = CompletionChangeDateStr.split(\"-\",3);\t\t\t\n\t\t\t\tvar CompletionYear = CompletionChangeDateStringArray[0];\n\t\t\t\tvar CompletionMonth = CompletionChangeDateStringArray[1];\n\t\t\t\tvar CompletionDay = CompletionChangeDateStringArray[2];\t\t\t\t\t\t\n\n\t\t\t\tvar CompletionChangeTimeStringArray = CompletionChangeTimeStr.split(\":\",2);\t\t\t\n\t\t\t\tvar CompletionHour = CompletionChangeTimeStringArray[0];\n\t\t\t\tvar CompletionMinute = CompletionChangeTimeStringArray[1];\n\t\t\t\t\n\t\t\t\tvar CompletionChangeDateTime = new Date(CompletionYear,CompletionMonth,CompletionDay,CompletionHour,CompletionMinute);\n\t\t\t\t\n\t\t\t\t/* alert('Date: ' + CompletionChangeDateTime.getDate());\n\t\t\t\talert('Month: ' + CompletionChangeDateTime.getMonth());\n\t\t\t\talert('Year: ' + CompletionChangeDateTime.getFullYear());\n\t\t\t\talert('Hour: ' + CompletionChangeDateTime.getHours());\n\t\t\t\talert('Minute: ' + CompletionChangeDateTime.getMinutes()); */\n\t\t\t\t\n\t\t\t\t//alert('CompletionChangeDate ' + document.forms[\"MyClassForm\"][\"ChangeDate\"].value + ' was chosen.');\n\t\t\t\t//alert('CompletionChangeTime ' + document.forms[\"MyClassForm\"][\"ChangeTime\"].value + ' was chosen.');\n\n\t\t\t\tif(CompletionChangeDateTime < PlannedChangeDateTime)\n\t\t\t\t{\n\t\t\t\t\talert(\"Completion Date: \" + document.forms[\"MyClassForm\"][\"PlannedChangeDate\"].value + \" \" + document.forms[\"MyClassForm\"][\"PlannedChangeTime\"].value + \" entered is before Planned Date: \" + document.forms[\"MyClassForm\"][\"PlannedChangeDate\"].value + \" \" + document.forms[\"MyClassForm\"][\"PlannedChangeTime\"].value + \"!\"); \n\t\t\t\t\treturn false;\n\t\t\t\t}\t\n\t\t\t}\n\t\t\t\n\t\t\tif (document.forms[\"MyClassForm\"][\"Summary\"].value == \"\")\n\t\t\t{\n\t\t\t\talert(\"Summary must be filled out!\");\n\t\t\t\treturn false;\n\t\t\t}\t\n\t\t}\n\t\t</script>";
     $content .= $javascriptFormValidation;
     $heading = array("Change Details");
     $titles = array("Summary", "Planned Date", "Planned Time", "Completion Date", "Completion Time", "Primary Contact", "Secondary Contact", "Impact", "Status", "Change Description");
     $postkeys = array("Summary", "PlannedChangeDate", "PlannedChangeTime", "ChangeDate", "ChangeTime", "PrimaryContact", "SecondaryContact", "Impact", "Status", "ChangeDescription");
     /*
     	Device specific change info
     */
     $query2 = "SELECT id, device_id, impact, effects, chgby_id, change_date, description, back_out, status\n\t\t\t\t\tFROM plugin_ChangeManager_Components\n\t\t\t\t\tWHERE change_id = '{$cid}'";
     $result2 = mysql_query($query2);
     if (!$result2) {
         return "<b>Oops something went wrong, unable to select changes </b>";
     }
     // Get all devices
     $allDevices = Device::get_devices();
     // For Field type index:
     $i = 9;
     while ($obj = mysql_fetch_object($result2)) {
         $form_sections++;
         // Determine device name
         $device = new Device($obj->device_id);
         $device_name = $device->get_name();
         $form->setType($allDevices);
         // Drop down
         $fieldType[$i + 1] = "drop_down";
         $form->setType($allUsers);
         // Drop down
         $fieldType[$i + 2] = "drop_down";
         // Determine user changed by name
         $user = new User($obj->chgby_id);
         $fullname = $user->get_full_name();
         $effects = $obj->effects;
         array_push($values, $device_name, $fullname, stripslashes($obj->description), stripslashes($effects), stripslashes($obj->back_out));
         array_push($heading, "*<break>*", "Device Details:  {$device_name}  <div style='text-align: right;'> \n<a href='{$this->url}&action=delete_device_component&cid={$cid}&component_id={$obj->id}&return=edit_change' style='color:#FFFFFF'>\nDelete <img src='icons/Delete.png' height=20></a></div>");
         array_push($titles, "*<break>*", "Device", "Changed By", "Change Details", "Effects", "Backout Procedure");
         array_push($postkeys, "device_component[{$obj->id}][Device]", "device_component[{$obj->id}][ChangedBy]", "device_component[{$obj->id}][Description]", "device_component[{$obj->id}][Effects]", "device_component[{$obj->id}][BackoutProcedure]");
         $fieldType[$i + 3] = "text_area.height:230px";
         $fieldType[$i + 4] = "text_area.height:90px";
         $fieldType[$i + 5] = "text_area.height:90px";
         //Update with the number of rows/fields we just added
         $i = $i + 5;
     }
     if ($add_device) {
         $form_sections++;
         array_push($heading, "*<break>*", "Device Details - New Device <span id=new_device></span>");
         array_push($titles, "*<break>*", "Device", "Changed By", "Change Details", "Effects", "Backout Procedure");
         $form->setType($allDevices);
         // Drop down
         $fieldType[$i + 1] = "drop_down";
         $form->setType($allUsers);
         // Drop down
         $fieldType[$i + 2] = "drop_down";
         array_push($postkeys, "new_device_component[Device]", "new_device_component[ChangedBy]", "new_device_component[Description]", "new_device_component[Effects]", "new_device_component[BackoutProcedure]");
         $fieldType[$i + 3] = "text_area.height:230px";
         $fieldType[$i + 4] = "text_area.height:90px";
         $fieldType[$i + 5] = "text_area.height:90px";
         array_push($values, "", $_SESSION['fullname'], "", "", "");
     }
     // Create Device index
     //set the table size
     $form->setFieldType($fieldType);
     $form->setSortable(false);
     $form->setHeadings($heading);
     $form->setTitles($titles);
     $form->setDatabase($postkeys);
     $form->setData($values);
     //set the table size
     $form->setTableWidth("94%");
     $form->setTableWidth("94%");
     $form->setTitleWidth("20%");
     $content .= $form->EditForm($form_sections);
     return $content;
 }