Example #1
0
 function showAll($headingName, $titles, $data, $handlers = array(), $mouseType = 0)
 {
     parent::setTitles($titles);
     parent::setData($data);
     parent::setEventHandler($handlers);
     parent::setHeadings($headingName);
     parent::setSortable(true);
     parent::setMouseHandlerType($mouseType);
     return parent::showForm(90);
 }
Example #2
0
 function editModalForm($headingName, $titleName, $infoArray, $infoKey, $modalID, $value)
 {
     parent::setHeadings($headingName);
     parent::setTitles($titleName);
     parent::setData($infoArray);
     parent::setSortable(false);
     parent::setDatabase($infoKey);
     parent::setModalID($modalID);
     parent::setUpdateValue($value);
     return parent::modalForm(10);
 }
Example #3
0
 private function list_secret_data()
 {
     $content = '';
     $modal_forms;
     $tool = new EdittingTools();
     $content .= $tool->createNewFilters();
     $content .= "<a name='modal' href='#Add_privatedata_modal'><img src='icons/Add.png' height=18>Add Private Data</a><br><br>";
     // We need to know all groups this user is in:
     $user = new User($_SESSION['userid']);
     $user_groups = $user->get_groups();
     $data = array();
     // Create modal for adding a new Private data entry
     // This modal should ask for which group to add it as and the password
     // We need to know all groups this user is in:
     $user = new User($_SESSION['userid']);
     $user_groups = $user->get_groups();
     if (sizeof($user_groups) == 1) {
         foreach ($user_groups as $gid => $gname) {
             $group_data = $gname;
         }
     } else {
         $group_data = "";
     }
     $modalForm = new Form("auto", 2);
     $modalForm->setHeadings(array("For which group would you like to add private"));
     $modalForm->setTitles(array("Group", "Group Password.tip.This is the shared secret for the group you selected above.", "Fill in Private Data Details below:", "Description", "Private Data <br><small><i>Stored encrypted</i></small>.tip.This data will be AES encrypted", "Type <br><small><a name='modal' href='#add_pdtype_modal'>Add Private data type</a></small>", "Notes <br><small><i>Stored encrypted</i></small>.tip.This data will be AES encrypted", "device_id"));
     $modalForm->setData(array("{$group_data}", "", "", "", "", "", "", $_GET['ID']));
     $modalForm->setDatabase(array("group_id", "group_pass", "dummy", "private_data_desc", "private_data_password", "private_data_type", "private_data_notes", "device_id"));
     $modalForm->setFieldType(array(0 => 'drop_down', 1 => 'password_autocomplete_off', 2 => 'static', 5 => 'drop_down', 6 => 'text_area', 7 => 'hidden'));
     // Drop down
     // We need to know all groups this user is in:
     $modalForm->setType($user_groups);
     $dataTypes = PrivateDataType::get_private_data_types();
     $modalForm->setType($dataTypes);
     //End Dropdown
     // Change button text
     $modalForm->setUpdateValue("add_private_data_for_group");
     $modalForm->setUpdateValue("add_private_data_for_group");
     $modalForm->setUpdateText("Add");
     $modalForm->setModalID("Add_privatedata_modal");
     $modal_forms .= $modalForm->modalForm();
     unset($modalForm);
     // End modal
     // Create modal forms
     // Add Modal for adding Private data types
     $modalForm = new Form("auto", 2);
     $modalForm->setHeadings(array("<br><br>Add Private Data Type"));
     $modalForm->setTitles(array("Name.tip.Descriptive String for this type", "Description"));
     $modalForm->setData(array("", ""));
     $modalForm->setDatabase(array("pdtype_name", "pdtype_desc"));
     // Change button text
     $modalForm->setUpdateValue("add_private_data_type");
     $modalForm->setUpdateText("Add Private Data Type");
     $modalForm->setModalID("add_pdtype_modal");
     $modal_forms .= $modalForm->modalForm();
     unset($modalForm);
     // End Modal for adding Private data types
     foreach ($user_groups as $gid => $gname) {
         // Create a modal per group, that asks for the group password
         // We only need one per group, as passwords are unqiue per group
         $modalForm = new Form("auto", 2);
         $modalForm->setHeadings(array("Please provide group password for {$gname}"));
         $modalForm->setTitles(array("Password", "group_id"));
         $modalForm->setData(array("", $gid));
         $modalForm->setDatabase(array('group_pass', 'group_id'));
         $modalForm->setFieldType(array(0 => 'password_autocomplete_off', 1 => 'hidden'));
         $myModalID = "modal_group_pass_" . $gid;
         // Change button text
         $modalForm->setUpdateValue("Decrypt_Private_Data");
         $modalForm->setUpdateText("Submit");
         $modalForm->setModalID($myModalID);
         $modal_forms .= $modalForm->modalForm();
         unset($modalForm);
         // End modal
         $group_private_data = PrivateData::get_private_data_by_group($gid);
         if ($group_private_data) {
             foreach ($group_private_data as $id => $pdname) {
                 $privDataObj = new PrivateData($id);
                 if (is_numeric($privDataObj->get_device_id())) {
                     // Means device assocication
                     continue;
                 }
                 // Here we check if the user submitted a group password
                 // Only for the group for which the pasword has been provided
                 $password = "******";
                 $actions = "<a name='modal' href='#modal_group_pass_" . $gid . "'>Unlock Private Data</a>";
                 if (isset($_POST['group_pass']) && $_POST['group_pass'] != '' && $privDataObj->get_group_id() == $_POST['group_id']) {
                     // now get private data (password)
                     $password = $privDataObj->get_private_data($_POST['group_pass']);
                     if ($password != false) {
                         // Decrypted successful!
                         // Get historical data, and create modal
                         $modalForm = new Form("auto", 2);
                         $modalForm->setHeadings(array("Changed (exipred) at:", "Private Data"));
                         // Loop through old data and fill arrays for form
                         $Htitles = array();
                         $Hdata = array();
                         $HfieldType = array();
                         $historical_passwords = $privDataObj->get_history($_POST['group_pass']);
                         if ($historical_passwords) {
                             foreach ($historical_passwords as $old_date => $old_data) {
                                 array_push($Htitles, $old_date);
                                 array_push($Hdata, $old_data);
                                 array_push($HfieldType, "static");
                             }
                         }
                         $modalForm->setTitles($Htitles);
                         $modalForm->setData($Hdata);
                         $modalForm->setFieldType($HfieldType);
                         unset($Htitles);
                         unset($Hdata);
                         unset($HfieldType);
                         $modalForm->setTitleWidth("40%");
                         $modalForm->setDatabase(array('date', 'old_data'));
                         $myHistoryModalID = "modal_old_pass_" . $id;
                         // Change button text
                         $modalForm->setUpdateValue("close");
                         $modalForm->setUpdateText("Press cancel");
                         $modalForm->setModalID($myHistoryModalID);
                         $modal_forms .= $modalForm->modalForm();
                         unset($modalForm);
                         // End modal
                         if ($privDataObj->get_notes($_POST['group_pass']) != '') {
                             $name_tooltip = ".tip.<b>Notes:</b><br>" . nl2br($privDataObj->get_notes($_POST['group_pass']));
                         }
                         // Now create a modal that allows us to update the private data object
                         // Start Update Modal
                         $PdataModal = new Form("auto", 2);
                         $PdataModal->setHeadings(array("Update Private Data"));
                         $PdataModal->setTitles(array("Description", "Private Data <br><small><i>Stored encrypted</i></small>.tip.This data will be AES encrypted", "Type <br><small><a name='modal' href='#add_pdtype_modal'>\n\t\t\t\t\t\t\tAdd Private data type</a></small>", "Notes<br><small><i>Stored encrypted</i></small>.tip.This data will be AES encrypted", "PDid", "", ""));
                         $PdataModal->setData(array($privDataObj->get_name(), $password, $privDataObj->get_type_name(), $privDataObj->get_notes($_POST['group_pass']), $id, $_POST['group_id'], $_POST['group_pass']));
                         $PdataModal->setDatabase(array('private_data_desc', 'private_data_password', 'private_data_type', 'private_data_notes', 'private_data_id', 'group_id', 'group_pass'));
                         $PdataModal->setFieldType(array(2 => 'drop_down', 3 => 'text_area', 4 => 'hidden', 5 => 'hidden', 6 => 'hidden'));
                         // Creat dropdown
                         $dataTypes = PrivateDataType::get_private_data_types();
                         $PdataModal->setType($dataTypes);
                         $PdataModal->setUpdateValue('update_private_data');
                         $PdataModalID = "modal_private_data_id" . $id;
                         // Change button text
                         $PdataModal->setModalID($PdataModalID);
                         $modalForms .= $PdataModal->modalForm();
                         // End Update modal
                         // Now a Modal to Delete an Entry
                         // We'll ask for the password again.
                         $modalFormDelete = new Form("auto", 2);
                         $modalFormDelete->setHeadings(array("Delete " . $privDataObj->get_name() . "<br>Please provide group password for " . $privDataObj->get_group_name()));
                         $modalFormDelete->setTitles(array("Password", "group_id", ""));
                         $modalFormDelete->setData(array("", $privDataObj->get_group_id(), $id));
                         $modalFormDelete->setDatabase(array('group_pass', 'group_id', 'private_data_id'));
                         $modalFormDelete->setFieldType(array(0 => 'password_autocomplete_off', 1 => 'hidden', 2 => 'hidden'));
                         $myDeleteModalID = "modal_delete_pass_" . $id;
                         // Change button text
                         $modalFormDelete->setUpdateValue("delete_private_data");
                         $modalFormDelete->setUpdateText("Delete");
                         $modalFormDelete->setModalID($myDeleteModalID);
                         $modalForms .= $modalFormDelete->modalForm();
                         // End Delete modal
                         if (count($historical_passwords) > 0) {
                             $history_string = "<a name='modal' href='#" . $myHistoryModalID . "'>History</a>";
                         } else {
                             $history_string = "<i>No History</i>";
                         }
                         $actions = "<a name='modal' href='#" . $PdataModalID . "'>Edit</a> &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp\n                                              \t\t<a name='modal' href='#" . $myDeleteModalID . "'>Delete</a> &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp\n\t\t\t\t\t\t\t{$history_string}";
                     } else {
                         $form = new Form();
                         $content .= $form->error("Warning: " . $privDataObj->get_error());
                     }
                 }
                 if (count($historical_passwords) > 0) {
                     $history_string = "<a name='modal' href='#" . $myHistoryModalID . "'>History</a>";
                 } else {
                     $history_string = "<i>No History</i>";
                 }
                 array_push($data, $privDataObj->get_type_desc() . $type_tooltip, $privDataObj->get_name() . $name_tooltip, $password, $privDataObj->get_group_name(), $actions);
             }
         }
     }
     $heading = array("Type", "Description", "Private Data", "Group", "Actions");
     $pdata_form = new Form("auto", 5);
     $pdata_form->setSortable(true);
     $pdata_form->setHeadings($heading);
     $pdata_form->setData($data);
     $pdata_form->setTableWidth("800px");
     $content .= $pdata_form->showForm();
     $content .= $modalForms;
     return "{$content} {$modal_forms} {$private_data_type_modal}";
 }
