Exemplo n.º 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}";
 }
Exemplo n.º 2
0
function renderCreateMultipeReports()
{
    global $tool, $form, $report_types;
    // Menu bar
    $content .= '<h2>Create Report</h2>';
    if ($_POST[step] != "2") {
        $headings = array("Please provide reporting information ");
        $postKeys = array("action", "step", "name", "date1", "date2");
        $keyTitle = array("action", "step", "Report Name", "Start Date", "End Date");
        $keyData = array("renderCheckReport", "2", "{$profile_id}", "", "");
        $form->setCols(2);
        $form->setData($keyData);
        $form->setTitles($keyTitle);
        $form->setDatabase($postKeys);
        $form->setTableWidth("auto");
        $fieldType[0] = "hidden";
        $fieldType[1] = "hidden";
        $fieldType[3] = "date_picker";
        $fieldType[4] = "date_picker";
        $form->setFieldType($fieldType);
        $form->setHeadings($headings);
        $form->setSortable(false);
        $form->setUpdateValue("");
        $form->setUpdateText("Continue to Select Profiles");
        $content .= $form->editForm();
    } elseif ($_POST[step] == "2") {
        $filter .= "<p>";
        $tool = new EdittingTools();
        $filter .= $tool->createNewFilters();
        $filter .= "<div style=\"clear:both;\"></div> </p>";
        $content .= $filter;
        // Fil array
        $keyData = array();
        foreach (CheckReportProfile::get_profiles() as $id => $name) {
            $profile = new CheckReportProfile($id);
            array_push($keyData, "<input type='checkbox' name='profile_id[]' value='{$id}'>", $profile->get_name());
        }
        $headings = array("Select All<input name='all' type='checkbox' value='Select All' onclick=\"checkAll(document.dataForm['profile_id[]'],this)\" ", "Profile");
        $form->setCols(2);
        $form->setTableWidth("auto");
        $form->setData($keyData);
        $form->setHeadings($headings);
        $form->setSortable(true);
        // manually create form
        $content .= "<p><b>Select the profiles you'd like to add to this report.</b></p>";
        $content .= "<form action='' id='dataForm' method='POST' name='dataForm'>";
        $content .= $form->showForm();
        $content .= "<div style='clear:both'></div>\n\t\t\t<INPUT TYPE=SUBMIT VALUE='Add Selected Checks' name='insert_multiple_reports'>\n\t\t\t<INPUT TYPE=hidden NAME=action VALUE='insert_multiple_reports'>\n\t\t\t<INPUT TYPE=hidden NAME=date1 VALUE='" . $_POST['date1'] . "'>\n\t\t\t<INPUT TYPE=hidden NAME=date2 VALUE='" . $_POST['date2'] . "'>\n\t\t\t<INPUT TYPE=hidden NAME=name VALUE='" . $_POST['name'] . "'>\n\t\t</form>";
    }
    echo $content;
}
Exemplo n.º 3
0
 function render_multiple_reports()
 {
     // Menu bar
     $form1 = new Form();
     $content = "<div style='font-size:10px; font-weight:100px;'>\n\t\t\t<a href='{$this->url}'>Accounting</a> >> Create reports</div>";
     $content .= '<h2>Create Report</h2>';
     $form = new Form();
     if ($_POST[step] != "2") {
         $headings = array("Please provide reporting information ");
         $postKeys = array("action", "step", "name", "date1", "date2");
         $keyTitle = array("action", "step", "Report Name", "Start Date", "End Date");
         $keyData = array("renderCheckReport", "2", "{$profile_id}", "", "");
         $form->setCols(2);
         $form->setData($keyData);
         $form->setTitles($keyTitle);
         $form->setDatabase($postKeys);
         $form->setTableWidth("auto");
         $fieldType[0] = "hidden";
         $fieldType[1] = "hidden";
         $fieldType[3] = "date_picker";
         $fieldType[4] = "date_picker";
         $form->setFieldType($fieldType);
         $form->setHeadings($headings);
         $form->setSortable(false);
         $form->setUpdateValue("");
         $form->setUpdateText("Continue to Select Profiles");
         $content .= $form->editForm();
     } elseif ($_POST[step] == "2") {
         $filter .= "<p>";
         $tool = new EdittingTools();
         $filter .= $tool->createNewFilters();
         $filter .= "<div style=\"clear:both;\"></div> </p>";
         $content .= $filter;
         // Fil array
         $keyData = array();
         $query = "select profile_id, title, client_id FROM accounting_profiles where archived = '0'";
         $result = mysql_query($query);
         if (!$result) {
             return "<b>Oops something went wrong, unable to select accounting profiles </b>";
         }
         while ($obj = mysql_fetch_object($result)) {
             if ($obj->client_id != '') {
                 $contact = new Contact($obj->client_id);
                 $contact_name = $contact->get_name();
             } else {
                 $contact_name = 'n/a';
             }
             array_push($keyData, "<input type='checkbox' name='profile_id[]' value='{$obj->profile_id}'>");
             array_push($keyData, $obj->title, $contact_name);
         }
         $headings = array("Select All<input name='all' type='checkbox' value='Select All' onclick=\"checkAll(document.dataForm['profile_id[]'],this)\" ", "Profile name", "Client");
         $form->setCols(3);
         $form->setTableWidth("1024px");
         $form->setData($keyData);
         $form->setHeadings($headings);
         $form->setSortable(true);
         // manually create form
         $content .= "<p><b>Select the profiles you'd like to add to this report.</b></p>";
         $content .= "<form action='' id='dataForm' method='GET' name='dataForm'>";
         $content .= $form->showForm();
         $content .= "<div style='clear:both'></div>\n                \t\t\t<INPUT TYPE=SUBMIT VALUE='Add Selected Checks' name='addChecksToProfile'>\n\t\t\t\t\t<INPUT TYPE=hidden NAME=action VALUE='create_multiple_reports'>\n\t\t\t\t\t<INPUT TYPE=hidden NAME=tab VALUE='" . $_GET['tab'] . "'>\n\t\t\t\t\t<INPUT TYPE=hidden NAME=date1 VALUE='" . $_POST['date1'] . "'>\n\t\t\t\t\t<INPUT TYPE=hidden NAME=date2 VALUE='" . $_POST['date2'] . "'>\n\t\t\t\t\t<INPUT TYPE=hidden NAME=name VALUE='" . $_POST['name'] . "'>\n\t\t\t\t\t<INPUT TYPE=hidden NAME=pluginID VALUE='" . $_GET['pluginID'] . "'>\n\t\t\t\t</form>";
     }
     return $content;
 }
