예제 #1
0
function __autoload($class_name)
{
    $class_path = NCONFDIR . '/include/classes/class.' . $class_name . '.php';
    if (!empty($class_name) && file_exists($class_path)) {
        #include(NCONFDIR.'/include/classes/class.'.$class_name.'.php');
        require_once $class_path;
        NConf_DEBUG::set("class {$class_name}", 'DEBUG', 'Autoload');
    }
}
function remove_lock()
{
    # remove lock file
    global $lock_file;
    $unlink_status = unlink($lock_file);
    if (!$unlink_status) {
        NConf_DEBUG::set('removing old lock failed', 'ERROR');
    }
}
예제 #3
0
    NConf_DEBUG::set(" should be available in " . (600 - $lock_file_age) . " seconds", '', 'Next execution');
    NConf_DEBUG::set("Remove the 'generate.lock' in the 'temp' directory", '', 'Force remove lock?');
    # check if file is older than 10min(600sec) so replace it (should not be, because file will be removed)
    # but this will prevent lock file to stay there
    if ($lock_file_age < 600) {
        # some one other is generating the config
        NConf_DEBUG::set('Someone else is already generating the configuration.', 'ERROR');
        # close page and cancel action
        if (NConf_DEBUG::status('ERROR')) {
            echo NConf_HTML::exit_error();
        }
    } else {
        # remove lock file
        $unlink_status = unlink($lock_file);
        if (!$unlink_status) {
            NConf_DEBUG::set('removing old lock failed', 'ERROR');
        }
    }
    # if file is older, script will continue, and try to get lock again
}
# create lock
$generate_lock_handle = fopen($lock_file, 'w');
$status = flock($generate_lock_handle, LOCK_EX | LOCK_NB);
//lock the file
?>

<!-- jQuery part -->
<script type="text/javascript">

    // jQuery execute generate
    $(document).ready(function(){
예제 #4
0
    });

</script>


<?php 
echo NConf_HTML::ui_box_header("Configuration Deployment");
echo NConf_HTML::ui_box_content();
echo '<div style="height: 20px;">
            <div id="loading">
                <img src="img/working_small.gif"> in progress...
            </div>
          </div>';
