Example #1
0
 private function update_entry()
 {
     $content = '';
     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'])) {
             $content .= $tmpform->success("Private data updated Succesfully");
             $_SESSION['action'] = "Updated private data for: " . $_POST['private_data_desc'];
         } else {
             $content .= $tmpform->error("Warning: Failed to Update Private data Reason: " . $privDataObj->get_error(), $_GET['ID']);
         }
     }
     return $content;
 }
Example #2
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 #3
0
<?php 
}
?>

<script type='text/javascript' src='js/mouseClicks.js'></script>

<?php 
/*Database coding: this checks for multiple different actions made by users and responds accordingly.*/
include_once "classes/Search.php";
include_once "classes/Form.php";
$form = new Form('auto', 'auto');
$keyword = $_GET['keyword'];
if ($keyword == '') {
    echo $form->warning("Did not complete search: Please make sure your search keyword isn't empty");
} else {
    $form->success("Search completed for \"" . $keyword . "\"");
}
$search = new Search();
$search->set_keyword($keyword);
$search->search_database();
echo "<p style='float:left; color:#666;'>Did you not find your result? Try searching in our archived section... <input type='checkbox' id='showArchived' value=''>Show archived items</input></p>";
echo "<div class='resultBox first'>";
echo "<h3 icon='contact'>Contacts<hr></h3>";
echo "<div class='results'>";
$contactResult = $search->get_contact_results();
if (empty($contactResult)) {
    echo "No results found...";
} else {
    foreach ($contactResult as $id => $value) {
        $notes = '';
        if (isset($value['group_id'])) {
Example #4
0
include_once 'classes/Form.php';
include_once 'classes/Event.php';
include_once 'classes/RRD.php';
include_once 'classes/Property.php';
include_once 'classes/Check.php';
//Make a new contact, a new tool bar, and a new form
$tool = new EdittingTools();
$form = new Form("auto", 3);
$status_array = array(0 => "Ok", 1 => "Warning", 2 => "Critical", 3 => "Unknown");
$status_collors = array(0 => "Green", 1 => "Orange", 2 => "Red", 3 => "Blue");
$report_types = array(summary => "Summary Report", one_up_all_up => "One Up all Up", one_down_all_down => "One Down all Down");
//checks the status of what's happening. If something was done successfully, it will be displayed
if (isset($_GET['update']) || isset($_GET['delete']) || isset($_GET['add'])) {
    switch (success) {
        case $_GET['update']:
            $form->success("Updated successfully");
            break;
        case $_GET['add']:
            $form->success("Added new data successfully");
            break;
        case $_GET['delete']:
            $form->success("Deleted successfully");
            break;
    }
}
// Templates
if ($_GET['action'] == "list_templates") {
    displayAllTemplates();
} elseif ($_GET['action'] == "showTemplate") {
    displayTemplate();
} elseif ($_GET['action'] == "editTemplate") {
Example #5
0
                $search_str .= " Location = " . $loc->get_name() . ", ";
            }
            if ($_GET['owner'] != "") {
                $own = new Contact($_GET['owner']);
                $search_str .= " Owner = " . $own->get_name() . ", ";
            }
            if ($_GET['assigned'] != "") {
                $assign = new Contact($_GET['assigned']);
                $search_str .= " Assigned To = " . $assign->get_name() . ", ";
            }
            if ($_GET['status'] != "") {
                $search_str .= " Status = " . $_GET['status'] . ", ";
            }
            $search_str = rtrim($search_str, ", ");
            //display what is searched and what is found
            Form::success("Searched for:" . $search_str . " | Results Found: " . $result_c_count . " child network(s), " . $result_p_count . " parent network(s)");
        } else {
            //just search for everything if nothing is searched
            $s_results = $IP_Search->search("", "", "", "", "", "", $family);
        }
        //if there's no result display nothing
        if (count($s_results) == 0) {
            $search_str = "";
        }
        //show the report
        display_report($ip_manager, $s_results, $search_str);
        echo "</div>";
    }
}
//this functions retrieves all network from the database and displays them
function display_all_networks($arr, $ip_manager)