コード例 #1
0
ファイル: main.php プロジェクト: pasichnichenko/nconf
    });

</script>


<?php 
echo NConf_HTML::ui_box_header("Configuration Deployment");
echo NConf_HTML::ui_box_content();
echo '<div style="height: 20px;">
            <div id="loading">
                <img src="img/working_small.gif"> in progress...
            </div>
          </div>';
// Load deployment class and create object
require_once "class.deployment.php";
require_once "class.deployment.modules.php";
// Load the NConf Deployment class
// It loads all the modules and handles the deployment basic stuff
$deployment = new NConf_Deployment();
// Loads the configuration of the user
// nconf/conf/deployment.ini
$deployment->import_config();
if (NConf_DEBUG::status('ERROR')) {
    // Show error if set
    echo NConf_HTML::limit_space(NConf_HTML::show_error());
} else {
    // Start deploying the files
    $deployment->run_deployment();
}
echo '</div>';
コード例 #2
0
ファイル: functions.php プロジェクト: pasichnichenko/nconf
function inheritance_HostToService($host_id, $mode = '')
{
    //NConf_DEBUG::open_group('inheritance for host_id: "'.$host_id.'"', 1);
    # Handling inheritance to services
    # check for host data
    if ($mode == 'apply_inheritance') {
        if (empty($_POST["apply_inheritance"][$host_id])) {
            // continue if service is empty
            NConf_DEBUG::set("not applying for host: " . $host_id, 'DEBUG', 'Inheritance filter');
            return;
        }
    }
    # These services will be modified
    $services = db_templates("get_services_from_host_id", $host_id);
    # array of inherited attributes
    $change_attrs = array("check_period" => "check period", "notification_period" => "notification period", "contact_groups" => "contact groups");
    $class_id = db_templates("get_id_of_class", "service");
    # array for preview functionality
    $preview_array = array();
    # make a diff with each service to detect which items must be linked and which must be removed
    foreach ($services as $service_id => $service_name) {
        NConf_DEBUG::open_group('inheritance for service: "' . $service_name . '"', 1);
        # initial value for history entry "edited"
        $edited = FALSE;
        $preview_array[$service_name] = array();
        if ($mode == 'apply_inheritance') {
            if (empty($_POST["apply_inheritance"][$host_id][$service_id])) {
                // continue if service is empty
                NConf_DEBUG::set("not applying for service: " . $service_name, 'DEBUG', 'Inheritance filter');
                continue;
            }
        }
        foreach ($change_attrs as $change_attr => $change_attr_friendly_name) {
            NConf_DEBUG::open_group("attribute: " . $change_attr_friendly_name, 2);
            if ($mode == 'apply_inheritance' and empty($_POST["apply_inheritance"][$host_id][$service_id][$change_attr])) {
                // continue if service is empty
                NConf_DEBUG::set("not applying for attribute: " . $change_attr_friendly_name, 'DEBUG', 'Inheritance filter');
                continue;
            }
            NConf_DEBUG::open_group("lookup values", 3);
            $attr_id = db_templates("get_attr_id", "service", $change_attr);
            # get current host data
            $new_items = db_templates("get_linked_item", $host_id, $change_attr, '', 'array_2fieldsTOassoc');
            # get current service data
            $current_items = db_templates("get_linked_item", $service_id, $change_attr, '', 'array_2fieldsTOassoc');
            # diff to get items to add
            $diff_array = array_diff($new_items, $current_items);
            # diff to get items to remove
            $diff_array2 = array_diff($current_items, $new_items);
            /* debugging:
               echo "<pre>";
               var_dump($diff_array);
               var_dump($diff_array2);
               echo "</pre>";
               */
            if ($mode == "preview") {
                $preview_array[$service_id]["service_name"] = $service_name;
                $preview_array[$service_id]["attrs"][$attr_id] = array("attr_name" => $change_attr, "attr_friendly_name" => $change_attr_friendly_name, "current" => $current_items, "new" => $new_items, "differs" => !empty($diff_array) or !empty($diff_array2));
                //                $preview_array[$service_id]["attrs"][$attr_id]["differs"] = (!empty($diff_array) OR !empty($diff_array2) );
            } else {
                # make changes in the DB
                // until now, there are no such special attributes:
                //$lac_OR_bidirectional = check_link_as_child_or_bidirectional($change_attr, $class_id);
                // perhaps later there must also be this logic.
                # remove items
                if (!empty($diff_array2)) {
                    NConf_DEBUG::open_group("remove items");
                    foreach ($diff_array2 as $attr_removed_name => $attr_removed_id) {
                        $query = 'DELETE FROM ItemLinks
                                    WHERE fk_id_item=' . $service_id . '
                                        AND fk_id_attr = "' . $attr_id . '"
                                        AND fk_item_linked2 = "' . $attr_removed_id . '"
                                 ';
                        db_handler($query, "delete", 'delete linked item "' . $attr_removed_name . '"');
                        history_add("unassigned", $change_attr_friendly_name, $attr_removed_name, $service_id);
                        $edited = TRUE;
                    }
                }
                # add items
                if (!empty($diff_array)) {
                    NConf_DEBUG::open_group("add items");
                    foreach ($diff_array as $attr_add_name => $attr_add_id) {
                        $query = 'INSERT INTO ItemLinks (fk_id_item,fk_item_linked2,fk_id_attr)
                                    VALUES (' . $service_id . ',' . $attr_add_id . ', ' . $attr_id . ')';
                        db_handler($query, "insert", 'insert linked item "' . $attr_add_name . '"');
                        history_add("assigned", $change_attr_friendly_name, $attr_add_name, $service_id);
                        $edited = TRUE;
                    }
                }
            }
        }
        NConf_DEBUG::close_group(2);
        //NConf_DEBUG::open_group('history "edited" entry', 1);
        # history entry "edited"
        if ($mode == "preview") {
            # clean service if nothing will change
            if (empty($preview_array[$service_name])) {
                unset($preview_array[$service_name]);
            }
        } elseif ($edited) {
            history_add("edited", "service", $service_name, $service_id);
        }
    }
    if ($mode == "preview") {
        # print preview
        # create a table with checkboxes for applying inheritance
        $preview = NConf_HTML::table_begin('class="ui-nconf-table ui-widget ui-widget-content ui-nconf-max-width"', array('', 50, 120, 100, 100));
        $preview .= '<thead class="ui-widget-header">
                      <tr>
                        <th>service</th>
                        <th name="checkbox_toggle_all" class="center pointer">update</th>
                        <th>attribute</th>
                        <th>service value</th>
                        <th>host value</th>
                      </tr>
                     </thead>';
        $bg_class = "even";
        foreach ($preview_array as $service_id => $service) {
            $i = 0;
            $service_name = $service["service_name"];
            # handle background for each service
            if ($bg_class == "odd") {
                $bg_class = "even";
            } else {
                $bg_class = "odd";
            }
            foreach ($service["attrs"] as $attribute_id => $values) {
                $i++;
                $preview .= '<tr class="' . $bg_class . '">';
                if ($i == 1) {
                    $preview .= '<td rowspan="' . count($service["attrs"]) . '" class="align_top">' . NConf_HTML::title($service_name) . '</td>';
                }
                # check box for applying
                $preview .= '<td class="center">';
                if ($values["differs"]) {
                    $preview .= '<input type="checkbox" class="pointer" name="apply_inheritance[' . $host_id . '][' . $service_id . '][' . $values["attr_name"] . ']" value="' . $attribute_id . '" checked=checked>';
                }
                $preview .= '</td>';
                $preview .= '<td>' . $values["attr_friendly_name"] . '</td>';
                # current values
                $preview .= '<td name="checkbox_toggle"';
                // color red
                if ($values["differs"]) {
                    $preview .= ' class="red"';
                }
                $preview .= '>';
                # generate value list
                $current_values = array_flip($values["current"]);
                $preview .= implode(", ", $current_values);
                $preview .= "</td>";
                # new values
                $preview .= '<td name="checkbox_toggle"';
                // color green
                if ($values["differs"]) {
                    $preview .= ' class="bold"';
                }
                $preview .= '>';
                # generate value list
                $new_values = array_flip($values["new"]);
                $preview .= implode(", ", $new_values);
                $preview .= "</td>";
                $preview .= "</tr>";
            }
        }
        $preview .= NConf_HTML::table_end();
        return $preview;
    } elseif (!NConf_DEBUG::status('ERROR') and $mode != "preview") {
        NConf_DEBUG::set('', 'INFO', 'Successfully updated all linked services.');
    }
    return;
}
コード例 #3
0
ファイル: foot.php プロジェクト: pasichnichenko/nconf
<!-- empty clear div for space to footer (without that, it will not work correctly when footer has clear:both! -->
<div class="clearer"></div>
<div id="footer">
    <div>
        <?php 
if (NConf_DEBUG::status("INFO")) {
    echo NConf_HTML::title("Info:", 2);
    echo NConf_DEBUG::show_debug("INFO");
    echo NConf_HTML::line();
}
// Display jQuery/ajax errors
echo '<div id="jquery_error" class="ui-state-error" style="display: none">';
echo '<span style="float: left; margin-right: 0.3em;" class="ui-icon ui-icon-alert">&nbsp;</span>';
echo NConf_HTML::title("Error:", 2);
echo '</div>';
if (NConf_DEBUG::status("ERROR")) {
    echo NConf_HTML::title("Error:", 2);
    echo '<font color="red">';
    echo NConf_DEBUG::show_debug("ERROR");
    echo '</font>';
    echo NConf_HTML::line();
}
if (DEBUG_MODE == 1) {
    echo '<div id="jquery_console_parent" style="padding: 0; display: none">';
    echo NConf_HTML::swap_content('<div id="jquery_console"></div>', "<b>jQuery debugging</b>", FALSE, FALSE);
    echo '</div>';
    NConf_DEBUG::display();
}
?>

        &nbsp;
コード例 #4
0
        if ($file_content === FALSE) {
            message($error, "The config file ({$full_path}) could not be read.");
        }
    }
}
###
# Info/Warning in the top right corner
###
echo '<h2>Edit static config files</h2>';
echo '<div class="editor_info">';
if (NConf_DEBUG::status('ERROR')) {
    $title = 'WARNING';
    $content = NConf_DEBUG::show_debug('ERROR', TRUE);
    $content .= '<br>The webserver user must have write permissions for your config directory, <br>otherwise NConf cannot save your changes.';
    echo NConf_HTML::show_error($title, $content);
} elseif (NConf_DEBUG::status('INFO') and !empty($saved)) {
    $title = 'Successfully saved file';
    $content = ICON_TRUE . NConf_DEBUG::show_debug('INFO', TRUE);
    echo NConf_HTML::show_highlight($title, $content);
} else {
    $title = 'Info';
    $content = 'This mask allows administrators to modify static Nagios configuration files.';
    echo NConf_HTML::show_highlight($title, $content);
}
echo '</div>';
echo '<form name="editor" action="' . $request_url . '" method="post">

