Example #1
0
 function get_content()
 {
     $last_events = Event::get_last_events(10);
     $form = new Form();
     $keyData = array();
     $keyHandlers = array();
     foreach ($last_events as $event_id => $status) {
         $event = new Event($event_id);
         $status = 3;
         $status = $event->get_status();
         $status_name = $this->status_array[$status];
         array_push($keyData, "<font color=" . $this->status_collors[$status] . "> {$status_name} </font>");
         array_push($keyData, $event->get_hostname());
         array_push($keyData, $event->get_check_name());
         //array_push($keyData, $event->get_check_name() .".tip.". $event->get_key1() ." ". $event->get_key2());
         array_push($keyData, $this->getHowLongAgo($event->get_insert_date()));
         //	array_push($keyData, $event->get_last_updated());
         $insert_time = strtotime($event->get_insert_date());
         $last_time = strtotime($event->get_last_updated());
         $diff = $this->strTime($last_time - $insert_time);
         array_push($keyData, $diff);
         //	array_push($keyData, $event->get_info_msg() );
         $check_id = $event->get_check_id();
         $check = new Check($check_id);
         if (is_null($check_id)) {
             array_push($keyHandlers, "");
         } else {
             array_push($keyHandlers, "handleEvent('monitor.php?action=showCheck&checkid={$check_id}')");
         }
     }
     $headings = array("Status", "Host", "Service", "Date", "Duration");
     $form->setCols(5);
     $form->setTableWidth("100%");
     $form->setData($keyData);
     $form->setEventHandler($keyHandlers);
     $form->setHeadings($headings);
     $form->setSortable(true);
     return $form->showForm() . " <div style='clear:both'></div>";
 }