// Load deployment class and create object
require_once "class.deployment.php";
require_once "class.deployment.modules.php";
// Load the NConf Deployment class
// It loads all the modules and handles the deployment basic stuff
$deployment = new NConf_Deployment();
// Loads the configuration of the user
// nconf/conf/deployment.ini
$deployment->import_config();
if (NConf_DEBUG::status('ERROR')) {
    // Show error if set
    echo NConf_HTML::limit_space(NConf_HTML::show_error());
} else {
    // Start deploying the files
    $deployment->run_deployment();
}
echo '</div>';
예제 #5
0
             case "entryname ASC":
                 NConf_DEBUG::set(CHECKCOMMAND_ORDER_COMMAND_NAME_ASC, 'INFO', CHECKCOMMAND_ORDER_PRETEXT);
                 $order_value = 'entryname DESC';
                 break;
             case "entryname DESC":
                 NConf_DEBUG::set(CHECKCOMMAND_ORDER_COMMAND_NAME_DESC, 'INFO', CHECKCOMMAND_ORDER_PRETEXT);
                 $order_value = 'sorting ASC, entryname ASC';
                 $ordering_default_service_name = TRUE;
                 break;
             case "sorting ASC, entryname ASC":
                 NConf_DEBUG::set(CHECKCOMMAND_ORDER_DEFAULT_SERVICE_NAME_ASC, 'INFO', CHECKCOMMAND_ORDER_PRETEXT);
                 $order_value = 'sorting DESC, entryname DESC';
                 $ordering_default_service_name = TRUE;
                 break;
             case "sorting DESC, entryname DESC":
                 NConf_DEBUG::set(CHECKCOMMAND_ORDER_DEFAULT_SERVICE_NAME_DESC, 'INFO', CHECKCOMMAND_ORDER_PRETEXT);
                 $order_value = 'entryname ASC';
                 break;
         }
     } elseif ($class == "service") {
         $order_value = (!empty($order) and $order == "hostname ASC, entryname ASC") ? 'hostname DESC, entryname DESC' : 'hostname ASC, entryname ASC';
     } else {
         $order_value = (!empty($order) and $order == "entryname ASC") ? 'entryname DESC' : 'entryname ASC';
     }
     echo '<td>
             <a href="' . $request_url4ordering . '&order=' . $order_value . '">' . $entry["friendly_name"] . '</a></td>';
 }
 if ($class == "host") {
     $order_value = $order == "BIN_IP ASC" ? 'BIN_IP DESC' : 'BIN_IP ASC';
     echo '<td width=100>
             <a href="' . $request_url4ordering . '&order=' . $order_value . '">' . FRIENDLY_NAME_IPADDRESS . '</a></td>';
예제 #6
0
            if (isset($_SESSION["cache"]["modify_attr"])) {
                unset($_SESSION["cache"]["modify_attr"]);
            }
            // set go back page (show attr ) with defined class
            $_SESSION["go_back_page"] = 'show_attr.php?class=' . $class_name;
            echo '<meta http-equiv="refresh" content="' . $redirecting_delay . '; url=' . $_SESSION["go_back_page"] . $naming_attr_message . '">';
            NConf_DEBUG::set('<a href="' . $_SESSION["go_back_page"] . $naming_attr_message . '"> [ this page ] (in ' . REDIRECTING_DELAY . ' seconds)</a>', 'INFO', "<br>redirecting to");
        } else {
            echo "<h2>Failed to modify attribute &quot;{$attr_name}&quot;</h2>";
        }
    }
} else {
    # write to db
    if (isset($_SESSION["cache"]["modify_attr"])) {
        unset($_SESSION["cache"]["modify_attr"]);
    }
    if (NConf_DEBUG::status('ERROR')) {
        $_SESSION["cache"]["use_cache"] = TRUE;
        echo NConf_HTML::limit_space(NConf_HTML::show_error());
        echo "<br><br>";
        echo NConf_HTML::back_button($_SESSION["go_back_page"]);
        # Cache
        foreach ($_POST as $key => $value) {
            $_SESSION["cache"]["modify_attr"][$attr_id][$key] = $value;
        }
    } else {
        echo NConf_DEBUG::show_debug('INFO', TRUE);
    }
}
mysql_close($dbh);
require_once 'include/foot.php';
예제 #7
0
            $_SESSION["cache"]["handle"][$key] = $value;
        }
    } else {
        if (isset($_SESSION["cache"]["handle"])) {
            unset($_SESSION["cache"]["handle"]);
        }
    }
    echo '</div>';
} elseif (isset($_POST["vererben"])) {
    # Handling inheritance to services
    inheritance_HostToService($id, 'apply_inheritance');
    echo NConf_DEBUG::show_debug('INFO', TRUE);
    if (isset($_SESSION["go_back_page"])) {
        // Go to next page without pressing the button
        echo '<meta http-equiv="refresh" content="' . REDIRECTING_DELAY . '; url=' . $_SESSION["go_back_page_ok"] . '">';
        NConf_DEBUG::set('<a href="' . $_SESSION["go_back_page_ok"] . '"> [ this page ] </a>', 'INFO', "<br>redirecting to");
    }
}
?>
<!-- Help text content -->
<div id="help_text" style="display: none">
    <div id="help_inheritance" title="host / service inheritance">
        <p>The host / service diff table gives you an overview of attributes being applied from a host onto its services.
        </p>
        <p>
            <strong>update</strong>
            <br>Service attributes, whose value differs from the host value, will be overwritten by default.
            <br>If you don't want to overwrite an attribute on the service side, disable the 'update' checkbox.
        </p>
        <p>
            <strong>service value</strong>