<fieldset class="inline">
<legend>choose a file</legend>
<table>
    <colgroup>
コード例 #5
0
ファイル: call_file.php プロジェクト: pasichnichenko/nconf
        } else {
            NConf_DEBUG::set($type . '-File "include/' . $type . '/' . $file_path . '" not found', 'ERROR');
        }
    }
}
# get also the debug informations
if ($debug == 'yes' and $json == 'no') {
    $title = 'Load file "' . $file_path . '" @ ' . date("H:i:s");
    // set ERROR
    if (NConf_DEBUG::status('ERROR')) {
        echo '<div id="ajax_error">';
        echo NConf_DEBUG::show_debug('ERROR', TRUE);
        echo '</div>';
    }
    // set DEBUG
    if (NConf_DEBUG::status('DEBUG')) {
        echo '<div id="ajax_debug">';
        echo NConf_HTML::swap_content(NConf_DEBUG::show_debug('DEBUG', TRUE), $title, FALSE, FALSE, 'color_list3');
        echo '</div>';
    }
    if (!empty($ajax) and $ajax == 'yes') {
        ?>
        <!-- jQuery part -->
        <script type="text/javascript">
            $(document).ready(function(){
                // fetch ERROR part and give to footer and display it
                $("#jquery_error").append( $("#ajax_error") );
                $("#ajax_error").parent("#jquery_error").show("blind");

                // fetch DEBUG part and give to footer (will be displayed if debug is enabled)
                $("#ajax_debug").prependTo( $("#jquery_console") );
コード例 #6
0
ファイル: head.php プロジェクト: pasichnichenko/nconf
                    <br>- INSTALL.php
                    <br>- UPDATE
                    <br>- UPDATE.php
                    <br>
                ');
    } else {
        # config not available, first run INSTALL.php
        require_once NCONFDIR . "/include/menu/menu_start.html";
        require_once NCONFDIR . "/include/menu/menu_install.php";
        require_once NCONFDIR . "/include/menu/menu_end.php";
        echo '<div id="maincontent">';
        message($critical, 'Setup required. To install NConf <b><a href="INSTALL.php">click here</a></b><br>');
    }
}
# Check for critical error, continue or abort
if (NConf_DEBUG::status('CRITICAL')) {
    $msg_critical = NConf_DEBUG::show_debug('CRITICAL');
    echo NConf_HTML::show_error('Error', $msg_critical);
    require_once NCONFDIR . '/include/foot.php';
    exit;
}
###
## Page authorisation check
###
require_once NCONFDIR . '/include/access_rules.php';
# Show page or EXIT the script ? (based on above auth-checks)
if ($NConf_PERMISSIONS->checkPageAccess() === TRUE and $NConf_PERMISSIONS->checkIdAuthorization() !== FALSE) {
    NConf_DEBUG::set("Access granted", 'DEBUG', "ACL");
    # go ahead in file
} elseif (!isset($_SESSION["group"]) and empty($_GET["goto"])) {
    # not logged in