public function run_deployment() { if (!ALLOW_DEPLOYMENT) { echo NConf_HTML::limit_space(NConf_HTML::show_error('ERROR', 'Deployment functionality is currently disabled.')); } elseif (ALLOW_DEPLOYMENT && (!ALLOW_DIRECT_DEPLOYMENT && empty($_POST["status"]))) { echo NConf_HTML::limit_space(NConf_HTML::show_error('ERROR', 'Please first run the "Generate Nagios config".')); } elseif (ALLOW_DEPLOYMENT && ALLOW_DIRECT_DEPLOYMENT || ALLOW_DEPLOYMENT && (!ALLOW_DIRECT_DEPLOYMENT && (!empty($_POST["status"]) && $_POST["status"] == "OK"))) { echo NConf_HTML::table_begin('class="table_checks"', array(170, 50, '')); // DEPLOY // First do the local module $local_module = $this->modules["local"]; if ($local_module->configured()) { NConf_DEBUG::set('', 'DEBUG', 'Deploying ' . $local_module->name); echo NConf_HTML::table_row_text(NConf_HTML::title($local_module->name, '', 'class="content_header"')); NConf_DEBUG::set($local_module->destinations, 'DEBUG', $local_module->name); $local_module->deploy(); echo NConf_HTML::table_row_text(NConf_HTML::line(), '', 'colspan=3'); } // Then do all other modules if they are configured foreach ($this->modules as $module) { // Dont do the "local" module // Check also if module is configured if ($module->name == "local" or !$module->configured()) { continue; } NConf_DEBUG::set('', 'DEBUG', 'Deploying ' . $module->name); echo NConf_HTML::table_row_text(NConf_HTML::title($module->name, '', 'class="content_header"')); NConf_DEBUG::set($module->destinations, 'DEBUG', $module->name); // run the deploy $module->deploy(); echo NConf_HTML::table_row_text(NConf_HTML::line(), '', 'colspan=3'); } echo NConf_HTML::table_end(); } else { echo NConf_HTML::text('Deployment is enabled, but your configuration seems to have errors.', TRUE, 'div', 'class="attention"'); } }
}); </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>';
# Show class selection $show_class_select = "yes"; if (isset($_GET["class"])) { $class = $_GET["class"]; } else { $class = "host"; } // Page output begin echo NConf_HTML::title('Show attributes: ' . $class); $content = 'This mask allows administrators to modify the data schema of the NConf application. There is no need to make any changes to the schema for ordinary operation. Users are strictly discouraged from changing any attribute names, datatypes, from modifying classes in any way, and from any other changes to the schema. Disregarding this may result in unexpected behavour of the application, failure to generate the Nagios configuration properly and may under certain circumstances <b>result in data corruption or loss!</b>'; echo NConf_HTML::limit_space(NConf_HTML::show_error('WARNING', $content), 'style="float: right; width: 555px;"'); echo '<form name="filter" action="' . $request_url . '" method="get"> <fieldset class="inline"> <legend>Select class</legend> <table>'; // Class Filter if (isset($show_class_select)) { echo '<tr>'; $result = db_handler('SELECT config_class FROM ConfigClasses ORDER BY config_class', "result", "Get Config Classes"); echo '</tr>'; echo '<tr>'; echo '<td><select name="class" style="width:192px" onchange="document.filter.submit()">'; //echo '<option value="">'.SELECT_EMPTY_FIELD.'</option>'; while ($row = mysql_fetch_row($result)) { echo "<option value={$row['0']}"; if (isset($class) and $row[0] == $class) {
?> </td> </tr> <tr> <td> <table> <tr> <td width="600" colspan=2> <?php if (isset($_SESSION["group"])) { # This will only be displayed on the main "home" page (when authenticated) echo VERSION_STRING . "<br><br>"; echo COPYRIGHT_STRING . "<br>"; if (constant("VERSION_NOT_FINAL_WARNING") !== '') { echo "<br>"; echo NConf_HTML::limit_space(NConf_HTML::show_error('Attention', VERSION_NOT_FINAL_WARNING)); } # new nconf version info if (defined('CHECK_UPDATE') and CHECK_UPDATE == 1 and $_SESSION["group"] == "admin") { echo '<script src="include/js/jquery_plugins/jquery.nconf_check_update.js" type="text/javascript"></script>'; echo js_prepare(' $(document).ready(function(){ $.nconf_check_update("' . VERSION_NUMBER . '"); }); '); # html container echo "<br>"; echo '<div id="check_update" style="display:none">'; echo NConf_HTML::limit_space(NConf_HTML::show_highlight('<span id="check_update_title"></span>', '<div id="check_update_content"></div>')); echo '</div>'; }
if ($deployment_info) { $content = 'The generated configuration has been written to the "nconf/output/" directory.<br> To set up more sophisticated deployment functionality, please edit your "config/deployment.ini" file accordingly.<br> For a complete list of available deployment options, refer to the online documentation on <a href="http://www.nconf.org" target="_blank">www.nconf.org</a>.'; system("bash /var/www/nconf/ADD-ONS/deploy_local.sh"); echo NConf_HTML::limit_space(NConf_HTML::show_highlight('Note', $content)); } else { // Show deployment button echo "<form method=\"POST\" action=\"call_file.php?module_file=deployment/main.php\" id=buttons>"; echo '<input type=hidden name=status value="' . $status . '">'; echo '<br><input type="submit" name="submit" value="Deploy" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only">'; echo "</form><br>"; } } else { // Simply show success message echo "<b>Changes updated successfully.</b><br><br>"; } } else { history_add("general", "config", "generate failed with syntax errors"); // Remove generated config - syntax check has failed if (DEBUG_MODE == 1) { // Move generated config to "output" dir, but tag it as FAILED system("mv " . NCONFDIR . "/temp/NagiosConfig.tgz " . NCONFDIR . "/output/NagiosConfig_FAILED.tgz." . time()); } // Remove generated config system("rm -rf " . NCONFDIR . "/temp/*"); $content = "Deployment not possible due to errors in configuration."; echo NConf_HTML::limit_space(NConf_HTML::show_error('Error', $content)); } mysql_close($dbh);
# get host name of service $hostID = db_templates("hostID_of_service", $item_ID); $hostname = db_templates("naming_attr", $hostID); $name = $hostname . ":" . $name; } if (!empty($name) or $name === "0") { $content .= "<li>{$name}</li>"; } } $content .= '</ul>'; echo '<br>'; echo '<div id="info_box">'; $title = 'Old value will be overwritten for the following item(s):'; echo NConf_HTML::limit_space(NConf_HTML::show_highlight($title, $content)); echo '</div>'; } echo '</form>'; } if (NConf_DEBUG::status('ERROR')) { echo NConf_HTML::show_error(); } // Run the Autocomplete function if (isset($prepare_status) and $prepare_status == 1) { # only run if prepare was ok js_Autocomplete_run('email', 'emaillist'); js_Autocomplete_run('pager', 'pagerlist'); } # close content box echo '</div>'; mysql_close($dbh); require_once 'include/foot.php';
echo '<br>'; echo '<div>'; echo '<button id="clone" class="ui-buttonset">clone services</button>'; /* echo '<a id="clone" href="#"> clone services </a>';*/ if (!empty($_SESSION["go_back_page"])) { $link = $_SESSION["go_back_page"]; } else { $link = "index.php"; } echo '<a id="continue" href="' . $link . '">continue</a>'; echo '<br><br>'; echo '<div id="clone_error" style="display: none;">'; echo NConf_HTML::show_error('Error:', '<span id="clone_error_content"></span>'); echo '</div>'; echo '<div id="feedback" style="display: none;">'; echo '<div style="width: 300px">'; echo '<h2>Progress:</h2>'; echo '<div> <div id="progressbar"></div> </div>'; echo '<div style="float: left">0%</div>'; echo '<div style="float: right">100%</div>'; echo '</div>'; echo '<div style="clear: both;"></div>'; echo '<br><h2 class="ui-nconf-header ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix">Feedback:</h2>'; echo '<div id="clone_feedback" class="ui-nconf-content ui-widget-content ui-corner-bottom" style="display: none;"></div>'; echo '</div>'; echo '
}); </script> <?php // Page output begin // set width of following divs echo '<div style="width: 535px">'; echo NConf_HTML::title('Show classes'); echo "<br>"; $content = 'This mask allows administrators to modify the data schema of the NConf application. There is no need to make any changes to the schema for ordinary operation. Users are strictly discouraged from changing any attribute names, datatypes, from modifying classes in any way, and from any other changes to the schema. Disregarding this may result in unexpected behavour of the application, failure to generate the Nagios configuration properly and may under certain circumstances <b>result in data corruption or loss!</b>'; echo NConf_HTML::show_error('WARNING', $content); // Attr manipulation if (isset($_GET["do"])) { if ($_GET["do"] == "up") { class_order($_GET["id"], "up"); } elseif ($_GET["do"] == "down") { class_order($_GET["id"], "down"); } } echo "<br>"; // for user and admin navigation $nav_tree = array("user", "admin"); foreach ($nav_tree as $nav_priv) { echo '<h2 class="content_header">' . ucfirst($nav_priv) . ' classes:</h2>'; $query = 'SELECT * FROM ConfigClasses WHERE nav_privs = "' . $nav_priv . '" ORDER BY grouping, ordering ASC, config_class'; $result = db_handler($query, "result", "ConfigClasses");
$file_content = @file_get_contents($full_path); 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>
$oncall_check = oncall_check(); } } # Check mandatory fields while ($attr = each($_POST)) { if (is_int($attr["key"])) { # Check mandatory fields $m_array = db_templates("mandatory", $config_class, $attr["key"]); if (check_mandatory($m_array, $_POST) == "no") { $write2db = "no"; } } } # Give error message if oncall or mandatory check fails if (isset($oncall_check) and $oncall_check === FALSE or isset($write2db) and $write2db == "no") { $content = NConf_HTML::show_error(); $content .= "<br><br>"; $content .= NConf_HTML::back_button($_SESSION["go_back_page"]); echo NConf_HTML::limit_space($content); // Cache $_SESSION["cache"]["use_cache"] = TRUE; foreach ($_POST as $key => $value) { $_SESSION["cache"]["handle"][$key] = $value; } mysql_close($dbh); require_once 'include/foot.php'; exit; } # clean existing cache if (isset($_SESSION["cache"]["handle"])) { unset($_SESSION["cache"]["handle"]);
### 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 # Go to login page, and redirect it to called page $url = 'index.php?goto=' . urlencode($_SERVER['REQUEST_URI']); # Redirect to login page with url as goto echo '<meta http-equiv="refresh" content="0; url=' . $url . '">'; message($info, '<b>redirecting to:</b> <a href="' . $url . '"> [ this page ] </a>'); require_once NCONFDIR . '/include/foot.php'; exit; } elseif (!isset($_SESSION["group"]) and !empty($_GET["goto"])) { # do nothing, login page will be displayed message($debug, "display login page"); } else { $message = $NConf_PERMISSIONS->message; NConf_DEBUG::set($message, 'INFO'); NConf_DEBUG::set("Access denied", 'DEBUG', "ACL"); //echo $message; echo NConf_HTML::limit_space(NConf_HTML::show_error('Error', $message)); require_once NCONFDIR . '/include/foot.php'; # EXIT because of no access exit; } # close header-part in DEBUG section $debug_entry = NConf_HTML::line() . NConf_HTML::text("Page specific debugging:", FALSE, 'b'); NConf_DEBUG::set($debug_entry);