예제 #8
0
 public final function import_config()
 {
     // parse config file to array
     if (is_readable($this->config_path)) {
         $ini_array = parse_ini_file($this->config_path, TRUE);
         if (!empty($ini_array)) {
             NConf_DEBUG::set($ini_array, "DEBUG", "Loaded " . $this->config_path);
             // handle each config group
             foreach ($ini_array as $config_group_name => $config_group) {
                 // get type and unset type in config array
                 $type = $config_group["type"];
                 unset($config_group["type"]);
                 // If titel is unset, set the groupname for it
                 if (empty($config_group["title"])) {
                     $config_group["title"] = $config_group_name;
                 }
                 // import config to its module
                 if (class_exists($type, false)) {
                     $this->modules[$type]->import($config_group);
                 } else {
                     NConf_DEBUG::set("Configuration error, this type of deployment is not available", 'ERROR', $type);
                 }
             }
         } else {
             NConf_DEBUG::set($this->config_path, 'ERROR', 'Configuration is empty, please check your configuration file and read the documentation: ');
         }
     } else {
         NConf_DEBUG::set($this->config_path, 'ERROR', 'Could not read configuration file: ');
     }
 }
예제 #9
0
#
require_once NCONFDIR . '/include/includeAllClasses.php';
#
# mysql-DB settings
#
require_once NCONFDIR . '/config/mysql.php';
#
# mysql Initiate connection
#
$dbh = mysql_connect(DBHOST, DBUSER, DBPASS);
mysql_select_db(DBNAME);
#
# some misc gui things
#
require_once NCONFDIR . '/include/gui.php';
#
# part for messages
#
require_once NCONFDIR . '/include/messages.php';
##
## LOAD Functions
##
require_once NCONFDIR . '/include/functions.php';
##
## start debug info
##
NConf_DEBUG::set('', 'DEBUG', 'Header / ACL / navigation debugging');
##
## LOAD Modules
##
require_once NCONFDIR . '/include/modules.php';
예제 #10
0
        }
    }
}
# get also the debug informations
if ($debug == 'yes' and $json == 'no') {
    $title = 'Load file "' . $file_path . '" @ ' . date("H:i:s");
    // set ERROR
    if (NConf_DEBUG::status('ERROR')) {
        echo '<div id="ajax_error">';
        echo NConf_DEBUG::show_debug('ERROR', TRUE);
        echo '</div>';
    }
    // set DEBUG
    if (NConf_DEBUG::status('DEBUG')) {
        echo '<div id="ajax_debug">';
        echo NConf_HTML::swap_content(NConf_DEBUG::show_debug('DEBUG', TRUE), $title, FALSE, FALSE, 'color_list3');
        echo '</div>';
    }
    if (!empty($ajax) and $ajax == 'yes') {
        ?>
        <!-- jQuery part -->
        <script type="text/javascript">
            $(document).ready(function(){
                // fetch ERROR part and give to footer and display it
                $("#jquery_error").append( $("#ajax_error") );
                $("#ajax_error").parent("#jquery_error").show("blind");

                // fetch DEBUG part and give to footer (will be displayed if debug is enabled)
                $("#ajax_debug").prependTo( $("#jquery_console") );
                $("#jquery_console_parent").fadeIn("slow");
            });
예제 #11
0
        # feedback for clone2hosts
        if ($_POST["action"] == "clone2hosts") {
            $host_name = db_templates("get_value", $destination_host_id, "host_name");
            $host_link = '<a href="modify_item_service.php?id=' . $destination_host_id . '"><span class="link_with_tag">' . $host_name . '</span></a>';
            NConf_DEBUG::set("<i>" . $new_service_name . "</i>", 'INFO', $host_link);
            if (NConf_DEBUG::status('ERROR')) {
                $service_link = '<a href="detail.php?id=' . $new_service_id . '" target="_blank" class="link_with_tag">' . $new_service_name . '</a>';
                NConf_DEBUG::set($service_link, 'ERROR', "failed with service");
            }
        }
    }
    if ($_POST["action"] == "cloneONhost") {
        // give new ID back
        echo '<div id="clone_success">' . $new_service_id . '</div>';
    }
}
# output for clone2hosts
if ($_POST["action"] == "clone2hosts") {
    $source_service_name = db_templates("get_value", $_POST["service_id"], "service_description");
    if (NConf_DEBUG::status('ERROR')) {
        # error
        $feedback = "Failed, see debug for details.";
        echo '<div id="clone_error">' . $feedback;
        echo NConf_DEBUG::show_debug('INFO', TRUE);
        echo '</div>';
    } else {
        $feedback .= 'Successfully cloned to the following hosts:</b><br>';
        $feedback .= NConf_DEBUG::show_debug('INFO', TRUE);
        echo '<div id="clone_success" class="feedback">' . $feedback . '</div>';
    }
}
예제 #12
0
require_once NCONFDIR . '/include/access_rules.php';
# Show page or EXIT the script ? (based on above auth-checks)
if ($NConf_PERMISSIONS->checkPageAccess() === TRUE and $NConf_PERMISSIONS->checkIdAuthorization() !== FALSE) {
    NConf_DEBUG::set("Access granted", 'DEBUG', "ACL");
    # go ahead in file
} elseif (!isset($_SESSION["group"]) and empty($_GET["goto"])) {
    # not logged in
    # Go to login page, and redirect it to called page
    $url = 'index.php?goto=' . urlencode($_SERVER['REQUEST_URI']);
    # Redirect to login page with url as goto
    echo '<meta http-equiv="refresh" content="0; url=' . $url . '">';
    message($info, '<b>redirecting to:</b> <a href="' . $url . '"> [ this page ] </a>');
    require_once NCONFDIR . '/include/foot.php';
    exit;
} elseif (!isset($_SESSION["group"]) and !empty($_GET["goto"])) {
    # do nothing, login page will be displayed
    message($debug, "display login page");
} else {
    $message = $NConf_PERMISSIONS->message;
    NConf_DEBUG::set($message, 'INFO');
    NConf_DEBUG::set("Access denied", 'DEBUG', "ACL");
    //echo $message;
    echo NConf_HTML::limit_space(NConf_HTML::show_error('Error', $message));
    require_once NCONFDIR . '/include/foot.php';
    # EXIT because of no access
    exit;
}
# close header-part in DEBUG section
$debug_entry = NConf_HTML::line() . NConf_HTML::text("Page specific debugging:", FALSE, 'b');
NConf_DEBUG::set($debug_entry);
예제 #13
0
<?php

