Esempio n. 1
0
function read_graph_config_option($config_name, $force = FALSE)
{
    /* users must have cacti user auth turned on to use this, or the guest account must be active */
    if (read_config_option("auth_method") == 0 || !isset($_SESSION["sess_user_id"])) {
        /* first attempt to get the db setting for guest */
        $guest_uid = db_fetch_cell("SELECT id FROM user_auth WHERE username='******'");
        $db_setting = db_fetch_row("select value from settings_graphs where name='{$config_name}' and user_id=" . $guest_uid);
        if (isset($db_setting["value"])) {
            return $db_setting["value"];
        } else {
            return read_default_graph_config_option($config_name);
        }
    }
    if (isset($_SESSION["sess_graph_config_array"]) || $force) {
        $graph_config_array = $_SESSION["sess_graph_config_array"];
    }
    if (!isset($graph_config_array[$config_name])) {
        $db_setting = db_fetch_row("select value from settings_graphs where name='{$config_name}' and user_id=" . $_SESSION["sess_user_id"]);
        if (isset($db_setting["value"])) {
            $graph_config_array[$config_name] = $db_setting["value"];
        } else {
            $graph_config_array[$config_name] = read_default_graph_config_option($config_name);
        }
        $_SESSION["sess_graph_config_array"] = $graph_config_array;
    }
    return $graph_config_array[$config_name];
}
Esempio n. 2
0
function read_graph_config_option($config_name) {
	/* users must have cacti user auth turned on to use this */
	if ((read_config_option("auth_method") == "0") || (!isset($_SESSION["sess_user_id"]))) {
		return read_default_graph_config_option($config_name);
	}

	if (!isset($_SESSION["sess_graph_config_array"][$config_name])) {
		$db_setting = db_fetch_row("select value from settings_graphs where name='$config_name' and user_id=" . $_SESSION["sess_user_id"]);

		if (isset($db_setting["value"])) {
			$_SESSION["sess_graph_config_array"][$config_name] = $db_setting["value"];
		}else{
			$_SESSION["sess_graph_config_array"][$config_name] = read_default_graph_config_option($config_name);
		}
	}

	return $_SESSION["sess_graph_config_array"][$config_name];
}
Esempio n. 3
0
function read_graph_config_option($config_name, $force = FALSE)
{
    /* users must have cacti user auth turned on to use this */
    if (read_config_option("global_auth") != "on" || !isset($_SESSION["sess_user_id"])) {
        return read_default_graph_config_option($config_name);
    }
    if (isset($_SESSION["sess_graph_config_array"]) || $force) {
        $graph_config_array = $_SESSION["sess_graph_config_array"];
    }
    if (!isset($graph_config_array[$config_name])) {
        $db_setting = db_fetch_row("select value from settings_graphs where name='{$config_name}' and user_id=" . $_SESSION["sess_user_id"]);
        if (isset($db_setting["value"])) {
            $graph_config_array[$config_name] = $db_setting["value"];
        } else {
            $graph_config_array[$config_name] = read_default_graph_config_option($config_name);
        }
        $_SESSION["sess_graph_config_array"] = $graph_config_array;
    }
    return $graph_config_array[$config_name];
}
Esempio n. 4
0
function read_graph_config_option($config_name, $force = FALSE)
{
    global $config;
    /* users must have cacti user auth turned on to use this, or the guest account must be active */
    if (isset($_SESSION["sess_user_id"])) {
        $effective_uid = $_SESSION["sess_user_id"];
    } else {
        if (isset($config["config_options_array"]["export_user_id"])) {
            $effective_uid = $config["config_options_array"]["export_user_id"];
        } else {
            if (read_config_option("auth_method") == 0) {
                /* first attempt to get the db setting for guest */
                $effective_uid = db_fetch_cell("SELECT id FROM user_auth WHERE username='******'");
                if (strlen($effective_uid) == 0) {
                    $effective_uid = 0;
                }
                $db_setting = db_fetch_row("select value from settings_graphs where name='{$config_name}' and user_id=" . $effective_uid);
                if (isset($db_setting["value"])) {
                    return $db_setting["value"];
                } else {
                    return read_default_graph_config_option($config_name);
                }
            } else {
                $effective_uid = 0;
            }
        }
    }
    if (!$force) {
        if (isset($_SESSION["sess_graph_config_array"])) {
            $graph_config_array = $_SESSION["sess_graph_config_array"];
        } else {
            if (isset($config["config_options_array"]["export_user_id"])) {
                if (isset($config["config_graph_settings_array"])) {
                    $graph_config_array = $config["config_graph_settings_array"];
                }
            }
        }
    }
    if (!isset($graph_config_array[$config_name])) {
        $db_setting = db_fetch_row("select value from settings_graphs where name='{$config_name}' and user_id=" . $effective_uid);
        if (isset($db_setting["value"])) {
            $graph_config_array[$config_name] = $db_setting["value"];
        } else {
            $graph_config_array[$config_name] = read_default_graph_config_option($config_name);
        }
        if (isset($_SESSION)) {
            $_SESSION["sess_graph_config_array"] = $graph_config_array;
        } else {
            $config["config_graph_settings_array"] = $graph_config_array;
        }
    }
    return $graph_config_array[$config_name];
}
Esempio n. 5
0
function read_graph_config_option($config_name, $force = FALSE)
{
    global $config;
    /* users must have cacti user auth turned on to use this, or the guest account must be active */
    if (isset($_SESSION['sess_user_id'])) {
        $effective_uid = $_SESSION['sess_user_id'];
    } else {
        if (isset($config['config_options_array']['export_user_id'])) {
            $effective_uid = $config['config_options_array']['export_user_id'];
        } else {
            if (read_config_option('auth_method') == 0) {
                /* first attempt to get the db setting for guest */
                $effective_uid = db_fetch_cell_prepared('SELECT id FROM user_auth WHERE username= ?', array(read_config_option('guest_user')));
                if (strlen($effective_uid) == 0) {
                    $effective_uid = 0;
                }
                $db_setting = db_fetch_row_prepared('SELECT value FROM settings_graphs WHERE name = ? AND user_id = ?', array($config_name, $effective_uid));
                if (isset($db_setting['value'])) {
                    return $db_setting['value'];
                } else {
                    return read_default_graph_config_option($config_name);
                }
            } else {
                $effective_uid = 0;
            }
        }
    }
    if (!$force) {
        if (isset($_SESSION['sess_graph_config_array'])) {
            $graph_config_array = $_SESSION['sess_graph_config_array'];
        } else {
            if (isset($config['config_options_array']['export_user_id'])) {
                if (isset($config['config_graph_settings_array'])) {
                    $graph_config_array = $config['config_graph_settings_array'];
                }
            }
        }
    }
    if (!isset($graph_config_array[$config_name])) {
        $db_setting = db_fetch_row_prepared('SELECT value FROM settings_graphs WHERE name = ? AND user_id = ?', array($config_name, $effective_uid));
        if (isset($db_setting['value'])) {
            $graph_config_array[$config_name] = $db_setting['value'];
        } else {
            $graph_config_array[$config_name] = read_default_graph_config_option($config_name);
        }
        if (isset($_SESSION)) {
            $_SESSION['sess_graph_config_array'] = $graph_config_array;
        } else {
            $config['config_graph_settings_array'] = $graph_config_array;
        }
    }
    return $graph_config_array[$config_name];
}