function remove_lock() { # remove lock file global $lock_file; $unlink_status = unlink($lock_file); if (!$unlink_status) { NConf_DEBUG::set('removing old lock failed', 'ERROR'); } }
function __autoload($class_name) { $class_path = NCONFDIR . '/include/classes/class.' . $class_name . '.php'; if (!empty($class_name) && file_exists($class_path)) { #include(NCONFDIR.'/include/classes/class.'.$class_name.'.php'); require_once $class_path; NConf_DEBUG::set("class {$class_name}", 'DEBUG', 'Autoload'); } }
function table_output($result, $item_class = '', $title = '', $level = 0) { # template cache for detect previouse loaded template global $template_cache; # the local template cache is for detecting endless loops global $template_cache_local; # handling the local template cache #reseting it if level is 0 if ($level == 0) { $template_cache_local = array(); } elseif ($level == 20) { # this is a hardcoded loop stopper, should come into action, but prevents that the page will endless load # normaly there will never be templates on 20 level inherited return; } # output will catch the content until return $output = ''; if (!empty($result)) { if (is_array($result) and !empty($result) and !empty($title)) { $output .= '<tr><td colspan=2><br>'; if ($item_class == 'template_inheritance') { $output .= '<b>inherited from</b> ' . $title; } else { $output .= '<b>' . $title . '</b>'; } $output .= '</td></tr>'; } $last_fname = ''; foreach ($result as $entry) { if (!empty($entry["config_class"]) and $entry["config_class"] == "service") { $host_query = 'SELECT attr_value AS hostname FROM ConfigValues,ConfigAttrs,ConfigClasses,ItemLinks WHERE fk_item_linked2=ConfigValues.fk_id_item AND id_attr=ConfigValues.fk_id_attr AND naming_attr="yes" AND fk_id_class = id_class AND config_class="host" AND ItemLinks.fk_id_item=' . $entry["item_id"]; $hostname = db_handler($host_query, "getOne", "Get linked hostnames (if service)"); } if (!empty($entry["friendly_name"])) { $group_name = $entry["friendly_name"]; } // group same attributes if (!empty($group_name) and $last_fname != $group_name) { $show_fname = $group_name; //$bgcolor = 'class="color_list2"'; } else { $show_fname = ''; } $output .= '<tr>'; //$output .= '<td '.$bgcolor.'>'.$show_fname.'</td>'; $output .= '<td class="color_list2">' . $show_fname . '</td>'; # print template (and detect repetitive) if ($item_class == 'template_inheritance') { $template_status = apply_template($template_cache, $entry["item_id"]); $local_template_status = apply_template($template_cache_local, $entry["item_id"]); NConf_DEBUG::set($local_template_status, 'DEBUG', "local repetitive status"); NConf_DEBUG::set($template_cache_local, 'DEBUG', "local template cache"); } else { $template_status = FALSE; $local_template_status = FALSE; } if (!empty($entry["config_class"]) and $entry["config_class"] == "service" && $item_class != "host") { $output .= '<td class="color_list1 highlight">'; $output .= '<a href="detail.php?id=' . $entry["item_id"] . '">'; $output .= $hostname . ': ' . $entry["attr_value"]; $output .= '</td>'; } else { $level_label = ''; for ($i = $level; $i > 1; $i--) { $level_label .= '<div style="width: 9px; display: inline-block;"></div>'; } if ($i == 1 and $level != 0) { ## add a mark $level_label .= '<span class="link_with_tag2"></span>'; } # mark previously applied templates if ($template_status === "repetitive") { # detect previously applied or template loop if ($local_template_status === "repetitive") { # endless loop $repetitive_text = "(circular template chain detected)"; $class = "ui-state-error highlight"; } else { $repetitive_text = "(previously applied)"; $class = "color_list1 highlight"; } $output .= '<td class="' . $class . '">'; $output .= $level_label . '<a href="detail.php?id=' . $entry["item_id"] . '">'; $output .= $entry["attr_value"] . '</a>'; $output .= '<span id="' . $entry["item_id"] . '" class="previously_applied" style="float: right;"><i>' . $repetitive_text . '</i></span>'; $output .= '</td>'; } else { # set id for coming repetitive if ($item_class == 'template_inheritance') { $output .= '<td id="' . $entry["item_id"] . '_first" class="color_list1 highlight">'; } else { $output .= '<td class="color_list1 highlight">'; } if (!empty($entry["item_id"])) { $output .= $level_label; $output .= '<a href="detail.php?id=' . $entry["item_id"] . '">'; $output .= $entry["attr_value"] . '</a>'; } else { $output .= $entry["attr_value"]; } $output .= '</td>'; } } $output .= '</tr>'; if (!empty($group_name)) { $last_fname = $group_name; $show_fname = ''; $bgcolor = ''; } # lookup template himself if ($item_class == 'template_inheritance') { if ($local_template_status === "repetitive") { NConf_DEBUG::set('', 'DEBUG', 'template is repetitive, stopping inheritance to prevent endless loop'); } else { $template_on_template = db_templates("template_inheritance_direct", $entry["item_id"]); if (!empty($template_on_template)) { //$output .= '<tr><td colspan=2><br><b>directly linked to service</b></td></tr>'; $output .= table_output($template_on_template, 'template_inheritance', '', ++$level); } } } } } return $output; }
} else { message($error, 'Error while linking ' . $id_1 . ' with ' . $id_2 . ':' . $query); if ($handle_action == "multimodify") { $info_summary["failed"][] = $name; } } } } else { if ($vice_versa_exists !== 0) { // Item is already linked (vice versa) NConf_DEBUG::set("already linked", 'DEBUG', "Skiping item"); if ($handle_action == "multimodify") { $info_summary["ignored"][] = $name; } } elseif ($links_himself === TRUE) { NConf_DEBUG::set("cannot link item with himself", 'DEBUG', "Skiping item"); if ($handle_action == "multimodify") { $info_summary["ignored"][] = $name; } } } } # increase assign_cust_order if needed if ($attr_datatype == "assign_cust_order") { $cust_order++; } } } else { # Lookup datatype $query = 'SELECT ConfigValues.attr_value, ConfigAttrs.datatype FROM `ConfigAttrs`, ConfigValues WHERE ConfigAttrs.id_attr = "' . $attr["key"] . '"
NConf_DEBUG::set(" should be available in " . (600 - $lock_file_age) . " seconds", '', 'Next execution'); NConf_DEBUG::set("Remove the 'generate.lock' in the 'temp' directory", '', 'Force remove lock?'); # check if file is older than 10min(600sec) so replace it (should not be, because file will be removed) # but this will prevent lock file to stay there if ($lock_file_age < 600) { # some one other is generating the config NConf_DEBUG::set('Someone else is already generating the configuration.', 'ERROR'); # close page and cancel action if (NConf_DEBUG::status('ERROR')) { echo NConf_HTML::exit_error(); } } else { # remove lock file $unlink_status = unlink($lock_file); if (!$unlink_status) { NConf_DEBUG::set('removing old lock failed', 'ERROR'); } } # if file is older, script will continue, and try to get lock again } # create lock $generate_lock_handle = fopen($lock_file, 'w'); $status = flock($generate_lock_handle, LOCK_EX | LOCK_NB); //lock the file ?> <!-- jQuery part --> <script type="text/javascript"> // jQuery execute generate $(document).ready(function(){
if ($userattrs_result["count"] == 1) { $_SESSION['group'] = GROUP_USER; NConf_DEBUG::set('', 'INFO', $_SESSION["group"] . ' access granted'); } else { NConf_DEBUG::set(TXT_LOGIN_NOT_AUTHORIZED, 'ERROR'); } } } # Users Infos # get Welcome name if (AUTH_FEEDBACK_AS_WELCOME_NAME == 1 and !empty($userattrs_result[0][AD_USERNAME_ATTRIBUTE][0])) { $_SESSION["userinfos"]["username"] = $userattrs_result[0][AD_USERNAME_ATTRIBUTE][0]; } else { $_SESSION["userinfos"]['username'] = $user_loginname; } } else { NConf_DEBUG::set("Can not connect to active directory server", 'DEBUG', 'ldap bind'); NConf_DEBUG::set(ldap_error($ldapconnection), 'DEBUG', "error message"); NConf_DEBUG::set(TXT_LOGIN_FAILED, 'ERROR'); } } else { # no AUTH TYPE matched.. cant login : NConf_DEBUG::set("No authentication type set in config, login restricted", 'ERROR'); } // Log to history if (!empty($_SESSION["group"])) { history_add("general", "login", "access granted (" . $_SESSION['group'] . ")"); } else { history_add("general", "login", "access denied (user: "******")"); } NConf_DEBUG::close_group();
$entries[] = array("id" => $id, "name" => $item_name, "title" => $item_class . ": ", "status" => "open", "childs" => $services); } else { # for single (any other) classes $entries[] = array("id" => $id, "name" => $item_name, "title" => $item_class . ": ", "type" => $item_class); } } } //foreach # service deletion: sort the array on hostnames ksort($entries); # Modify text on top tree element (root) when deleting services if ($item_class == "service") { $items = "services"; } else { $items = "items"; } $tree_view = array("root" => array("id" => "root", "status" => 'open', "name" => "The following {$items} will be deleted", "type" => "parent", "childs" => $entries)); # display tree echo '<br><div>'; displayTree_list($tree_view); echo '</div>'; } else { NConf_DEBUG::set("No item to delete", "ERROR"); } if (NConf_DEBUG::status('ERROR')) { echo NConf_HTML::limit_space(NConf_HTML::show_error()); echo "<br><br>"; echo NConf_HTML::back_button($_SESSION["go_back_page"]); } mysql_close($dbh); require_once 'include/foot.php';
case "entryname ASC": NConf_DEBUG::set(CHECKCOMMAND_ORDER_COMMAND_NAME_ASC, 'INFO', CHECKCOMMAND_ORDER_PRETEXT); $order_value = 'entryname DESC'; break; case "entryname DESC": NConf_DEBUG::set(CHECKCOMMAND_ORDER_COMMAND_NAME_DESC, 'INFO', CHECKCOMMAND_ORDER_PRETEXT); $order_value = 'sorting ASC, entryname ASC'; $ordering_default_service_name = TRUE; break; case "sorting ASC, entryname ASC": NConf_DEBUG::set(CHECKCOMMAND_ORDER_DEFAULT_SERVICE_NAME_ASC, 'INFO', CHECKCOMMAND_ORDER_PRETEXT); $order_value = 'sorting DESC, entryname DESC'; $ordering_default_service_name = TRUE; break; case "sorting DESC, entryname DESC": NConf_DEBUG::set(CHECKCOMMAND_ORDER_DEFAULT_SERVICE_NAME_DESC, 'INFO', CHECKCOMMAND_ORDER_PRETEXT); $order_value = 'entryname ASC'; break; } } elseif ($class == "service") { $order_value = (!empty($order) and $order == "hostname ASC, entryname ASC") ? 'hostname DESC, entryname DESC' : 'hostname ASC, entryname ASC'; } else { $order_value = (!empty($order) and $order == "entryname ASC") ? 'entryname DESC' : 'entryname ASC'; } echo '<td> <a href="' . $request_url4ordering . '&order=' . $order_value . '">' . $entry["friendly_name"] . '</a></td>'; } if ($class == "host") { $order_value = $order == "BIN_IP ASC" ? 'BIN_IP DESC' : 'BIN_IP ASC'; echo '<td width=100> <a href="' . $request_url4ordering . '&order=' . $order_value . '">' . FRIENDLY_NAME_IPADDRESS . '</a></td>';
public final function import_config() { // parse config file to array if (is_readable($this->config_path)) { $ini_array = parse_ini_file($this->config_path, TRUE); if (!empty($ini_array)) { NConf_DEBUG::set($ini_array, "DEBUG", "Loaded " . $this->config_path); // handle each config group foreach ($ini_array as $config_group_name => $config_group) { // get type and unset type in config array $type = $config_group["type"]; unset($config_group["type"]); // If titel is unset, set the groupname for it if (empty($config_group["title"])) { $config_group["title"] = $config_group_name; } // import config to its module if (class_exists($type, false)) { $this->modules[$type]->import($config_group); } else { NConf_DEBUG::set("Configuration error, this type of deployment is not available", 'ERROR', $type); } } } else { NConf_DEBUG::set($this->config_path, 'ERROR', 'Configuration is empty, please check your configuration file and read the documentation: '); } } else { NConf_DEBUG::set($this->config_path, 'ERROR', 'Could not read configuration file: '); } }
if (is_int($attr["key"])) { // add attribute add_attribute($id, $attr["key"], $attr["value"]); } } //// // Handle not visible attributes // lookup visible=no attributes $attrs_visible_no = read_attributes($config_class, 'no'); // add attributes (visible=no) foreach ($attrs_visible_no as $attribute_key => $attribute_value) { NConf_DEBUG::set($attribute_key . " -> " . $attribute_value, 'DEBUG', "Add attribute"); $result = add_attribute($id, $attribute_key, $attribute_value); } if (DB_NO_WRITES != 1) { NConf_DEBUG::set('Successfully added <b>' . escape_string($_POST[$id_naming_attr]) . '</b>', 'INFO'); } # cache if (isset($_SESSION["cache"]["modify"])) { unset($_SESSION["cache"]["modify"]); } if ($config_class == "host") { $_SESSION["created_id"] = $id; $step2 = "yes"; } if ($id) { $_SESSION["created_id"] = $id; } } } # end of write2db
ConfigValues.fk_id_item AS id, attr_value AS entryname, (SELECT attr_value FROM ConfigValues,ConfigAttrs WHERE id_attr=fk_id_attr AND attr_name="service_enabled" AND fk_id_item=id) AS service_enabled FROM ConfigValues, ConfigAttrs, ConfigClasses, ItemLinks WHERE id_attr = ConfigValues.fk_id_attr AND naming_attr = "yes" AND id_class = fk_id_class AND config_class = "advanced-service" AND ConfigValues.fk_id_item = ItemLinks.fk_id_item AND fk_item_linked2 = ' . $host_id . ' ORDER BY entryname '; $old_linked_data[$attribute_id] = db_handler($query, "array_direct", "Get advanced-service of host with its service_enabled status"); NConf_DEBUG::set($advanced_services, 'DEBUG', "send items"); $class_id = db_templates("get_id_of_class", "advanced-service"); $name = db_templates("naming_attr", $id); # history entry status for "edited" $edited = FALSE; $handle_action = 'modify'; $items2write = $advanced_services; # special case for advanced_services ! # items_write2db will look for $advanced_services and use the "bidirection/child" feature, to swap the data require_once 'include/items_write2db.php'; // needs $items2write if (!NConf_DEBUG::status('ERROR')) { echo '<div id="modify_success">' . $edited . '</div>'; }
# special # its riski to allow to multimodify the check_command of mutliple (perhaps different) services # perhaps more checks are needed here $service_items = explode(",", $id_items); $command_param_count_array = array(); $most_counts = 0; foreach ($service_items as $service_item) { $temp_check_command_id = db_templates("get_checkcommand_of_service", $service_item); $command_param_count = db_templates("get_command_param_count_of_checkcommand", $temp_check_command_id); $command_param_count_array[] = $command_param_count; if ($command_param_count > $most_counts) { $most_counts = $command_param_count; $check_command_id = $temp_check_command_id; } } NConf_DEBUG::set($command_param_count_array, "DEBUG", "Command param counters"); # check if count is different for selected services $command_param_count_unique = array_unique($command_param_count_array); if (count($command_param_count_unique) > 1) { $warning_check_command_arguments = TXT_MULTIMODIFY_PARAMS_OF_CHECK_COMMAND_DIFFER; } $command_param_count = $most_counts; } if ($command_param_count == "0") { # no command syntax if param count == 0 # display no attribute but value of hidden attribute must be "!" echo ' <td> <input name="' . $entry["id_attr"] . '" type="hidden" value="!"> </td>'; # continue with next attribute (normaly these are bidirectional ones, param count is the last of normal attributes)
# require_once NCONFDIR . '/include/includeAllClasses.php'; # # mysql-DB settings # require_once NCONFDIR . '/config/mysql.php'; # # mysql Initiate connection # $dbh = mysql_connect(DBHOST, DBUSER, DBPASS); mysql_select_db(DBNAME); # # some misc gui things # require_once NCONFDIR . '/include/gui.php'; # # part for messages # require_once NCONFDIR . '/include/messages.php'; ## ## LOAD Functions ## require_once NCONFDIR . '/include/functions.php'; ## ## start debug info ## NConf_DEBUG::set('', 'DEBUG', 'Header / ACL / navigation debugging'); ## ## LOAD Modules ## require_once NCONFDIR . '/include/modules.php';
$filename = $path_parts['basename']; $dirname = $path_parts['dirname']; NConf_DEBUG::set($file_path, 'DEBUG', 'call ' . $type . '-file'); # Do not allow to go out of directory if ($dirname and stristr($dirname, '..')) { NConf_DEBUG::set('Its not allowed to go out of the directory or having ".." in the file path ("' . $dirname . '")', 'ERROR'); $path = realpath($file_path); } else { if (!$file_path) { NConf_DEBUG::set('No File given', 'ERROR'); } elseif (file_exists('include/' . $type . '/' . $file_path)) { # file found, load it NConf_DEBUG::set('Loading ' . $type . '-File "include/' . $type . '/' . $file_path . '"', 'DEBUG', 'call_file'); require_once 'include/' . $type . '/' . $file_path; } 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">';
$result = db_handler($query, "insert", "clone items linked as child of original service onto new service"); # HISTORY add :linked as child items $query = 'SELECT fk_id_item,fk_id_attr,cust_order FROM ItemLinks WHERE fk_item_linked2 = ' . $service_tpl["fk_id_item"] . ' ORDER BY fk_id_item'; $linkedAsChild_items = db_handler($query, "array", "for history: get linked as child items"); foreach ($linkedAsChild_items as $entry) { history_add("assigned", $entry["fk_id_attr"], $new_service_id, $entry["fk_id_item"], "resolve_assignment"); } # feedback for clone2hosts if ($_POST["action"] == "clone2hosts") { $host_name = db_templates("get_value", $destination_host_id, "host_name"); $host_link = '<a href="modify_item_service.php?id=' . $destination_host_id . '"><span class="link_with_tag">' . $host_name . '</span></a>'; NConf_DEBUG::set("<i>" . $new_service_name . "</i>", 'INFO', $host_link); if (NConf_DEBUG::status('ERROR')) { $service_link = '<a href="detail.php?id=' . $new_service_id . '" target="_blank" class="link_with_tag">' . $new_service_name . '</a>'; NConf_DEBUG::set($service_link, 'ERROR', "failed with service"); } } } if ($_POST["action"] == "cloneONhost") { // give new ID back echo '<div id="clone_success">' . $new_service_id . '</div>'; } } # output for clone2hosts if ($_POST["action"] == "clone2hosts") { $source_service_name = db_templates("get_value", $_POST["service_id"], "service_description"); if (NConf_DEBUG::status('ERROR')) { # error $feedback = "Failed, see debug for details."; echo '<div id="clone_error">' . $feedback;
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);
<?php if (empty($_POST["host_id"])) { NConf_DEBUG::set("failed, received not all required infos", 'ERROR'); exit; } $host_ID = $_POST["host_id"]; // mark added services $added_service[] = !empty($_POST["highlight_service"]) ? $_POST["highlight_service"] : array(); # get class or take service as default if (!empty($_POST["class"])) { $class = $_POST["class"]; } else { $class = "service"; } if ($class == "advanced-service") { $list_title = 'Unassign an advanced service from this host<br>'; } elseif ($class == "hostgroup_service") { $list_title = ' List of advanced services inherited over hostgroups<br>'; } elseif ($class == "service") { $list_title = ' Edit services directly linked to a host<br>'; } //// // Content of Page //// echo '<div id="content">'; echo $list_title; if ($class == "service") { echo '<table class="ui-widget ui-nconf-table" width="328">'; echo '<colgroup>'; echo '<col width="30">';
<?php require_once 'include/head.php'; //set_page(); # Get ID if (!empty($_REQUEST["id"])) { $id = $_REQUEST["id"]; } else { NConf_DEBUG::set("No id", 'ERROR'); } #determine if class or attribute if (!empty($_REQUEST["type"])) { $type = $_REQUEST["type"]; } else { NConf_DEBUG::set("This type does not exist", 'ERROR'); } // end / exit page if error if (NConf_DEBUG::status('ERROR')) { echo NConf_HTML::exit_error(); } if ($type == "class") { ######################################## ## configure user friendly names here ## ######################################## $user_friendly_names = array("id_attr" => "Attribute ID", "id_class" => "Class ID", "attr_name" => "Nagios-specific attribute name", "config_class" => "Nagios-specific class name", "friendly_name" => "Friendly name (shown in GUI)", "description" => "description, example or help-text", "datatype" => "Data type", "max_length" => "max. text-field length (chars)", "poss_values" => "Possible values", "predef_value" => "Predefined value", "mandatory" => "Is attribute mandatory", "ordering" => "Ordering position", "nav_visible" => "Is Class visible in Navigation", "visible" => "Is attribute visible", "write_to_conf" => "write attribute to configuration", "naming_attr" => "naming attribute", "link_as_child" => "link selected item(s) as children", "fk_show_class_items" => "items of class to be assigned", "fk_id_class" => "attribute belongs to class", "grouping" => "Navigation Group", "nav_links" => "Configure Links", "nav_privs" => "Viewable by", "out_file" => "generated filename", "nagios_object" => "Nagios object definition"); ######################################## ######################################## $HTTP_referer = 'show_class.php'; #query $query = 'SELECT * FROM ConfigClasses WHERE id_class = ' . $id; } elseif ($type == "attr") {
// after echo because we want the redirect only in the footer NConf_DEBUG::set('<a href="' . $url . '"> add services </a>', 'INFO', "<br>redirecting to"); } else { // normal way to add items if (isset($_SESSION["cache"]["handle"])) { unset($_SESSION["cache"]["handle"]); } if (NConf_DEBUG::status('ERROR')) { echo NConf_HTML::show_error(); echo "<br><br>"; echo NConf_HTML::back_button($_SESSION["go_back_page"]); // Cache $_SESSION["cache"]["use_cache"] = TRUE; foreach ($_POST as $key => $value) { $_SESSION["cache"]["handle"][$key] = $value; } } else { // Item added, go back to overview of its class $url = 'overview.php?class=' . $config_class; echo '<meta http-equiv="refresh" content="' . REDIRECTING_DELAY . '; url=' . $url . '">'; // add extra line (br) for more space echo NConf_DEBUG::show_debug('INFO', TRUE); NConf_DEBUG::set('<a href="' . $url . '"> overview </a>', 'INFO', "<br>redirecting to"); } } echo ' </td> </tr> </table> '; mysql_close($dbh); require_once 'include/foot.php';
$_SESSION["cache"]["handle"][$key] = $value; } } else { if (isset($_SESSION["cache"]["handle"])) { unset($_SESSION["cache"]["handle"]); } } echo '</div>'; } elseif (isset($_POST["vererben"])) { # Handling inheritance to services inheritance_HostToService($id, 'apply_inheritance'); echo NConf_DEBUG::show_debug('INFO', TRUE); if (isset($_SESSION["go_back_page"])) { // Go to next page without pressing the button echo '<meta http-equiv="refresh" content="' . REDIRECTING_DELAY . '; url=' . $_SESSION["go_back_page_ok"] . '">'; NConf_DEBUG::set('<a href="' . $_SESSION["go_back_page_ok"] . '"> [ this page ] </a>', 'INFO', "<br>redirecting to"); } } ?> <!-- Help text content --> <div id="help_text" style="display: none"> <div id="help_inheritance" title="host / service inheritance"> <p>The host / service diff table gives you an overview of attributes being applied from a host onto its services. </p> <p> <strong>update</strong> <br>Service attributes, whose value differs from the host value, will be overwritten by default. <br>If you don't want to overwrite an attribute on the service side, disable the 'update' checkbox. </p> <p> <strong>service value</strong>
public function checkPageAccess() { # URL check $debug = NConf_HTML::swap_content($this->debug, "URL ACL feedback", FALSE, TRUE); NConf_DEBUG::set($debug, 'DEBUG', NConf_HTML::status_text("URL ACL status", $this->url_check_status)); if ($this->url_check_status === FALSE) { $this->message = "You don't have permission to access this page!"; } return $this->url_check_status; }
// foreach ($old_naming_attr_array as $attribute){ // $update_query = 'UPDATE `ConfigAttrs` SET `naming_attr` = "no" WHERE `id_attr` = '.$attribute["id_attr"]; // db_handler($update_query, "insert", "set old naming attr to 'no'"); // } // $naming_attr_message = "&naming_attr=changed"; // } //} // Go to next page without pressing the button // Delete Cache of modify (if still exist) if (isset($_SESSION["cache"]["modify_attr"])) { unset($_SESSION["cache"]["modify_attr"]); } // set go back page (show attr ) with defined class $_SESSION["go_back_page"] = 'show_attr.php?class=' . $class_name; echo '<meta http-equiv="refresh" content="' . $redirecting_delay . '; url=' . $_SESSION["go_back_page"] . $naming_attr_message . '">'; NConf_DEBUG::set('<a href="' . $_SESSION["go_back_page"] . $naming_attr_message . '"> [ this page ] (in ' . REDIRECTING_DELAY . ' seconds)</a>', 'INFO', "<br>redirecting to"); } else { echo "<h2>Failed to modify attribute "{$attr_name}"</h2>"; } } } else { # write to db if (isset($_SESSION["cache"]["modify_attr"])) { unset($_SESSION["cache"]["modify_attr"]); } if (NConf_DEBUG::status('ERROR')) { $_SESSION["cache"]["use_cache"] = TRUE; echo NConf_HTML::limit_space(NConf_HTML::show_error()); echo "<br><br>"; echo NConf_HTML::back_button($_SESSION["go_back_page"]); # Cache
} else { message($debug, '[ FAILED ]'); } //// // Add other attributes (visible=yes) foreach ($attrs_visible_yes as $attribute_key => $attribute_value) { NConf_DEBUG::set($attribute_key . " -> " . $attribute_value, 'DEBUG', "Add attribute"); $result = add_attribute($new_service_ID, $attribute_key, $attribute_value); } //// // Handle not visible attributes // lookup visible=no attributes $attrs_visible_no = read_attributes('service', 'no'); // add attributes (visible=no) foreach ($attrs_visible_no as $attribute_key => $attribute_value) { NConf_DEBUG::set($attribute_key . " -> " . $attribute_value, 'DEBUG', "Add attribute"); $result = add_attribute($new_service_ID, $attribute_key, $attribute_value); } // give feedback for jQuery // add service to list of added services echo '<div id="add_success">' . $new_service_ID . '</div>'; } // END if ( $insert ){ //NConf_DEBUG::group_end(); } // END while } else { // give feedback for jQuery echo "No service to add"; } // END is_array($_POST["checkcommands"])
function prepare_check_command_params($values) { # Implode the splitet fields (exploded in handle_item.php) if (is_array($values)) { NConf_DEBUG::open_group("params for check command"); foreach ($values as $field_key => $value_array) { # trim values NConf_DEBUG::set($value_array, '', "bevore trimming"); $value_array_trimmed = array(); foreach ($value_array as $value) { $value_array_trimmed[] = trim($value); } NConf_DEBUG::set($value_array_trimmed, '', "after trimming"); if (array_diff($value_array, $value_array_trimmed)) { NConf_DEBUG::set("trimmed check command params", 'INFO'); } # string starts with a "!" $imploded = "!"; # implode the other arguments $imploded .= implode("!", $value_array_trimmed); # Save it to the POST-var, so the var will be added later in the script $_POST[$field_key] = $imploded; } NConf_DEBUG::close_group(); } }
public final function configured() { if (!empty($this->destinations)) { return TRUE; } else { NConf_DEBUG::set('has no configuration, skipping', 'DEBUG', 'Module ' . $this->name); return FALSE; } }
# Create oncall link, if $ONCALL_GROUPS is defined if (!empty($ONCALL_GROUPS)) { array_push($user_menu_begin2, array("nav_links" => "Change on-call settings::overview.php?class=contact&xmode=pikett", "friendly_name" => "", "grouping" => "")); } # Generate Nagios config link array_push($user_menu_begin2, array("nav_links" => "Generate Nagios config::generate_config.php", "friendly_name" => "", "grouping" => "")); # create output create_menu($user_menu_begin2); ### # user navigation links of classes # Select ConfigClasses $query = 'SELECT grouping, nav_links, friendly_name FROM ConfigClasses WHERE nav_privs = "user" AND nav_visible = "yes" ORDER BY UPPER(grouping), ordering ASC, config_class'; $user_menu_end = db_handler($query, "array", "Select user Navigation classes"); /* -> this seems to be not needed anymore, it makes not correct ordering in the menu # sorts a multidimensional array (grouping) # because of manual added entries like "generate nagios config" $tmp = Array(); foreach($user_menu_end as &$ma){ $tmp[] = &$ma["grouping"]; } NConf_DEBUG::set($tmp, 'DEBUG', 'temporary'); NConf_DEBUG::set($user_menu_end, 'DEBUG', 'user_menu_end'); array_multisort($tmp, $user_menu_end); */ NConf_DEBUG::set($user_menu_end, 'DEBUG', 'Create menu user'); # Display menu create_menu($user_menu_end); echo '</div>'; // FIX menu user end //include('include/menu/static_content/menu_user_end.php'); include 'include/menu/static_content/menu_user_end.html';
$output .= '</div>'; $output .= '<div name="help_services"></div>'; $output .= '<div style="clear: both"></div>'; $output .= '<div>'; // Service select field $output .= '<fieldset class="inline">'; $output .= '<legend>Add additional services to host</legend>'; $output .= '<table>'; $output .= '<tr> <td> <select id="add_checkcommand" name="add_checkcommand">'; // create service name list (also checks for default service name) # use check_name or service_name as ordering $service_order = "check_name"; $service_names = db_templates('get_name_of_services', '', $service_order); NConf_DEBUG::set($service_names, 'DEBUG', " get service names for add selection"); foreach ($service_names as $checkcommand) { if (!empty($checkcommand["default_service_name"])) { if ($service_order == "check_name") { $output .= '<option value=' . $checkcommand["item_ID"] . '>' . $checkcommand["check_name"] . ' (' . $checkcommand["default_service_name"] . ')</option>'; } else { $output .= '<option value=' . $checkcommand["item_ID"] . '>' . $checkcommand["default_service_name"] . ' (' . $checkcommand["check_name"] . ')</option>'; } } elseif (!empty($checkcommand["check_name"])) { $output .= '<option value=' . $checkcommand["item_ID"] . '>' . $checkcommand["check_name"] . '</option>'; } } $output .= "</select>"; $output .= '</td>'; $output .= '<td>'; $output .= '<button id="add"></button>';