예제 #1
0
function page_router()
{
    global $authorizations;
    global $NagiosUser;
    list($mode, $type) = array(NULL, NULL);
    list($state_filter, $name_filter, $objtype_filter, $host_filter) = array(NULL, NULL, NULL, NULL);
    if (isset($_GET['type'])) {
        $type = strtolower($_GET['type']);
    } else {
        $type = 'overview';
    }
    if (isset($_GET['mode'])) {
        $mode = strtolower($_GET['mode']);
    } else {
        $mode = 'html';
    }
    if (isset($_GET['state_filter']) && trim($_GET['state_filter']) != '') {
        $state_filter = process_state_filter(htmlentities($_GET['state_filter']));
    }
    if (isset($_GET['name_filter']) && trim($_GET['name_filter']) != '') {
        $name_filter = process_name_filter(htmlentities($_GET['name_filter']), ENT_QUOTES);
    }
    if (isset($_GET['host_filter']) && trim($_GET['host_filter']) != '') {
        $host_filter = htmlentities($_GET['host_filter'], ENT_QUOTES);
    }
    if (isset($_GET['objtype_filter']) && trim($_GET['objtype_filter']) != '') {
        $objtype_filter = process_objtype_filter(htmlentities($_GET['objtype_filter']));
    }
    list($data, $html_output_function) = array(NULL, NULL);
    switch ($type) {
        case 'services':
        case 'hosts':
            $data = hosts_and_services_data($type, $state_filter, $name_filter, $host_filter);
            $html_output_function = 'hosts_and_services_output';
            break;
        case 'hostgroups':
        case 'servicegroups':
            if ($type == 'hostgroups' || $type == 'servicegroups') {
                $data = hostgroups_and_servicegroups_data($type, $name_filter);
                $html_output_function = 'hostgroups_and_servicegroups_output';
            }
            break;
        case 'hostdetail':
        case 'servicedetail':
            $data = host_and_service_detail_data($type, $name_filter);
            if (!$data) {
                send_home();
            }
            //bail if not authorized
            $html_output_function = 'host_and_service_detail_output';
            break;
        case 'object':
            if ($objtype_filter) {
                if ($NagiosUser->if_has_authKey('authorized_for_configuration_information')) {
                    $data = object_data($objtype_filter, $name_filter);
                    $type = $objtype_filter;
                    $html_output_function = 'object_output';
                } else {
                    send_home();
                }
            }
            break;
        case 'backend':
            $xmlout = tac_xml(get_tac_data());
            break;
        case 'overview':
        default:
            //create function to return tac data as an array
            $html_output_function = 'get_tac_html';
            break;
    }
    $output = NULL;
    switch ($mode) {
        case 'html':
        default:
            $output = mode_header($mode);
            $output .= $html_output_function($type, $data, $mode);
            $output .= mode_footer($mode);
            break;
        case 'json':
            header('Content-type: application/json');
            $output = json_encode($data);
            break;
        case 'xml':
            if ($type != 'backend') {
                require_once DIRBASE . '/views/xml.php';
                $title = ucwords($type);
                build_xml_page($data, $title);
                header('Location: ' . BASEURL . 'tmp/' . $title . '.xml');
            }
            header('Content-type: text/xml');
            if ($type == 'backend') {
                echo $xmlout;
            }
            //xml backend access for nagios fusion
            #$output = build_xml_data($data, $title);
            break;
    }
    print $output;
}
예제 #2
0
function bpi_route_command($cmd)
{
    print "<p class='gohome'><a href='index.php'>BPI Home</a></p>";
    switch ($cmd) {
        ///////////////////////////ADD GROUP////////////////////////////
        case 'add':
            //and new group form
            //do stuff
            print "<div class='container'>";
            if (isset($_POST['addSubmitted'])) {
                $config = process_post($_POST);
                if (isset($config)) {
                    append_file($config);
                }
                print "<p><a href='index.php?cmd=add'>Add More Groups</a></p>";
            } else {
                empty_form();
            }
            print "</div>\n";
            break;
            ///////////////////////////DELETE GROUP////////////////////////////
        ///////////////////////////DELETE GROUP////////////////////////////
        case 'delete':
            //delete stuff
            if (isset($_GET['arg'])) {
                //add javascript confirmation of group deletion
                $arg = htmlentities(trim($_GET['arg']));
                delete_group($arg);
            } else {
                print "<p class='error'>Error: No BPI Group specifies to delete.</p>";
            }
            break;
            ///////////////////////////EDIT GROUP////////////////////////////
        ///////////////////////////EDIT GROUP////////////////////////////
        case 'edit':
            print "<div class='container'>";
            //edit existing groups
            if (isset($_GET['arg'])) {
                //add javascript confirmation of group deletion
                $arg = htmlentities(trim($_GET['arg']));
                $config = get_config_array($arg);
                if (isset($_POST['editSubmitted'])) {
                    $config = process_post($_POST);
                    //process the form data, make sure it comes back valid
                    if (isset($config)) {
                        edit_group($arg, $config);
                    }
                } else {
                    loaded_form($config);
                }
            } else {
                print "<p class='error'>Error: No BPI Group specifies to delete.</p>";
            }
            print "</div>\n";
            break;
        case 'fixconfig':
            include 'config_functions/fix_config.php';
            break;
        default:
            //default to view page if value is bad
            send_home();
            break;
    }
    //end SWITCH
}
예제 #3
0
function page_filter($filter)
{
    print "<div id='addgrouplink'><a href='index.php?cmd=add'>Create A New Group</a></div>";
    print "<div id='notes'><p class='note'>Essential group members are denoted with: **</p></div>";
    switch ($filter) {
        case 1:
            print "<h4 class='header'><a href='index.php?filter=1'>High Priority</a></h4>\n";
            print "<h5 class='header'><a href='index.php'>Show All Groups</a></h5>\n";
            bpi_view('1');
            //display all group trees
            break;
        case 2:
            print "<h4 class='header'><a href='index.php?filter=2'>Medium Priority</a></h4>\n";
            print "<h5 class='header'><a href='index.php'>Show All Groups</a></h5>\n";
            bpi_view('2');
            break;
        case 3:
            print "<h4 class='header'><a href='index.php?filter=3'>Low Priority</a></h4>\n";
            print "<h5 class='header'><a href='index.php'>Show All Groups</a></h5>\n";
            bpi_view('3');
            break;
        default:
            send_home();
            break;
    }
}