Example #4
0
function displayDevice($devices)
{
    //global all variables
    global $deviceKey, $deviceForm, $tool, $headings, $titles, $deviceTypes, $location;
    //if this isn't in ajax mode display the Ajax buttons
    if (!isset($_GET['mode'])) {
        if ($_GET['tab'] == 2) {
            $name = array($devices->get_name(), "Interface", "Device Control.first.");
        } else {
            if ($_GET['tab'] == 1) {
                $name = array($devices->get_name(), "Interface.first.", "Device Control");
            } else {
                $name = array($devices->get_name() . ".first.", "Interface", "Device Control");
            }
        }
        $page = array("devices.php?action=showID&ID={$_GET['ID']}&mode=deviceInfo", "devices.php?action=showID&ID={$_GET['ID']}&mode=deviceInterface", "devices.php?action=showID&ID={$_GET['ID']}&mode=deviceControl");
        echo $tool->createNewButtons($name, "devicePart", $page);
    }
    //the division for the interfae, control port, and info page to show
    echo "<div id='devicePart'>";
    //success message for the ajax mode
    switch (success) {
        case $_GET['update']:
            $deviceForm->success("Updated successfully");
            break;
        case $_GET['add']:
            $deviceForm->success("Added new data successfully");
            break;
        case $_GET['delete']:
            $deviceForm->success("Deleted and archived data successfully");
            break;
    }
    //if ajax mod is part of displaying the interface
    if ($_GET['mode'] == deviceInterface || $_GET['tab'] == 1) {
        //set the table attributes
        $deviceForm->setCols(11);
        $deviceForm->setTableWidth("100%");
        $deviceForm->setTitleWidth("10%");
        //create tools for this mode
        /*Taken out for user interface issues
        		$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);*/
        //can be displayed in both percent and bPS mode
        if ($_GET['output'] == percent) {
            $headings = array("Interface name", "Interface alias", "Interface description", "Status", "Discovered interface speed(bps)", "Current throughput in % \n\t\t\t\t\t\t  <a href='#' style='color:yellow;' onclick=\"handleEvent('devices.php?action=showID&ID={$_GET['ID']}&output=bps&tab=1');\">[switch to bps] </a>", "Interface MTU", "IPv4/IPv6 address", "Interface duplex", "Interface type", "Discovered interface index");
        } else {
            $headings = array("Interface name", "Interface alias", "Interface description", "Status", "Discovered interface speed(bps)", "Current throughput in bps\n\t\t\t\t\t\t\t  <a href='#' style='color:yellow;' onclick=\"handleEvent('devices.php?action=showID&ID={$_GET['ID']}&output=percent&tab=1');\">[switch to percent] </a>", "Interface MTU", "IPv4/IPv6 address", "Interface duplex", "Interface type", "Discovered interface index");
        }
        //get all the interfacese
        $interfaces = $devices->get_interfaces();
        $info = array();
        $title = array();
        $handlers = array();
        //put all the interface information into the arrays
        foreach ($interfaces as $id => $value) {
            //array_push($title, "");
            array_push($title, $value->get_name() . '//' . $value->get_interface_id() . '//' . $value->get_device_id());
            array_push($info, $value->get_alias());
            array_push($info, $value->get_descr());
            array_push($info, $value->get_oper_status());
            $speed = $tool->calculator("convertBits", $value->get_speed());
            array_push($info, $speed);
            //calculate the percentage if it's in percent mode, otherwise convert it in to the right bits
            if ($value->get_inbits() > $value->get_outbits()) {
                $highBits = $value->get_inbits();
            } else {
                $highBits = $value->get_outbits();
            }
            if ($_GET['output'] == percent) {
                if ($value->get_speed() > 0) {
                    $percentage = $highBits / $value->get_speed();
                    $percentage = $tool->calculator("convertPercent", $percentage);
                } else {
                    $percentage = "0%";
                }
                array_push($info, $percentage);
            } else {
                $highBits = $tool->calculator("convertBits", $highBits);
                array_push($info, $highBits);
            }
            array_push($info, $value->get_mtu());
            $ipv4 = $value->get_ipv4_addresses();
            $ipv6 = $value->get_ipv6_addresses();
            $ip = "";
            //store both ipv4 and ipv6 addresses
            foreach ($ipv4 as $ipID => $ipValue) {
                $ip .= $ipID . "<br/>";
            }
            foreach ($ipv6 as $ipID => $ipValue) {
                $ip .= $ipID . "<br/>";
            }
            array_push($info, $ip);
            array_push($info, "");
            array_push($info, $value->get_type());
            array_push($info, $value->get_ifindex());
            //prepare strings into html format to display the graph and push it into the handler
            $nameTitle = str_replace(" ", "%20", $value->get_name());
            $name = str_replace(" ", "-", $value->get_name());
            $name = str_replace("/", "-", $name);
            $graphLink = "rrdgraph.php?file=deviceid" . $value->get_device_id() . "_" . $name . ".rrd&title=" . $nameTitle . "---Bits%20Per%20Second&type=traffic";
            array_push($handlers, $graphLink);
        }
        //If there are info, display the interfaces, else give a warniing message
        if (count($info) > 0) {
            echo $deviceForm->showAll($headings, $title, $info, $handlers, 3);
        } else {
            $deviceForm->warning("You have no Interfaces");
        }
    } elseif ($_GET['mode'] == deviceControl || $_GET['tab'] == 2) {
        //set the form attributes
        $deviceForm->setCols(7);
        /*check if the device type is a power or console device
         *if it is a control or console device, the user can add both management and control port
         *Otherwise the user can only add management ports
         */
        //if ($devices->get_device_type()==5 || $devices->get_device_type()==6)
        if ($devices->get_device_class() == 'console_server' || $devices->get_device_class() == 'power_control') {
            $cPorts = array();
            if ($_SESSION['access'] >= 50) {
                $toolNames = array("New management port.tip.Management Ports are ports that help you manage this device using power or console ports.", "New control port.tip.Control ports are ports that help you manage connected devices. Examples are power ports on remote power controls and serial ports on console servers.");
                $toolIcons = array("add", "add");
                $toolHandlers = array("return LoadPage('devices.php?action=add&item=mPort&mode=deviceControl&ID={$_GET['ID']}', 'devicePart');", "return LoadPage('devices.php?action=add&item=cPort&mode=deviceControl&ID={$_GET['ID']}&deviceClass=" . $devices->get_device_class() . "', 'devicePart');");
            }
        } else {
            if ($_SESSION['access'] >= 50) {
                $toolNames = array("New management port.tip.Management Ports are ports that help you manage this device using power or console ports.");
                $toolIcons = array("add");
                $toolHandlers = array("return LoadPage('devices.php?action=add&item=mPort&mode=deviceControl&ID={$_GET['ID']}', 'devicePart');");
            }
        }
        //create the tool
        echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers);
        //create the headings titles and info emptyy arrays for both management and control ports
        $cHeadings = array("Description", "Physical port", "Port name", "Port type", "Group", "Managed device", "Action");
        $mHeadings = array("Description", "Physical port", "Port name", "Port type", "Group", "Control device", "Action");
        $cTitles = array();
        $mTitles = array();
        $cInfo = array();
        $mInfo = array();
        //get all the control and management ports to store in an array for display
        $management = $devices->get_management_ports();
        $control = $devices->get_control_ports();
        $mPorts = array();
        $index = 0;
        //insert the ports into an array
        foreach ($management as $id => $value) {
            $mPorts[$index] = new ControlPort($id);
            $index++;
        }
        foreach ($control as $id => $value) {
            $cPorts[$index] = new ControlPort($id);
            $index++;
        }
        //push the info of these ports into the table
        foreach ($mPorts as $id => $value) {
            array_push($mTitles, $mPorts[$id]->get_description());
        }
        if (isset($cPorts)) {
            foreach ($cPorts as $id => $value) {
                array_push($cTitles, $cPorts[$id]->get_description());
            }
        }
        foreach ($mPorts as $id => $value) {
            array_push($mInfo, $mPorts[$id]->get_port());
            array_push($mInfo, $mPorts[$id]->get_name());
            array_push($mInfo, $mPorts[$id]->get_type());
            array_push($mInfo, $mPorts[$id]->get_group());
            array_push($mInfo, $mPorts[$id]->get_control_device_name());
            $portID = $mPorts[$id]->get_id();
            if ($_SESSION['access'] >= 50) {
                array_push($mInfo, "<a href='#' onclick=\"return LoadPage('devices.php?action=edit&ID={$_GET['ID']}&mode=deviceControl&mportID={$id}&portID={$portID}', 'devicePart');\">Edit</a> | <a href='#' onclick=\"handleEvent('devices.php?action=remove&ID={$_GET['ID']}&mportID={$id}&portID={$portID}');\">Delete</a>");
            } else {
                array_push($mInfo, 'No Access');
            }
        }
        if (isset($cPorts)) {
            foreach ($cPorts as $id => $value) {
                array_push($cInfo, $cPorts[$id]->get_port());
                array_push($cInfo, $cPorts[$id]->get_name());
                array_push($cInfo, $cPorts[$id]->get_type());
                array_push($cInfo, $cPorts[$id]->get_group());
                array_push($cInfo, $cPorts[$id]->get_managed_device_name());
                $portID = $cPorts[$id]->get_id();
                if ($_SESSION['access'] >= 50) {
                    array_push($cInfo, "<a href='#' onclick=\"return LoadPage('devices.php?action=edit&ID={$_GET['ID']}&mode=deviceControl&cportID={$id}&portID={$portID}', 'devicePart');\">Edit</a> | <a href='#' onclick=\"handleEvent('devices.php?action=remove&ID={$_GET['ID']}&cportID={$id}&portID={$portID}');\">Delete</a>");
                } else {
                    array_push($cInfo, 'No Access');
                }
            }
        }
        //if the user is editting this information, make it all editable
        if ($_GET['action'] == edit) {
            $deviceForm->setCols(2);
            $fieldType = array("hidden", "", "", "", "static", "", "drop_down");
            //checks to see if it's management or control ports to give different forms
            if (isset($_GET['mportID'])) {
                $name = $devices->get_name();
                $headings = array("Port Information 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", "Group", "Control device");
                $group = $mPorts[$_GET['mportID']]->get_group();
                if ($group == '') {
                    $fieldType = array("hidden", "", "", "", "static", "static", "drop_down");
                    $group = "NOT APPLICABLE";
                }
                $info = array("mport", $mPorts[$_GET['mportID']]->get_description(), $mPorts[$_GET['mportID']]->get_port(), $mPorts[$_GET['mportID']]->get_name(), $mPorts[$_GET['mportID']]->get_type(), $group, $mPorts[$_GET['mportID']]->get_control_device_name());
                if ($mPorts[$_GET['mportID']]->get_type() == "console") {
                    $portTypeName = "console_server";
                } else {
                    $portTypeName = "power_control";
                }
                $types = $devices->get_devices_by_class($portTypeName);
                $deviceKey = array("pType", "description", "physicalPort", "portName", "portType", "group", "controlledDevice");
            } else {
                if (isset($_GET['cportID'])) {
                    $name = $devices->get_name();
                    $headings = array("Port Information 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", "Group", "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.");
                    $group = $cPorts[$_GET['cportID']]->get_group();
                    if ($group == '') {
                        $fieldType = array("hidden", "", "", "", "static", "static", "drop_down");
                        $group = "NOT APPLICABLE";
                    }
                    $info = array("cport", $cPorts[$_GET['cportID']]->get_description(), $cPorts[$_GET['cportID']]->get_port(), $cPorts[$_GET['cportID']]->get_name(), $cPorts[$_GET['cportID']]->get_type(), $group, $cPorts[$_GET['cportID']]->get_managed_device_name());
                    $types = $devices->get_devices();
                    array_push($types, "Other devices");
                    $deviceKey = array("pType", "description", "physicalPort", "portName", "portType", "group", "managedDevice");
                }
            }
            $deviceForm->setFieldType($fieldType);
            echo $deviceForm->editPortForm($headings, $titles, $info, $deviceKey, $types);
        } else {
            if ($_GET['action'] == showID) {
                //show the ports
                if (isset($cPorts)) {
                    echo "<div style='clear:both;'></div><h2>Control Ports</h2>";
                    echo $deviceForm->showAll($cHeadings, $cTitles, $cInfo);
                }
                if (isset($mPorts)) {
                    echo "<div style='clear:both;'></div><h2>Management  Ports</h2>";
                    echo $deviceForm->showAll($mHeadings, $mTitles, $mInfo);
                }
                if (!isset($mPorts) && !isset($cPorts)) {
                    $deviceForm->warning("You have no Ports");
                }
            }
        }
    } else {
        $deviceForm->setCols(2);
        //make the tool bar for this page
        if ($_SESSION['access'] >= 50) {
            $toolNames = array("Edit Device", "Delete Device");
            $toolIcons = array("edit", "delete");
            $toolHandlers = array("handleEvent('devices.php?action=edit&ID={$_GET['ID']}');", "handleEvent('devices.php?action=remove&ID={$_GET['ID']}')");
        }
        echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers);
        //make the headings
        $headings = array("Device Information");
        //store all the device information values into an array
        $info = array($devices->get_name(), $devices->get_device_fqdn(), $devices->get_location_name(), $devices->get_type_name(), $devices->get_snmp_ro(), $devices->get_device_oob(), $devices->get_notes());
        //if the user is editting this information, make it all editable
        if ($_GET['action'] == edit) {
            $deviceKey = array("name", "device_fqdn", "location", "device_type", "SNMP Community String.tip.Read only SNMP community used for SNMP data collection", "device_oob", "notes");
            $fieldType = array("", "", "drop_down", "drop_down", "", "", "text_area");
            $deviceForm->setFieldType($fieldType);
            $type = array($location, $deviceTypes);
            echo $deviceForm->editDeviceForm($headings, $titles, $info, $deviceKey, $type);
        } elseif ($_GET['action'] == showID) {
            //store all the device information values into an array
            $info = array($devices->get_name(), $devices->get_device_fqdn(), $devices->get_location_name(), $devices->get_type_name(), $devices->get_snmp_ro(), $devices->get_device_oob(), nl2br($devices->get_notes()));
            echo $deviceForm->showDeviceForm($headings, $titles, $info);
            // Everything below is for viewing & edditing Private Data for this device.
            $modalForms = "";
            echo "<div style='clear:both;'></div>";
            echo "<h2>Private Data</h2>";
            // Here we check if we just deleted a private data entry
            if (isset($_POST['delete_private_data'])) {
                $form = new Form();
                // Yes update
                $privDataObj = new PrivateData($_POST['private_data_id']);
                if ($privDataObj->delete($_POST['group_pass'])) {
                    $form->success("Private entry Deleted");
                    $_SESSION['action'] = "Removed private data for: " . $devices->get_name();
                } else {
                    $form->error("Warning: Failed to delete Private data Reason: " . $privDataObj->get_error(), $_GET['ID']);
                    unset($_POST['group_pass']);
                }
            }
            // Check if we just added a private data Type
            if (isset($_POST['add_private_data_type'])) {
                $form = new Form();
                $no_error = true;
                // Check mandotry fields
                if ($_POST['pdtype_name'] == '') {
                    $form->error("Error: Private DataType name is empty");
                    $no_error = false;
                } elseif ($_POST['pdtype_desc'] == '') {
                    $form->error("Error: Private DataType Description is empty");
                    $no_error = false;
                }
                if ($no_error) {
                    $privDataTypeObj = new PrivateDataType();
                    $privDataTypeObj->set_name($_POST['pdtype_name']);
                    $privDataTypeObj->set_desc($_POST['pdtype_desc']);
                    if ($privDataTypeObj->insert()) {
                        $form->success("Private data type '" . $_POST['pdtype_name'] . "' Added");
                        $_SESSION['action'] = "Added private data Type";
                    } else {
                        $form->error("Warning: Failed to Add Private data Reason: " . $privDataTypeObj->get_error());
                    }
                }
            }
            // Check if we just added a private data entry
            if (isset($_POST['add_private_data_for_group'])) {
                $form = new Form();
                $no_error = true;
                // Check mandotry fields
                if (!is_numeric($_POST['device_id'])) {
                    $form->error("Error: Invalid device id");
                    $no_error = false;
                } elseif (!is_numeric($_POST['group_id'])) {
                    $form->error("Error: No Group Specified");
                    $no_error = false;
                } elseif (!is_numeric($_POST['private_data_type'])) {
                    $form->error("Error: No Private Data type specified");
                    $no_error = false;
                } elseif ($_POST['private_data_password'] == '') {
                    $form->error("Warning: Private Data string was empty");
                    //$no_error = false;
                }
                if ($no_error) {
                    $privDataObj = new PrivateData();
                    $privDataObj->set_group_id($_POST['group_id']);
                    $privDataObj->set_type_id($_POST['private_data_type']);
                    $privDataObj->set_device_id($_POST['device_id']);
                    $privDataObj->set_notes($_POST['private_data_notes']);
                    $privDataObj->set_name($_POST['private_data_desc']);
                    $privDataObj->set_private_data($_POST['private_data_password']);
                    if ($privDataObj->insert($_POST['group_pass'])) {
                        $form->success("Private data entry Added");
                        $_SESSION['action'] = "Added private data for: " . $devices->get_name();
                    } else {
                        $form->error("Warning: Failed to Add Private data Reason: " . $privDataObj->get_error(), $_GET['ID']);
                        unset($_POST['group_pass']);
                    }
                }
            }
            echo "<a name='modal' href='#Add_privatedata_modal'><img src='icons/Add.png' height=18>Add Private Data</a><br>";
            // Add Modal for adding Private data types
            $modalForm = new Form("auto", 2);
            $modalForm->setHeadings(array("<br><br>Add Private Data Type"));
            $modalForm->setTitles(array("Name.tip.Descriptive String for this type", "Description"));
            $modalForm->setData(array("", ""));
            $modalForm->setDatabase(array("pdtype_name", "pdtype_desc"));
            // Change button text
            $modalForm->setUpdateValue("add_private_data_type");
            $modalForm->setUpdateText("Add Private Data Type");
            $modalForm->setModalID("add_pdtype_modal");
            $private_data_type_modal = $modalForm->modalForm();
            unset($modalForm);
            // End Modal for adding Private data types
            // Create modal for adding a new Private data entry
            // This modal should ask for which group to add it as and the password
            // We need to know all groups this user is in:
            $user = new User($_SESSION['userid']);
            $user_groups = $user->get_groups();
            if (sizeof($user_groups) == 1) {
                foreach ($user_groups as $gid => $gname) {
                    $group_data = $gname;
                }
            } else {
                $group_data = "";
            }
            $modalForm = new Form("auto", 2);
            $modalForm->setHeadings(array("For which group would you like to add private"));
            $modalForm->setTitles(array("Group", "Group Password.tip.This is the shared secret for the group you selected above.", "Fill in Private Data Details below:", "Description", "Private Data<br><small>Stored encrypted</small>.tip.This is the data that will be encrypted", "Type <br><small><a name='modal' href='#add_pdtype_modal'>Add Private data type</a></small>", "Notes <br><small><i>Stored encrypted</i></small>.tip.This data will be AES encrypted", "device_id"));
            $modalForm->setData(array("{$group_data}", "", "", "", "", "", "", $_GET['ID']));
            $modalForm->setDatabase(array("group_id", "group_pass", "dummy", "private_data_desc", "private_data_password", "private_data_type", "private_data_notes", "device_id"));
            $modalForm->setFieldType(array(0 => 'drop_down', 1 => 'password_autocomplete_off', 2 => 'static', 5 => 'drop_down', 6 => 'text_area', 7 => 'hidden'));
            // Drop down
            // We need to know all groups this user is in:
            $modalForm->setType($user_groups);
            $dataTypes = PrivateDataType::get_private_data_types();
            $modalForm->setType($dataTypes);
            //End Dropdown
            // Change button text
            $modalForm->setUpdateValue("add_private_data_for_group");
            $modalForm->setUpdateText("Add");
            $modalForm->setModalID("Add_privatedata_modal");
            echo $modalForm->modalForm();
            unset($modalForm);
            // End modal
            // Also create a table with PrivateData
            // 1st get all entries for this device
            $all_private_data = PrivateData::get_private_data_by_device($_GET['ID']);
            // Only if there is any private data for this device
            if ($all_private_data && $_GET['action'] == showID) {
                $i++;
                // Check if we just updated the info,
                // If so we need to update Private data
                if (isset($_POST['update_private_data'])) {
                    // Yes update
                    $tmpform = new Form();
                    $privDataObj = new PrivateData($_POST['private_data_id']);
                    $privDataObj->set_name($_POST['private_data_desc']);
                    $privDataObj->set_notes($_POST['private_data_notes']);
                    $privDataObj->set_type_id($_POST['private_data_type']);
                    $privDataObj->set_private_data($_POST['private_data_password']);
                    if ($privDataObj->update($_POST['group_pass'])) {
                        $tmpform->success("Private data updated Succesfully");
                        unset($tmpform);
                        $_SESSION['action'] = "Updated private data for: " . $devices->get_name();
                    } else {
                        print "NOK " . $privDataObj->get_error();
                        $tmpform->error("Warning: Failed to Update Private data Reason: " . $privDataObj->get_error(), $_GET['ID']);
                    }
                }
                // Placeholder for modal forms
                $heading = array("Type", "Description", "Private Data", "Group", "Actions");
                $data = array();
                foreach ($all_private_data as $id => $group_id) {
                    $privDataObj = new PrivateData($id);
                    // Only show tooltip when data is available
                    // This is for type description
                    if ($privDataObj->get_type_desc() != '') {
                        $type_tooltip = ".tip.Private Data Type keyword:<br> " . $privDataObj->get_type_name();
                    } else {
                        $type_tooltip = "";
                    }
                    // This is for type name + Notes
                    //if ($privDataObj->get_notes() != '') {
                    //	$name_tooltip = ".tip.<b>Notes:</b><br>".nl2br($privDataObj->get_notes());
                    //} else {
                    //	$name_tooltip = "";
                    //}
                    // We also need to create a modal that will Ask the user for a password
                    // We only need one per group, as passwords are unqiue per group
                    $modalForm = new Form("auto", 2);
                    $modalForm->setHeadings(array("Please provide group password for " . $privDataObj->get_group_name()));
                    $modalForm->setTitles(array("Password", "group_id"));
                    $modalForm->setData(array("", $privDataObj->get_group_id()));
                    $modalForm->setDatabase(array('group_pass', 'group_id'));
                    $modalForm->setFieldType(array(0 => 'password_autocomplete_off', 1 => 'hidden'));
                    $myModalID = "modal_group_pass_" . $privDataObj->get_group_id();
                    // Change button text
                    $modalForm->setUpdateValue("Decrypt_Private_Data");
                    $modalForm->setUpdateText("Submit");
                    $modalForm->setModalID($myModalID);
                    $modalForms .= $modalForm->modalForm();
                    unset($modalForm);
                    // End modal
                    $name_tooltip = "";
                    // Here we check if the user submitted a group password
                    // Only for the group for which the pasword has been provided
                    if (isset($_POST['group_pass']) && $_POST['group_pass'] != '' && $privDataObj->get_group_id() == $_POST['group_id']) {
                        // now get private data (password)
                        $password = $privDataObj->get_private_data($_POST['group_pass']);
                        if ($password != false) {
                            // Decrypted successful!
                            // This is for type name + Notes
                            if ($privDataObj->get_notes($_POST['group_pass']) != '') {
                                $name_tooltip = ".tip.<b>Notes:</b><br>" . nl2br($privDataObj->get_notes($_POST['group_pass']));
                            }
                            // Get historical data, and create modal
                            $modalForm = new Form("auto", 2);
                            $modalForm->setHeadings(array("Changed (exipred) at:", "Private Data"));
                            // Loop through old data and fill arrays for form
                            $Htitles = array();
                            $Hdata = array();
                            $HfieldType = array();
                            $historical_passwords = $privDataObj->get_history($_POST['group_pass']);
                            if ($historical_passwords) {
                                foreach ($historical_passwords as $old_date => $old_data) {
                                    array_push($Htitles, $old_date);
                                    array_push($Hdata, $old_data);
                                    array_push($HfieldType, "static");
                                }
                            }
                            $modalForm->setTitles($Htitles);
                            $modalForm->setData($Hdata);
                            $modalForm->setFieldType($HfieldType);
                            unset($Htitles);
                            unset($Hdata);
                            unset($HfieldType);
                            $modalForm->setTitleWidth("40%");
                            $modalForm->setDatabase(array('date', 'old_data'));
                            $myHistoryModalID = "modal_old_pass_" . $id;
                            // Change button text
                            $modalForm->setUpdateValue("close");
                            $modalForm->setUpdateText("Press cancel");
                            $modalForm->setModalID($myHistoryModalID);
                            $modalForms .= $modalForm->modalForm();
                            unset($modalForm);
                            // End modal
                            // Now create a modal that allows us to update the private data object
                            // Start Update Modal
                            $PdataModal = new Form("auto", 2);
                            $PdataModal->setHeadings(array("Update Private Data"));
                            $PdataModal->setTitles(array("Description", "Private Data <br><small><i>Stored encrypted</i></small>.tip.This data will be AES encrypted", "Type <br><small><a name='modal' href='#add_pdtype_modal'>Add Private data type</a></small>", "Notes<br><small><i>Stored encrypted</i></small>.tip.This data will be AES encrypted", "PDid", "", ""));
                            $PdataModal->setData(array($privDataObj->get_name(), $password, $privDataObj->get_type_name(), $privDataObj->get_notes($_POST['group_pass']), $id, $_POST['group_id'], $_POST['group_pass']));
                            $PdataModal->setDatabase(array('private_data_desc', 'private_data_password', 'private_data_type', 'private_data_notes', 'private_data_id', 'group_id', 'group_pass'));
                            $PdataModal->setFieldType(array(2 => 'drop_down', 3 => 'text_area', 4 => 'hidden', 5 => 'hidden', 6 => 'hidden'));
                            // Creat dropdown
                            $dataTypes = PrivateDataType::get_private_data_types();
                            $PdataModal->setType($dataTypes);
                            $PdataModal->setUpdateValue('update_private_data');
                            $PdataModalID = "modal_private_data_id" . $id;
                            // Change button text
                            $PdataModal->setModalID($PdataModalID);
                            $modalForms .= $PdataModal->modalForm();
                            // End Update modal
                            // Now a Modal to Delete an Entry
                            // We'll ask for the password again.
                            $modalFormDelete = new Form("auto", 2);
                            $modalFormDelete->setHeadings(array("Delete " . $privDataObj->get_name() . "<br>Please provide group password for " . $privDataObj->get_group_name()));
                            $modalFormDelete->setTitles(array("Password", "group_id", ""));
                            $modalFormDelete->setData(array("", $privDataObj->get_group_id(), $id));
                            $modalFormDelete->setDatabase(array('group_pass', 'group_id', 'private_data_id'));
                            $modalFormDelete->setFieldType(array(0 => 'password_autocomplete_off', 1 => 'hidden', 2 => 'hidden'));
                            $myDeleteModalID = "modal_delete_pass_" . $id;
                            // Change button text
                            $modalFormDelete->setUpdateValue("delete_private_data");
                            $modalFormDelete->setUpdateText("Delete");
                            $modalFormDelete->setModalID($myDeleteModalID);
                            $modalForms .= $modalFormDelete->modalForm();
                            // End Delete modal
                            if (count($historical_passwords) > 0) {
                                $history_string = "<a name='modal' href='#" . $myHistoryModalID . "'>History</a>";
                            } else {
                                $history_string = "<i>No History</i>";
                            }
                            array_push($data, $privDataObj->get_type_desc() . $type_tooltip, $privDataObj->get_name() . "{$name_tooltip}", $password, $privDataObj->get_group_name(), "<a name='modal' href='#" . $PdataModalID . "'>Edit</a> &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp\n\t\t\t\t\t\t\t\t<a name='modal' href='#" . $myDeleteModalID . "'>Delete</a> &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp\n\t\t\t\t\t\t\t\t{$history_string}");
                            // Replace Heading of original Form, where used to be Group,
                            // we now make the Edit / Delete fields
                        } else {
                            array_push($data, $privDataObj->get_type_desc() . $type_tooltip, $privDataObj->get_name(), "*********", $privDataObj->get_group_name(), "<b>Could not retrieve Private Data. Reason: " . $privDataObj->get_error() . "</b><br><a name='modal' href='#" . $myModalID . "'>Unlock Private Data</a>");
                        }
                    } else {
                        array_push($data, $privDataObj->get_type_desc() . $type_tooltip, $privDataObj->get_name() . $name_tooltip, "*********", $privDataObj->get_group_name(), "<a name='modal' href='#" . $myModalID . "'>Unlock Private Data</a>");
                    }
                }
                $pdata_form = new Form("auto", 5);
                $pdata_form->setSortable(true);
                $pdata_form->setHeadings($heading);
                $pdata_form->setData($data);
                $pdata_form->setTableWidth("777px");
                echo $pdata_form->showForm();
                echo $modalForms;
            } else {
                //echo "No Private data for this Device";
            }
            echo $private_data_type_modal;
        }
    }
    echo "</div>";
}
Example #5
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;
 }
