/*
+-------------------------------------------------------------------------+
| Copyright (C) 2002 Ian Berry |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| cacti: the rrdtool frontend [php-auth, php-tree, php-form] |
+-------------------------------------------------------------------------+
| This code is currently maintained and debugged by Ian Berry, any |
| questions or comments regarding this code should be directed to: |
| - iberry@raxnet.net |
+-------------------------------------------------------------------------+
| - raXnet - http://www.raxnet.net/ |
+-------------------------------------------------------------------------+
*/?>
function read_graph_config_option($config_name) {
include ("config_settings.php");
$graph_config_array = unserialize($_SESSION["sess_graph_config_array"]);
if (!isset($graph_config_array[$config_name])) {
$graph_config_array[$config_name] = db_fetch_cell("select value from settings_graphs where name='$config_name' and user_id=" . $_SESSION["sess_user_id"]);
if (empty($graph_config_array[$config_name])) {
$graph_config_array[$config_name] = $settings_graphs[$config_name]["default"];
}
$_SESSION["sess_graph_config_array"] = serialize($graph_config_array);
}
return $graph_config_array[$config_name];
}
function read_config_option($config_name) {
$config_array = unserialize($_SESSION["sess_config_array"]);
if (!isset($config_array[$config_name])) {
$config_array[$config_name] = db_fetch_cell("select value from settings where name='$config_name'");
$_SESSION["sess_config_array"] = serialize($config_array);
}
return $config_array[$config_name];
}
function form_input_validate($field_value, $field_name, $regexp_match, $allow_nulls, $custom_message = 3) {
if (($allow_nulls == true) && ($field_value == "")) {
$array_field_names = unserialize($_SESSION["sess_field_values"]);
$array_field_names[$field_name] = $field_value;
$_SESSION["sess_field_values"] = serialize($array_field_names);
return $field_value;
}
if ((!ereg($regexp_match, $field_value) || (($allow_nulls == false) && ($field_value == "")))) {
raise_message($custom_message);
$array_error_fields = unserialize($_SESSION["sess_error_fields"]);
$array_error_fields[$field_name] = $field_name;
$_SESSION["sess_error_fields"] = serialize($array_error_fields);
}else{
$array_field_names = unserialize($_SESSION["sess_field_values"]);
$array_field_names[$field_name] = $field_value;
$_SESSION["sess_field_values"] = serialize($array_field_names);
}
return $field_value;
}
function is_error_message() {
include("config_arrays.php");
$array_messages = unserialize($_SESSION["sess_messages"]);
if (is_array($array_messages)) {
foreach (array_keys($array_messages) as $current_message_id) {
if ($messages[$current_message_id]["type"] == "error") { return true; }
}
}
return false;
}
function raise_message($message_id) {
$array_messages = unserialize($_SESSION["sess_messages"]);
$array_messages[$message_id] = $message_id;
$_SESSION["sess_messages"] = serialize($array_messages);
}
function display_output_messages() {
include("config_arrays.php");
include_once("form.php");
global $colors;
$array_messages = unserialize($_SESSION["sess_messages"]);
if (is_array($array_messages)) {
foreach (array_keys($array_messages) as $current_message_id) {
eval ('$message = "' . $messages[$current_message_id]["message"] . '";');
switch ($messages[$current_message_id]["type"]) {
case 'info':
start_box("", "98%", "00438C", "3", "center", "");
print "