} else { #entry not existing, lets try to modify: if ($config_class == "host") { # Vererben ? $vererben1_result = db_templates("vererben", $id); while ($row = mysql_fetch_assoc($vererben1_result)) { $vererben1[$row["item_id"]] = $row["attr_name"]; } } ?> <table> <tr> <td> <?php # Check mandatory fields NConf_DEBUG::open_group("check mandatory"); $m_array = db_templates("mandatory", $config_class); # special case for # - class: service # - attributes: checkcommand and hostname # they will not be editable on "modify" so do not make theme mandatory if ($config_class == "service") { # get id of attr check_command and host_name $check_command_attr_id = db_templates("get_attr_id", $config_class, "check_command"); $host_name_attr_id = db_templates("get_attr_id", $config_class, "host_name"); if (isset($m_array[$check_command_attr_id])) { unset($m_array[$check_command_attr_id]); } if (isset($m_array[$host_name_attr_id])) { unset($m_array[$host_name_attr_id]); }
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(); } }
if (($item_class == "service" or $item_class == "advanced-service") and $entry["attr_name"] == "check_params") { #do nothing here, print title later if really needed } else { echo '<td class="middle">' . $entry["friendly_name"] . '</td>'; } # check if items being displayed are "services" if (isset($entry["fk_show_class_items"])) { $srvquery = mysql_query('SELECT config_class FROM ConfigClasses WHERE id_class=' . $entry["fk_show_class_items"]); $srv = mysql_fetch_assoc($srvquery); } ### process "text" fields if ($entry["datatype"] == "text") { # check special case for check_params if (($item_class == "service" or $item_class == "advanced-service") and $entry["attr_name"] == "check_params") { # check_param stuff NConf_DEBUG::open_group("params for check command (service parameters)"); # get id of check_command if ($handle_action == "add") { if (!empty($_SESSION["cache"]["handle"][$check_command_attr_id][0])) { $check_command_id = $_SESSION["cache"]["handle"][$check_command_attr_id][0]; } elseif (!empty($check_command_first_id)) { # When adding a new service, this will help displaying the correct command_param for the first check_command # This is only needed for not changed check_command select field $check_command_id = $check_command_first_id; } $command_param_count = db_templates("get_command_param_count_of_checkcommand", $check_command_id); # Read default checkcommand params of selected check command and override predefined value (which makes more sense here) $default_params = db_templates("get_default_checkcommand_params", $check_command_id); $item_data[$entry["id_attr"]] = $default_params; } elseif ($handle_action == "modify" and !empty($_GET["id"])) { $check_command_id = db_templates("get_checkcommand_of_service", $_GET["id"]);
ConfigAttrs.friendly_name DESC, ItemLinks.cust_order, attr_value'; $result = db_handler($query2, "array", "get linked entries"); echo table_output($result, $item_class, "This item is linked to"); # get entries $result = db_templates("linked_as_child", $_GET["id"], '', '', 'array'); echo table_output($result, $item_class, "Child items linked"); echo '</table>'; echo '</div>'; ### # template inheritance if ($item_class == "host" or $item_class == "service" or $item_class == "advanced-service") { # do not output content directly, so we can evaluate if there are templates $output = ''; NConf_DEBUG::open_group("template inheritance"); $output .= 'Templates are applied in the following order:'; $output .= '<table class="ui-nconf-table ui-nconf-max-width">'; $output .= $colgroup; # create tables if ($item_class == "host") { $direct_host_templates = db_templates("template_inheritance_direct", $item_id); if (!empty($direct_host_templates)) { $output .= '<tr><td colspan=2><br><b>directly linked to host</b></td></tr>'; $output .= table_output($direct_host_templates, 'template_inheritance'); } # notification period inheritance $p2 = db_templates("template_inheritance", $item_id, "notification_period", "host_template"); $output .= table_output($p2, 'template_inheritance', '"notification period"'); # check period templates $p3 = db_templates("template_inheritance", $item_id, "check_period", "host_template");
<?php # USER login default # for other methods, expand this file and configure it in the config part # --> AUTH_TYPE # information what is needed after this script: # - check username and pw # - set $_SESSION['group'] to GROUP_USER or GROUP_ADMIN # - optional parameters # - $_SESSION['username'] for "welcome username, and history entries" NConf_DEBUG::open_group("Authentication"); # authentication type message($debug, "Authentication type: " . AUTH_TYPE); message($debug, "Encryption type: " . PASSWD_ENC); # Handle loginname if (defined("AUTH_METHOD") and AUTH_METHOD == "basic") { message($debug, "Auth method: " . AUTH_METHOD); $user_loginname = $_SERVER['PHP_AUTH_USER']; $_POST["password"] = $_SERVER['PHP_AUTH_PW']; } else { $user_loginname = $_POST["username"]; } # prepare password function function prepare_password($password, $clean = FALSE) { # if encryption is also in password, it has to be in UPPERCASE ( {crypt} -> {CRYPT}, {MD5} etc... if (preg_match('/(^\\{.*\\})(.*)/', $password, $matched)) { # will find [0]:whole string, [1]:crypt type, [2]:password $crypt = strtoupper($matched[1]); $pw = $matched[2]; if ($crypt == "{CLEAR}" or $clean == TRUE) {
<?php while ($attr = each($items2write)) { # only entries with attribute id in the key will be accepted if (is_int($attr["key"])) { # Get name of attribute: $attr_name = db_templates("friendly_attr_name", $attr["key"]); if ($attr_name) { NConf_DEBUG::open_group($attr_name); if ($handle_action == "multimodify") { $HIDDEN_selected_attr = $attr_name; } } if (is_array($attr["value"])) { # modify assign_one/assign_many in ItemLinks # get datatype for handling assign_cust_order $attr_datatype = db_templates("attr_datatype", $attr["key"]); # Check if the values are modifyied, only save changed values if (!isset($old_linked_data[$attr["key"]])) { //$old_linked_data[$attr["key"]] = array("0" => ""); $old_linked_data[$attr["key"]] = array(); } # if no value is selected there comes an empty 0 (zero) item, remove this if (isset($attr["value"][0]) and empty($attr["value"][0])) { unset($attr["value"][0]); } NConf_DEBUG::set($old_linked_data[$attr["key"]], 'DEBUG', "old data"); NConf_DEBUG::set($attr["value"], 'DEBUG', "new data"); # check replace_mode $replace_mode = !empty($_POST["replace_mode"]) ? $_POST["replace_mode"] : "replace"; # Assigned items
foreach ($l_data as $data) { history_add("assigned", $data["fk_id_attr"], $data["fk_item_linked2"], $data["{$new_host_id}"], "resolve_assignment"); } } ############# # clone each service individually # fetch list of services $query = 'SELECT fk_id_item,fk_id_attr FROM ItemLinks,ConfigItems,ConfigClasses WHERE id_item = fk_id_item AND id_class = fk_id_class AND config_class = "service" AND fk_item_linked2 = ' . $_POST["template_id"] . ' ORDER BY fk_id_item'; $services = db_handler($query, "array", "fetch list of services"); # iterate through all services foreach ($services as $service_tpl) { NConf_DEBUG::open_group("clone service " . $service_tpl["fk_id_item"]); # create a new item_id for each cloned service $query = 'INSERT INTO ConfigItems (id_item,fk_id_class) VALUES (NULL,(SELECT id_class FROM ConfigClasses WHERE config_class="service"))'; $new_service_id = db_handler($query, "insert_id", "create a new item_id for each cloned service"); # link new service to cloned host $query = 'INSERT INTO ItemLinks (fk_id_item,fk_item_linked2,fk_id_attr) VALUES (' . $new_service_id . ',' . $new_host_id . ',' . $service_tpl["fk_id_attr"] . ')'; $result = db_handler($query, "insert", "link new service to cloned host"); if ($result) { message($debug, 'Successfully linked service ' . $new_service_id . ' to host ' . $new_host_id); } else { message($error, 'Error linking service ' . $new_service_id . ' to host ' . $new_host_id . ' ' . $query); } # clone basic data of original service onto new service $query = 'INSERT INTO ConfigValues (fk_id_attr,attr_value,fk_id_item) SELECT id_attr,attr_value,' . $new_service_id . ' FROM ConfigAttrs,ConfigValues,ConfigItems