if (empty($_POST["host_id"])) {
    NConf_DEBUG::set("failed, received not all required infos", 'ERROR');
    exit;
}
$host_ID = $_POST["host_id"];
// mark added services
$added_service[] = !empty($_POST["highlight_service"]) ? $_POST["highlight_service"] : array();
# get class or take service as default
if (!empty($_POST["class"])) {
    $class = $_POST["class"];
} else {
    $class = "service";
}
if ($class == "advanced-service") {
    $list_title = 'Unassign an advanced service from this host<br>';
} elseif ($class == "hostgroup_service") {
    $list_title = '&nbsp;List of advanced services inherited over hostgroups<br>';
} elseif ($class == "service") {
    $list_title = '&nbsp;Edit services directly linked to a host<br>';
}
////
// Content of Page
////
echo '<div id="content">';
echo $list_title;
if ($class == "service") {
    echo '<table class="ui-widget ui-nconf-table" width="328">';
    echo '<colgroup>';
    echo '<col width="30">';
예제 #14
0
                            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");
            }
        }
        //foreach
        #############
        # show success message
        echo '<b>Successfully cloned selected host to &quot;' . $_POST["hostname"] . '&quot;</b>';
        echo '<br><br>Click for details: ';
        echo '<a href="detail.php?id=' . $new_host_id . '">' . $_POST["hostname"] . '</a>';
    } else {
        # else of write2db
        // Cache
        foreach ($_POST as $key => $value) {
            $_SESSION["cache"]["clone"][$key] = $value;
        }
        // Error message
        echo NConf_DEBUG::show_debug('ERROR', TRUE, $_SESSION["go_back_page"]);
    }
    # end of write2db
    ?>
                </td>
            </tr>
        </table>
    <?php 
}
// END Entry exists ?
mysql_close($dbh);
require_once 'include/foot.php';
예제 #15
0
                    $_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();
