Exemplo n.º 1
0
function generate_tree($id, $mode = '')
{
    # selected item
    # get childs
    $child_array = get_childs($id, $mode);
    # get information of selected item
    $query = 'SELECT DISTINCT attr_value as name,ItemLinks.fk_id_item AS item_id,
                  (SELECT config_class FROM ConfigItems,ConfigClasses
                      WHERE id_class=fk_id_class AND id_item=item_id) AS type,
                  (SELECT attr_value
                    FROM ConfigValues, ItemLinks, ConfigAttrs, ConfigClasses
                    WHERE ConfigValues.fk_id_item = ItemLinks.fk_item_linked2
                    AND id_attr = ConfigValues.fk_id_attr
                    AND attr_name = "icon_image"
                    AND id_class = fk_id_class
                    AND config_class = "os"
                    AND ItemLinks.fk_id_item = item_id
                  ) AS os_icon
                FROM ConfigValues,ItemLinks,ConfigAttrs,ConfigClasses
                WHERE ItemLinks.fk_id_item=ConfigValues.fk_id_item
                    AND id_attr=ItemLinks.fk_id_attr
                    AND ConfigAttrs.visible="yes"
                    AND fk_id_class=id_class
                    AND (SELECT naming_attr FROM ConfigAttrs WHERE id_attr=ConfigValues.fk_id_attr)="yes"
                    AND ItemLinks.fk_id_item="' . $id . '"
                ORDER BY config_class DESC,attr_value';
    $selected_item_info = db_handler($query, "assoc", "Get informations on selected item");
    # get informations about host
    # prepend inforomation from selected host to the top of the list
    array_unshift($child_array, get_informations($id));
    # set values of selected item AND put all childs (generated bevore) in it.
    $root_item = array($id => array("id" => $id, "selected" => TRUE, "status" => 'open', "name" => $selected_item_info["name"], "type" => $selected_item_info["type"], "os_icon" => $selected_item_info["os_icon"], "childs" => $child_array));
    # get parents
    $parents_flat = get_parents($id);
    # make the parents array ordered top2down
    $parents_flat = array_reverse($parents_flat);
    # prepare list (if there are parents call the prepare function
    if (!empty($parents_flat)) {
        $tree = prepare_dependency($parents_flat, $root_item);
    } else {
        $tree = $root_item;
    }
    ## Display the top tree item
    # check for parent loop error
    if (isset($tree[0]["status"]) and $tree[0]["status"] == "loop_error") {
        # make a error item at the top
        $dependency_tree = array("root" => array("id" => "root", "status" => 'open', "name" => TXT_DEPVIEW_ERROR_LOOP, "type" => "warn", "childs" => $tree));
    } else {
        # make a root tree at the top
        $dependency_tree = array("root" => array("id" => "root", "status" => 'open', "name" => "Top level", "type" => "parent", "childs" => $tree));
    }
    //echo "<pre>";
    //var_dump($tree);
    //echo "</pre>";
    echo '<div>';
    displayTree_list($dependency_tree);
    echo '</div>';
}
 protected function checkIdPermission($ID)
 {
     # checks the requested id, its class should be accessible for the user, otherwise access will be denied.
     $class_id = db_templates("get_classid_of_item", $ID);
     $query = 'SELECT id_class
                 FROM ConfigClasses
                 WHERE nav_privs = "' . $this->group . '"
                     AND id_class = "' . $class_id . '"';
     $user_class_permissions = db_handler($query, "getOne", "Check if user has access to the class of the requested item");
     # set authorization
     # special behaviour for multiple ids (then its not allowed to set to true if already FALSE state was set)
     if (!empty($user_class_permissions) and $this->requested_id_authorized !== FALSE) {
         $this->requested_id_authorized = TRUE;
     } else {
         $this->requested_id_authorized = FALSE;
     }
 }
 # vererben = assign changes to linked services
 if (isset($_POST["multimodify"])) {
     # Implode the splitet fields (exploded in handle_item.php)
     if (isset($_POST["exploded"])) {
         prepare_check_command_params($_POST["exploded"]);
     }
     # get old data
     $old_linked_data = get_linked_data($id);
     # Check for existing entry
     $query = 'SELECT id_attr
                 FROM ConfigAttrs,ConfigClasses
                 WHERE naming_attr="yes"
                     AND id_class=fk_id_class
                     AND config_class="' . $config_class . '"
              ';
     $id_naming_attr = db_handler($query, "getOne", "naming_attr ID:");
     if (isset($_POST[$id_naming_attr]) and $config_class != "service") {
         # naming attr not allowed
         message($error, "Naming attribute cannot be modified with multiple items");
     } else {
         # entry is not a naming attr, lets try to modify:
         if ($config_class == "host") {
             # Vererben ?
             if (isset($vererben1)) {
                 unset($vererben1);
             }
             $vererben1_result = db_templates("vererben", $id);
             while ($row = mysql_fetch_assoc($vererben1_result)) {
                 $vererben1[$row["item_id"]] = $row["attr_name"];
             }
         }
Exemplo n.º 4
0
        $url = $_SESSION["go_back_page"];
        echo '<meta http-equiv="refresh" content="' . REDIRECTING_DELAY . '; url=' . $url . '">';
        message($info, '<b>redirecting to:</b> <a href="' . $url . '"> [ this page ] (in ' . REDIRECTING_DELAY . ' seconds)</a>');
    } else {
        message($error, 'Error deleting class ' . $_POST["id"] . ':' . $query);
    }
} else {
    if (!empty($_SERVER["HTTP_REFERER"])) {
        $_SESSION["after_delete_page"] = $_SERVER["HTTP_REFERER"];
    }
    # class name
    $query = 'SELECT config_class FROM ConfigClasses where id_class=' . $_GET["id"];
    $class_name = db_handler($query, 'getOne', "get class name");
    // Fetch attr name
    $query = 'SELECT attr_name  FROM ConfigAttrs, ConfigClasses WHERE id_class=' . $_GET["id"] . ' AND fk_id_class=ConfigClasses.id_class';
    $attr = db_handler($query, "array", "Get Attrs of this Class");
    if (isset($attr[0]["attr_name"])) {
        // warning message
        $content = 'The class you chose to delete contains one or more attributes.
                    <br>If you proceed, all items belonging to this class, all attributes and
                    <br>any asscociated data will be lost!
                    <br><br>Are you <b>ABSOLUTELY SURE</b> you want to proceed?
                <br><br>List of attributes defined for this class:<br>(items using these attributes are not listed here explicitly)
            <br>
                   ';
        $content .= '<ul>';
        foreach ($attr as $item) {
            $content .= '<li>' . $item["attr_name"] . '</li>';
        }
        $content .= '</ul>';
    } else {
Exemplo n.º 5
0
         echo '<col width="30">';
         echo '<col width="30">';
     } else {
         # xmode view
         echo '<col width="60">';
     }
     echo '</colgroup>';
 }
 # Fetch column titles
 $query = 'SELECT ConfigAttrs.friendly_name
                         FROM ConfigAttrs,ConfigClasses
                         WHERE id_class=fk_id_class
                         AND naming_attr="yes"
                         AND config_class="' . $class . '"
                         ';
 $title_result = db_handler($query, 'result', "Friendly name");
 echo '<thead class="ui-widget-header">';
 echo '<tr>';
 if ($class == "host") {
     echo '<td width="30">' . FRIENDLY_NAME_OS_LOGO . '</td>';
 }
 while ($entry = mysql_fetch_assoc($title_result)) {
     if ($class == "host") {
         $order_value = (!empty($order) and $order == "hostname ASC") ? 'hostname DESC' : 'hostname ASC';
     } elseif ($class == "checkcommand") {
         # checkcommands could be sorted in 4 special ways:
         $ordering_default_service_name = FALSE;
         switch ($order) {
             case "entryname ASC":
                 NConf_DEBUG::set(CHECKCOMMAND_ORDER_COMMAND_NAME_ASC, 'INFO', CHECKCOMMAND_ORDER_PRETEXT);
                 $order_value = 'entryname DESC';
Exemplo n.º 6
0
 foreach ($ids as $id) {
     # Delete Services if item = host
     $item_class = db_templates("class_name", $id);
     if ($item_class == "host") {
         # WARN services linked to host
         $get_srv_query = 'SELECT attr_value, ConfigValues.fk_id_item AS item_id,"service" AS config_class,
                         "service name" AS friendly_name
                         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 = "service"
                         AND ConfigValues.fk_id_item = ItemLinks.fk_id_item
                         AND fk_item_linked2 = ' . $id . '
                         ORDER BY attr_value';
         $result = db_handler($get_srv_query, "result", "get services linked to host");
         # prepare services
         $services = array();
         while ($entry = mysql_fetch_assoc($result)) {
             $services[] = array("id" => $entry["item_id"], "name" => $entry["attr_value"], "type" => "service");
         }
     }
     # Lookup class and name of item
     $item_class = db_templates("class_name", $id);
     $item_name = db_templates("naming_attr", $id);
     # on service items we want to group it by their associated hostname
     if ($item_class == "service") {
         # service deletions
         # get host name of service
         $hostID = db_templates("hostID_of_service", $id);
         $hostname = db_templates("naming_attr", $hostID);
Exemplo n.º 7
0
                WHERE id_attr=' . $_POST["id"];
    $result = db_handler($query, "result", "Delete entry");
    if ($result) {
        message($debug, '', "ok");
        history_add("removed", "Attribute", $_POST["name"]);
        echo TXT_DELETED;
        $url = $_SESSION["go_back_page"];
        echo '<meta http-equiv="refresh" content="' . REDIRECTING_DELAY . '; url=' . $url . '">';
        NConf_DEBUG::set('<a href="' . $url . '"> [ this page ] (in ' . REDIRECTING_DELAY . ' seconds)</a>', 'INFO', "<br>redirecting to");
    } else {
        message($error, 'Error deleting id_attr ' . $_POST["id"] . ':' . $query);
    }
} elseif (!empty($_GET["id"])) {
    // Fetch attr name
    $query = 'SELECT attr_name, config_class FROM ConfigAttrs, ConfigClasses WHERE id_attr=' . $_GET["id"] . ' AND fk_id_class=ConfigClasses.id_class';
    $attr = db_handler($query, "assoc", "Fetch attr name");
    // warning message
    $content = 'All &quot;<b>' . $attr["config_class"] . '</b>&quot; items will lose their &quot;<b>' . $attr["attr_name"] . '</b>&quot; attribute.
            <br>All data associated with this attribute will also be lost.
            This action cannot be undone.';
    $content .= '<br><br>
                 Are you <b>REALLY SURE</b> you want to proceed?<br><br>';
    // Buttons
    $content_button = '
        <form name="delete_attr" action="delete_attr.php" method="post">
            <input type="hidden" name="id" value="' . $_GET["id"] . '">
            <input type="hidden" name="name" value="' . $attr["attr_name"] . '">
    ';
    if (!empty($_GET["from"])) {
        $content_button .= '<input type="hidden" name="from" value="' . $_GET["from"] . '">';
    }
Exemplo n.º 8
0
 //     ordering = '$ordering',
 //     visible = '$visible',
 //     write_to_conf = '$write2conf',
 //     naming_attr = '$naming_attr',
 //     link_as_child = '$link_as_child',
 //     link_bidirectional = '$link_bidirectional',
 //     fk_show_class_items = $fk_show_class_items,
 //     fk_id_class = '$fk_id_class'
 // WHERE
 //     id_attr = $attr_id
 // ");
 # get old ordering number
 $old_ordering = db_handler("SELECT ordering FROM ConfigAttrs WHERE id_attr={$attr_id}", "getOne", "GET old ordering number of attr");
 // UPDATE ConfigAttrs
 $query = "UPDATE ConfigAttrs\n                SET\n                attr_name = '{$attr_name}',\n                friendly_name = '{$friendly_name}',\n                description = '{$description}',\n                max_length = '{$max_length}',\n                poss_values = '{$poss_values}',\n                predef_value = '{$predef_value}',\n                mandatory = '{$mandatory}',\n                ordering = '{$ordering}',\n                visible = '{$visible}',\n                write_to_conf = '{$write2conf}'\n                WHERE\n                id_attr = {$attr_id}";
 $result = db_handler($query, "update", "Modify attribute parameters");
 if ($result) {
     # handle the ordering of the other items
     set_attr_order($attr_id, $ordering, $fk_id_class, $old_ordering);
     echo NConf_HTML::text("Successfully modified attribute &quot;{$attr_name}&quot;", FALSE);
     if ($naming_attr_message == "&naming_attr=last") {
         echo TXT_NAMING_ATTR_LAST;
     }
     // 2009-03-04 A. Gargiulo: disabled this code because we don't want users to be able to
     // modify all of the attr params, especially the naming attr (could cause data inconsistency)!
     // When succesfully set new entry including new naming attribute, delete the old one
     //if($naming_attr == "yes"){
     //    if ( (count($old_naming_attr_array) != "0") AND $naming_attr == "yes" ){
     //        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'");
Exemplo n.º 9
0
             AND naming_attr = "yes"
             AND ConfigItems.fk_id_class = id_class
             AND (
                 config_class = "checkcommand"
                 OR config_class = "misccommand"
                 )
             AND attr_value="' . escape_string($_POST[$id_naming_attr]) . '"
             AND fk_id_item <> ' . $id;
 } else {
     $query = 'SELECT attr_value, fk_id_item
             FROM ConfigValues
             WHERE fk_id_attr=' . $id_naming_attr . '
             AND attr_value = "' . escape_string($_POST[$id_naming_attr]) . '"
             AND fk_id_item <> ' . $id;
 }
 $result = db_handler($query, "result", "does entry already exist");
 # Entry exists ?
 if (mysql_num_rows($result)) {
     NConf_DEBUG::set('An item with the name &quot;' . $_POST[$id_naming_attr] . '&quot; already exists!', 'ERROR');
     NConf_DEBUG::set('For its details click the link below or go back:', 'ERROR');
     $list_items = '';
     while ($entry = mysql_fetch_assoc($result)) {
         $list_items .= '<li><a href="detail.php?id=' . $entry["fk_id_item"] . '">' . $entry["attr_value"] . '</a></li>';
     }
     $list = '<ul>' . $list_items . '</ul>';
     NConf_DEBUG::set($list, 'ERROR');
 } else {
     #entry not existing, lets try to modify:
     if ($config_class == "host") {
         # Vererben ?
         $vererben1_result = db_templates("vererben", $id);
Exemplo n.º 10
0
          ';
 $result = db_handler($query, "result", "Link service with same contactgroups as host (select)");
 if ($result) {
     if (mysql_num_rows($result) > 0) {
         while ($contactgroup_ID = mysql_fetch_row($result)) {
             // get contact_groups attr id
             $contact_groups_id = db_templates("get_attr_id", "service", "contact_groups");
             //remove from attrs_visible_yes
             unset($attrs_visible_yes[$contact_groups_id]);
             $query = 'INSERT INTO ItemLinks (fk_id_item,fk_item_linked2,fk_id_attr) 
                         VALUES ( ' . $new_service_ID . '
                                 ,' . $contactgroup_ID[0] . '
                                 ,' . $contact_groups_id . '
                                )
                      ';
             $status = db_handler($query, "insert", "Link service with same contactgroups as host (insert)");
             if ($status) {
                 history_add("assigned", $contact_groups_id, $contactgroup_ID[0], $new_service_ID, "resolve_assignment");
             }
         }
         // END while
     }
 } 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);
 }
Exemplo n.º 11
0
            if ($entry["datatype"] != "assign_one") {
                // split predefined values
                $predef_values = preg_split("/" . SELECT_VALUE_SEPARATOR . "/", $entry["predef_value"]);
            } else {
                // set predefined value as array, to use same loop as splited values
                $predef_values = array($entry["predef_value"]);
            }
            foreach ($predef_values as $predef_value) {
                if (empty($predef_value)) {
                    // empty values must not be looked up
                    $entry2 = '';
                } else {
                    // lookup for id
                    $query2 = 'SELECT fk_id_item 
                                FROM ConfigValues,ConfigAttrs 
                                WHERE id_attr=fk_id_attr 
                                AND naming_attr="yes" 
                                AND fk_id_class="' . $entry["fk_show_class_items"] . '"
                                AND attr_value="' . $predef_value . '";
                    ';
                    $entry2 = db_handler($query2, "getOne", "Load linked item: ( not visible assign_MANY/CUST_ORDER )");
                }
                // output
                $output2 = '<input type="hidden" name="' . $entry["id_attr"] . '[]" value="' . $entry2 . '">';
                echo $output2;
                message('DEBUG', "Hidden Field:" . str_replace("<", "", $output2));
            }
        }
    }
    // end of while
}
Exemplo n.º 12
0
set_page();
# go to show attribute page, when modify was ok
$HTTP_referer = 'show_class.php';
$_SESSION["go_back_page_ok"] = $HTTP_referer;
message($debug, "set go_back_page_ok : " . $_SESSION["go_back_page_ok"]);
if (isset($_GET['id'])) {
    $id = $_GET['id'];
    $title = "Modify class";
} else {
    $id = "new";
    $title = "Add class";
}
if ($id != "new") {
    # get entries
    $query = 'SELECT * FROM ConfigClasses WHERE id_class="' . $id . '"';
    $class_entry = db_handler($query, "assoc", "get entries");
    $old_grouping = $class_entry["grouping"];
    $old_nav_privs = $class_entry["nav_privs"];
} else {
    # new entry does not have predefined values like the modify part
    $class_entry = array("nav_visible" => "", "config_class" => "", "friendly_name" => "", "grouping" => "", "nav_privs" => "", "nav_links" => "", "class_type" => "", "out_file" => "", "nagios_object" => "", "ordering" => "");
    $old_grouping = '';
    $old_nav_privs = '';
}
# new group must be defined in both scenarios
$class_entry["new_group"] = "";
# Check cache
if (isset($_SESSION["cache"]["modify_class"][$id])) {
    # Cache
    foreach ($_SESSION["cache"]["modify_class"][$id] as $key => $value) {
        $class_entry[$key] = $value;
Exemplo n.º 13
0
                 # found a services name, which does not exist
                 $new_service_name = $try_service_name;
             }
             # give the service name back for writing to db
             $insert_attr_value = $new_service_name;
         }
     }
     # save value to DB
     $query = 'INSERT INTO ConfigValues
                                 (attr_value, fk_id_attr, fk_id_item)
                             VALUES
                                 ("' . $insert_attr_value . '", "' . $attr["key"] . '", ' . $id . ' )
                             ON DUPLICATE KEY UPDATE
                                 attr_value="' . $insert_attr_value . '"
                             ';
     $insert = db_handler($query, "insert", 'Insert entry');
     if ($insert) {
         message($debug, 'Successfully added (' . stripslashes($insert_attr_value) . ')');
         if ($handle_action == "multimodify") {
             $info_summary["ok"][] = $name;
         }
         history_add("modified", $attr["key"], $insert_attr_value, $id);
         $edited = TRUE;
     } else {
         message($error, 'Error while adding ' . stripslashes($insert_attr_value) . ':' . $query);
         if ($handle_action == "multimodify") {
             $info_summary["failed"][] = $name;
         }
     }
 } else {
     // The data value has not changed, so no saving is needed
Exemplo n.º 14
0
                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>';
}
Exemplo n.º 15
0
echo '<div class="ui-nconf-header ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix">';
echo '<div><h2>Details</h2></div>';
echo '<div id="ui-nconf-icon-bar">';
if (!isset($_GET["xmode"])) {
    if ($type == "attr") {
        echo '<a href="modify_attr.php?id=' . $_GET["id"] . '">' . ICON_EDIT . '</a>';
        echo '<a href="delete_attr.php?id=' . $_GET["id"] . '">' . ICON_DELETE . '</a>';
    } elseif ($type == "class") {
        echo '<a href="modify_class.php?id=' . $_GET["id"] . '">' . ICON_EDIT . '</a>';
        echo '<a href="delete_class.php?id=' . $_GET["id"] . '">' . ICON_DELETE . '</a>';
    }
}
echo '</div>';
echo '</div>';
echo '<div class="ui-nconf-content ui-widget-content ui-corner-bottom">';
echo '<table class="ui-nconf-table ui-nconf-max-width">';
# get entries
$entries = db_handler($query, "array", "Get Details of {$type}");
foreach ($entries[0] as $title => $value) {
    // Change the titles for more user friendly titles
    $title = strtr($title, $user_friendly_names);
    // Display the row
    echo '<tr>';
    echo '<td class="color_list2" width="200">' . $title . ':</td>';
    echo '<td class="color_list1 highlight">' . $value . '</td>';
    echo '</tr>';
}
echo '</table>';
echo '</div>';
mysql_close($dbh);
require_once 'include/foot.php';
Exemplo n.º 16
0
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");
    if ($result) {
        $header_content = '<div style="width: 150px;">Class Name</div>';
        $header_content .= '<div style="width: 160px;">Friendly Name</div>';
        $header_content .= '<div class="center" style="width: 70px;">Visible</div>';
        $header_content .= '<div class="center" style="width: 60px;" colspan=2>Ordering</div>';
        $header_content .= '<div class="center" style="width: 40px;">Edit</div>';
        $header_content .= '<div class="center" style="width: 40px;">Delete</div>';
        echo NConf_HTML::ui_box_header($header_content);
        $box_content = '<colgroup>
                    <col width=150>
                    <col width=160>
                    <col width=70>
                    <col width=30>
                    <col width=30>
                    <col width=40>
Exemplo n.º 17
0
$write2db = check_mandatory($mandatory, $_POST);
if ($write2db == "yes") {
    if ($class_id == "new") {
        $title = "Add class";
        // Generate navigation link string
        $nav_links = 'Show::overview.php?class=' . $config_class . ';;Add::handle_item.php?item=' . $config_class;
        // Make insert (adding class)
        $query = "INSERT INTO ConfigClasses (config_class, friendly_name, nav_visible, grouping, nav_links, nav_privs, class_type, ordering, out_file, nagios_object)\n                        VALUES ('{$config_class}', '{$friendly_name}', '{$nav_visible}', '{$grouping}', '{$nav_links}', '{$nav_privs}', '{$class_type}', '{$ordering}', '{$out_file}', '{$nagios_object}')";
        $action = "created";
    } else {
        $title = "Modify class";
        // UPDATE ConfigAttrs
        $action = "modified";
        $query = "UPDATE ConfigClasses\n            SET\n                config_class = '{$config_class}',\n                friendly_name = '{$friendly_name}',\n                nav_visible = '{$nav_visible}',\n                grouping = '{$grouping}',\n                nav_links = '{$nav_links}',\n                nav_privs = '{$nav_privs}',\n                class_type = '{$class_type}',\n                ordering = '{$ordering}',\n                out_file = '{$out_file}',\n                nagios_object = '{$nagios_object}'\n            WHERE\n                id_class = {$class_id}\n            ";
    }
    $result = db_handler($query, "result", "{$action} Entry");
    if ($result) {
        echo "<h2>{$title}</h2>Successfully {$action} class &quot;{$config_class}&quot;";
        history_add($action, "Class", $config_class);
        // 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");
    } else {
        echo "<h2>Failed to {$action} attribute &quot;{$config_class}&quot;</h2>";
    }
} else {
    if (isset($_SESSION["cache"]["modify_class"])) {
        unset($_SESSION["cache"]["modify_class"]);
    }
    if (NConf_DEBUG::status('ERROR')) {
        echo NConf_DEBUG::show_debug('ERROR', TRUE, $_SESSION["go_back_page"]);
Exemplo n.º 18
0
}
//set_page();
// Check chache
if (isset($_SESSION["cache"]["clone_service"])) {
    $cache = $_SESSION["cache"]["clone_service"];
} elseif (!empty($_GET["service_id"])) {
    $cache["service_id"] = $_GET["service_id"];
}
# Fetch all hosts
$query = 'SELECT fk_id_item,attr_value FROM ConfigValues,ConfigAttrs,ConfigClasses 
                WHERE id_attr=fk_id_attr 
                    AND naming_attr="yes" 
                    AND id_class=fk_id_class 
                    AND config_class="host" 
                ORDER BY attr_value';
$hosts = db_handler($query, "array_2fieldsTOassoc", "get all hosts");
$host_id = $_GET["id"];
$item_name = db_templates("naming_attr", $host_id);
echo '<h2>&nbsp;Clone Service from host ' . $item_name . '</h2>';
echo '
  <br>
    <table>
    ';
echo define_colgroup();
?>
      <tr><td class="middle"><br>services to clone
          </td>
          <td colspan=3>
            <?php 
echo '<input id="host_ID" type="hidden" name="source_host_id" value="' . $host_id . '">';
?>
Exemplo n.º 19
0
         $write2db = 'no';
     }
 }
 if ($write2db == "yes") {
     ################
     #### write to db
     ################
     # get class id
     $class_id = db_templates("get_id_of_class", $config_class);
     $query = 'INSERT INTO ConfigItems
                 (id_item, fk_id_class)
                 VALUES
                 (NULL, "' . $class_id . '" )
                 ';
     if (DB_NO_WRITES != 1) {
         $insert = db_handler($query, "insert", "Insert");
         if (!$insert) {
             message($error, 'Error while adding entry to ConfigItems:' . $query);
         }
     }
     if ($insert) {
         # Get ID of insert:
         $id = mysql_insert_id();
         # add item CREATED to history
         if ($config_class == "service") {
             history_add("created", $config_class, $_POST[$id_naming_attr], $id, "add_service", $host_id);
         } else {
             history_add("created", $config_class, $_POST[$id_naming_attr], $id);
         }
         while ($attr = each($_POST)) {
             // only add attributes (which have int(id) as attr key
Exemplo n.º 20
0
 # Titel
 echo '<tr>
         <td>
             <b>timeperiod details</b>
         </td>
     </tr>
 ';
 # get basic entries
 $query = 'SELECT ConfigAttrs.friendly_name,attr_value, ConfigAttrs.datatype
                         FROM ConfigAttrs,ConfigValues,ConfigItems
                         WHERE id_attr=fk_id_attr
                         AND id_item=fk_id_item
                         AND ConfigAttrs.visible="yes"
                         AND id_item=' . $_GET["id"] . '
                         ORDER BY ConfigAttrs.ordering';
 $result = db_handler($query, "result", "get basic entries");
 if ($result) {
     while ($entry = mysql_fetch_assoc($result)) {
         echo '<tr>';
         echo '<td style="vertical-align:text-top" width="150" class="color_list2">&nbsp;' . $entry["friendly_name"] . ':&nbsp;</td>';
         if ($entry["datatype"] == "password") {
             $password = show_password($entry["attr_value"]);
             // show password
             echo '<td class="color_list1 highlight">&nbsp;' . $password . '</td>';
         } else {
             // Link handling
             if (preg_match('/^http*/', $entry["attr_value"])) {
                 # Link
                 echo '<td class="color_list1 highlight">&nbsp;<a target="_blank"href="' . $entry["attr_value"] . '">' . $entry["attr_value"] . '</a></td>';
             } else {
                 # normal text
Exemplo n.º 21
0
    <h2 class="ui-widget-header header"><span><?php 
echo TXT_MENU_ADDITIONAL;
?>
</span></h2>
    <div class="ui-widget-content box_content">
        <?php 
// FIX menu admin begin
include 'include/menu/static_content/menu_admin_begin.html';
?>

<!-- ###################### -->

        <?php 
// Select ConfigClasses
$query = 'SELECT * FROM ConfigClasses WHERE nav_privs = "admin" AND nav_visible = "yes" ORDER BY UPPER(grouping), ordering ASC, config_class';
$result = db_handler($query, "array", "Select admin Navigation classes");
// Creates admin menu dynamic
create_menu($result);
?>

    </div>

    <?php 
// FIX menu user end
include 'include/menu/static_content/menu_admin_end.html';
// FIX administration menu (attributes and classes)
include 'include/menu/menu_administration.html';
Exemplo n.º 22
0
 function auth_by_sql($sqlquery, $login = FALSE)
 {
     # Connect to external database if given
     if (defined("AUTH_DBNAME")) {
         # if AUTH config is given, use it
         $auth_db_link = mysql_connect(AUTH_DBHOST, AUTH_DBUSER, AUTH_DBPASS, TRUE);
         mysql_select_db(AUTH_DBNAME, $auth_db_link);
         $result = db_handler($sqlquery, 'getOne', "Authentication by sql");
         mysql_close($auth_db_link);
     } else {
         # otherwise just use the NConf DB connection
         $result = db_handler($sqlquery, 'getOne', "Authentication by sql using NConf DB");
     }
     if ($result and $login === TRUE) {
         # get Welcome name
         if (AUTH_FEEDBACK_AS_WELCOME_NAME == 1 and !empty($result)) {
             $_SESSION["userinfos"]['username'] = $result;
         } else {
             $_SESSION["userinfos"]['username'] = $_POST["username"];
         }
         return TRUE;
     } elseif ($result and $login === FALSE) {
         return $result;
     } else {
         return FALSE;
     }
 }
Exemplo n.º 23
0
        <h2>&nbsp;Overview</h2>';
// Attr manipulation
if (!empty($_GET["do"]) and !empty($_GET["id"])) {
    if ($_GET["do"] == "up") {
        attr_order($_GET["id"], "up");
    } elseif ($_GET["do"] == "down") {
        attr_order($_GET["id"], "down");
    }
}
$query = 'SELECT ConfigAttrs.friendly_name, ConfigAttrs.ordering, id_attr, attr_name, datatype, mandatory, naming_attr
            FROM ConfigAttrs,ConfigClasses
                WHERE id_class=fk_id_class
                AND config_class="' . $class . '"
                ORDER BY ConfigAttrs.ordering
    ';
$result = db_handler($query, "result", "get attributes from class");
// Table beginning will be added in the output function
$table = '';
if ($result != "") {
    $table .= '<thead class="ui-widget-header">';
    $table .= '<tr>';
    $table .= '<th width=30>&nbsp;</th>';
    $table .= '<th width=170>Attribute Name</th>';
    $table .= '<th width=170>Friendly Name</th>';
    $table .= '<th width=100>Datatype</th>';
    $table .= '<th width=70 class="center">Mandatory</th>';
    $table .= '<th width=60 class="center">Ordering</th>';
    $table .= '<th width=50 class="center">PK</th>';
    $table .= '<th width=40 class="center">Edit</th>';
    $table .= '<th width=40 class="center">Delete</th>';
    $table .= "</tr>";
Exemplo n.º 24
0
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;
}
Exemplo n.º 25
0
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;
}
}
// check if static config folder(s) are readable
foreach ($STATIC_CONFIG as $static_folder) {
    if (!is_readable($static_folder)) {
        $content = "<br>Could not access static config folder '" . $static_folder . "'.";
        $content .= "<br>Check your \$STATIC_CONFIG array in 'config/nconf.php'.";
        NConf_DEBUG::set($content, 'ERROR');
        echo NConf_HTML::limit_space(NConf_HTML::show_error('Error'));
        remove_lock();
        exit;
    }
}
// fetch all monitor and collector servers from DB
$servers = array();
$query = "SELECT fk_id_item AS item_id,attr_value,config_class\n                  FROM ConfigValues,ConfigAttrs,ConfigClasses\n                  WHERE id_attr=fk_id_attr\n                      AND naming_attr='yes'\n                      AND id_class=fk_id_class\n                      AND (config_class = 'nagios-collector' OR config_class = 'nagios-monitor') \n                  ORDER BY attr_value";
$result = db_handler($query, "result", "fetch all monitor and collector servers from DB");
while ($entry = mysql_fetch_assoc($result)) {
    $renamed = preg_replace('/-|\\s/', '_', $entry["attr_value"]);
    if ($entry["config_class"] == 'nagios-collector') {
        $renamed = preg_replace('/Nagios|Icinga/i', 'collector', $renamed);
    }
    array_push($servers, $renamed);
}
# GENERATE CONFIG
echo NConf_HTML::title('Generate config log:');
echo '<div>
            <pre>';
//system(NCONFDIR."/bin/generate_config.pl");
$command = NCONFDIR . "/bin/generate_config.pl";
$output = array();
exec($command, $output);
Exemplo n.º 27
0
# create output
create_menu($user_menu_begin);
$user_menu_begin2 = array();
# 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&amp;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>';
Exemplo n.º 28
0
                         WHERE id_item=fk_id_item
                             AND id_attr=fk_id_attr
                             AND naming_attr="yes"
                             AND id_item <> ' . $_GET["id"] . '
                             AND ConfigItems.fk_id_class=' . $entry["fk_show_class_items"] . '
                             AND (SELECT fk_id_item FROM ItemLinks,ConfigAttrs,ConfigClasses
                                     WHERE id_attr=fk_id_attr
                                     AND id_class=fk_id_class
                                     AND config_class="' . $item_class . '"
                                     AND (attr_name="parents" OR attr_name="dependent_service_description")
                                     AND fk_item_linked2="' . $_GET["id"] . '"
                                     AND fk_id_item=id_item) IS NULL
                         ORDER BY attr_value';
     }
 }
 $result2 = db_handler($query2, "result", "assign_cust_order");
 # split predef value
 $predef_value = preg_split("/" . SELECT_VALUE_SEPARATOR . "/", $entry["predef_value"]);
 $selected_items = array();
 # generate base array
 $base_array = array();
 $search_array = array();
 while ($entry_row = mysql_fetch_assoc($result2)) {
     $base_array[$entry_row["id_item"]] = $entry_row;
     # we need a simpler array for searching when using predef_value:
     $search_array[$entry_row["id_item"]] = $entry_row["attr_value"];
 }
 if (isset($_SESSION["cache"]["handle"][$entry["id_attr"]])) {
     if (isset($_SESSION["cache"]["handle"][$entry["id_attr"]])) {
         foreach ($_SESSION["cache"]["handle"][$entry["id_attr"]] as $key => $value) {
             if (array_key_exists($value, $base_array)) {
Exemplo n.º 29
0
# movable content
echo '<div>';
if (!empty($_GET["id"])) {
    # Normal query
    $query = 'SELECT timestamp, action, attr_name FROM History
            WHERE fk_id_item=' . $_GET["id"] . '
            AND action <> "edited"
            ORDER BY timestamp DESC, id_hist DESC
            LIMIT ' . HISTORY_TAB_LIMIT . ';';
    if (!empty($_GET["filter"])) {
        $title .= '<br>--> filtered for <i>' . $_GET["filter"] . '</i>';
    }
}
# Content
echo '<table class="ui-nconf-table ui-nconf-max-width">';
$result = db_handler($query, 'result', "get history entries");
if (mysql_num_rows($result) == 0) {
    echo '<tr class="box_content"><td colspan=3>no history data found</td></tr>';
} else {
    echo '<tr class="box_content">
                <td colspan=2>Last ' . HISTORY_TAB_LIMIT . ' changes:</td>
                <td>
                    <div align="right">
                        <a href="history.php?id=' . $_GET["id"] . '">show all changes</a>
                    </div>
                </td>
              </tr>';
    echo '<tr>';
    echo '<td class="ui-state-default">When</td>
                  <td class="ui-state-default">Action</td>
                  <td class="ui-state-default" style="border-right: 0px;">Object</td>';
Exemplo n.º 30
0
         history_add("assigned", $entry["fk_id_attr"], $entry["fk_item_linked2"], $new_service_id, "resolve_assignment");
     }
     // try history
     /*
     history_add("added",    fk_id_attr =    ,  attr_value   ,   fk_id_item (service id)
     history_add("assigned", fk_id_attr = $timeperiod_id, fk_item_linked2 = $timeperiod["item_id"], fk_id_item = $new_service_ID, "resolve_assignment");
     */
     # clone items linked as child of original service onto new service
     $query = 'INSERT INTO ItemLinks (fk_id_item,fk_item_linked2,fk_id_attr,cust_order)
                 SELECT fk_id_item,' . $new_service_id . ',fk_id_attr,cust_order FROM ItemLinks
                     WHERE fk_item_linked2 = ' . $service_tpl["fk_id_item"] . ' ORDER BY fk_id_item';
     $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") {