Example #2
0
function displayReportProfile()
{
    //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, $report_types;
    include_once 'classes/Contact.php';
    $toolNames = array("Edit Profile", "Add Check", "Delete Profile", "Create Report");
    $toolIcons = array("edit", "add", "delete", "report");
    $toolHandlers = array("handleEvent('" . $_SERVER['PHP_SELF'] . "?action=editReportProfile&profileid=" . $_GET[profileid] . "')", "handleEvent('" . $_SERVER['PHP_SELF'] . "?action=add_check_to_profile&profileid=" . $_GET[profileid] . "')", "handleEvent('" . $_SERVER['PHP_SELF'] . "?action=deleteReportProfile&profileid=" . $_GET[profileid] . "')", "handleEvent('" . $_SERVER['PHP_SELF'] . "?action=renderProfileReportForm&profileid=" . $_GET[profileid] . "')");
    echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers);
    if (is_numeric($_GET[profileid])) {
        $profile = new CheckReportProfile($_GET[profileid]);
    } else {
        $form->warning("Invalid Profile id id");
        return;
    }
    // Create left div
    echo "<div style='position: relative; float:left; clear:both; width:;'>";
    $headings = array("Report Profile Details");
    $keyTitle = array("Name.tip.descriptive name for this profile", "Client.tip.Optionally specify the contact client", "Report Type", "Notes");
    $keyHandlers = array();
    $keyData = array();
    // Get contact name
    if ($profile->get_contact_id()) {
        $contact = new Contact($profile->get_contact_id());
        $contact_name = $contact->get_name();
    } else {
        $contact_name = "N/A";
    }
    $keyData = array($profile->get_name(), $contact_name, $report_types[$profile->get_report_type()], nl2br($profile->get_notes()));
    $form->setCols(2);
    $form->setTableWidth("450px");
    $form->setData($keyData);
    $form->setTitles($keyTitle);
    $form->setEventHandler($keyHandlers);
    $form->setHeadings($headings);
    $form->setSortable(false);
    echo $form->showForm();
    echo "</div>";
    // Right div
    echo "<div style='position: relative; float:left; margin-left:25px; width:'>";
    // Now we need to create a link to add checks
    // Here a table of checks
    $checks = $profile->get_checks();
    if ($profile->get_error()) {
        print "error " . $profile->get_error() . "<br>";
    }
    $headings = array("Delete", "Check Name", "Template", "Device");
    $keyHandlers = array();
    $keyData = array();
    foreach ($checks as $check_id => $check_name) {
        $check = new Check($check_id);
        array_push($keyData, "<a href='" . $_SERVER['PHP_SELF'] . "?action=del_check_from_profile&profileid=" . $profile->get_profile_id() . "&checkid=" . $check_id . "'>" . "<img src='icons/Delete.png' height=20px></a>", $check->get_name(), $check->get_template_name(), $check->get_hostname());
    }
    $form2 = new Form("auto");
    $form2->setCols(4);
    $form2->setTableWidth("auto");
    $form2->setData($keyData);
    $form2->setEventHandler($keyHandlers);
    $form2->setHeadings($headings);
    $form2->setSortable(true);
    echo $form2->showForm();
    echo "</div>";
}
Example #3
0
function displayService($services)
{
    //global all variables
    global $serviceKey, $serviceForm, $tool, $headings, $titles, $serviceTypes, $location, $status_array;
    $serviceForm->setCols(2);
    //make the tool bar for this page
    if ($_SESSION['access'] >= 50) {
        $toolNames = array("Edit Service", "Delete Service");
        $toolIcons = array("edit", "delete");
        $toolHandlers = array("handleEvent('services.php?action=edit&ID={$_GET['ID']}', 'devicePart');", "handleEvent('services.php?action=remove&ID={$_GET['ID']}')");
        echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers);
    }
    //check the service layer and display according to the layer
    //if the layer is 3
    if ($services->get_service_layer() == 3) {
        //store the values in the heading and title array
        $headings = array("Service Information", "*<break>*", "Port Specific Information", "*<break>*", "Routing Specific Information", "*<break>*", "IPv4 Information", "*<break>*", "IPv6 Information");
        $titles = array("Customer name", "Customer ID", "Service type", "Service ID", "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.Specifies 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");
        $layer3Service = new Layer3_service($services->get_service_id());
        //add all the prefixes for ipv4 and ipv6 together
        foreach (array_keys($layer3Service->get_prefixes(4)) as $prefix) {
            $address4Prefix .= $prefix . "<br />";
        }
        foreach (array_keys($layer3Service->get_prefixes(6)) as $prefix) {
            $address6Prefix .= $prefix . "<br />";
        }
        //switch the values into strings
        $layer3Service->get_portal_statistics() == 1 ? $stats = 'Yes' : ($stats = 'No');
        $layer3Service->get_tagged() == 1 ? $tagged = 'Tagged' : ($tagged = 'Untagged');
        $layer3Service->get_ipv4_unicast() == 1 ? $uni4 = 'True' : ($uni4 = 'False');
        $layer3Service->get_ipv4_multicast() == 1 ? $multi4 = 'True' : ($multi4 = 'False');
        $layer3Service->get_ipv6_unicast() == 1 ? $uni6 = 'True' : ($uni6 = 'False');
        $layer3Service->get_ipv6_multicast() == 1 ? $multi6 = 'True' : ($multi6 = 'False');
        //store the values in the info
        $info = array($layer3Service->get_contact_name(), $layer3Service->get_contact_id(), $layer3Service->get_service_type_name(), $layer3Service->get_service_id(), $stats, $layer3Service->get_name(), $layer3Service->get_notes(), $layer3Service->get_status(), $layer3Service->get_in_production_date(), $layer3Service->get_out_production_date(), $layer3Service->get_pe_name(), $layer3Service->get_port_name(), $layer3Service->get_mtu(), $tagged, $layer3Service->get_vlan_id(), $layer3Service->get_logical_router(), $layer3Service->get_routing_type(), $layer3Service->get_bgp_as(), $layer3Service->get_traffic_policing(), $uni4, $multi4, $layer3Service->get_pe_address(4), $layer3Service->get_ce_address(4), $address4Prefix, $uni6, $multi6, $layer3Service->get_pe_address(6), $layer3Service->get_ce_address(6), $address6Prefix);
    } elseif ($services->get_service_layer() == 2) {
        //store the values in the heading and title array
        $headings = array("Service Information", "*<break>*", "Layer 2 Specific Information");
        $titles = array("Customer name", "Customer ID", "Service type", "Service ID", "Include statistics in portal?", "Service description (name)", "Notes", "Status.tip.Specify the production status of this Service", "In production date", "Out of production date", "*<break>*", "Vlan number");
        $layer2Service = new Layer2_service($services->get_service_id());
        //change the value into strings
        $layer2Service->get_portal_statistics() == 1 ? $stats = 'Yes' : ($stats = 'No');
        $info = array($layer2Service->get_contact_name(), $layer2Service->get_contact_id(), $layer2Service->get_service_type_name(), $layer2Service->get_service_id(), $stats, $layer2Service->get_name(), $layer2Service->get_notes(), $layer2Service->get_status(), $layer2Service->get_in_production_date(), $layer2Service->get_out_production_date(), $layer2Service->get_vlan_id());
        $layer2Interfaces = $layer2Service->get_interfaces();
        //store the interface port into the array
        $titles2 = array();
        $info2 = array();
        $headings2 = array("Device Name", "Port name", "Tagged", "Vlan", "MTU", "Actions");
        $handlers = array();
        //~atoonk/test/rrd/graph.php?file=deviceid12_ge-0-0-3.653&titel=cr1.keltx1.bc.net -- ge-0/0/3.653
        //add the ports information together
        $key = array("interfaceID", "deviceName", "portName", "tagged", "vlan", "mtu");
        $titlePort = array("Interface ID", "Device Name", "Port name.tip.Name of the physical interface, for example ge-2/0/1<br>Do not use subinterface format no ge-2/0/1.10", "Tagged", "Vlan.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", "MTU.tip.Default for ORAN and CU_ALL is 9000 bytes, the commodity and IX instance use 1500");
        $infoPort = array();
        $headingPort = array('Port Information');
        $fieldType = array("static", "drop_down", "", "radio", "", "");
        $types = array(Device::get_devices());
        //push all the interface port information
        foreach ($layer2Interfaces as $id => $value) {
            $infoPort = array();
            //Array ( [service_interface_id] => 184 [device_id] => 11 [device_name] => cr1.victx1.bc.net [port_name] => ge-0/1/2 [tagged] => 1 [vlan_id] => 0 [mtu] => 1500 )
            $oriPortName = $value[port_name];
            $portName = str_replace("/", "-", $value[port_name]);
            $portName = str_replace(" ", "-", $portName);
            // Determine port alias /descs
            //print_r(Port::get_device_interfaces($value[device_id]));
            if ($value[tagged] == 1) {
                // Nortel hack
                // Nortel BPS / baystack switches don't append the vlan id to the interface
                // So if it's a Nortel switch don't append
                // Nortel interfaces start with ifc24 (Slot: 1 Port: 24)
                if (!preg_match("/ifc\\d+\\s\\(Slot:/", $oriPortName)) {
                    $oriPortName = $oriPortName . "." . $value[vlan];
                    $portName = $portName . "." . $value[vlan];
                }
            }
            // Determine port alias /descs
            $device = new Device($value[device_id]);
            $port = new Port($device->get_interface_id_by_name($oriPortName));
            $port_alias = $port->get_alias();
            $port_alias = '';
            if ($port->get_alias() != '') {
                $port_alias = " <i> (" . $port->get_alias() . ")</i>";
            }
            // Done Determine port alias /descs
            $link = 'rrdgraph.php?file=deviceid' . $value[device_id] . "_" . $portName . ".rrd&title=" . $value[device_name] . "%20--%20" . $oriPortName;
            array_push($handlers, $link);
            array_push($titles2, $value['device_name'] . "//" . $device->get_interface_id_by_name($oriPortName) . "//" . $value[device_id]);
            array_push($infoPort, $value['service_interface_id']);
            array_push($infoPort, $value['device_name']);
            foreach ($value as $subID => $subValue) {
                if ($subID == "tagged") {
                    if ($subValue == 1) {
                        array_push($info2, 'Tagged');
                        array_push($infoPort, 'Tagged');
                    } else {
                        array_push($info2, 'Untagged');
                        array_push($infoPort, 'Untagged');
                    }
                } else {
                    if ($subID != "service_interface_id" && $subID != "device_id" && $subID != "device_name") {
                        // Append port desc
                        if ($subID == 'port_name') {
                            array_push($info2, $subValue . $port_alias);
                            array_push($infoPort, $subValue);
                        } else {
                            array_push($info2, $subValue);
                            array_push($infoPort, $subValue);
                        }
                    }
                }
            }
            if ($_SESSION['access'] >= 50) {
                array_push($info2, "<a name=modal href='#dialog" . $id . "'>Edit</a> | <a href='#' onclick=\"handleEvent('services.php?action=remove&ID={$_GET['ID']}&portID={$id}')\">Delete</a>");
            } else {
                array_push($info2, 'No Access');
            }
            //create the modal form for current values for the interface ports
            $serviceForm2 = $serviceForm;
            $serviceForm2->setFieldType($fieldType);
            $ff .= $serviceForm2->modalForm($headingPort, $titlePort, $infoPort, $key, $types, "", "dialog" . $id);
        }
        //For ports
        $newKey = array("deviceName", "portName", "tagged", "vlan", "mtu");
        $newTitlePort = array("Device Name", "Port name.tip.Name of the physical interface, for example ge-2/0/1<br>Do not use subinterface format no ge-2/0/1.10", "Tagged", "Vlan.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", "MTU.tip.Default for ORAN and CU_ALL is 9000 bytes, the commodity and IX instance use 1500");
        $newHeadingPort = array('Port Information');
        //create a new modal form for a new interface ports
        $fieldType = array("drop_down", "", "radio", "", "");
        $serviceForm->setFieldType($fieldType);
        $serviceForm->setNewModalID("newInterface");
        echo $serviceForm->newModalForm($newHeadingPort, $newTitlePort, $newKey, $types);
    }
    //if the user is editting this information, make it all editable
    if ($_GET['action'] == edit) {
        // Get all L3 & L2 service types
        $allServiceTypes = ServiceType::get_service_types();
        $lay3Types = array();
        $lay2Types = array();
        foreach ($allServiceTypes as $id => $value) {
            $curServiceType = new ServiceType($id);
            if ($curServiceType->get_service_layer() == 3) {
                $lay3Types[$id] = $curServiceType->get_name();
            } elseif ($curServiceType->get_service_layer() == 2) {
                $lay2Types[$id] = $curServiceType->get_name();
            }
        }
        //if the layer is 3 use a different key
        if ($services->get_service_layer() == 3) {
            // Get all L3 service types
            $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();
                }
            }
            // Now we have all L3 service types
            $serviceKey = array("cusName", "cusID", "serviceType", "serviceID", "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");
            $fieldType = array("static", "static", "drop_down", "static", "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");
            $allCustomData = array($layer3Service->get_pe_address(4), $layer3Service->get_ce_address(4), $layer3Service->get_pe_address(6), $layer3Service->get_ce_address(6));
            $customKeys = array("pRoutAd4", "cRoutAd4", "pRoutAd6", "cRoutAd6");
            $custom = array();
            foreach ($allCustomData as $id => $value) {
                $full = explode("/", $value, 2);
                $address = $full[0];
                $length = $full[1];
                $custom[$id] = "<input name=\"" . $customKeys[$id] . "\" id=\"" . $customKeys[$id] . "\" value=\"" . $address . "\" type=\"text\" maxChar=\"250\" style='width: 30%;'> / <input name=\"" . $customKeys[$id] . "-length\" id=\"" . $customKeys[$id] . "-length\" value=\"" . $length . "\" type=\"text\" maxChar=\"2\" style='width: 2%;'>";
            }
            //store the values in the info
            $info = array($layer3Service->get_contact_name(), $layer3Service->get_contact_id(), $layer3Service->get_service_type_name(), $layer3Service->get_service_id(), $stats, $layer3Service->get_name(), $layer3Service->get_notes(), $layer3Service->get_status(), $layer3Service->get_in_production_date(), $layer3Service->get_out_production_date(), $layer3Service->get_pe_name(), $layer3Service->get_port_name(), $layer3Service->get_mtu(), $tagged, $layer3Service->get_vlan_id(), $layer3Service->get_logical_router(), $layer3Service->get_routing_type(), $layer3Service->get_bgp_as(), $layer3Service->get_traffic_policing(), $uni4, $multi4, $custom[0], $custom[1], $address4Prefix, $uni6, $multi6, $custom[2], $custom[3], $address6Prefix);
            $serviceForm->setFieldType($fieldType);
            $MTU = array(1500 => '1500', 9000 => '9000');
            $routingType = array('BGP' => 'BGP', 'Static' => 'Static');
            $types = array($lay3Types, $status_array, Device::get_devices(), $MTU, $routingType);
            $serviceForm->setData($fieldCustomInfo);
            echo $serviceForm->editServiceForm($headings, $titles, $info, $serviceKey, $types);
        }
        //if the layer is 2 use a different key
        if ($services->get_service_layer() == 2) {
            $titles = array("Customer name", "Customer ID", "Service type", "Service ID", "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");
            $serviceKey = array("cusName", "cusID", "serviceType", "serviceID", "stats", "description", "notes", "status", "in_production", "out_production", "vlanNum");
            $fieldType = array("static", "static", "drop_down", "static", "radio", "", "text_area", "drop_down", "date_picker", "date_picker", "");
            global $status_array;
            $types = array($status_array);
            $serviceForm->setFieldType($fieldType);
            #print "<hr>2nd form<hr><pre>";print_r($serviceForm);print "</pre>end 2nd form<hr>";
            #echo $serviceForm->editServiceForm($headings, $titles, $info, $serviceKey,$types);
            $editForm = new Form();
            $editForm->setCols(2);
            $editForm->setFieldType($fieldType);
            $editForm->setType($lay2Types);
            $editForm->setType($status_array);
            $editForm->setHeadings($headings);
            $editForm->setTitles($titles);
            $editForm->setDatabase($serviceKey);
            $editForm->setData($info);
            echo $editForm->EditForm(2);
        }
    } else {
        if ($_GET['action'] == showID) {
            //if the layer is 3 show the service form
            if ($services->get_service_layer() == 3) {
                $id = $layer3Service->get_service_id();
                $title = $layer3Service->get_name();
                $title = str_replace(" ", "%20", $title);
                $link = 'rrdgraph.php?file=service_id_' . $id . '.rrd&title=' . $title;
                $directLink = "services.php?action=showGraphDetail&serviceID=" . $id . "&title=" . $title . "&type=traffic";
                echo "<div class='graph'>\r\n\t\t\t\t\t<a href='{$directLink}' class='screenshot' title='Statistics' rel='{$link}'><img src='{$link}'/></a>\r\n\t\t\t\t\t</div>";
                echo $serviceForm->showServiceForm($headings, $titles, $info);
            } elseif ($services->get_service_layer() == 2) {
                $titles = array("Customer name", "Customer ID", "Service type", "Service ID", "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.Specifies 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");
                echo $serviceForm->showServiceForm($headings, $titles, $info);
                $serviceForm->setCols(6);
                if ($_SESSION['access'] >= 50) {
                    $toolNames = array("Add Interface");
                    $toolIcons = array("add");
                    $formType = array("newInterface");
                    echo $tool->createNewModal($toolNames, $toolIcons, $formType);
                }
                echo $ff . $serviceForm->showAll($headings2, $titles2, $info2, $handlers, 3);
            }
        }
    }
}
Example #4
0
 function render_create_report()
 {
     if (isset($_GET['pid']) && is_numeric($_GET['pid'])) {
         $pid = $_GET['pid'];
     } else {
         return "<b>Sorry invalid profile id " . $_GET['pid'] . "</b>";
     }
     $profile_name = $this->get_accounting_profile_name($pid);
     // Menu bar
     $content = "<div style='font-size:10px; font-weight:100px;'>\n\t\t\t<a href='{$this->url}'>Accounting</a> >> <a href='{$this->url}&pid={$pid}&action=show_accounting_profile'>{$profile_name}</a>\n\t\t\t>> <a href='{$this->url}&pid={$pid}&action=show_reports''> Reports</a> </div>";
     $content .= "<h2>Create Report</h2>";
     $headings = array("Please select reporting Period ");
     $postKeys = array("action", "tab", "pluginID", "pid", "date1", "date2");
     $keyTitle = array("action", "tab", "pluginID", "pid", "Start Date", "End Date");
     $keyData = array("render_report", $_GET['tab'], $_GET['pluginID'], $pid, "", "");
     $form = new Form();
     $form->setCols(2);
     $form->setData($keyData);
     $form->setTitles($keyTitle);
     $form->setDatabase($postKeys);
     $form->setTableWidth("400px");
     $fieldType[0] = "hidden";
     $fieldType[1] = "hidden";
     $fieldType[2] = "hidden";
     $fieldType[3] = "hidden";
     $fieldType[4] = "date_picker";
     $fieldType[5] = "date_picker";
     $form->setFieldType($fieldType);
     $form->setHeadings($headings);
     $form->setSortable(false);
     $form->setUpdateValue("gen_report");
     $form->setUpdateText("Generate Report");
     $form->setMethod("GET");
     $content .= $form->editForm();
     return $content;
 }