예제 #16
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;
}
         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;
         }
     }
     ###
     # end of write2db
     ###
     if (NConf_DEBUG::status('ERROR')) {
         echo NConf_DEBUG::show_debug('ERROR', TRUE);
         echo "<br><br>";
         echo NConf_HTML::back_button($_SESSION["go_back_page"]);
         // Cache
         $_SESSION["cache"]["use_cache"] = TRUE;
         foreach ($_POST as $key => $value) {
             $_SESSION["cache"]["handle"][$key] = $value;
         }
     } else {
         if (isset($_SESSION["cache"]["handle"])) {
             unset($_SESSION["cache"]["handle"]);
         }
         # get inheritance table for this host
         $preview[$name] = inheritance_HostToService($id, "preview");
     }
 }
예제 #18
0
 public static function show_error($title = "Error:", $content = '')
 {
     $output = '';
     $output .= '<div class="ui-state-error ui-corner-all fg-error">';
     $output .= '<span style="float: left; margin-right: 0.3em;" class="ui-icon ui-icon-alert">&nbsp;</span>';
     $output .= NConf_HTML::title($title, 2);
     if (!empty($content)) {
         $output .= $content;
     } else {
         $output .= NConf_DEBUG::show_debug('ERROR', TRUE);
     }
     $output .= '</div>';
     return $output;
 }
예제 #19
0
        }
    }
}
###
# Info/Warning in the top right corner
###
echo '<h2>Edit static config files</h2>';
echo '<div class="editor_info">';
if (NConf_DEBUG::status('ERROR')) {
    $title = 'WARNING';
    $content = NConf_DEBUG::show_debug('ERROR', TRUE);
    $content .= '<br>The webserver user must have write permissions for your config directory, <br>otherwise NConf cannot save your changes.';
    echo NConf_HTML::show_error($title, $content);
} elseif (NConf_DEBUG::status('INFO') and !empty($saved)) {
    $title = 'Successfully saved file';
    $content = ICON_TRUE . NConf_DEBUG::show_debug('INFO', TRUE);
    echo NConf_HTML::show_highlight($title, $content);
} else {
    $title = 'Info';
    $content = 'This mask allows administrators to modify static Nagios configuration files.';
    echo NConf_HTML::show_highlight($title, $content);
}
echo '</div>';
echo '<form name="editor" action="' . $request_url . '" method="post">

<fieldset class="inline">
<legend>choose a file</legend>
<table>
    <colgroup>
        <col width="70">
        <col>
예제 #20
0
    echo NConf_HTML::title("Info:", 2);
    echo NConf_DEBUG::show_debug("INFO");
    echo NConf_HTML::line();
}
// Display jQuery/ajax errors
echo '<div id="jquery_error" class="ui-state-error" style="display: none">';
echo '<span style="float: left; margin-right: 0.3em;" class="ui-icon ui-icon-alert">&nbsp;</span>';
echo NConf_HTML::title("Error:", 2);
echo '</div>';
if (NConf_DEBUG::status("ERROR")) {
    echo NConf_HTML::title("Error:", 2);
    echo '<font color="red">';
    echo NConf_DEBUG::show_debug("ERROR");
    echo '</font>';
    echo NConf_HTML::line();
}
if (DEBUG_MODE == 1) {
    echo '<div id="jquery_console_parent" style="padding: 0; display: none">';
    echo NConf_HTML::swap_content('<div id="jquery_console"></div>', "<b>jQuery debugging</b>", FALSE, FALSE);
    echo '</div>';
    NConf_DEBUG::display();
}
?>

        &nbsp;
    </div>
