Ejemplo n.º 1
0
<?php

require_once 'include/head.php';
//set_page();
echo NConf_HTML::title('Delete class');
if (isset($_POST["delete"]) and $_POST["delete"] == "yes" and (isset($_POST["id"]) and $_POST["id"] != "")) {
    # Delete entry
    $query = 'DELETE FROM ConfigClasses
                WHERE id_class=' . $_POST["id"];
    $result = db_handler($query, "result", "Delete Class");
    if ($result) {
        echo TXT_DELETED;
        history_add("removed", "Class", $_POST["class_name"]);
        # set url for redirect
        $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"])) {
Ejemplo n.º 2
0
     $query = 'DELETE FROM ConfigItems
                 WHERE id_item=' . $id;
     $result = db_handler($query, "result", "Delete entry");
     if ($result) {
         # increase deleted items
         if (mysql_affected_rows() > 0) {
             $deleted_items++;
         }
         message($debug, '', "ok");
         # Special service handling
         if ($class == "service" and !empty($Host_ID)) {
             # Enter also the Host_ID of the deleted service into the History table
             history_add("removed", $class, $item_name, $Host_ID);
         } else {
             # Enter normal deletion, which object is deleted, without a "parent / linked" id
             history_add("removed", $class, $item_name);
         }
         // Go to next page without pressing the button (also have a look if class is not host, otherwise go back to overview )
         if (!empty($_POST["from"]) and $class != "host") {
             $url = $_POST["from"];
         } else {
             $url = $_SESSION["after_delete_page"];
         }
     } elseif (DB_NO_WRITES != 1) {
         message($error, 'Error deleting ' . $id . ':' . $query);
     }
 }
 // foreach
 # Feedback of delete action
 if ($deleted_items > 0) {
     //echo TXT_DELETED.' '.$deleted_items.' item(s)<br>';
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
    $ordering = $max_ord + 1;
}
# write to db
if ($write2db == "yes") {
    # ADD OR MODIFY
    if ($attr_id == "new") {
        ##
        ## ADD CONTENT ##
        ##
        $query = "INSERT INTO ConfigAttrs (attr_name,friendly_name,description,datatype,max_length,poss_values,predef_value,mandatory,ordering,visible,write_to_conf,naming_attr,link_as_child,link_bidirectional,fk_show_class_items,fk_id_class) VALUES ('{$attr_name}','{$friendly_name}','{$description}','{$datatype}','{$max_length}','{$poss_values}','{$predef_value}','{$mandatory}','{$ordering}','{$visible}','{$write2conf}','{$naming_attr}','{$link_as_child}','{$link_bidirectional}',{$fk_show_class_items},'{$fk_id_class}')";
        $result = db_handler($query, "result", "insert");
        if ($result) {
            # Get ID of insert:
            $new_id = mysql_insert_id();
            echo NConf_HTML::text("Successfully added attribute &quot;{$attr_name}&quot;");
            history_add("created", "Attribute", $attr_name);
            # Check for other itmes with same order number, and change theme
            set_attr_order($new_id, $ordering, $fk_id_class);
            # Delete Cache of modify (if still exist)
            if (isset($_SESSION["cache"]["modify_attr"])) {
                unset($_SESSION["cache"]["modify_attr"]);
            }
            # Go to show_attr page and show the class which the new added attribute belongs to
            $url = 'show_attr.php?class=' . $class_name;
            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 {
            echo "<h2>Failed to add attribute &quot;{$attr_name}&quot;</h2>";
        }
    } else {
        ##
Ejemplo n.º 5
0
<?php

require_once 'include/head.php';
echo NConf_HTML::title('Delete Attribute');
if (DB_NO_WRITES == 1) {
    message($info, TXT_DB_NO_WRITES);
}
if (isset($_POST["delete"]) and $_POST["delete"] == "yes" and (isset($_POST["id"]) and $_POST["id"] != "")) {
    // Delete entry
    $query = 'DELETE FROM ConfigAttrs
                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>
Ejemplo n.º 6
0
        $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"]);
        // Cache
        foreach ($_POST as $key => $value) {
            if ($key == "selectusergroup") {
Ejemplo n.º 7
0
             (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
         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");
        if ($deployment_info) {
            $content = 'The generated configuration has been written to the "nconf/output/" directory.<br>
                            To set up more sophisticated deployment functionality, please edit your "config/deployment.ini" file accordingly.<br>
                            For a complete list of available deployment options, refer to the online documentation on 
                            <a href="http://www.nconf.org" target="_blank">www.nconf.org</a>.';
            system("bash  /var/www/nconf/ADD-ONS/deploy_local.sh");
            echo NConf_HTML::limit_space(NConf_HTML::show_highlight('Note', $content));
        } else {
            // Show deployment button
            echo "<form method=\"POST\" action=\"call_file.php?module_file=deployment/main.php\" id=buttons>";
            echo '<input type=hidden name=status value="' . $status . '">';
            echo '<br><input type="submit" name="submit" value="Deploy" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only">';
            echo "</form><br>";
        }
    } else {
        // Simply show success message
        echo "<b>Changes updated successfully.</b><br><br>";
    }
} else {
    history_add("general", "config", "generate failed with syntax errors");
    // Remove generated config - syntax check has failed
    if (DEBUG_MODE == 1) {
        // Move generated config to "output" dir, but tag it as FAILED
        system("mv " . NCONFDIR . "/temp/NagiosConfig.tgz " . NCONFDIR . "/output/NagiosConfig_FAILED.tgz." . time());
    }
    // Remove generated config
    system("rm -rf " . NCONFDIR . "/temp/*");
    $content = "Deployment not possible due to errors in configuration.";
    echo NConf_HTML::limit_space(NConf_HTML::show_error('Error', $content));
}
mysql_close($dbh);
Ejemplo n.º 9
0
 public final function history($message, $status)
 {
     if ($status === TRUE) {
         history_add('module', 'deploy ' . $this->name, $message . ' (OK)');
     } else {
         history_add('module', 'deploy ' . $this->name, $message . ' (FAILED)');
     }
 }
Ejemplo n.º 10
0
function process_tinyadm()
{
    global $db;
    @session_start();
    remove_magic_quotes();
    if (!isset($_SESSION['user'])) {
        $_SESSION['user'] = '';
    }
    if (!isset($_SESSION['password'])) {
        $_SESSION['password'] = '';
    }
    if (!isset($_SESSION['database'])) {
        $_SESSION['database'] = '';
    }
    if (!isset($_SESSION['table'])) {
        $_SESSION['table'] = '';
    }
    if (!isset($_SESSION['last_sql'])) {
        $_SESSION['last_sql'] = '';
    }
    if (!isset($_SESSION['sql_history'])) {
        $_SESSION['sql_history'] = array();
    }
    $act = get_var('act');
    if ($act == 'login') {
        setcookie('tinymy_user', get_var('user'), time() + 5184000);
        // 2 months
        $_SESSION['user'] = addslashes(get_var('user'));
        $_SESSION['password'] = addslashes(get_var('password'));
    }
    $db = new sqldb($_SESSION['user'], $_SESSION['password'], $_SESSION['database']);
    if (!$db->is_connected()) {
        return draw_login_form();
    }
    if ($act == 'login') {
        // switch to default databas
        if (get_cookie('tinymy_database')) {
            $_SESSION['database'] = get_cookie('tinymy_database');
        }
    }
    switch ($act) {
        case 'sel_db':
            $_SESSION['database'] = get_var('d');
            $_SESSION['table'] = '';
            setcookie('tinymy_database', get_var('d'), time() + 5184000);
            // 2 months
            redirect_self();
            exit;
        case 'use_history':
            $idx = (int) get_var('idx');
            if (isset($_SESSION['sql_history'][$idx])) {
                $_SESSION['database'] = $_SESSION['sql_history'][$idx]['db'];
                $_SESSION['last_sql'] = $_SESSION['sql_history'][$idx]['sql'];
            }
            redirect_self();
            exit;
        case 'sel_table':
            $_SESSION['table'] = get_var('table');
            break;
        case 'do_export':
            ob_end_clean();
            // we need to pass through the following output from export immediately, without caching
            do_export();
            break;
        case 'logout':
            session_unset();
            session_destroy();
            redirect_self();
            exit;
        case 'exec_sql':
            history_add(get_var('sql'));
    }
    ob_start();
    // menu needs to be created after the possible sql has executed
    echo '<div id="content">';
    if ($act != 'export' && $act != 'do_export') {
        draw_sqlarea();
    }
    switch ($act) {
        case 'history':
            draw_history();
            break;
        case 'export':
            draw_export();
            break;
        case 'sel_db':
            break;
        case 'sel_table':
        case 'show_structure':
            h('<p style="margin-bottom: 8px;"><a href="?act=show_contents">Show contents of %s</a></p>', $_SESSION['table']);
            exec_sql_internal(sprintf('desc `%s`', mysqli_escape_string($db->conn_id, $_SESSION['table'])));
            exec_sql_singlerow(sprintf('show create table `%s`', mysqli_escape_string($db->conn_id, $_SESSION['table'])));
            break;
        case 'show_contents':
            h('<p style="margin-bottom: 8px;"><a href="?act=show_structure">Show structure of %s</a></p>', $_SESSION['table']);
            $res = mysqli_query($db->conn_id, sprintf("select count(*) from `%s`", mysqli_escape_string($db->conn_id, $_SESSION['table'])));
            if (!$res) {
                $db->error();
                //
            } else {
                list($reccount) = mysqli_fetch_row($res);
                pager($reccount);
                exec_sql_internal(sprintf('select * from `%s` %s', mysqli_escape_string($db->conn_id, $_SESSION['table']), pager_limits()));
            }
        case 'exec_sql':
            exec_sql();
            // in case the query changed the database, switch to it
            $cur_database = $db->get_current_database();
            if ($cur_database != $_SESSION['database']) {
                $_SESSION['database'] = $cur_database;
                setcookie('tinymy_database', $cur_database, time() + 5184000);
                // 2 months
            }
            break;
    }
    echo '</div>';
    // content
    $content = ob_get_contents();
    ob_end_clean();
    // menu needs to be created after all the sql has executed
    draw_db_menu();
    echo $content;
}
Ejemplo n.º 11
0
                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();
Ejemplo n.º 12
0
 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);
 }
 ////
 // Handle not visible attributes
Ejemplo n.º 13
0
         }
         # 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
         //echo 'The value is not different, so no change is needed.<br><br>';
         if ($handle_action == "multimodify") {
             $info_summary["ignored"][] = $name;
         }
     }
 }
     }
 }
 ################
 #### write to db
 ################
 # get class id
 $class_id = db_templates("get_id_of_class", $config_class);
 # history entry status for "edited"
 $edited = FALSE;
 $handle_action = 'multimodify';
 $items2write = $_POST;
 require 'include/items_write2db.php';
 // needs $items2write
 # history entry "edited"
 if ($edited) {
     history_add("edited", $config_class, $name, $id);
 }
 if ($config_class == "host") {
     # Vererben ?
     if (isset($vererben2)) {
         unset($vererben2);
     }
     $vererben2_result = db_templates("vererben", $id);
     while ($row = mysql_fetch_assoc($vererben2_result)) {
         $vererben2[$row["item_id"]] = $row["attr_name"];
     }
     if ($vererben1 !== $vererben2) {
         $ask_vererben = 1;
     }
 }
 ###