Example #6
0
function renderCheckReport()
{
    global $tool, $form, $status_array, $status_collors, $report_types;
    // Generating rerports can take a while
    // Increase time out
    $report_id = $_GET[report_id];
    $profile_id = $_GET[profileid];
    if (isset($report_id)) {
        // This means a saved report
        $mode = "saved_report";
        $report = new Report($report_id);
        $profile_name = $report->get_name();
        $report_type = $report->get_report_type();
        $from = $report->get_start_time();
        $to = $report->get_end_time();
        $profile = new CheckReportProfile($report->get_profile_id());
        $profile_name = $profile->get_name();
        $report_checks = array();
        foreach ($profile->get_checks() as $report_id => $report_name) {
            array_push($report_checks, $report_id);
        }
    } else {
        // else a live report
        $profile_name = '';
        if (is_numeric($profile_id)) {
            $mode = "report";
            $profile = new CheckReportProfile($_GET[profileid]);
            $report_type = $profile->get_report_type();
            $profile_name = $profile->get_name();
            $report_checks = array();
            foreach ($profile->get_checks() as $report_id => $report_name) {
                array_push($report_checks, $report_id);
            }
        } else {
            $report_checks = $_GET[checks];
            if (!is_array($report_checks)) {
                $form->warning("NO checks specified ");
                return;
            } elseif (count($report_checks) < 1) {
                $form->warning("NO checks specified ");
                return;
            }
            $mode = "checks";
            $report_type = $_GET['report_type'];
        }
        $from = $_GET[from];
        $to = $_GET[to];
    }
    // Different report types
    // * one_down_all_down ie worst case
    // * one_up_all_up     ie best case
    // * summary
    if ($report_type != 'one_down_all_down' && $report_type != 'one_up_all_up') {
        $report_type = 'summary';
    }
    // Check From date
    if (is_numeric($from) && date($from)) {
        $start_stamp = date($from);
    }
    // Check From date
    if (is_numeric($from) && date($from)) {
        $start_stamp = date($from);
    } elseif ($from != '' && strtotime($from)) {
        $start_stamp = strtotime($from);
    } else {
        $form->warning("Invalid start date {$from}");
        return false;
    }
    // Check To date
    if (is_numeric($to) && date($to)) {
        $end_stamp = date($to);
    } elseif ($to != '' && strtotime($to)) {
        $end_stamp = strtotime($to);
    } else {
        $form->warning("Invalid End date {$to}");
        return false;
    }
    if ($mode == 'saved_report') {
        $timers = array();
        $timers[ok] = $report->get_ok_secs();
        $timers[warning] = $report->get_warning_secs();
        $timers[critical] = $report->get_critical_secs();
        $timers[unknown] = $report->get_unknown_secs();
        //$timers[other] = $report->get_other_secs();
        $timers[no_data] = $report->get_no_data_secs();
    } else {
        $timers = get_report_data($start_stamp, $end_stamp, $report_type, $report_checks);
    }
    print "<h2>Availability Report</h2>";
    if ($mode == 'saved_report') {
        print "<div style='background-color: orange; color: black;\n\t\t width: 500px; padding: 1px; padding-right:\n\t\t1px; border: 2px black solid; position: relative; float: right; padding-top: 0.1em;\n\t\tpadding-right: 0.1em;\n\t\tpadding-bottom: 0.1em;\n\t\tpadding-left: 0.1em;\n\t\t'>\n\n\t\t<b>Note:</b> This is a saved report; the time data is extracted from the report data however all other data\n\t\tsuch as the events are re-generated from the database. <br>This is based on which checks are currently in the\n\t\tReport profile and not at the time of report generation<br>\n\t\t</div><br><br>";
    }
    echo "<div style='position: relative; float:left; clear:both; width:;'>";
    echo "<br><b>Report for: {$profile_name}:</b><ul>";
    foreach ($report_checks as $check_id) {
        $check = new Check($check_id);
        print "<li>" . $check->get_name() . " (" . $check->get_desc() . ")</li>";
    }
    print "</ul></div>";
    echo "<div style='position: relative; float:left; margin-left:105px; width:;'>\n\t\t<br><b>Reporting Detaills:</b><ul>\n\t\t\t<li>" . date("F j, Y, H:i ", $start_stamp) . " -- " . date("F j, Y, H:i ", $end_stamp) . "</li>\n\t\t\t<li>Reporting Type: {$report_types[$report_type]}</li>\n\t\t</ul>\n\t\t</div>";
    $totalsec = $timers[ok] + $timers[warning] + $timers[critical] + $timers[unknown] + $timers[no_data];
    $data = array("Ok", strTime($timers[ok]), $timers[ok] / $totalsec * 100 . "%", "Warning", strTime($timers[warning]), $timers[warning] / $totalsec * 100 . "%", "Critical", strTime($timers[critical]), $timers[critical] / $totalsec * 100 . "%", "Unknown", strTime($timers[unknown]), $timers[unknown] / $totalsec * 100 . "%", "No Measurement data", strTime($timers[no_data]), $timers[no_data] / $totalsec * 100 . "%");
    $headings = array("Status", "Time", "Percentage");
    $form->setCols(3);
    $form->setTableWidth("500px");
    $form->setHeadings($headings);
    $form->setSortable(true);
    $form->setData($data);
    echo "<div style='position: relative; float:left; clear:both; width:;'>";
    echo $form->showForm();
    echo "</div";
    echo "<div style='position: relative; float:left; margin-left:25px; width:;'>";
    print report_chart($timers);
    echo "</div>";
    $keyData = array();
    $keyData = array();
    $recent_events = Event::get_events_for_checks($report_checks, $start_stamp, $end_stamp);
    foreach ($recent_events as $event_id => $status) {
        unset($event);
        $event = new Event($event_id);
        $status = 3;
        $status = $event->get_status();
        $status_name = $status_array[$status];
        array_push($keyData, "<font color={$status_collors[$status]}> {$status_name} </font>");
        array_push($keyData, $event->get_check_name());
        array_push($keyData, $event->get_hostname());
        //array_push($keyData, $event->get_check_name() .".tip.". $event->get_key1() ." ". $event->get_key2());
        array_push($keyData, $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 = strTime($last_time - $insert_time);
        array_push($keyData, $diff);
        array_push($keyData, $event->get_info_msg());
    }
    $headings = array("Status", "Check Name", "Host", "Insert Time", "Last Check", "Duration", "Service Information");
    $form = new Form("auto");
    $form->setCols(7);
    $form->setTableWidth("auto");
    $form->setData($keyData);
    $form->setTitles($keyTitle);
    $form->setEventHandler($keyHandlers);
    $form->setHeadings($headings);
    $form->setSortable(true);
    print "<div style='clear:both'></div><h3>Events</h3>";
    print $form->showForm();
}
Example #7
0
function display_report($ip_manager, $arr = array(), $search_str = "")
{
    $ip_fam = 4;
    if (isset($_GET['report'])) {
        $ip_fam = $_GET['report'];
    }
    $all_ip = $arr;
    $free = 0;
    $reserved = 0;
    $assigned = 0;
    $allstats = 0;
    $totalspace = "0";
    $limit = 0;
    foreach ($all_ip as $n_ip => $n_name) {
        if (!IP_Database::is_parent($n_ip)) {
            $t_ip = new IP_Database($n_ip);
            $allstats++;
            $ip_manager->set_IP($t_ip->get_address_ip(), $ip_fam);
            switch ($t_ip->get_status()) {
                case "FREE":
                    $free = bcadd($ip_manager->get_ipPerNet(), $free);
                    break;
                case "RESERVED":
                    $reserved = bcadd($ip_manager->get_ipPerNet(), $reserved);
                    break;
                case "ASSIGNED":
                    $assigned = bcadd($ip_manager->get_ipPerNet(), $assigned);
                    break;
            }
            $totalspace = bcadd($ip_manager->get_ipPerNet(), $totalspace);
        }
    }
    $limit = strlen($totalspace) - 10;
    if ($limit < 10) {
        $limit = 0;
    }
    //set the default column
    $form = new Form("auto", 2);
    $temp_space = explode(".", $totalspace);
    $totalspace = $temp_space[0];
    if ($totalspace == 0) {
        $divisor = 1;
    } else {
        $divisor = $totalspace;
    }
    //their calories and locations correspondingly
    $num_slash = "";
    if ($_GET['report'] == 6) {
        $num_slash = "Number of /48s";
        $data_slash = bcdiv($totalspace, bcpow(2, 80), 2);
        $num_slash2 = "Number of /64s";
        $data_slash2 = bcdiv($totalspace, bcpow(2, 64), 2);
        //create the headings for these
        if ($search_str != "") {
            $search_str = " for " . $search_str;
        }
        $heading = array("IPV6 Report" . $search_str);
        $free = bcdiv($free, bcpow(10, $limit), 2);
        $assigned = bcdiv($assigned, bcpow(10, $limit), 2);
        $reserved = bcdiv($reserved, bcpow(10, $limit), 2);
        $divisor = bcdiv($divisor, bcpow(10, $limit), 2);
        if ($divisor == 0) {
            $divisor = 1;
        }
        $titles = array("Number of IPs", $num_slash, $num_slash2, "Percent of free IPs", "Percent of assigned IPs", "Percent of reserved IPs");
        $data = array(number_format($totalspace) . " IPs in " . number_format($allstats) . " Networks", number_format($data_slash), number_format($data_slash2), bcmul(bcdiv($free, $divisor, 5), 100, 2) . "%", bcmul(bcdiv($assigned, $divisor, 5), 100, 2) . "%", bcmul(bcdiv($reserved, $divisor, 5), 100, 2) . "%");
    } else {
        if ($_GET['report'] == 4 || !isset($_GET['report'])) {
            $num_slash = "Number of /24s";
            $data_slash = bcdiv($totalspace, 256, 2);
            //create the headings for these
            if ($search_str != "") {
                $search_str = " for " . $search_str;
            }
            $heading = array("IPV4 Report" . $search_str);
            $titles = array("Number of IPs", $num_slash, "Percent of free IPs", "Percent of assigned IPs", "Percent of reserved IPs");
            $data = array(number_format($totalspace) . " IPs in " . number_format($allstats) . " Networks", number_format($data_slash), bcmul(bcdiv($free, $divisor, 5), 100, 2) . "%", bcmul(bcdiv($assigned, $divisor, 5), 100, 2) . "%", bcmul(bcdiv($reserved, $divisor, 5), 100, 2) . "%");
        }
    }
    $form->setSortable(false);
    // or false for not sortable
    $form->setTitles($titles);
    $form->setHeadings($heading);
    $form->setData($data);
    //set the table size
    $form->setTableWidth("600px");
    $form->setTitleWidth("20%");
    echo $form->showForm();
    $chart_arr = array(free => $free, assigned => $assigned, reserved => $reserved);
    print report_chart($chart_arr);
}
Example #8
0
 function newModalForm($headingName, $titleName, $infoKey, $type = '', $customer = '')
 {
     parent::setHeadings($headingName);
     parent::setTitles($titleName);
     parent::setSortable(false);
     parent::setDatabase($infoKey);
     foreach ($type as $id => $value) {
         if (is_array($value)) {
             parent::setType($value);
         } else {
             parent::setType($type);
             break;
         }
     }
     parent::setAddValue('addPort');
     return parent::newModalForm(10);
 }
Example #9
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 #10
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;
 }