</div> <!-- END OF DIV "footer" -->

</body>
</html>
예제 #21
0
    // after echo because we want the redirect only in the footer
    NConf_DEBUG::set('<a href="' . $url . '"> add services </a>', 'INFO', "<br>redirecting to");
} else {
    // normal way to add items
    if (isset($_SESSION["cache"]["handle"])) {
        unset($_SESSION["cache"]["handle"]);
    }
    if (NConf_DEBUG::status('ERROR')) {
        echo NConf_HTML::show_error();
        echo "<br><br>";
        echo NConf_HTML::back_button($_SESSION["go_back_page"]);
        // Cache
        $_SESSION["cache"]["use_cache"] = TRUE;
        foreach ($_POST as $key => $value) {
            $_SESSION["cache"]["handle"][$key] = $value;
        }
    } else {
        // Item added, go back to overview of its class
        $url = 'overview.php?class=' . $config_class;
        echo '<meta http-equiv="refresh" content="' . REDIRECTING_DELAY . '; url=' . $url . '">';
        // add extra line (br) for more space
        echo NConf_DEBUG::show_debug('INFO', TRUE);
        NConf_DEBUG::set('<a href="' . $url . '"> overview </a>', 'INFO', "<br>redirecting to");
    }
}
echo '      </td>
        </tr>
    </table>
';
mysql_close($dbh);
require_once 'include/foot.php';
예제 #22
0
             if (is_int($attr["key"])) {
                 // add attribute
                 add_attribute($id, $attr["key"], $attr["value"]);
             }
         }
         ////
         // Handle not visible attributes
         // lookup visible=no attributes
         $attrs_visible_no = read_attributes($config_class, 'no');
         // add attributes (visible=no)
         foreach ($attrs_visible_no as $attribute_key => $attribute_value) {
             NConf_DEBUG::set($attribute_key . " -> " . $attribute_value, 'DEBUG', "Add attribute");
             $result = add_attribute($id, $attribute_key, $attribute_value);
         }
         if (DB_NO_WRITES != 1) {
             NConf_DEBUG::set('Successfully added <b>' . escape_string($_POST[$id_naming_attr]) . '</b>', 'INFO');
         }
         # cache
         if (isset($_SESSION["cache"]["modify"])) {
             unset($_SESSION["cache"]["modify"]);
         }
         if ($config_class == "host") {
             $_SESSION["created_id"] = $id;
             $step2 = "yes";
         }
         if ($id) {
             $_SESSION["created_id"] = $id;
         }
     }
 }
 # end of write2db
 public function checkPageAccess()
 {
     # URL check
     $debug = NConf_HTML::swap_content($this->debug, "URL ACL feedback", FALSE, TRUE);
     NConf_DEBUG::set($debug, 'DEBUG', NConf_HTML::status_text("URL ACL status", $this->url_check_status));
     if ($this->url_check_status === FALSE) {
         $this->message = "You don't have permission to access this page!";
     }
     return $this->url_check_status;
 }
