Example #1
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 #2
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 #3
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 #4
0
     $assign = Contact::get_groups();
     $form->setSortable(false);
     // or false for not sortable
     $form->setHeadings($heading);
     $form->setType($status);
     $form->setType($location);
     $form->setType($assign);
     $form->setTitles($titles);
     $form->setData($data);
     $form->setDatabase($keys);
     $form->setFieldType($fieldType);
     //set the table size
     $form->setTableWidth("1024px");
     $form->setTitleWidth("20%");
     $form->setUpdateValue("searchVLAN");
     $form->setUpdateText("Search VLAN");
     //create the form
     echo $form->editForm();
 }
 //show all the vlans if that is called (ALL 4096 VLANS)
 if ($_GET['action'] == 'showAll') {
     $vlan_manager = new Vlan_database();
     $all_vlans = $vlan_manager->get_all_vlans();
     $num_max = 4096;
     $arr = array();
     foreach ($all_vlans as $id => $v_id) {
         $arr[$v_id] = $id;
     }
     //set the default column
     $form = new Form("auto", 6);
     //create the headings for these
Example #5
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 #6
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 #7
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 #8
0
 function render_new_change()
 {
     /**
     These are the fields for the change form:
     	Summary
     	PlannedChangeDate
     	PlannedChangeTime
     	ChangeDate
     	ChangeTime
     	PrimaryContact
     	SecondaryContact
     	Impact
     	Status
     	ChangeDescription
     */
     $content = "<h1>New Change  </h1>";
     // Add Javascript input form validation function
     // Form.php form always renders forms with form name of "MyClassForm".
     $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;
     // 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]);
     asort($allUsers);
     /*
     	First Generic change info
     */
     $values = array();
     $form = new Form("auto", 2);
     // Need to count the number of sections in this form
     // Used by editForm($numHead)  later
     // First Include the datescripts initialized with correct date
     $year = date("Y", mktime());
     $month = date("m", mktime());
     $day = date("d", mktime());
     $hour = date("H", mktime());
     $minute = date("i", mktime());
     $sql_PlannedTime = "{$hour}:00";
     $sql_ChangeTime = "{$hour}:30";
     $planned_date = "{$year}-{$month}-{$day}";
     $fieldType[1] = "date_picker";
     $fieldType[2] = "drop_down";
     $form->setType($this->timetable);
     // Drop down
     $change_date = "{$year}-{$month}-{$day}";
     $fieldType[3] = "date_picker";
     $fieldType[4] = "drop_down";
     $form->setType($this->timetable);
     // Drop down
     $fieldType[5] = "drop_down";
     $form->setType($allUsers);
     // Drop down
     $fieldType[6] = "drop_down";
     $form->setType($allUsers);
     // Drop down
     $fieldType[7] = "drop_down";
     $form->setType($this->impact_values);
     // Drop down
     $fieldType[8] = "drop_down";
     $form->setType($this->status_values);
     // Drop down
     array_push($values, "", $planned_date, $sql_PlannedTime, "", "", $_SESSION['fullname'], "", "  ", "  ", "");
     $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");
     $fieldType[9] = "text_area";
     $i = 9;
     /*
     	Device specific change info
     */
     array_push($heading, "*<break>*", "Device Details - New Device");
     array_push($titles, "*<break>*", "Device", "Changed By", "Change Details", "Effects", "Backout Procedure");
     $allDevices = Device::get_devices();
     $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";
     $fieldType[$i + 4] = "text_area";
     $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%");
     $form->setUpdateValue("InsertChange");
     $form->setUpdateText("Create New Change");
     $content .= $form->EditForm(2);
     return $content;
 }