"Delete", 2 => "Change Graph Template", 5 => "Change Host", 3 => "Duplicate", 4 => "Convert to Graph Template" ); /* set default action */ if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; } switch ($_REQUEST["action"]) { case 'save': form_save(); break; case 'actions': form_actions(); break; case 'graph_diff': include_once("./include/top_header.php"); graph_diff(); include_once("./include/bottom_footer.php"); break; case 'item': include_once("./include/top_header.php"); item(); include_once("./include/bottom_footer.php"); break; case 'graph_remove': graph_remove(); header("Location: graphs.php"); break; case 'graph_edit': include_once("./include/top_header.php"); graph_edit(); include_once("./include/bottom_footer.php"); break; default: include_once("./include/top_header.php"); graph(); include_once("./include/bottom_footer.php"); break; } /* -------------------------- Global Form Functions -------------------------- */ function add_tree_names_to_actions_array() { global $graph_actions; /* add a list of tree names to the actions dropdown */ $trees = db_fetch_assoc("select id,name from graph_tree order by name"); if (sizeof($trees) > 0) { foreach ($trees as $tree) { $graph_actions{"tr_" . $tree["id"]} = "Place on a Tree (" . $tree["name"] . ")"; } } } /* -------------------------- The Save Function -------------------------- */ function form_save() { if ((isset($_POST["save_component_graph_new"])) && (!empty($_POST["graph_template_id"]))) { $save["id"] = $_POST["local_graph_id"]; $save["graph_template_id"] = $_POST["graph_template_id"]; $save["host_id"] = $_POST["host_id"]; $local_graph_id = sql_save($save, "graph_local"); change_graph_template($local_graph_id, $_POST["graph_template_id"], true); /* update the title cache */ update_graph_title_cache($local_graph_id); } if (isset($_POST["save_component_graph"])) { $save1["id"] = $_POST["local_graph_id"]; $save1["host_id"] = $_POST["host_id"]; $save1["graph_template_id"] = $_POST["graph_template_id"]; $save2["id"] = $_POST["graph_template_graph_id"]; $save2["local_graph_template_graph_id"] = $_POST["local_graph_template_graph_id"]; $save2["graph_template_id"] = $_POST["graph_template_id"]; $save2["image_format_id"] = form_input_validate($_POST["image_format_id"], "image_format_id", "", true, 3); $save2["title"] = form_input_validate($_POST["title"], "title", "", false, 3); $save2["height"] = form_input_validate($_POST["height"], "height", "^[0-9]+$", false, 3); $save2["width"] = form_input_validate($_POST["width"], "width", "^[0-9]+$", false, 3); $save2["upper_limit"] = form_input_validate($_POST["upper_limit"], "upper_limit", "^-?[0-9]+$", false, 3); $save2["lower_limit"] = form_input_validate($_POST["lower_limit"], "lower_limit", "^-?[0-9]+$", false, 3); $save2["vertical_label"] = form_input_validate($_POST["vertical_label"], "vertical_label", "", true, 3); $save2["auto_scale"] = form_input_validate((isset($_POST["auto_scale"]) ? $_POST["auto_scale"] : ""), "auto_scale", "", true, 3); $save2["auto_scale_opts"] = form_input_validate($_POST["auto_scale_opts"], "auto_scale_opts", "", true, 3); $save2["auto_scale_log"] = form_input_validate((isset($_POST["auto_scale_log"]) ? $_POST["auto_scale_log"] : ""), "auto_scale_log", "", true, 3); $save2["auto_scale_rigid"] = form_input_validate((isset($_POST["auto_scale_rigid"]) ? $_POST["auto_scale_rigid"] : ""), "auto_scale_rigid", "", true, 3); $save2["auto_padding"] = form_input_validate((isset($_POST["auto_padding"]) ? $_POST["auto_padding"] : ""), "auto_padding", "", true, 3); $save2["base_value"] = form_input_validate($_POST["base_value"], "base_value", "^[0-9]+$", false, 3); $save2["export"] = form_input_validate((isset($_POST["export"]) ? $_POST["export"] : ""), "export", "", true, 3); $save2["unit_value"] = form_input_validate($_POST["unit_value"], "unit_value", "", true, 3); $save2["unit_exponent_value"] = form_input_validate((($_POST["unit_exponent_value"] == "") ? "NULL" : $_POST["unit_exponent_value"]), "unit_exponent_value", (($_POST["unit_exponent_value"] == "") ? "" : "^-?[0-9]+$"), true, 3); if (!is_error_message()) { $local_graph_id = sql_save($save1, "graph_local"); } if (!is_error_message()) { $save2["local_graph_id"] = $local_graph_id; $graph_templates_graph_id = sql_save($save2, "graph_templates_graph"); if ($graph_templates_graph_id) { raise_message(1); /* if template information chanegd, update all necessary template information */ if ($_POST["graph_template_id"] != $_POST["_graph_template_id"]) { /* check to see if the number of graph items differs, if it does; we need user input */ if ((!empty($_POST["graph_template_id"])) && (!empty($_POST["local_graph_id"])) && (sizeof(db_fetch_assoc("select id from graph_templates_item where local_graph_id=$local_graph_id")) != sizeof(db_fetch_assoc("select id from graph_templates_item where local_graph_id=0 and graph_template_id=" . $_POST["graph_template_id"])))) { /* set the template back, since the user may choose not to go through with the change at this point */ db_execute("update graph_local set graph_template_id=" . $_POST["_graph_template_id"] . " where id=$local_graph_id"); db_execute("update graph_templates_graph set graph_template_id=" . $_POST["_graph_template_id"] . " where local_graph_id=$local_graph_id"); header("Location: graphs.php?action=graph_diff&id=$local_graph_id&graph_template_id=" . $_POST["graph_template_id"]); exit; } } }else{ raise_message(2); } /* update the title cache */ update_graph_title_cache($local_graph_id); } if ((!is_error_message()) && ($_POST["graph_template_id"] != $_POST["_graph_template_id"])) { change_graph_template($local_graph_id, $_POST["graph_template_id"], true); }elseif (!empty($_POST["graph_template_id"])) { update_graph_snmp_query_cache($local_graph_id); } } if (isset($_POST["save_component_input"])) { /* first; get the current graph template id */ $graph_template_id = db_fetch_cell("select graph_template_id from graph_local where id=" . $_POST["local_graph_id"]); /* get all inputs that go along with this graph template */ $input_list = db_fetch_assoc("select id,column_name from graph_template_input where graph_template_id=$graph_template_id"); if (sizeof($input_list) > 0) { foreach ($input_list as $input) { /* we need to find out which graph items will be affected by saving this particular item */ $item_list = db_fetch_assoc("select graph_templates_item.id from graph_template_input_defs,graph_templates_item where graph_template_input_defs.graph_template_item_id=graph_templates_item.local_graph_template_item_id and graph_templates_item.local_graph_id=" . $_POST["local_graph_id"] . " and graph_template_input_defs.graph_template_input_id=" . $input["id"]); /* loop through each item affected and update column data */ if (sizeof($item_list) > 0) { foreach ($item_list as $item) { /* if we are changing templates, the POST vars we are searching for here will not exist. this is because the db and form are out of sync here, but it is ok to just skip over saving the inputs in this case. */ if (isset($_POST{$input["column_name"] . "_" . $input["id"]})) { db_execute("update graph_templates_item set " . $input["column_name"] . "='" . $_POST{$input["column_name"] . "_" . $input["id"]} . "' where id=" . $item["id"]); } } } } } } if (isset($_POST["save_component_graph_diff"])) { if ($_POST["type"] == "1") { $intrusive = true; }elseif ($_POST["type"] == "2") { $intrusive = false; } change_graph_template($_POST["local_graph_id"], $_POST["graph_template_id"], $intrusive); } if ((isset($_POST["save_component_graph_new"])) && (empty($_POST["graph_template_id"]))) { header("Location: graphs.php?action=graph_edit&host_id=" . $_POST["host_id"] . "&new=1"); }elseif ((is_error_message()) || (empty($_POST["local_graph_id"])) || (isset($_POST["save_component_graph_diff"])) || ($_POST["graph_template_id"] != $_POST["_graph_template_id"]) || ($_POST["host_id"] != $_POST["_host_id"])) { header("Location: graphs.php?action=graph_edit&id=" . (empty($local_graph_id) ? $_POST["local_graph_id"] : $local_graph_id) . (isset($_POST["host_id"]) ? "&host_id=" . $_POST["host_id"] : "")); }else{ header("Location: graphs.php"); } } /* ------------------------ The "actions" function ------------------------ */ function form_actions() { global $colors, $graph_actions; /* if we are to save this form, instead of display it */ if (isset($_POST["selected_items"])) { $selected_items = unserialize(stripslashes($_POST["selected_items"])); if ($_POST["drp_action"] == "1") { /* delete */ db_execute("delete from graph_templates_graph where " . array_to_sql_or($selected_items, "local_graph_id")); db_execute("delete from graph_templates_item where " . array_to_sql_or($selected_items, "local_graph_id")); db_execute("delete from graph_tree_items where " . array_to_sql_or($selected_items, "local_graph_id")); db_execute("delete from graph_local where " . array_to_sql_or($selected_items, "id")); }elseif ($_POST["drp_action"] == "2") { /* change graph template */ for ($i=0;($i graph template */ for ($i=0;($i"; $graph_array[$i] = $matches[1]; } $i++; } include_once("./include/top_header.php"); /* add a list of tree names to the actions dropdown */ add_tree_names_to_actions_array(); start_box("" . $graph_actions{$_POST["drp_action"]} . "", "60%", $colors["header_panel"], "3", "center", ""); print "
\n"; if ($_POST["drp_action"] == "1") { /* delete */ print "

Are you sure you want to delete the following graphs?

$graph_list

\n "; }elseif ($_POST["drp_action"] == "2") { /* change graph template */ print "

Choose a graph template and click save to change the graph template for the following graphs. Be aware that all warnings will be suppressed during the conversion, so graph data loss is possible.

$graph_list

New Graph Template:
"; form_dropdown("graph_template_id",db_fetch_assoc("select graph_templates.id,graph_templates.name from graph_templates"),"name","id","","","0"); print "

\n "; }elseif ($_POST["drp_action"] == "3") { /* duplicate */ print "

When you click save, the following graphs will be duplicated. You can optionally change the title format for the new graphs.

$graph_list

Title Format:
"; form_text_box("title_format", " (1)", "", "255", "30", "text"); print "

\n "; }elseif ($_POST["drp_action"] == "4") { /* graph -> graph template */ print "

When you click save, the following graphs will be converted into graph templates. You can optionally change the title format for the new graph templates.

$graph_list

Title Format:
"; form_text_box("title_format", " Template", "", "255", "30", "text"); print "

\n "; }elseif (ereg("^tr_([0-9]+)$", $_POST["drp_action"], $matches)) { /* place on tree */ print "

When you click save, the following graphs will be place under the branch selected below.

$graph_list

Destination Branch:
"; grow_dropdown_tree($matches[1], "tree_item_id", "0"); print "

\n \n "; }elseif ($_POST["drp_action"] == "5") { /* change host */ print "

Choose a new host for these graphs:

$graph_list

New Host:
"; form_dropdown("host_id",db_fetch_assoc("select id,CONCAT_WS('',description,' (',hostname,')') as name from host order by description,hostname"),"name","id","","","0"); print "

\n "; } if (!isset($graph_array)) { print "You must select at least one graph.\n"; $save_html = ""; }else{ $save_html = ""; } print " Cancel $save_html "; end_box(); include_once("./include/bottom_footer.php"); } /* ----------------------- item - Graph Items ----------------------- */ function item() { global $colors, $consolidation_functions, $graph_item_types, $struct_graph_item; if (empty($_GET["id"])) { $template_item_list = array(); $header_label = "[new]"; }else{ $template_item_list = db_fetch_assoc("select graph_templates_item.id, graph_templates_item.text_format, graph_templates_item.value, graph_templates_item.hard_return, graph_templates_item.graph_type_id, graph_templates_item.consolidation_function_id, data_template_rrd.data_source_name, cdef.name as cdef_name, colors.hex from graph_templates_item left join data_template_rrd on graph_templates_item.task_item_id=data_template_rrd.id left join data_local on data_template_rrd.local_data_id=data_local.id left join data_template_data on data_local.id=data_template_data.local_data_id left join cdef on cdef_id=cdef.id left join colors on color_id=colors.id where graph_templates_item.local_graph_id=" . $_GET["id"] . " order by graph_templates_item.sequence"); $host_id = db_fetch_cell("select host_id from graph_local where id=" . $_GET["id"]); $header_label = "[edit: " . get_graph_title($_GET["id"]) . "]"; } $graph_template_id = db_fetch_cell("select graph_template_id from graph_local where id=" . $_GET["id"]); if (empty($graph_template_id)) { $add_text = "graphs_items.php?action=item_edit&local_graph_id=" . $_GET["id"] . "&host_id=$host_id"; }else{ $add_text = ""; } start_box("Graph Items $header_label", "98%", $colors["header"], "3", "center", $add_text); draw_graph_items_list($template_item_list, "graphs_items.php", "local_graph_id=" . $_GET["id"], (empty($graph_template_id) ? false : true)); end_box(); } /* ------------------------------------ graph - Graphs ------------------------------------ */ function graph_diff() { global $colors, $struct_graph_item, $graph_item_types, $consolidation_functions; $template_query = "select graph_templates_item.id, graph_templates_item.text_format, graph_templates_item.value, graph_templates_item.hard_return, graph_templates_item.consolidation_function_id, graph_templates_item.graph_type_id, CONCAT_WS(' - ',data_template_data.name,data_template_rrd.data_source_name) as task_item_id, cdef.name as cdef_id, colors.hex as color_id from graph_templates_item left join data_template_rrd on graph_templates_item.task_item_id=data_template_rrd.id left join data_local on data_template_rrd.local_data_id=data_local.id left join data_template_data on data_local.id=data_template_data.local_data_id left join cdef on cdef_id=cdef.id left join colors on color_id=colors.id"; /* first, get information about the graph template as that's what we're going to model this graph after */ $graph_template_items = db_fetch_assoc(" $template_query where graph_templates_item.graph_template_id=" . $_GET["graph_template_id"] . " and graph_templates_item.local_graph_id=0 order by graph_templates_item.sequence"); /* next, get information about the current graph so we can make the appropriate comparisons */ $graph_items = db_fetch_assoc(" $template_query where graph_templates_item.local_graph_id=" . $_GET["id"] . " order by graph_templates_item.sequence"); $graph_template_inputs = db_fetch_assoc("select graph_template_input.column_name, graph_template_input_defs.graph_template_item_id from graph_template_input,graph_template_input_defs where graph_template_input.id=graph_template_input_defs.graph_template_input_id and graph_template_input.graph_template_id=" . $_GET["graph_template_id"]); /* ok, we want to loop through the array with the GREATEST number of items so we don't have to worry about tacking items on the end */ if (sizeof($graph_template_items) > sizeof($graph_items)) { $items = $graph_template_items; }else{ $items = $graph_items; } ?>
The template you have selected requires some changes to be made to the structure of your graph. Below is a preview of your graph along with changes that need to be completed as shown in the left-hand column.

Graph Preview", "98%", $colors["header"], "3", "center", ""); $graph_item_actions = array("normal" => "", "add" => "+", "delete" => "-"); $group_counter = 0; $i = 0; $mode = "normal"; $_graph_type_name = ""; if (sizeof($items) > 0) { foreach ($items as $item) { reset($struct_graph_item); /* graph grouping display logic */ $bold_this_row = false; $use_custom_row_color = false; $action_css = ""; unset($graph_preview_item_values); if ((sizeof($graph_template_items) > sizeof($graph_items)) && ($i >= sizeof($graph_items))) { $mode = "add"; $user_message = "When you click save, the items marked with a '+' will be added (Recommended)."; }elseif ((sizeof($graph_template_items) < sizeof($graph_items)) && ($i >= sizeof($graph_template_items))) { $mode = "delete"; $user_message = "When you click save, the items marked with a '-' will be removed (Recommended)."; } /* here is the fun meshing part. first we check the graph template to see if there is an input for each field of this row. if there is, we revert to the value stored in the graph, if not we revert to the value stored in the template. got that? ;) */ for ($j=0; ($j < count($graph_template_inputs)); $j++) { if ($graph_template_inputs[$j]["graph_template_item_id"] == (isset($graph_template_items[$i]["id"]) ? $graph_template_items[$i]["id"] : "")) { /* if we find out that there is an "input" covering this field/item, use the value from the graph, not the template */ $graph_item_field_name = (isset($graph_template_inputs[$j]["column_name"]) ? $graph_template_inputs[$j]["column_name"] : ""); $graph_preview_item_values[$graph_item_field_name] = (isset($graph_items[$i][$graph_item_field_name]) ? $graph_items[$i][$graph_item_field_name] : ""); } } /* go back through each graph field and find out which ones haven't been covered by the "inputs" above. for each one, use the value from the template */ while (list($field_name, $field_array) = each($struct_graph_item)) { if ($mode == "delete") { $graph_preview_item_values[$field_name] = (isset($graph_items[$i][$field_name]) ? $graph_items[$i][$field_name] : ""); }elseif (!isset($graph_preview_item_values[$field_name])) { $graph_preview_item_values[$field_name] = (isset($graph_template_items[$i][$field_name]) ? $graph_template_items[$i][$field_name] : ""); } } /* "prepare" array values */ $consolidation_function_id = $graph_preview_item_values["consolidation_function_id"]; $graph_type_id = $graph_preview_item_values["graph_type_id"]; /* color logic */ if (($graph_item_types[$graph_type_id] != "GPRINT") && ($graph_item_types[$graph_type_id] != $_graph_type_name)) { $bold_this_row = true; $use_custom_row_color = true; $hard_return = ""; if ($group_counter % 2 == 0) { $alternate_color_1 = "EEEEEE"; $alternate_color_2 = "EEEEEE"; $custom_row_color = "D5D5D5"; }else{ $alternate_color_1 = $colors["alternate"]; $alternate_color_2 = $colors["alternate"]; $custom_row_color = "D2D6E7"; } $group_counter++; } $_graph_type_name = $graph_item_types[$graph_type_id]; /* alternating row colors */ if ($use_custom_row_color == false) { if ($i % 2 == 0) { $action_column_color = $alternate_color_1; }else{ $action_column_color = $alternate_color_2; } }else{ $action_column_color = $custom_row_color; } print ""; $i++; /* make the left-hand column blue or red depending on if "add"/"remove" mode is set */ if ($mode == "add") { $action_column_color = $colors["header"]; $action_css = ""; }elseif ($mode == "delete") { $action_column_color = "C63636"; $action_css = "text-decoration: line-through;"; } if ($bold_this_row == true) { $action_css .= " font-weight:bold;"; } /* draw the TD that shows the user whether we are going to: KEEP, ADD, or DROP the item */ print "" . $graph_item_actions[$mode] . ""; print "Item # " . $i . "\n"; if (empty($graph_preview_item_values["task_item_id"])) { $graph_preview_item_values["task_item_id"] = "No Task"; } switch (true) { case ereg("(AREA|STACK|GPRINT|LINE[123])", $_graph_type_name): $matrix_title = "(" . $graph_preview_item_values["task_item_id"] . "): " . $graph_preview_item_values["text_format"]; break; case ereg("(HRULE|VRULE)", $_graph_type_name): $matrix_title = "HRULE: " . $graph_preview_item_values["value"]; break; case ereg("(COMMENT)", $_graph_type_name): $matrix_title = "COMMENT: " . $graph_preview_item_values["text_format"]; break; } /* use the cdef name (if in use) if all else fails */ if ($matrix_title == "") { if ($graph_preview_item_values["cdef_id"] != "") { $matrix_title .= "CDEF: " . $graph_preview_item_values["cdef_id"]; } } if ($graph_preview_item_values["hard_return"] == "on") { $hard_return = "<HR>"; } print "" . htmlspecialchars($matrix_title) . $hard_return . "\n"; print "" . $graph_item_types{$graph_preview_item_values["graph_type_id"]} . "\n"; print "" . $consolidation_functions{$graph_preview_item_values["consolidation_function_id"]} . "\n"; print " \n"; print "" . $graph_preview_item_values["color_id"] . "\n"; print ""; } }else{ form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],0); ?> No Items
 
 When you click save, the graph items will remain untouched (could cause inconsistencies).

"> ">
*Turn Graph Debug Mode.

Graph Template Selection $header_label", "98%", $colors["header"], "3", "center", ""); $form_array = array( "graph_template_id" => array( "method" => "drop_sql", "friendly_name" => "Selected Graph Template", "description" => "Choose a graph template to apply to this graph. Please note that graph data may be lost if you change the graph template after one is already applied.", "value" => (isset($graphs) ? $graphs["graph_template_id"] : "0"), "none_value" => "None", "sql" => "select graph_templates.id,graph_templates.name from graph_templates order by name" ), "host_id" => array( "method" => "drop_sql", "friendly_name" => "Host", "description" => "Choose the host that this graph belongs to.", "value" => (isset($_GET["host_id"]) ? $_GET["host_id"] : $host_id), "none_value" => "None", "sql" => "select id,CONCAT_WS('',description,' (',hostname,')') as name from host order by description,hostname" ), "graph_template_graph_id" => array( "method" => "hidden", "value" => (isset($graphs) ? $graphs["id"] : "0") ), "local_graph_id" => array( "method" => "hidden", "value" => (isset($graphs) ? $graphs["local_graph_id"] : "0") ), "local_graph_template_graph_id" => array( "method" => "hidden", "value" => (isset($graphs) ? $graphs["local_graph_template_graph_id"] : "0") ), "_graph_template_id" => array( "method" => "hidden", "value" => (isset($graphs) ? $graphs["graph_template_id"] : "0") ), "_host_id" => array( "method" => "hidden", "value" => (isset($host_id) ? $host_id : "0") ) ); /* don't display the "debug field" for a new form */ if (empty($_GET["id"])) { unset($form_array["debug"]); } draw_edit_form( array( "config" => array(), "fields" => $form_array ) ); end_box(); /* only display the "inputs" area if we are using a graph template for this graph */ if (!empty($graphs["graph_template_id"])) { start_box("Supplimental Graph Template Data", "98%", $colors["header"], "3", "center", ""); ?> Graph Fields $struct_graph[$field_name]); $form_array[$field_name]["value"] = (isset($graphs) ? $graphs[$field_name] : ""); $form_array[$field_name]["form_id"] = (isset($graphs) ? $graphs["id"] : "0"); if (!(($use_graph_template == false) || ($graphs_template{"t_" . $field_name} == "on"))) { $form_array[$field_name]["method"] = "hidden"; } } draw_edit_form( array( "config" => array( "no_form_tag" => true ), "fields" => $form_array ) ); $input_item_list = db_fetch_assoc("select * from graph_template_input where graph_template_id=" . $graphs["graph_template_id"] . " order by name"); /* modifications to the default graph items array */ $struct_graph_item["task_item_id"]["sql"] = "select CONCAT_WS('', case when host.description is null then 'No Host - ' when host.description is not null then '' end,data_template_data.name_cache,' (',data_template_rrd.data_source_name,')') as name, data_template_rrd.id from data_template_data,data_template_rrd,data_local left join host on data_local.host_id=host.id where data_template_rrd.local_data_id=data_local.id and data_template_data.local_data_id=data_local.id " . (empty($host_id) ? "" : " and data_local.host_id=$host_id") . " order by name"; ?> Graph Item Fields 0) { foreach ($input_item_list as $item) { $current_def_value = db_fetch_row("select graph_templates_item." . $item["column_name"] . ", graph_templates_item.id from graph_templates_item,graph_template_input_defs where graph_template_input_defs.graph_template_item_id=graph_templates_item.local_graph_template_item_id and graph_template_input_defs.graph_template_input_id=" . $item["id"] . " and graph_templates_item.local_graph_id=" . $_GET["id"] . " limit 0,1"); $form_array += array($item["column_name"] . "_" . $item["id"] => $struct_graph_item{$item["column_name"]}); $form_array{$item["column_name"] . "_" . $item["id"]}["friendly_name"] = $item["name"]; $form_array{$item["column_name"] . "_" . $item["id"]}["value"] = $current_def_value{$item["column_name"]}; } }else{ print "No Inputs"; } if (sizeof($input_item_list > 0)) { draw_edit_form( array( "config" => array(), "fields" => $form_array ) ); } end_box(); } /* graph item list goes here */ if ((!empty($_GET["id"])) && (empty($graphs["graph_template_id"]))) { item(); } if (!empty($_GET["id"])) { ?>
&rra_id=1" alt=""> RRDTool Says:

Graph Configuration", "98%", $colors["header"], "3", "center", ""); $form_array = array(); while (list($field_name, $field_array) = each($struct_graph)) { $form_array += array($field_name => $struct_graph[$field_name]); $form_array[$field_name]["value"] = (isset($graphs) ? $graphs[$field_name] : ""); $form_array[$field_name]["form_id"] = (isset($graphs) ? $graphs["id"] : "0"); if (!(($use_graph_template == false) || ($graphs_template{"t_" . $field_name} == "on"))) { $form_array[$field_name]["method"] = "template_" . $form_array[$field_name]["method"]; $form_array[$field_name]["description"] = ""; } } draw_edit_form( array( "config" => array( "no_form_tag" => true ), "fields" => $form_array ) ); end_box(); } if ((isset($_GET["id"])) || (isset($_GET["new"]))) { form_hidden_box("save_component_graph","1",""); form_hidden_box("save_component_input","1",""); }else{ form_hidden_box("save_component_graph_new","1",""); } form_save_button("graphs.php"); } function graph() { global $colors, $graph_actions; /* remember these search fields in session vars so we don't have to keep passing them around */ if (isset($_REQUEST["page"])) { $_SESSION["sess_graph_current_page"] = $_REQUEST["page"]; }elseif (isset($_SESSION["sess_graph_current_page"])) { $_REQUEST["page"] = $_SESSION["sess_graph_current_page"]; }else{ $_REQUEST["page"] = "1"; /* default value */ } if (isset($_REQUEST["filter"])) { $_SESSION["sess_graph_filter"] = $_REQUEST["filter"]; }elseif (isset($_SESSION["sess_graph_filter"])) { $_REQUEST["filter"] = $_SESSION["sess_graph_filter"]; }else{ $_REQUEST["filter"] = ""; /* default value */ } if (isset($_REQUEST["host_id"])) { $_SESSION["sess_graph_host_id"] = $_REQUEST["host_id"]; }elseif (isset($_SESSION["sess_graph_host_id"])) { $_REQUEST["host_id"] = $_SESSION["sess_graph_host_id"]; }else{ $_REQUEST["host_id"] = ""; /* default value */ } start_box("Graph Management", "98%", $colors["header"], "3", "center", "graphs.php?action=graph_edit&host_id=" . $_REQUEST["host_id"]); ?> ">
Filter by host:  ">  
$page_number"; }else{ $url_page_select .= "$page_number"; } if (($i+read_config_option("num_rows_graph")) < $total_rows) { $url_page_select .= ","; } } $nav = " \n \n \n
<< "; if ($_REQUEST["page"] > 1) { $nav .= ""; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= ""; } $nav .= " Showing Rows " . ((read_config_option("num_rows_graph")*($_REQUEST["page"]-1))+1) . " to " . ((($total_rows < read_config_option("num_rows_graph")) || ($total_rows < (read_config_option("num_rows_graph")*$_REQUEST["page"]))) ? $total_rows : (read_config_option("num_rows_graph")*$_REQUEST["page"])) . " of $total_rows [$url_page_select] "; if (($_REQUEST["page"] * read_config_option("num_rows_graph")) < $total_rows) { $nav .= ""; } $nav .= "Next"; if (($_REQUEST["page"] * read_config_option("num_rows_graph")) < $total_rows) { $nav .= ""; } $nav .= " >>
\n"; print " $nav Graph Title Template Name Size
"; $i = 0; if (sizeof($graph_list) > 0) { foreach ($graph_list as $graph) { form_alternate_row_color($colors["alternate"],$colors["light"],$i); ?> ">\\1", title_trim($graph["title_cache"], read_config_option("max_title_graph")));?> None" : $graph["name"]); ?> x "> No Graphs Found"; } end_box(false); /* add a list of tree names to the actions dropdown */ add_tree_names_to_actions_array(); ?>