예제 #24
0
function prepare_check_command_params($values)
{
    # Implode the splitet fields (exploded in handle_item.php)
    if (is_array($values)) {
        NConf_DEBUG::open_group("params for check command");
        foreach ($values as $field_key => $value_array) {
            # trim values
            NConf_DEBUG::set($value_array, '', "bevore trimming");
            $value_array_trimmed = array();
            foreach ($value_array as $value) {
                $value_array_trimmed[] = trim($value);
            }
            NConf_DEBUG::set($value_array_trimmed, '', "after trimming");
            if (array_diff($value_array, $value_array_trimmed)) {
                NConf_DEBUG::set("trimmed check command params", 'INFO');
            }
            # string starts with a "!"
            $imploded = "!";
            # implode the other arguments
            $imploded .= implode("!", $value_array_trimmed);
            # Save it to the POST-var, so the var will be added later in the script
            $_POST[$field_key] = $imploded;
        }
        NConf_DEBUG::close_group();
    }
}
예제 #25
0
            } else {
                message($debug, '[ FAILED ]');
            }
            ////
            // Add other attributes (visible=yes)
            foreach ($attrs_visible_yes as $attribute_key => $attribute_value) {
                NConf_DEBUG::set($attribute_key . " -> " . $attribute_value, 'DEBUG', "Add attribute");
                $result = add_attribute($new_service_ID, $attribute_key, $attribute_value);
            }
            ////
            // Handle not visible attributes
            // lookup visible=no attributes
            $attrs_visible_no = read_attributes('service', 'no');
            // add attributes (visible=no)
            foreach ($attrs_visible_no as $attribute_key => $attribute_value) {
                NConf_DEBUG::set($attribute_key . " -> " . $attribute_value, 'DEBUG', "Add attribute");
                $result = add_attribute($new_service_ID, $attribute_key, $attribute_value);
            }
            // give feedback for jQuery
            // add service to list of added services
            echo '<div id="add_success">' . $new_service_ID . '</div>';
        }
        // END if ( $insert ){
        //NConf_DEBUG::group_end();
    }
    // END while
} else {
    // give feedback for jQuery
    echo "No service to add";
}
// END is_array($_POST["checkcommands"])
예제 #26
0
# 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>';
// FIX menu user end
//include('include/menu/static_content/menu_user_end.php');
include 'include/menu/static_content/menu_user_end.html';
 public final function configured()
 {
     if (!empty($this->destinations)) {
         return TRUE;
     } else {
         NConf_DEBUG::set('has no configuration, skipping', 'DEBUG', 'Module ' . $this->name);
         return FALSE;
     }
 }
예제 #28
0
 public static function open_group($TITLE, $GROUPLEVEL = 'current', $LEVEL = "DEBUG")
 {
     if ($GROUPLEVEL == 'current') {
         $GROUPLEVEL = self::$GROUP_LEVEL;
     } elseif ($GROUPLEVEL == 'next') {
         $GROUPLEVEL = self::$GROUP_LEVEL + 1;
         self::$GROUP_LEVEL = $GROUPLEVEL;
     } elseif (is_int($GROUPLEVEL)) {
         self::$GROUP_LEVEL = $GROUPLEVEL;
     }
     self::set('', $LEVEL, $TITLE, $GROUPLEVEL);
 }
예제 #29
0
$output .= '</div>';
$output .= '<div name="help_services"></div>';
$output .= '<div style="clear: both"></div>';
$output .= '<div>';
// Service select field
$output .= '<fieldset class="inline">';
$output .= '<legend>Add additional services to host</legend>';
$output .= '<table>';
$output .= '<tr>
                    <td>
                        <select id="add_checkcommand" name="add_checkcommand">';
// create service name list (also checks for default service name)
# use check_name or service_name as ordering
$service_order = "check_name";
$service_names = db_templates('get_name_of_services', '', $service_order);
NConf_DEBUG::set($service_names, 'DEBUG', " get service names for add selection");
foreach ($service_names as $checkcommand) {
    if (!empty($checkcommand["default_service_name"])) {
        if ($service_order == "check_name") {
            $output .= '<option value=' . $checkcommand["item_ID"] . '>' . $checkcommand["check_name"] . ' (' . $checkcommand["default_service_name"] . ')</option>';
        } else {
            $output .= '<option value=' . $checkcommand["item_ID"] . '>' . $checkcommand["default_service_name"] . ' (' . $checkcommand["check_name"] . ')</option>';
        }
    } elseif (!empty($checkcommand["check_name"])) {
        $output .= '<option value=' . $checkcommand["item_ID"] . '>' . $checkcommand["check_name"] . '</option>';
    }
}
$output .= "</select>";
$output .= '</td>';
$output .= '<td>';
$output .= '<button id="add"></button>';