Ejemplo n.º 15
0
     // 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") {
     // give new ID back
     echo '<div id="clone_success">' . $new_service_id . '</div>';
Ejemplo n.º 16
0
                 ("' . $new_service_name . '", "' . $service_name_attr_id . '", ' . $new_service_id . ' )
             ON DUPLICATE KEY UPDATE
                 attr_value="' . $new_service_name . '"
             ';
 $insert = db_handler($query, "insert", 'Set name of cloned service to "' . $new_service_name . '"');
 # 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
                 WHERE id_attr=fk_id_attr
                     AND id_item=fk_id_item
                     AND id_item=' . $service_tpl["fk_id_item"] . '
                     AND naming_attr = "no"
                 ORDER BY ordering';
 $result = db_handler($query, "insert", "clone basic data of original service onto new service");
 # Now the service name is also entered, so make history entry
 history_add("added", "service", $new_service_id, $destination_host_id, "resolve_assignment");
 # clone items linked to original service onto new service
 $query = 'INSERT INTO ItemLinks (fk_id_item,fk_item_linked2,fk_id_attr,cust_order)
             SELECT ' . $new_service_id . ',fk_item_linked2,fk_id_attr,cust_order FROM ItemLinks 
                 WHERE fk_id_item=' . $service_tpl["fk_id_item"] . ' 
                     AND fk_item_linked2 <> ' . $source_host_id . '
                 ORDER BY fk_item_linked2';
 $result = db_handler($query, "insert", "clone items linked to original service onto new service");
 # 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");
 if ($_GET["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 . '"><b>' . $host_name . '</b></a> (new service name is "' . $new_service_name . '")';