Exemplo n.º 4
0
            $names = array("Add New VLAN", "Search", "Show All VLANs");
            $icons = array("add", "search", "icons/vlan-01.png");
            $handlers = array("window.location.href='" . $_SERVER['SCRIPT_NAME'] . "?tab=" . $_GET['tab'] . "&pluginID=" . $_GET['pluginID'] . "&className=" . $_GET['className'] . "&family=vlan&action=add'", "window.location.href='" . $_SERVER['SCRIPT_NAME'] . "?tab=" . $_GET['tab'] . "&pluginID=" . $_GET['pluginID'] . "&className=" . $_GET['className'] . "&family=vlan&action=search'", "window.location.href='" . $_SERVER['SCRIPT_NAME'] . "?tab=" . $_GET['tab'] . "&pluginID=" . $_GET['pluginID'] . "&className=" . $_GET['className'] . "&family=vlan&action=showAll'");
        }
        echo EdittingTools::createNewTools($names, $icons, $handlers, "VLAN Tool");
    } else {
        echo EdittingTools::createNewModal($names, $icons, $modalID, "IP Tool");
    }
} else {
    echo EdittingTools::createNewModal($names, $icons, $modalID, "IP Tool");
}
//If it's the vlan overview, create filters
if (isset($_GET['family'])) {
    if ($_GET['family'] == 'vlan' && !isset($_GET['action']) && !isset($_GET['v_id'])) {
        $listFilter = array("FREE" => "FREE", "RESERVED" => "RESERVED", "ASSIGNED" => "ASSIGNED");
        echo EdittingTools::createNewFilters($listFilter);
    }
}
//CRUD detection for networks
if (!empty($_POST)) {
    //Check the network
    if (isset($_POST['ipv6'])) {
        $ip = $_POST['ipv6'] . "/" . $_POST['netmask6'];
    } else {
        if (isset($_POST['ip1'])) {
            $ip = $_POST['ip1'] . "." . $_POST['ip2'] . "." . $_POST['ip3'] . "." . $_POST['ip4'] . "/" . $_POST['netmask'];
        } else {
            $ip = "";
        }
    }
    //If nothing is entered, a warning is issued
Exemplo n.º 5
0
 function render_list_changes()
 {
     // This renders all the changes p
     $content = "<h1>Change Manager</h1>";
     // Tools menu
     $tool = new EdittingTools();
     if ($_SESSION['access'] >= 50) {
         $toolNames = array("New Change", "List Changes", "Search", "Report");
         $toolIcons = array("add", "stat", "search", "report");
         $toolHandlers = array("window.location.href='{$this->url}&action=new_change'", "window.location.href='{$this->url}&action=render_report'", "window.location.href='{$this->url}&action=search'", "window.location.href='{$this->url}&action=report'");
         $content .= $tool->createNewTools($toolNames, $toolIcons, $toolHandlers);
     }
     $content .= $tool->createNewFilters();
     $content .= " <div style=\"clear:both;\"></div><br> ";
     // Prepare query
     $query = "SELECT change_id, title, notes, change_date, planned_change_date, \n\t\t\t\t\tchange_contact_1, change_contact_2, status\n\t\t\t\t\tFROM plugin_ChangeManager_Changes\n\t\t\t\t\tORDER BY change_id DESC";
     $result = mysql_query($query);
     if (!$result) {
         return "<b>Oops something went wrong, unable to select changes </b>";
     }
     $form = new Form("auto", 6);
     $heading = array("Change ID", "Change", "Planned Time", "Contact", "Status", "Actions");
     $data = array();
     $handler = array();
     while ($obj = mysql_fetch_object($result)) {
         $user = new User($obj->change_contact_1);
         $contact_name = $user->get_full_name();
         $actions = "<a href='{$this->url}&action=delete_change&cid={$obj->change_id}&return=list_changes'>\n<img src='icons/Delete.png' height=18></a> ";
         if ($obj->status > 0) {
             $actions .= "<a href='{$this->url}&action=email_change&cid={$obj->change_id}'>\n<img src='icons/Email.png' height=18></a> ";
         }
         array_push($data, $obj->change_id, $obj->title, $obj->planned_change_date, $contact_name, $this->status_values[$obj->status], $actions);
         // Event handler
         $url = $this->url . "&action=show_change&cid={$obj->change_id}";
         array_push($handler, "handleEvent('{$url}')");
     }
     $form->setSortable(true);
     // or false for not sortable
     $form->setHeadings($heading);
     $form->setEventHandler($handler);
     $form->setData($data);
     //set the table size
     #$form->setTableWidth("100%");
     $content .= $form->showForm();
     return $content;
 }