Example #11
0
function displayMyPass()
{
    global $tool, $propertyForm;
    print "<h2>Change password</h2>";
    // 1st check if local user
    $user_id = $_SESSION[userid];
    $user_name = $_SESSION[username];
    $user = new User($user_id);
    if (!$user->is_local_user($user_name, 'local')) {
        print "Sorry this feature is only available for Local users.<br>\n\t\t\tYou are not a local user, most likely an LDAP user. LDAP users have to\n\t\t\tUpdate their account at the LDAP server.<br>";
        return;
    }
    $form = new Form("auto", 2);
    $heading = array("<h3>Change Password</h3>");
    $titles = array("Current password:"******"New password:"******"Confirm new password:"******"<input name='oldpass' type='password' id='oldpass'>";
    $custom2 = "<input name='newpass1' type='password' id='newpass1'>";
    $custom3 = "<input name='newpass2' type='password' id='newpass2'>";
    $customData = array($custom1, $custom2, $custom3);
    $fieldType = array("custom", "custom", "custom");
    $form->setFieldType($fieldType);
    $form->setData($customData);
    $form->setHeadings($heading);
    $form->setTitles($titles);
    $form->setDatabase($postkeys);
    $form->setTableWidth("500px");
    $form->setUpdateValue("changePass");
    $form->setUpdateText("Save Password");
    echo $form->editForm();
}
Example #12
0
function displayPaths()
{
    global $tool, $propertyForm;
    $my_paths = array("path_snmpwalk" => "snmpwalk", "path_snmpget" => "snmpget", "path_rrdupdate" => "rrdupdate", "path_rrdtool" => "rrdtool", "path_rrddir" => "RRD Directory");
    $content = "";
    $content .= "<h1>System Paths</h1>";
    $content .= "<div style='padding-left: 600px;'>\n\t\t\t<a class='tooltip' title='This will try to detect the tools below in the current \$path'><img src='icons/Info.png' height='19'></a>\n\t\t\t<a href='javascript:LoadPage(\"configurations.php?action=paths&mode=autodetect\",\"settingsInfo\")'>\n\t\t\tclick here to Auto Discover paths</a></div>";
    $form = new Form("auto", 2);
    $keyHandlers = array();
    $keyData = array();
    $keyTitle = array();
    $postKeys = array();
    foreach ($my_paths as $id => $path) {
        $property = new Property();
        $value = $property->get_property($id);
        if ($value === false) {
            $value = "WARNING: Property '{$id}' Not Found in Property table, Contact your admininistrator" . $property->get_error();
        }
        $desc = $property->get_desc($id);
        if (is_readable($value)) {
            $check = "<font size='' color='green'>Found!</font>";
            if ($id == 'path_rrdtool') {
                $cmd = "{$value} -v| awk '{print \$2}'|head -1";
                exec($cmd, $output, $return_var);
                if ($output[0] < "1.4") {
                    $check = "<font size='' color='Orange'>Found version {$output['0']}! You need at least RRDtool version 1.4.0 otherwise some graphs won't display correctlty</font>";
                }
            }
        } else {
            $check = "<font size='' color='orange'>Not Found!</font>";
        }
        array_push($postKeys, "{$id}");
        array_push($keyData, "{$value}");
        array_push($keyTitle, "<font size='2'>{$path}</font><br><i>{$desc}</i><br>{$check}");
        #$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("Program", "Path");
    $form->setSortable(true);
    // or false for not sortable
    $form->setHeadings($heading);
    $form->setEventHandler($handler);
    $form->setData($keyData);
    $form->setTitles($keyTitle);
    $form->setTableWidth("800px");
    $form->setDatabase($postKeys);
    $form->setUpdateValue("savePaths");
    $form->setUpdateText("Save Program Paths");
    $content .= $form->editForm();
    print $content;
}
Example #13
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;
 }