form save validation checks; save code unification/cleaup

git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/trunk/cacti@472 860744bd-22fc-0310-8c96-e9fe5004b5ca
This commit is contained in:
Ian Berry committed 2003-02-06 06:04:00 +00:00
1 parent b663633c1d
commit f93b7e58f5
13 files changed
+1152 -1320

No files matched your search

+55 -58
View File
@@ -32,9 +32,8 @@ include_once ('include/form.php');
switch ($_REQUEST["action"]) {
case 'save':
$redirect_location = form_save();
form_save();
header ("Location: $redirect_location"); exit;
break;
case 'item_movedown':
item_movedown();
@@ -99,11 +98,59 @@ function draw_cdef_preview($cdef_id) {
function form_save() {
if (isset($_POST["save_component_cdef"])) {
cdef_save();
return "cdef.php";
$save["id"] = $_POST["id"];
$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
if (!is_error_message()) {
$cdef_id = sql_save($save, "cdef");
if ($cdef_id) {
raise_message(1);
}else{
raise_message(2);
}
}
if (is_error_message()) {
header ("Location: cdef.php?action=edit&id=" . (empty($cdef_id) ? $_POST["id"] : $cdef_id));
}else{
header ("Location: cdef.php");
}
}elseif (isset($_POST["save_component_item"])) {
item_save();
return "cdef.php?action=edit&id=" . $_POST["cdef_id"];
if ($_POST["value_function"] != "0") { $current_type = 1; $current_value = $_POST["value_function"]; }
if ($_POST["value_operator"] != "0") { $current_type = 2; $current_value = $_POST["value_operator"]; }
if ($_POST["value_special_data_source"] != "0") { $current_type = 4; $current_value = $_POST["value_special_data_source"]; }
if ($_POST["value_cdef"] != "0") { $current_type = 5; $current_value = $_POST["value_cdef"]; }
if ($_POST["value_custom"] != "") { $current_type = 6; $current_value = $_POST["value_custom"]; }
if (!(isset($current_type))) {
/* YOU MUST SELECT SOMETHING */
header ("Location: cdef.php?action=edit&id=" . $_POST["cdef_id"]); exit;
}
$sequence = get_sequence($_POST["id"], "sequence", "cdef_items", "cdef_id=" . $_POST["cdef_id"]);
$save["id"] = $_POST["id"];
$save["cdef_id"] = $_POST["cdef_id"];
$save["sequence"] = $sequence;
$save["type"] = $current_type;
$save["value"] = $current_value;
if (!is_error_message()) {
$cdef_item_id = sql_save($save, "cdef_items");
if ($cdef_item_id) {
raise_message(1);
}else{
raise_message(2);
}
}
if (is_error_message()) {
header ("Location: cdef.php?action=item_edit&cdef_id=" . $_POST["cdef_id"] . "&id=" . (empty($cdef_item_id) ? $_POST["id"] : $cdef_item_id));
}else{
header ("Location: cdef.php?action=edit&id=$cdef_id");
}
}
}
@@ -123,29 +170,6 @@ function item_remove() {
db_execute("delete from cdef_items where id=" . $_GET["id"]);
}
function item_save() {
if ($_POST["value_function"] != "0") { $current_type = 1; $current_value = $_POST["value_function"]; }
if ($_POST["value_operator"] != "0") { $current_type = 2; $current_value = $_POST["value_operator"]; }
if ($_POST["value_special_data_source"] != "0") { $current_type = 4; $current_value = $_POST["value_special_data_source"]; }
if ($_POST["value_cdef"] != "0") { $current_type = 5; $current_value = $_POST["value_cdef"]; }
if ($_POST["value_custom"] != "") { $current_type = 6; $current_value = $_POST["value_custom"]; }
if (!(isset($current_type))) {
/* YOU MUST SELECT SOMETHING */
header ("Location: cdef.php?action=edit&id=" . $_POST["cdef_id"]); exit;
}
$sequence = get_sequence($_POST["id"], "sequence", "cdef_items", "cdef_id=" . $_POST["cdef_id"]);
$save["id"] = $_POST["id"];
$save["cdef_id"] = $_POST["cdef_id"];
$save["sequence"] = $sequence;
$save["type"] = $current_type;
$save["value"] = $current_value;
sql_save($save, "cdef_items");
}
function item_edit() {
global $colors, $cdef_functions, $cdef_operators, $custom_data_source_types;
@@ -153,8 +177,6 @@ function item_edit() {
$cdef = db_fetch_row("select * from cdef_items where id=" . $_GET["id"]);
$current_type = $cdef["type"];
$values[$current_type] = $cdef["value"];
}else{
unset($cdef);
}
start_box("", "98%", "aaaaaa", "3", "center", "");
@@ -213,16 +235,7 @@ function item_edit() {
form_hidden_box("save_component_item","1","");
end_box();
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "cdef.php");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("cdef.php");
}
/* ---------------------
@@ -245,13 +258,6 @@ function cdef_remove() {
}
}
function cdef_save() {
$save["id"] = $_POST["id"];
$save["name"] = $_POST["name"];
sql_save($save, "cdef");
}
function cdef_edit() {
global $colors, $cdef_item_types;
@@ -318,16 +324,7 @@ function cdef_edit() {
form_hidden_box("save_component_cdef","1","");
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "cdef.php");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("cdef.php");
}
function cdef() {
+25 -23
View File
@@ -29,9 +29,8 @@ include_once ('include/form.php');
switch ($_REQUEST["action"]) {
case 'save':
$redirect_location = form_save();
form_save();
header ("Location: $redirect_location"); exit;
break;
case 'remove':
color_remove();
@@ -60,8 +59,24 @@ switch ($_REQUEST["action"]) {
function form_save() {
if (isset($_POST["save_component_color"])) {
color_save();
return "color.php";
$save["id"] = $_POST["id"];
$save["hex"] = form_input_validate($_POST["hex"], "hex", "^[a-fA-F0-9]+$", false, 3);
if (!is_error_message()) {
$color_id = sql_save($save, "colors");
if ($color_id) {
raise_message(1);
}else{
raise_message(2);
}
}
if (is_error_message()) {
header ("Location: color.php?action=edit&id=" . (empty($color_id) ? $_POST["id"] : $color_id));
}else{
header ("Location: color.php");
}
}
}
@@ -69,13 +84,6 @@ function form_save() {
Color Functions
----------------------- */
function color_save() {
$save["id"] = $_POST["id"];
$save["hex"] = $_POST["hex"];
sql_save($save, "colors");
}
function color_remove() {
db_execute("delete from colors where id=" . $_GET["id"]);
}
@@ -85,11 +93,12 @@ function color_edit() {
if (isset($_GET["id"])) {
$color = db_fetch_row("select * from colors where id=" . $_GET["id"]);
$header_label = "[edit: " . $color["hex"] . "]";
}else{
unset($color);
$header_label = "[new]";
}
start_box("<strong>Colors [edit]</strong>", "98%", $colors["header"], "3", "center", "");
start_box("<strong>Colors</strong> $header_label", "98%", $colors["header"], "3", "center", "");
?>
<form method="post" action="color.php">
@@ -101,20 +110,13 @@ function color_edit() {
</td>
<?php form_text_box("hex",$color["hex"],"","6", "40");?>
</tr>
<?php
end_box();
form_hidden_id("id",$_GET["id"]);
form_hidden_box("save_component_color","1","");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right" background="images/blue_line.gif">
<?php form_save_button("save", "color.php");?>
</form>
</td>
</tr>
<?php
end_box();
form_save_button("color.php");
}
function color() {
+90 -98
View File
@@ -31,9 +31,8 @@ include_once ('include/form.php');
switch ($_REQUEST["action"]) {
case 'save':
$redirect_location = form_save();
form_save();
header ("Location: $redirect_location"); exit;
break;
case 'field_remove':
field_remove();
@@ -73,11 +72,94 @@ switch ($_REQUEST["action"]) {
-------------------------- */
function form_save() {
global $registered_cacti_names;
if (isset($_POST["save_component_data_input"])) {
return data_save();
$save["id"] = $_POST["id"];
$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
$save["input_string"] = form_input_validate($_POST["input_string"], "input_string", "", true, 3);
$save["output_string"] = form_input_validate($_POST["output_string"], "output_string", "", true, 3);
$save["type_id"] = form_input_validate($_POST["type_id"], "type_id", "", true, 3);
if (!is_error_message()) {
$data_input_id = sql_save($save, "data_input");
if ($data_input_id) {
raise_message(1);
/* get a list of each field so we can note their sequence of occurance in the database */
if (!empty($_POST["id"])) {
db_execute("update data_input_fields set sequence=0 where data_input_id=" . $_POST["id"]);
if (preg_match_all("/<([_a-zA-Z0-9]+)>/", $_POST["input_string"], $matches)) {
$j = 0;
for ($i=0; ($i < count($matches[1])); $i++) {
if (in_array($matches[1][$i], $registered_cacti_names) == false) {
$j++; db_execute("update data_input_fields set sequence=$j where data_input_id=" . $_POST["id"] . " and input_output='in' and data_name='" . $matches[1][$i] . "'");
}
}
}
if (preg_match_all("/<([_a-zA-Z0-9]+)>/", $_POST["output_string"], $matches)) {
$j = 0;
for ($i=0; ($i < count($matches[1])); $i++) {
if (in_array($matches[1][$i], $registered_cacti_names) == false) {
$j++; db_execute("update data_input_fields set sequence=$j where data_input_id=" . $_POST["id"] . " and input_output='out' and data_name='" . $matches[1][$i] . "'");
}
}
}
}
}else{
raise_message(2);
}
}
if ((is_error_message()) || (empty($_POST["id"]))) {
header ("Location: data_input.php?action=edit&id=" . (empty($data_input_id) ? $_POST["id"] : $data_input_id));
}else{
header ("Location: data_input.php");
}
}elseif (isset($_POST["save_component_field"])) {
field_save();
return "data_input.php?action=edit&id=" . $_POST["data_input_id"];
$save["id"] = $_POST["id"];
$save["data_input_id"] = $_POST["data_input_id"];
$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
$save["data_name"] = form_input_validate($_POST["data_name"], "data_name", "", true, 3);
$save["input_output"] = $_POST["input_output"];
$save["update_rra"] = form_input_validate($_POST["update_rra"], "update_rra", "", true, 3);
$save["sequence"] = $_POST["sequence"];
$save["type_code"] = form_input_validate($_POST["type_code"], "type_code", "", true, 3);
$save["regexp_match"] = form_input_validate($_POST["regexp_match"], "regexp_match", "", true, 3);
$save["allow_nulls"] = form_input_validate($_POST["allow_nulls"], "allow_nulls", "", true, 3);
if (!is_error_message()) {
$data_input_field_id = sql_save($save, "data_input_fields");
if ($data_input_field_id) {
raise_message(1);
if (!empty($data_input_field_id)) {
if (preg_match_all("/<([_a-zA-Z0-9]+)>/", db_fetch_cell("select " . $_POST["input_output"] . "put_string from data_input where id=" . $_POST["data_input_id"]), $matches)) {
$j = 0;
for ($i=0; ($i < count($matches[1])); $i++) {
if (in_array($matches[1][$i], $registered_cacti_names) == false) {
$j++;
if ($matches[1][$i] == $_POST["data_name"]) {
db_execute("update data_input_fields set sequence=$j where data_input_id=" . $_POST["data_input_id"] . " and input_output='" . $_POST["input_output"]. "' and data_name='" . $matches[1][$i] . "'");
}
}
}
}
}
}else{
raise_message(2);
}
}
if (is_error_message()) {
header ("Location: data_input.php?action=field_edit&data_input_id=" . $_POST["data_input_id"] . "&id=" . (empty($data_input_field_id) ? $_POST["id"] : $data_input_field_id));
}else{
header ("Location: data_input.php?action=edit&id=" . $_POST["data_input_id"]);
}
}
}
@@ -86,7 +168,7 @@ function form_save() {
-------------------------- */
function field_remove() {
global $config, $registered_cacti_names;
global $registered_cacti_names;
if ((read_config_option("remove_verification") == "on") && ($_GET["confirm"] != "yes")) {
include ('include/top_header.php');
@@ -114,37 +196,6 @@ function field_remove() {
}
}
function field_save() {
global $registered_cacti_names;
$save["id"] = $_POST["id"];
$save["data_input_id"] = $_POST["data_input_id"];
$save["name"] = $_POST["name"];
$save["data_name"] = $_POST["data_name"];
$save["input_output"] = $_POST["input_output"];
$save["update_rra"] = $_POST["update_rra"];
$save["sequence"] = $_POST["sequence"];
$save["type_code"] = $_POST["type_code"];
$save["regexp_match"] = $_POST["regexp_match"];
$save["allow_nulls"] = $_POST["allow_nulls"];
$data_input_field_id = sql_save($save, "data_input_fields");
if (!empty($data_input_field_id)) {
if (preg_match_all("/<([_a-zA-Z0-9]+)>/", db_fetch_cell("select " . $_POST["input_output"] . "put_string from data_input where id=" . $_POST["data_input_id"]), $matches)) {
$j = 0;
for ($i=0; ($i < count($matches[1])); $i++) {
if (in_array($matches[1][$i], $registered_cacti_names) == false) {
$j++;
if ($matches[1][$i] == $_POST["data_name"]) {
db_execute("update data_input_fields set sequence=$j where data_input_id=" . $_POST["data_input_id"] . " and input_output='" . $_POST["input_output"]. "' and data_name='" . $matches[1][$i] . "'");
}
}
}
}
}
}
function field_edit() {
global $colors, $registered_cacti_names;
@@ -260,16 +311,7 @@ function field_edit() {
form_hidden_box("save_component_field","1","");
end_box();
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "data_input.php");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("data_input.php");
}
/* -----------------------
@@ -293,47 +335,6 @@ function data_remove() {
}
}
function data_save() {
global $registered_cacti_names;
$save["id"] = $_POST["id"];
$save["name"] = $_POST["name"];
$save["input_string"] = $_POST["input_string"];
$save["output_string"] = $_POST["output_string"];
$save["type_id"] = $_POST["type_id"];
$data_input_id = sql_save($save, "data_input");
/* get a list of each field so we can note their sequence of occurance in the database */
if (!empty($_POST["id"])) {
db_execute("update data_input_fields set sequence=0 where data_input_id=" . $_POST["id"]);
if (preg_match_all("/<([_a-zA-Z0-9]+)>/", $_POST["input_string"], $matches)) {
$j = 0;
for ($i=0; ($i < count($matches[1])); $i++) {
if (in_array($matches[1][$i], $registered_cacti_names) == false) {
$j++; db_execute("update data_input_fields set sequence=$j where data_input_id=" . $_POST["id"] . " and input_output='in' and data_name='" . $matches[1][$i] . "'");
}
}
}
if (preg_match_all("/<([_a-zA-Z0-9]+)>/", $_POST["output_string"], $matches)) {
$j = 0;
for ($i=0; ($i < count($matches[1])); $i++) {
if (in_array($matches[1][$i], $registered_cacti_names) == false) {
$j++; db_execute("update data_input_fields set sequence=$j where data_input_id=" . $_POST["id"] . " and input_output='out' and data_name='" . $matches[1][$i] . "'");
}
}
}
}
if (empty($_POST["id"])) {
return "data_input.php?action=edit&id=$data_input_id";
}else{
return "data_input.php";
}
}
function data_edit() {
global $colors, $input_types;
@@ -459,16 +460,7 @@ function data_edit() {
form_hidden_box("save_component_data_input","1","");
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "data_input.php");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("data_input.php");
}
function data() {
+40 -60
View File
@@ -31,9 +31,8 @@ include_once ('include/form.php');
switch ($_REQUEST["action"]) {
case 'save':
$redirect_location = form_save();
form_save();
header ("Location: $redirect_location"); exit;
break;
case 'remove':
snmp_remove();
@@ -62,9 +61,45 @@ switch ($_REQUEST["action"]) {
function form_save() {
if (isset($_POST["save_component_snmp_query"])) {
$url = snmp_save();
$save["id"] = $_POST["id"];
$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
$save["description"] = form_input_validate($_POST["description"], "description", "", true, 3);
$save["xml_path"] = form_input_validate($_POST["xml_path"], "xml_path", "", false, 3);
$save["graph_template_id"] = $_POST["graph_template_id"];
$save["data_input_id"] = $_POST["data_input_id"];
return $url;
if (!is_error_message()) {
$snmp_query_id = sql_save($save, "snmp_query");
if ($snmp_query_id) {
raise_message(1);
db_execute ("delete from snmp_query_dt_field where snmp_query_id=$snmp_query_id");
db_execute ("delete from snmp_query_dt_rrd where snmp_query_id=$snmp_query_id");
while (list($var, $val) = each($_POST)) {
if (eregi("^mdt_([0-9]+)_([0-9]+)_check", $var)) {
$data_template_id = ereg_replace("^mdt_([0-9]+)_([0-9]+).+", "\\1", $var);
$data_input_field_id = ereg_replace("^mdt_([0-9]+)_([0-9]+).+", "\\2", $var);
db_execute ("replace into snmp_query_dt_field (snmp_query_id,data_template_id,data_input_field_id,action_id) values($snmp_query_id,$data_template_id,$data_input_field_id," . $_POST{"mdt_" . $data_template_id . "_" . $data_input_field_id . "_action_id"} . ")");
}elseif (eregi("^dsdt_([0-9]+)_([0-9]+)_check", $var)) {
$data_template_id = ereg_replace("^dsdt_([0-9]+)_([0-9]+).+", "\\1", $var);
$data_template_rrd_id = ereg_replace("^dsdt_([0-9]+)_([0-9]+).+", "\\2", $var);
db_execute ("replace into snmp_query_dt_rrd (snmp_query_id,data_template_id,data_template_rrd_id,snmp_field_name) values($snmp_query_id,$data_template_id,$data_template_rrd_id,'" . $_POST{"dsdt_" . $data_template_id . "_" . $data_template_rrd_id . "_snmp_field_output"} . "')");
}
}
}else{
raise_message(2);
}
}
if ((is_error_message()) || (empty($_POST["id"]))) {
header ("Location: snmp.php?action=edit&id=" . (empty($snmp_query_id) ? $_POST["id"] : $snmp_query_id));
}else{
header ("Location: snmp.php");
}
}
}
@@ -88,55 +123,11 @@ function snmp_remove() {
}
}
function snmp_save() {
$save["id"] = $_POST["id"];
$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
$save["description"] = form_input_validate($_POST["description"], "description", "", true, 3);
$save["xml_path"] = form_input_validate($_POST["xml_path"], "xml_path", "", false, 3);
$save["graph_template_id"] = $_POST["graph_template_id"];
$save["data_input_id"] = $_POST["data_input_id"];
$snmp_query_id = sql_save($save, "snmp_query");
db_execute ("delete from snmp_query_dt_field where snmp_query_id=$snmp_query_id");
db_execute ("delete from snmp_query_dt_rrd where snmp_query_id=$snmp_query_id");
while (list($var, $val) = each($_POST)) {
if (eregi("^mdt_([0-9]+)_([0-9]+)_check", $var)) {
$data_template_id = ereg_replace("^mdt_([0-9]+)_([0-9]+).+", "\\1", $var);
$data_input_field_id = ereg_replace("^mdt_([0-9]+)_([0-9]+).+", "\\2", $var);
//if (isset($_POST{"dt_" . $data_template_id})) {
db_execute ("replace into snmp_query_dt_field (snmp_query_id,data_template_id,data_input_field_id,action_id) values($snmp_query_id,$data_template_id,$data_input_field_id," . $_POST{"mdt_" . $data_template_id . "_" . $data_input_field_id . "_action_id"} . ")");
//}
}elseif (eregi("^dsdt_([0-9]+)_([0-9]+)_check", $var)) {
$data_template_id = ereg_replace("^dsdt_([0-9]+)_([0-9]+).+", "\\1", $var);
$data_template_rrd_id = ereg_replace("^dsdt_([0-9]+)_([0-9]+).+", "\\2", $var);
//if (isset($_POST{"dt_" . $data_template_id})) {
db_execute ("replace into snmp_query_dt_rrd (snmp_query_id,data_template_id,data_template_rrd_id,snmp_field_name) values($snmp_query_id,$data_template_id,$data_template_rrd_id,'" . $_POST{"dsdt_" . $data_template_id . "_" . $data_template_rrd_id . "_snmp_field_output"} . "')");
//}
}
}
if (is_error_message()) {
return $_SERVER["HTTP_REFERER"];
}else{
if (empty($_POST["id"])) {
return "snmp.php?action=edit&id=$snmp_query_id";
}else{
return "snmp.php";
}
}
}
function snmp_edit() {
include_once ("include/xml_functions.php");
global $colors, $paths, $snmp_query_field_actions;
display_output_messages();
if (isset($_GET["id"])) {
$snmp_query = db_fetch_row("select * from snmp_query where id=" . $_GET["id"]);
$header_label = "[edit: " . $snmp_query["name"] . "]";
@@ -331,23 +322,12 @@ function snmp_edit() {
form_hidden_box("save_component_snmp_query","1","");
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "snmp.php");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("snmp.php");
}
function snmp() {
global $colors;
display_output_messages();
start_box("<strong>SNMP Queries</strong>", "98%", $colors["header"], "3", "center", "snmp.php?action=edit");
print "<tr bgcolor='#" . $colors["header_panel"] . "'>";
+140 -180
View File
@@ -31,9 +31,8 @@ include_once ('include/form.php');
switch ($_REQUEST["action"]) {
case 'save':
$redirect_location = form_save();
form_save();
header ("Location: $redirect_location"); exit;
break;
case 'data_edit':
include_once ("include/top_header.php");
@@ -69,27 +68,145 @@ switch ($_REQUEST["action"]) {
-------------------------- */
function form_save() {
if ((isset($_POST["save_component_data_source"])) && (isset($_POST["save_component_data"]))) {
$url = ds_save();
data_save();
include_once ("include/utility_functions.php");
if (isset($_POST["save_component_data_source"])) {
$save["id"] = $_POST["local_data_id"];
$save["data_template_id"] = $_POST["data_template_id"];
$save["host_id"] = $_POST["host_id"];
if (is_error_message()) {
return $_SERVER["HTTP_REFERER"];
}elseif (($_POST["data_template_id"] != $_POST["_data_template_id"]) || ($_POST["host_id"] != $_POST["_host_id"])) {
return $url;
}else{
return "data_sources.php";
}
}elseif (isset($_POST["save_component_data_source"])) {
return ds_save();
}elseif (isset($_POST["save_component_data"])) {
data_save();
$local_data_id = sql_save($save, "data_local");
unset($save);
if (read_config_option("full_view_data_source") == "") {
return "data_sources.php?action=ds_edit&local_data_id=" . $_POST["local_data_id"] . "&view_rrd=" . $_POST["current_rrd"];
}elseif (read_config_option("full_view_data_source") == "on") {
return "data_sources.php";
$save["id"] = $_POST["data_template_data_id"];
$save["local_data_template_data_id"] = $_POST["local_data_template_data_id"];
$save["local_data_id"] = $local_data_id;
$save["data_template_id"] = form_input_validate($_POST["data_template_id"], "data_template_id", "", true, 3);
$save["data_input_id"] = form_input_validate($_POST["data_input_id"], "data_input_id", "", true, 3);
$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
$save["data_source_path"] = form_input_validate($_POST["data_source_path"], "data_source_path", "", true, 3);
$save["active"] = form_input_validate($_POST["active"], "active", "", true, 3);
$save["rrd_step"] = form_input_validate($_POST["rrd_step"], "rrd_step", "^[0-9]+$", false, 3);
if (!is_error_message()) {
$data_template_data_id = sql_save($save, "data_template_data");
if ($data_template_data_id) {
raise_message(1);
/* if no data source path has been entered, generate one */
if (empty($_POST["data_source_path"])) {
generate_data_source_path($local_data_id);
}
/* save entried in 'selected rras' field */
db_execute("delete from data_template_data_rra where data_template_data_id=$data_template_data_id");
for ($i=0; ($i < count($_POST["rra_id"])); $i++) {
db_execute("insert into data_template_data_rra (rra_id,data_template_data_id)
values (" . $_POST["rra_id"][$i] . ",$data_template_data_id)");
}
}else{
raise_message(2);
}
}
unset($save);
/* if this is a new data source and a template has been selected, skip item creation this time
otherwise it throws off the templatate creation because of the NULL data */
if ($_POST["data_template_id"] == $_POST["_data_template_id"]) {
$save["id"] = $_POST["data_template_rrd_id"];
$save["local_data_template_rrd_id"] = $_POST["local_data_template_rrd_id"];
$save["local_data_id"] = $local_data_id;
$save["data_template_id"] = form_input_validate($_POST["data_template_id"], "data_template_id", "", true, 3);
$save["rrd_maximum"] = form_input_validate($_POST["rrd_maximum"], "rrd_maximum", "^[0-9]+$", false, 3);
$save["rrd_minimum"] = form_input_validate($_POST["rrd_minimum"], "rrd_minimum", "^[0-9]+$", false, 3);
$save["rrd_heartbeat"] = form_input_validate($_POST["rrd_heartbeat"], "rrd_heartbeat", "^[0-9]+$", false, 3);
$save["data_source_type_id"] = $_POST["data_source_type_id"];
$save["data_source_name"] = form_input_validate($_POST["data_source_name"], "data_source_name", "^[a-zA-Z0-9_]{1,19}$", false, 3);
$save["data_input_field_id"] = $_POST["data_input_field_id"];
if (!is_error_message()) {
$data_template_rrd_id = sql_save($save, "data_template_rrd");
if ($data_template_rrd_id) {
raise_message(1);
}else{
raise_message(2);
}
}
}
if (!is_error_message()) {
update_poller_cache($local_data_id);
if ($_POST["host_id"] != $_POST["_host_id"]) {
/* push out all nessesary host information */
push_out_host($_POST["host_id"]);
/* reset current host for display purposes */
$_SESSION["sess_data_source_current_host_id"] = $_POST["host_id"];
}
if ($_POST["data_template_id"] != $_POST["_data_template_id"]) {
/* update all nessesary template information */
change_data_template($local_data_id, $_POST["data_template_id"]);
}
}
}
if ((isset($_POST["save_component_data"])) && (!is_error_message())) {
/* ok, first pull out all 'input' values so we know how much to save */
$input_fields = db_fetch_assoc("select
data_template_data.data_input_id,
data_local.host_id
data_input_fields.id,
data_input_fields.input_output,
data_input_fields.data_name,
data_input_fields.regexp_match,
data_input_fields.allow_nulls,
data_input_fields.type_code
from data_template_data
left join data_input_fields on data_input_fields.data_input_id=data_template_data.data_input_id
left join data_local on data_template_data.local_data_id=data_local.id
where data_template_data.id=" . $_POST["data_template_data_id"] . "
and data_input_fields.input_output='in'");
if (sizeof($input_fields) > 0) {
foreach ($input_fields as $input_field) {
/* save the data into the 'data_input_data' table */
$form_name = "value_" . $input_field["data_name"];
$form_value = $_POST[$form_name];
if (isset($_POST[$form_name])) {
if ($input_field["allow_nulls"] == "on") {
$allow_nulls = true;
}elseif (empty($input_field["allow_nulls"])) {
$allow_nulls = false;
}
/* run regexp match on input string */
$form_value = form_input_validate($form_value, $form_name, $input_field["regexp_match"], $allow_nulls, 3);
/* make sure we don't overwrite 'host fields' */
if ((!is_error_message()) && ((empty($input_field["host_id"]) || (empty($input_field["type_code"]))))) {
db_execute("replace into data_input_data (data_input_field_id,data_template_data_id,t_value,value) values
(" . $input_field["id"] . "," . $_POST["data_template_data_id"] . ",'" . db_fetch_cell("select t_value from data_input_data where data_input_field_id=" . $input_field["id"] . " and data_template_data_id=" . $_POST["data_template_data_id"]) . "','$form_value')");
}
}
}
}
if ((read_config_option("full_view_data_source") == "") && (is_error_message())) {
/* ds data edit page */
}
}
if ((is_error_message()) || ($_POST["data_template_id"] != $_POST["_data_template_id"]) || ($_POST["host_id"] != $_POST["_host_id"])) {
header ("Location: data_sources.php?action=ds_edit&local_data_id=" . (empty($local_data_id) ? $_POST["local_data_id"] : $local_data_id) . "&host_id=" . $_POST["host_id"] . "&view_rrd=" . $_POST["view_rrd"]);
}else{
header ("Location: data_sources.php");
}
}
@@ -125,54 +242,9 @@ function draw_data_form_select($main_action) {
data - Custom Data
---------------------------- */
function data_save() {
/* ok, first pull out all 'input' values so we know how much to save */
$input_fields = db_fetch_assoc("select
data_template_data.data_input_id,
data_local.host_id
data_input_fields.id,
data_input_fields.input_output,
data_input_fields.data_name,
data_input_fields.regexp_match,
data_input_fields.allow_nulls,
data_input_fields.type_code
from data_template_data
left join data_input_fields on data_input_fields.data_input_id=data_template_data.data_input_id
left join data_local on data_template_data.local_data_id=data_local.id
where data_template_data.id=" . $_POST["data_template_data_id"] . "
and data_input_fields.input_output='in'");
if (sizeof($input_fields) > 0) {
foreach ($input_fields as $input_field) {
/* save the data into the 'data_input_data' table */
$form_name = "value_" . $input_field["data_name"];
$form_value = $_POST[$form_name];
if (isset($_POST[$form_name])) {
if ($input_field["allow_nulls"] == "on") {
$allow_nulls = true;
}elseif (empty($input_field["allow_nulls"])) {
$allow_nulls = false;
}
/* run regexp match on input string */
$form_value = form_input_validate($form_value, $form_name, $input_field["regexp_match"], $allow_nulls, 3);
/* make sure we don't overwrite 'host fields' */
if ((!is_error_message()) && ((empty($input_field["host_id"]) || (empty($input_field["type_code"]))))) {
db_execute("replace into data_input_data (data_input_field_id,data_template_data_id,t_value,value) values
(" . $input_field["id"] . "," . $_POST["data_template_data_id"] . ",'" . db_fetch_cell("select t_value from data_input_data where data_input_field_id=" . $input_field["id"] . " and data_template_data_id=" . $_POST["data_template_data_id"]) . "','$form_value')");
}
}
}
}
}
function data_edit() {
global $config, $colors;
display_output_messages();
if (isset($_GET["local_data_id"])) {
$data = db_fetch_row("select id,data_input_id,data_template_id,name from data_template_data where local_data_id=" . $_GET["local_data_id"]);
$template_data = db_fetch_row("select id,data_input_id from data_template_data where data_template_id=" . $data["data_template_id"] . " and local_data_id=0");
@@ -246,16 +318,7 @@ function data_edit() {
form_hidden_box("save_component_data","1","");
if (read_config_option("full_view_data_source") == "") {
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "data_sources.php");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("data_sources.php");
}
}
@@ -317,92 +380,6 @@ function ds_remove() {
}
}
function ds_save() {
include_once ("include/utility_functions.php");
$save["id"] = $_POST["local_data_id"];
$save["data_template_id"] = $_POST["data_template_id"];
$save["host_id"] = $_POST["host_id"];
$local_data_id = sql_save($save, "data_local");
unset($save);
$save["id"] = $_POST["data_template_data_id"];
$save["local_data_template_data_id"] = $_POST["local_data_template_data_id"];
$save["local_data_id"] = $local_data_id;
$save["data_template_id"] = $_POST["data_template_id"];
$save["data_input_id"] = $_POST["data_input_id"];
$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
$save["data_source_path"] = $_POST["data_source_path"];
$save["active"] = $_POST["active"];
$save["rrd_step"] = form_input_validate($_POST["rrd_step"], "rrd_step", "^[0-9]+$", false, 3);
if (!is_error_message()) {
$data_template_data_id = sql_save($save, "data_template_data");
}
/* if no data source path has been entered, generate one */
if (empty($_POST["data_source_path"])) {
generate_data_source_path($local_data_id);
}
/* save entried in 'selected rras' field */
db_execute("delete from data_template_data_rra where data_template_data_id=$data_template_data_id");
for ($i=0; ($i < count($_POST["rra_id"])); $i++) {
db_execute("insert into data_template_data_rra (rra_id,data_template_data_id)
values (" . $_POST["rra_id"][$i] . ",$data_template_data_id)");
}
unset($save);
/* if this is a new data source and a template has been selected, skip item creation this time
otherwise it throws off the templatate creation because of the NULL data */
if ($_POST["data_template_id"] == $_POST["_data_template_id"]) {
$save["id"] = $_POST["data_template_rrd_id"];
$save["local_data_template_rrd_id"] = $_POST["local_data_template_rrd_id"];
$save["local_data_id"] = $local_data_id;
$save["data_template_id"] = $_POST["data_template_id"];
$save["rrd_maximum"] = form_input_validate($_POST["rrd_maximum"], "rrd_maximum", "^[0-9]+$", false, 3);
$save["rrd_minimum"] = form_input_validate($_POST["rrd_minimum"], "rrd_minimum", "^[0-9]+$", false, 3);
$save["rrd_heartbeat"] = form_input_validate($_POST["rrd_heartbeat"], "rrd_heartbeat", "^[0-9]+$", false, 3);
$save["data_source_type_id"] = $_POST["data_source_type_id"];
$save["data_source_name"] = form_input_validate($_POST["data_source_name"], "data_source_name", "^[a-zA-Z0-9_]{1,19}$", false, 3);
$save["data_input_field_id"] = $_POST["data_input_field_id"];
if (!is_error_message()) {
sql_save($save, "data_template_rrd");
}
}
if (!is_error_message()) {
update_poller_cache($local_data_id);
if ($_POST["host_id"] != $_POST["_host_id"]) {
/* push out all nessesary host information */
push_out_host($_POST["host_id"]);
/* reset current host for display purposes */
$_SESSION["sess_data_source_current_host_id"] = $_POST["host_id"];
}
if ($_POST["data_template_id"] != $_POST["_data_template_id"]) {
/* update all nessesary template information */
change_data_template($local_data_id, $_POST["data_template_id"]);
}
}
if (is_error_message()) {
return "data_sources.php?action=ds_edit&local_data_id=$local_data_id&host_id=" . $_POST["host_id"] . "&view_rrd=" . $_POST["view_rrd"];
}else{
if (($_POST["data_template_id"] != $_POST["_data_template_id"]) || ($_POST["host_id"] != $_POST["_host_id"])) {
return "data_sources.php?action=ds_edit&local_data_id=$local_data_id&host_id=" . $_POST["host_id"] . "&view_rrd=" . $_POST["view_rrd"];
}else{
return "data_sources.php";
}
}
}
function ds_edit() {
include_once ("include/rrd_functions.php");
@@ -428,8 +405,6 @@ function ds_edit() {
$use_data_template = false;
}
display_output_messages();
$data_template_name = db_fetch_cell("select name from data_template where id=" . $data["data_template_id"]);
if (read_config_option("full_view_data_source") == "") {
@@ -580,16 +555,7 @@ function ds_edit() {
form_hidden_id("current_rrd",$_GET["view_rrd"]);
form_hidden_box("save_component_data_source","1","");
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "data_sources.php");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("data_sources.php");
}
function ds() {
@@ -597,20 +563,14 @@ function ds() {
include_once ('include/tree_view_functions.php');
if (empty($_GET["host_id"])) {
$_GET["host_id"] = 0;
}
/* if no host_id is specified, use the session one */
if (!isset($_GET["host_id"])) {
$_GET["host_id"] = $_SESSION["sess_data_source_current_host_id"];
$_GET["host_id"] = (empty($_SESSION["sess_data_source_current_host_id"]) ? 0 : $_SESSION["sess_data_source_current_host_id"]);
}
/* remember the last used host_id */
$_SESSION["sess_data_source_current_host_id"] = $_GET["host_id"];
display_output_messages();
start_box("<strong>Data Sources</strong>", "98%", $colors["header"], "3", "center", "data_sources.php?action=ds_edit");
?>
+122 -115
View File
@@ -30,9 +30,8 @@ include_once ("include/config_arrays.php");
switch ($_REQUEST["action"]) {
case 'save':
$redirect_location = form_save();
form_save();
header ("Location: $redirect_location"); exit;
break;
case 'template_remove':
template_remove();
@@ -60,10 +59,128 @@ switch ($_REQUEST["action"]) {
-------------------------- */
function form_save() {
global $config;
include_once ("include/utility_functions.php");
if (isset($_POST["save_component_template"])) {
return template_save();
/* save: data_template */
$save["id"] = $_POST["data_template_id"];
$save["name"] = form_input_validate($_POST["template_name"], "template_name", "", false, 3);
$save["graph_template_id"] = 0;
if (!is_error_message()) {
$data_template_id = sql_save($save, "data_template");
if ($data_template_id) {
raise_message(1);
}else{
raise_message(2);
}
}
unset ($save);
/* save: data_template_data */
$save["id"] = $_POST["data_template_data_id"];
$save["local_data_template_data_id"] = 0;
$save["local_data_id"] = 0;
$save["data_template_id"] = $data_template_id;
$save["data_input_id"] = form_input_validate($_POST["data_input_id"], "data_input_id", "", true, 3);
$save["t_name"] = form_input_validate($_POST["t_name"], "t_name", "", true, 3);
$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
$save["t_active"] = form_input_validate($_POST["t_active"], "t_active", "", true, 3);
$save["active"] = form_input_validate($_POST["active"], "active", "", true, 3);
$save["t_rrd_step"] = form_input_validate($_POST["t_rrd_step"], "t_rrd_step", "", true, 3);
$save["rrd_step"] = form_input_validate($_POST["rrd_step"], "rrd_step", "^[0-9]+$", false, 3);
$save["t_rra_id"] = form_input_validate($_POST["t_rra_id"], "t_rra_id", "", true, 3);
if (!is_error_message()) {
$data_template_data_id = sql_save($save, "data_template_data");
if ($data_template_data_id) {
raise_message(1);
}else{
raise_message(2);
}
}
unset ($save);
/* save: data_template_rrd */
$save["id"] = $_POST["data_template_rrd_id"];
$save["local_data_template_rrd_id"] = 0;
$save["local_data_id"] = 0;
$save["data_template_id"] = $data_template_id;
$save["t_rrd_maximum"] = form_input_validate($_POST["t_rrd_maximum"], "t_rrd_maximum", "", true, 3);
$save["rrd_maximum"] = form_input_validate($_POST["rrd_maximum"], "rrd_maximum", "^[0-9]+$", false, 3);
$save["t_rrd_minimum"] = form_input_validate($_POST["t_rrd_minimum"], "t_rrd_minimum", "", true, 3);
$save["rrd_minimum"] = form_input_validate($_POST["rrd_minimum"], "rrd_minimum", "^[0-9]+$", false, 3);
$save["t_rrd_heartbeat"] = form_input_validate($_POST["t_rrd_heartbeat"], "t_rrd_heartbeat", "", true, 3);
$save["rrd_heartbeat"] = form_input_validate($_POST["rrd_heartbeat"], "rrd_heartbeat", "^[0-9]+$", false, 3);
$save["t_data_source_type_id"] = form_input_validate($_POST["t_data_source_type_id"], "t_data_source_type_id", "", true, 3);
$save["data_source_type_id"] = form_input_validate($_POST["data_source_type_id"], "data_source_type_id", "", true, 3);
$save["t_data_source_name"] = form_input_validate($_POST["t_data_source_name"], "t_data_source_name", "", true, 3);
$save["data_source_name"] = form_input_validate($_POST["data_source_name"], "data_source_name", "^[a-zA-Z0-9_]{1,19}$", false, 3);
$save["data_input_field_id"] = $_POST["data_input_field_id"];
if (!is_error_message()) {
$data_template_rrd_id = sql_save($save, "data_template_rrd");
if ($data_template_rrd_id) {
raise_message(1);
}else{
raise_message(2);
}
}
if (!is_error_message()) {
/* save entried in 'selected rras' field */
db_execute("delete from data_template_data_rra where data_template_data_id=$data_template_data_id");
for ($i=0; ($i < count($_POST["rra_id"])); $i++) {
db_execute("insert into data_template_data_rra (rra_id,data_template_data_id)
values (" . $_POST["rra_id"][$i] . ",$data_template_data_id)");
}
/* push out all data source settings to child data source using this template */
push_out_data_source($data_template_data_id);
push_out_data_source_item($data_template_rrd_id);
/* ok, first pull out all 'input' values so we know how much to save */
$input_fields = db_fetch_assoc("select
id,
input_output,
data_name
from data_input_fields
where data_input_id=" . $_POST["data_input_id"] . "
and input_output='in'");
db_execute("delete from data_input_data where data_template_data_id=$data_template_data_id");
if (sizeof($input_fields) > 0) {
foreach ($input_fields as $input_field) {
/* save the data into the 'host_template_data' table */
$form_value = "value_" . $input_field["data_name"];
$form_value = $_POST[$form_value];
$form_is_templated_value = "t_value_" . $input_field["data_name"];
$form_is_templated_value = $_POST[$form_is_templated_value];
if ((!empty($form_value)) || (!empty($form_is_templated_value))) {
db_execute("insert into data_input_data (data_input_field_id,data_template_data_id,t_value,value)
values (" . $input_field["id"] . ",$data_template_data_id,'$form_is_templated_value','$form_value')");
}
}
}
/* push out all "custom data" for this data source template */
push_out_data_template($data_template_id);
}
if ((is_error_message()) || (empty($_POST["data_template_id"]))) {
header ("Location: data_templates.php?action=template_edit&data_template_id=" . (empty($data_template_id) ? $_POST["data_template_id"] : $data_template_id)) . "&view_rrd=" . ($_POST["current_rrd"] ? $_POST["current_rrd"] : $data_template_rrd_id);
}else{
header ("Location: data_templates.php");
}
}
}
@@ -72,8 +189,6 @@ function form_save() {
---------------------------- */
function template_remove() {
global $config;
if ((read_config_option("remove_verification") == "on") && ($_GET["confirm"] != "yes")) {
include ('include/top_header.php');
form_confirm("Are You Sure?", "Are you sure you want to delete the data template <strong>'" . db_fetch_cell("select name from data_template where id=" . $_GET["data_template_id"]) . "'</strong>? This is generally not a good idea if you have data sources attached to this template even though it should not affect any data sources.", getenv("HTTP_REFERER"), "data_templates.php?action=template_remove&data_template_id=" . $_GET["data_template_id"]);
@@ -93,105 +208,6 @@ function template_remove() {
}
}
function template_save() {
include_once ("include/utility_functions.php");
if ($_POST["rrd_maximum"] == "") { $_POST["rrd_maximum"] = 0; }
if ($_POST["rrd_minimum"] == "") { $_POST["rrd_minimum"] = 0; }
/* save: data_template */
$save["id"] = $_POST["data_template_id"];
$save["name"] = $_POST["template_name"];
$save["graph_template_id"] = 0;
$data_template_id = sql_save($save, "data_template");
unset ($save);
/* save: data_template_data */
$save["id"] = $_POST["data_template_data_id"];
$save["local_data_template_data_id"] = 0;
$save["local_data_id"] = 0;
$save["data_template_id"] = $data_template_id;
$save["data_input_id"] = $_POST["data_input_id"];
$save["t_name"] = $_POST["t_name"];
$save["name"] = $_POST["name"];
$save["t_active"] = $_POST["t_active"];
$save["active"] = $_POST["active"];
$save["t_rrd_step"] = $_POST["t_rrd_step"];
$save["rrd_step"] = $_POST["rrd_step"];
$save["t_rra_id"] = $_POST["t_rra_id"];
$data_template_data_id = sql_save($save, "data_template_data");
unset ($save);
/* save: data_template_rrd */
$save["id"] = $_POST["data_template_rrd_id"];
$save["local_data_template_rrd_id"] = 0;
$save["local_data_id"] = 0;
$save["data_template_id"] = $data_template_id;
$save["t_rrd_maximum"] = $_POST["t_rrd_maximum"];
$save["rrd_maximum"] = $_POST["rrd_maximum"];
$save["t_rrd_minimum"] = $_POST["t_rrd_minimum"];
$save["rrd_minimum"] = $_POST["rrd_minimum"];
$save["t_rrd_heartbeat"] = $_POST["t_rrd_heartbeat"];
$save["rrd_heartbeat"] = $_POST["rrd_heartbeat"];
$save["t_data_source_type_id"] = $_POST["t_data_source_type_id"];
$save["data_source_type_id"] = $_POST["data_source_type_id"];
$save["t_data_source_name"] = $_POST["t_data_source_name"];
$save["data_source_name"] = $_POST["data_source_name"];
$save["data_input_field_id"] = $_POST["data_input_field_id"];
$data_template_rrd_id = sql_save($save, "data_template_rrd");
/* save entried in 'selected rras' field */
db_execute("delete from data_template_data_rra where data_template_data_id=$data_template_data_id");
for ($i=0; ($i < count($_POST["rra_id"])); $i++) {
db_execute("insert into data_template_data_rra (rra_id,data_template_data_id)
values (" . $_POST["rra_id"][$i] . ",$data_template_data_id)");
}
/* push out all data source settings to child data source using this template */
push_out_data_source($data_template_data_id);
push_out_data_source_item($data_template_rrd_id);
/* ok, first pull out all 'input' values so we know how much to save */
$input_fields = db_fetch_assoc("select
id,
input_output,
data_name
from data_input_fields
where data_input_id=" . $_POST["data_input_id"] . "
and input_output='in'");
db_execute("delete from data_input_data where data_template_data_id=$data_template_data_id");
if (sizeof($input_fields) > 0) {
foreach ($input_fields as $input_field) {
/* save the data into the 'host_template_data' table */
$form_value = "value_" . $input_field["data_name"];
$form_value = $_POST[$form_value];
$form_is_templated_value = "t_value_" . $input_field["data_name"];
$form_is_templated_value = $_POST[$form_is_templated_value];
if ((!empty($form_value)) || (!empty($form_is_templated_value))) {
db_execute("insert into data_input_data (data_input_field_id,data_template_data_id,t_value,value)
values (" . $input_field["id"] . ",$data_template_data_id,'$form_is_templated_value','$form_value')");
}
}
}
/* push out all "custom data" for this data source template */
push_out_data_template($data_template_id);
if (empty($_POST["data_template_id"])) {
return "data_templates.php?action=template_edit&data_template_id=" . $data_template_id . "&view_rrd=" . ($_POST["current_rrd"] ? $_POST["current_rrd"] : $data_template_rrd_id);
}else{
return "data_templates.php";
}
}
function template_edit() {
global $colors, $struct_data_source, $struct_data_source_item, $data_source_types;
@@ -343,16 +359,7 @@ function template_edit() {
form_hidden_id("current_rrd",$_GET["view_rrd"]);
form_hidden_box("save_component_template","1","");
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "data_templates.php");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("data_templates.php");
}
function template() {
+184 -182
View File
@@ -30,9 +30,8 @@ include_once ("include/config_arrays.php");
switch ($_REQUEST["action"]) {
case 'save':
$redirect_location = form_save();
form_save();
header ("Location: $redirect_location"); exit;
break;
case 'gprint_presets_remove':
if ((read_config_option("remove_verification") == "on") && ($_GET["confirm"] != "yes")) {
@@ -168,29 +167,189 @@ function draw_tabs() {
-------------------------- */
function form_save() {
global $config;
include_once ("include/utility_functions.php");
if (isset($_POST["save_component_template"])) {
return template_save();
}elseif (isset($_POST["save_component_item"])) {
item_save();
if (read_config_option("full_view_graph_template") == "") {
return "graph_templates.php?action=item&graph_template_id=" . $_POST["graph_template_id"];
}elseif (read_config_option("full_view_graph_template") == "on") {
return "graph_templates.php?action=template_edit&graph_template_id=" . $_POST["graph_template_id"];
}
}elseif (isset($_POST["save_component_input"])) {
input_save();
$save["id"] = $_POST["graph_template_id"];
$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
if (read_config_option("full_view_graph_template") == "") {
return "graph_templates.php?action=item&graph_template_id=" . $_POST["graph_template_id"];
}elseif (read_config_option("full_view_graph_template") == "on") {
return "graph_templates.php?action=template_edit&graph_template_id=" . $_POST["graph_template_id"];
if (!is_error_message()) {
$graph_template_id = sql_save($save, "graph_templates");
if ($graph_template_id) {
raise_message(1);
}else{
raise_message(2);
}
}
}elseif (isset($_POST["save_component_gprint_presets"])) {
gprint_presets_save();
return "graph_templates.php?action=gprint_presets";
unset ($save);
$save["id"] = $_POST["graph_template_graph_id"];
$save["local_graph_template_graph_id"] = 0;
$save["local_graph_id"] = 0;
$save["graph_template_id"] = $graph_template_id;
$save["t_image_format_id"] = $_POST["t_image_format_id"];
$save["image_format_id"] = form_input_validate($_POST["image_format_id"], "image_format_id", "", true, 3);
$save["t_title"] = form_input_validate($_POST["t_title"], "t_title", "", true, 3);
$save["title"] = form_input_validate($_POST["title"], "title", "", false, 3);
$save["t_height"] = form_input_validate($_POST["t_height"], "t_height", "", true, 3);
$save["height"] = form_input_validate($_POST["height"], "height", "^[0-9]+$", false, 3);
$save["t_width"] = form_input_validate($_POST["t_width"], "t_width", "", true, 3);
$save["width"] = form_input_validate($_POST["width"], "width", "^[0-9]+$", false, 3);
$save["t_upper_limit"] = form_input_validate($_POST["t_upper_limit"], "t_upper_limit", "", true, 3);
$save["upper_limit"] = form_input_validate($_POST["upper_limit"], "upper_limit", "^[0-9]+$", false, 3);
$save["t_lower_limit"] = form_input_validate($_POST["t_lower_limit"], "t_lower_limit", "", true, 3);
$save["lower_limit"] = form_input_validate($_POST["lower_limit"], "lower_limit", "^[0-9]+$", false, 3);
$save["t_vertical_label"] = form_input_validate($_POST["t_vertical_label"], "t_vertical_label", "", true, 3);
$save["vertical_label"] = form_input_validate($_POST["vertical_label"], "vertical_label", "", true, 3);
$save["t_auto_scale"] = form_input_validate($_POST["t_auto_scale"], "t_auto_scale", "", true, 3);
$save["auto_scale"] = form_input_validate($_POST["auto_scale"], "auto_scale", "", true, 3);
$save["t_auto_scale_opts"] = form_input_validate($_POST["t_auto_scale_opts"], "t_auto_scale_opts", "", true, 3);
$save["auto_scale_opts"] = form_input_validate($_POST["auto_scale_opts"], "auto_scale_opts", "", true, 3);
$save["t_auto_scale_log"] = form_input_validate($_POST["t_auto_scale_log"], "t_auto_scale_log", "", true, 3);
$save["auto_scale_log"] = form_input_validate($_POST["auto_scale_log"], "auto_scale_log", "", true, 3);
$save["t_auto_scale_rigid"] = form_input_validate($_POST["t_auto_scale_rigid"], "t_auto_scale_rigid", "", true, 3);
$save["auto_scale_rigid"] = form_input_validate($_POST["auto_scale_rigid"], "auto_scale_rigid", "", true, 3);
$save["t_auto_padding"] = form_input_validate($_POST["t_auto_padding"], "t_auto_padding", "", true, 3);
$save["auto_padding"] = form_input_validate($_POST["auto_padding"], "auto_padding", "", true, 3);
$save["t_base_value"] = form_input_validate($_POST["t_base_value"], "t_base_value", "", true, 3);
$save["base_value"] = form_input_validate($_POST["base_value"], "base_value", "^[0-9]+$", false, 3);
$save["t_export"] = form_input_validate($_POST["t_export"], "t_export", "", true, 3);
$save["export"] = form_input_validate($_POST["export"], "export", "", true, 3);
$save["t_unit_value"] = form_input_validate($_POST["t_unit_value"], "t_unit_value", "", true, 3);
$save["unit_value"] = form_input_validate($_POST["unit_value"], "unit_value", "", true, 3);
$save["t_unit_exponent_value"] = form_input_validate($_POST["t_unit_exponent_value"], "t_unit_exponent_value", "", true, 3);
$save["unit_exponent_value"] = form_input_validate($_POST["unit_exponent_value"], "unit_exponent_value", "^[0-9]+$", false, 3);
if (!is_error_message()) {
$graph_template_graph_id = sql_save($save, "graph_templates_graph");
if ($graph_template_graph_id) {
raise_message(1);
push_out_graph($graph_template_graph_id);
}else{
raise_message(2);
}
}
}
if (isset($_POST["save_component_item"])) {
/* generate a new sequence if needed */
if (empty($_POST["sequence"])) {
$_POST["sequence"] = get_sequence($_POST["sequence"], "sequence", "graph_templates_item", "graph_template_id=" . $_POST["graph_template_id"] . " and local_graph_id=0");
}
$save["id"] = $_POST["graph_template_item_id"];
$save["graph_template_id"] = $_POST["graph_template_id"];
$save["local_graph_id"] = 0;
$save["task_item_id"] = form_input_validate($_POST["task_item_id"], "task_item_id", "", true, 3);
$save["color_id"] = form_input_validate($_POST["color_id"], "color_id", "", true, 3);
$save["graph_type_id"] = form_input_validate($_POST["graph_type_id"], "graph_type_id", "", true, 3);
$save["cdef_id"] = form_input_validate($_POST["cdef_id"], "cdef_id", "", true, 3);
$save["consolidation_function_id"] = form_input_validate($_POST["consolidation_function_id"], "consolidation_function_id", "", true, 3);
$save["text_format"] = form_input_validate($_POST["text_format"], "text_format", "", true, 3);
$save["value"] = form_input_validate($_POST["value"], "value", "", true, 3);
$save["hard_return"] = form_input_validate($_POST["hard_return"], "hard_return", "", true, 3);
$save["gprint_id"] = form_input_validate($_POST["gprint_id"], "gprint_id", "", true, 3);
$save["sequence"] = $_POST["sequence"];
if (!is_error_message()) {
$graph_template_item_id = sql_save($save, "graph_templates_item");
if ($graph_template_item_id) {
raise_message(1);
push_out_graph_item($graph_template_item_id);
}else{
raise_message(2);
}
}
if (is_error_message()) {
header ("Location: graph_templates.php?action=item_edit&graph_template_item_id=" . (empty($graph_template_item_id) ? $_POST["graph_template_item_id"] : $graph_template_item_id) . "&graph_template_id=" . $_POST["graph_template_id"]);
exit;
}elseif (read_config_option("full_view_graph_template") == "") {
header ("Location: graph_templates.php?action=item&graph_template_id=" . $_POST["graph_template_id"]);
exit;
}elseif (read_config_option("full_view_graph_template") == "on") {
header ("graph_templates.php?action=template_edit&graph_template_id=" . $_POST["graph_template_id"]);
exit;
}
}
if ((isset($_POST["save_component_input"])) && (!is_error_message())) {
$save["id"] = $_POST["graph_template_input_id"];
$save["graph_template_id"] = $_POST["graph_template_id"];
$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
$save["description"] = form_input_validate($_POST["description"], "description", "", true, 3);
$save["column_name"] = form_input_validate($_POST["column_name"], "column_name", "", true, 3);
if (!is_error_message()) {
$graph_template_input_id = sql_save($save, "graph_template_input");
if ($graph_template_input_id) {
raise_message(1);
db_execute("delete from graph_template_input_defs where graph_template_input_id=$graph_template_input_id");
while (list($var, $val) = each($_POST)) {
if (eregi("^i_", $var)) {
$var = str_replace("i_", "", $var);
unset($save);
$save["graph_template_input_id"] = $graph_template_input_id;
$save["graph_template_item_id"] = $var;
sql_save($save, "graph_template_input_defs");
}
}
}else{
raise_message(2);
}
}
if (is_error_message()) {
header ("Location: graph_templates.php?action=input_edit&graph_template_input_id=" . (empty($graph_template_input_id) ? $_POST["graph_template_input_id"] : $graph_template_input_id) . "&graph_template_id=" . $_POST["graph_template_id"]);
exit;
}elseif (read_config_option("full_view_graph_template") == "") {
header ("Location: graph_templates.php?action=item&graph_template_id=" . $_POST["graph_template_id"]);
exit;
}elseif (read_config_option("full_view_graph_template") == "on") {
header ("graph_templates.php?action=template_edit&graph_template_id=" . $_POST["graph_template_id"]);
exit;
}
}
if (isset($_POST["save_component_gprint_presets"])) {
$save["id"] = $_POST["gprint_preset_id"];
$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
$save["gprint_text"] = form_input_validate($_POST["gprint_text"], "gprint_text", "", false, 3);
if (!is_error_message()) {
$gprint_preset_id = sql_save($save, "graph_templates_gprint");
if ($gprint_preset_id) {
raise_message(1);
}else{
raise_message(2);
}
}
if (is_error_message()) {
header ("Location: graph_templates.php?action=gprint_presets_edit&gprint_preset_id=" . (empty($gprint_preset_id) ? $_POST["gprint_preset_id"] : $gprint_preset_id));
exit;
}else{
header ("graph_templates.php?action=gprint_presets");
exit;
}
}
if ((is_error_message()) || (empty($_POST["graph_template_id"]))) {
header ("Location: graph_templates.php?action=template_edit&graph_template_id=" . (empty($graph_template_id) ? $_POST["graph_template_id"] : $graph_template_id));
}else{
header ("Location: graph_templates.php");
}
}
@@ -201,14 +360,6 @@ function form_save() {
function gprint_presets_remove() {
db_execute("delete from graph_templates_gprint where id=" . $_GET["gprint_preset_id"]);
}
function gprint_presets_save() {
$save["id"] = $_POST["gprint_preset_id"];
$save["name"] = $_POST["name"];
$save["gprint_text"] = $_POST["gprint_text"];
sql_save($save, "graph_templates_gprint");
}
function gprint_presets_edit() {
global $colors;
@@ -247,16 +398,7 @@ function gprint_presets_edit() {
form_hidden_id("gprint_preset_id",$gprint_preset["id"]);
form_hidden_box("save_component_gprint_presets","1","");
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "graph_templates.php?action=gprint_presets");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("graph_templates.php?action=gprint_presets");
}
function gprint_presets() {
@@ -476,33 +618,6 @@ function item_remove() {
db_execute("delete from graph_templates_item where id=" . $_GET["graph_template_item_id"]);
}
function item_save() {
include_once ("include/utility_functions.php");
/* generate a new sequence if needed */
if (empty($_POST["sequence"])) {
$_POST["sequence"] = get_sequence($_POST["sequence"], "sequence", "graph_templates_item", "graph_template_id=" . $_POST["graph_template_id"] . " and local_graph_id=0");
}
$save["id"] = $_POST["graph_template_item_id"];
$save["graph_template_id"] = $_POST["graph_template_id"];
$save["local_graph_id"] = 0;
$save["task_item_id"] = $_POST["task_item_id"];
$save["color_id"] = $_POST["color_id"];
$save["graph_type_id"] = $_POST["graph_type_id"];
$save["cdef_id"] = $_POST["cdef_id"];
$save["consolidation_function_id"] = $_POST["consolidation_function_id"];
$save["text_format"] = $_POST["text_format"];
$save["value"] = $_POST["value"];
$save["hard_return"] = $_POST["hard_return"];
$save["gprint_id"] = $_POST["gprint_id"];
$save["sequence"] = $_POST["sequence"];
$graph_template_item_id = sql_save($save, "graph_templates_item");
push_out_graph_item($graph_template_item_id);
}
function item_edit() {
global $colors, $struct_graph_item, $graph_item_types, $consolidation_functions;
@@ -568,16 +683,7 @@ function item_edit() {
form_hidden_id("_graph_type_id",$template_item["graph_type_id"]);
form_hidden_box("save_component_item","1","");
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "graph_templates.php?action=template_edit&graph_template_id=" . $_GET["graph_template_id"]);?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("graph_templates.php?action=template_edit&graph_template_id=" . $_GET["graph_template_id"]);
}
/* ----------------------------
@@ -615,67 +721,6 @@ function template_remove() {
}
}
function template_save() {
include_once ("include/utility_functions.php");
if ($_POST["upper_limit"] == "") { $_POST["upper_limit"] = 0; }
if ($_POST["lower_limit"] == "") { $_POST["lower_limit"] = 0; }
if ($_POST["unit_exponent_value"] == "") { $_POST["unit_exponent_value"] = 0; }
$save["id"] = $_POST["graph_template_id"];
$save["name"] = $_POST["name"];
$graph_template_id = sql_save($save, "graph_templates");
unset ($save);
$save["id"] = $_POST["graph_template_graph_id"];
$save["local_graph_template_graph_id"] = 0;
$save["local_graph_id"] = 0;
$save["graph_template_id"] = $graph_template_id;
$save["t_image_format_id"] = $_POST["t_image_format_id"];
$save["image_format_id"] = $_POST["image_format_id"];
$save["t_title"] = $_POST["t_title"];
$save["title"] = $_POST["title"];
$save["t_height"] = $_POST["t_height"];
$save["height"] = $_POST["height"];
$save["t_width"] = $_POST["t_width"];
$save["width"] = $_POST["width"];
$save["t_upper_limit"] = $_POST["t_upper_limit"];
$save["upper_limit"] = $_POST["upper_limit"];
$save["t_lower_limit"] = $_POST["t_lower_limit"];
$save["lower_limit"] = $_POST["lower_limit"];
$save["t_vertical_label"] = $_POST["t_vertical_label"];
$save["vertical_label"] = $_POST["vertical_label"];
$save["t_auto_scale"] = $_POST["t_auto_scale"];
$save["auto_scale"] = $_POST["auto_scale"];
$save["t_auto_scale_opts"] = $_POST["t_auto_scale_opts"];
$save["auto_scale_opts"] = $_POST["auto_scale_opts"];
$save["t_auto_scale_log"] = $_POST["t_auto_scale_log"];
$save["auto_scale_log"] = $_POST["auto_scale_log"];
$save["t_auto_scale_rigid"] = $_POST["t_auto_scale_rigid"];
$save["auto_scale_rigid"] = $_POST["auto_scale_rigid"];
$save["t_auto_padding"] = $_POST["t_auto_padding"];
$save["auto_padding"] = $_POST["auto_padding"];
$save["t_base_value"] = $_POST["t_base_value"];
$save["base_value"] = $_POST["base_value"];
$save["t_export"] = $_POST["t_export"];
$save["export"] = $_POST["export"];
$save["t_unit_value"] = $_POST["t_unit_value"];
$save["unit_value"] = $_POST["unit_value"];
$save["t_unit_exponent_value"] = $_POST["t_unit_exponent_value"];
$save["unit_exponent_value"] = $_POST["unit_exponent_value"];
$graph_template_graph_id = sql_save($save, "graph_templates_graph");
push_out_graph($graph_template_graph_id);
if (empty($_POST["graph_template_id"])) {
return "graph_templates.php?action=template_edit&graph_template_id=$graph_template_id";
}else{
return "graph_templates.php";
}
}
function template_edit() {
global $colors, $struct_graph, $image_types;
@@ -735,16 +780,7 @@ function template_edit() {
form_hidden_id("graph_template_graph_id",$template_graph["id"]);
form_hidden_box("save_component_template","1","");
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "graph_templates.php");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("graph_templates.php");
}
function template() {
@@ -799,31 +835,6 @@ function input_remove() {
}
}
function input_save() {
$save["id"] = $_POST["graph_template_input_id"];
$save["graph_template_id"] = $_POST["graph_template_id"];
$save["name"] = $_POST["name"];
$save["description"] = $_POST["description"];
$save["column_name"] = $_POST["column_name"];
$graph_template_input_id = sql_save($save, "graph_template_input");
db_execute("delete from graph_template_input_defs where graph_template_input_id=$graph_template_input_id");
while (list($var, $val) = each($_POST)) {
if (eregi("^i_", $var)) {
$var = str_replace("i_", "", $var);
unset($save);
$save["graph_template_input_id"] = $graph_template_input_id;
$save["graph_template_item_id"] = $var;
sql_save($save, "graph_template_input_defs");
}
}
}
function input_edit() {
global $colors, $consolidation_functions, $graph_item_types, $struct_graph_item;
@@ -940,16 +951,7 @@ function input_edit() {
form_hidden_id("graph_template_input_id",$_GET["graph_template_input_id"]);
form_hidden_box("save_component_input","1","");
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "graph_templates.php?action=template_edit&graph_template_id=" . $_GET["graph_template_id"]);?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("graph_templates.php?action=template_edit&graph_template_id=" . $_GET["graph_template_id"]);
}
?>
+140 -180
View File
@@ -32,9 +32,8 @@ define("ROWS_PER_PAGE", 30);
switch ($_REQUEST["action"]) {
case 'save':
$redirect_location = form_save();
form_save();
header ("Location: $redirect_location"); exit;
break;
case 'graph_diff':
include_once ("include/top_header.php");
@@ -133,28 +132,142 @@ function draw_graph_form_select($main_action) {
-------------------------- */
function form_save() {
if ((isset($_POST["save_component_input"])) && (isset($_POST["save_component_graph"]))) {
graph_save();
input_save();
return "graphs.php?action=graph_edit&local_graph_id=" . $_POST["local_graph_id"];
}elseif (isset($_POST["save_component_graph"])) {
graph_save();
return "graphs.php?action=graph_edit&local_graph_id=" . $_POST["local_graph_id"];
}elseif (isset($_POST["save_component_input"])) {
input_save();
return "graphs.php?action=item&local_graph_id=" . $_POST["local_graph_id"];
}elseif (isset($_POST["save_component_graph_diff"])) {
graph_diff_save();
return "graphs.php?action=graph_edit&local_graph_id=" . $_POST["local_graph_id"];
}elseif (isset($_POST["save_component_item"])) {
item_save();
include_once ("include/utility_functions.php");
if (isset($_POST["save_component_graph"])) {
$save["id"] = $_POST["local_graph_id"];
$save["graph_template_id"] = $_POST["graph_template_id"];
if (read_config_option("full_view_graph") == "") {
return "graphs.php?action=item&local_graph_id=" . $_POST["local_graph_id"];
}else{
return "graphs.php?action=graph_edit&local_graph_id=" . $_POST["local_graph_id"];
$local_graph_id = sql_save($save, "graph_local");
unset($save);
$save["id"] = $_POST["graph_template_graph_id"];
$save["local_graph_template_graph_id"] = $_POST["local_graph_template_graph_id"];
$save["local_graph_id"] = $local_graph_id;
$save["graph_template_id"] = $_POST["graph_template_id"];
$save["image_format_id"] = form_input_validate($_POST["image_format_id"], "image_format_id", "", true, 3);
$save["title"] = form_input_validate($_POST["title"], "title", "", false, 3);
$save["height"] = form_input_validate($_POST["height"], "height", "^[0-9]+$", false, 3);
$save["width"] = form_input_validate($_POST["width"], "width", "^[0-9]+$", false, 3);
$save["upper_limit"] = form_input_validate($_POST["upper_limit"], "upper_limit", "^[0-9]+$", false, 3);
$save["lower_limit"] = form_input_validate($_POST["lower_limit"], "lower_limit", "^[0-9]+$", false, 3);
$save["vertical_label"] = form_input_validate($_POST["vertical_label"], "vertical_label", "", true, 3);
$save["auto_scale"] = form_input_validate($_POST["auto_scale"], "auto_scale", "", true, 3);
$save["auto_scale_opts"] = form_input_validate($_POST["auto_scale_opts"], "auto_scale_opts", "", true, 3);
$save["auto_scale_log"] = form_input_validate($_POST["auto_scale_log"], "auto_scale_log", "", true, 3);
$save["auto_scale_rigid"] = form_input_validate($_POST["auto_scale_rigid"], "auto_scale_rigid", "", true, 3);
$save["auto_padding"] = form_input_validate($_POST["auto_padding"], "auto_padding", "", true, 3);
$save["base_value"] = form_input_validate($_POST["base_value"], "base_value", "^[0-9]+$", false, 3);
$save["export"] = form_input_validate($_POST["export"], "export", "", true, 3);
$save["unit_value"] = form_input_validate($_POST["unit_value"], "unit_value", "", true, 3);
$save["unit_exponent_value"] = form_input_validate($_POST["unit_exponent_value"], "unit_exponent_value", "^[0-9]+$", false, 3);
if (!is_error_message()) {
$graph_templates_graph_id = sql_save($save, "graph_templates_graph");
if ($graph_templates_graph_id) {
raise_message(1);
/* if template information chanegd, update all nessesary 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"])) && (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&local_graph_id=$local_graph_id&graph_template_id=" . $_POST["graph_template_id"]);
exit;
}
change_graph_template($local_graph_id, $_POST["graph_template_id"], true);
}
}else{
raise_message(2);
}
}
}
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) {
db_execute("update graph_templates_item set " . $input["column_name"] . "='" . $_POST{$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_item"])) {
$save["id"] = $_POST["graph_template_item_id"];
$save["graph_template_id"] = $_POST["graph_template_id"];
$save["local_graph_id"] = $_POST["local_graph_id"];
$save["task_item_id"] = form_input_validate($_POST["task_item_id"], "task_item_id", "", true, 3);
$save["color_id"] = form_input_validate($_POST["color_id"], "color_id", "", true, 3);
$save["graph_type_id"] = form_input_validate($_POST["graph_type_id"], "graph_type_id", "", true, 3);
$save["cdef_id"] = form_input_validate($_POST["cdef_id"], "cdef_id", "", true, 3);
$save["consolidation_function_id"] = form_input_validate($_POST["consolidation_function_id"], "consolidation_function_id", "", true, 3);
$save["text_format"] = form_input_validate($_POST["text_format"], "text_format", "", true, 3);
$save["value"] = form_input_validate($_POST["value"], "value", "", true, 3);
$save["hard_return"] = form_input_validate($_POST["hard_return"], "hard_return", "", true, 3);
$save["gprint_id"] = form_input_validate($_POST["gprint_id"], "gprint_id", "", true, 3);
$save["sequence"] = $_POST["sequence"];
if (!is_error_message()) {
$graph_template_item_id = sql_save($save, "graph_templates_item");
if ($graph_template_item_id) {
raise_message(1);
}else{
raise_message(2);
}
}
if (is_error_message()) {
header ("Location: graphs.php?action=item_edit&graph_template_item_id=" . (empty($graph_template_item_id) ? $_POST["graph_template_item_id"] : $graph_template_item_id) . "&local_graph_id=" . $_POST["local_graph_id"]);
exit;
}elseif (read_config_option("full_view_graph") == "") {
header ("Location: graphs.php?action=item&local_graph_id=" . $_POST["local_graph_id"]);
exit;
}elseif (read_config_option("full_view_graph") == "on") {
header ("Location: graphs.php?action=graph_edit&local_graph_id=" . $_POST["local_graph_id"]);
exit;
}
}
if ((is_error_message()) || (empty($_POST["local_graph_id"])) || (isset($_POST["save_component_input"])) || (isset($_POST["save_component_graph_diff"]))) {
header ("Location: graphs.php?action=graph_edit&local_graph_id=" . (empty($local_graph_id) ? $_POST["local_graph_id"] : $local_graph_id));
}else{
header ("Location: graphs.php");
}
}
/* -----------------------
@@ -329,16 +442,7 @@ function item() {
form_hidden_box("save_component_input","1","");
if ((read_config_option("full_view_graph") == "") && (sizeof($input_item_list) > 0)) {
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "graphs.php");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("graphs.php");
}
}
@@ -358,24 +462,6 @@ function item_remove() {
db_execute("delete from graph_templates_item where id=" . $_GET["graph_template_item_id"]);
}
function item_save() {
$save["id"] = $_POST["graph_template_item_id"];
$save["graph_template_id"] = $_POST["graph_template_id"];
$save["local_graph_id"] = $_POST["local_graph_id"];
$save["task_item_id"] = $_POST["task_item_id"];
$save["color_id"] = $_POST["color_id"];
$save["graph_type_id"] = $_POST["graph_type_id"];
$save["cdef_id"] = $_POST["cdef_id"];
$save["consolidation_function_id"] = $_POST["consolidation_function_id"];
$save["text_format"] = $_POST["text_format"];
$save["value"] = $_POST["value"];
$save["hard_return"] = $_POST["hard_return"];
$save["gprint_id"] = $_POST["gprint_id"];
$save["sequence"] = $_POST["sequence"];
$graph_template_item_id = sql_save($save, "graph_templates_item");
}
function item_edit() {
global $colors, $struct_graph_item, $graph_item_types, $consolidation_functions;
@@ -430,125 +516,13 @@ function item_edit() {
end_box();
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", $_SERVER["HTTP_REFERER"]);?>
</td>
</tr>
</form>
<?php
end_box();
}
/* ------------------------------------
input - Graph Template Item Inputs
------------------------------------ */
function input_save() {
/* 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"]);
/* get some variables */
$column_name = $input["column_name"];
$column_value = $_POST{$column_name . "_" . $input["id"]};
/* loop through each item affected and update column data */
if (sizeof($item_list) > 0) {
foreach ($item_list as $item) {
db_execute("update graph_templates_item set $column_name='$column_value' where id=" . $item["id"]);
}
}
}
}
form_save_button( $_SERVER["HTTP_REFERER"]);
}
/* ------------------------------------
graph - Graphs
------------------------------------ */
function graph_save() {
include_once ("include/utility_functions.php");
if ($_POST["lower_limit"] == "") { $_POST["lower_limit"] = 0; }
if ($_POST["upper_limit"] == "") { $_POST["upper_limit"] = 0; }
if ($_POST["unit_exponent_value"] == "") { $_POST["unit_exponent_value"] = 0; }
$save["id"] = $_POST["local_graph_id"];
$save["graph_template_id"] = $_POST["graph_template_id"];
$local_graph_id = sql_save($save, "graph_local");
unset($save);
$save["id"] = $_POST["graph_template_graph_id"];
$save["local_graph_template_graph_id"] = $_POST["local_graph_template_graph_id"];
$save["local_graph_id"] = $local_graph_id;
$save["graph_template_id"] = $_POST["graph_template_id"];
$save["image_format_id"] = $_POST["image_format_id"];
$save["title"] = $_POST["title"];
$save["height"] = $_POST["height"];
$save["width"] = $_POST["width"];
$save["upper_limit"] = $_POST["upper_limit"];
$save["lower_limit"] = $_POST["lower_limit"];
$save["vertical_label"] = $_POST["vertical_label"];
$save["auto_scale"] = $_POST["auto_scale"];
$save["auto_scale_opts"] = $_POST["auto_scale_opts"];
$save["auto_scale_log"] = $_POST["auto_scale_log"];
$save["auto_scale_rigid"] = $_POST["auto_scale_rigid"];
$save["auto_padding"] = $_POST["auto_padding"];
$save["base_value"] = $_POST["base_value"];
$save["export"] = $_POST["export"];
$save["unit_value"] = $_POST["unit_value"];
$save["unit_exponent_value"] = $_POST["unit_exponent_value"];
sql_save($save, "graph_templates_graph");
/* if template information chanegd, update all nessesary 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"])) && (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&local_graph_id=$local_graph_id&graph_template_id=" . $_POST["graph_template_id"]);
exit;
}
change_graph_template($local_graph_id, $_POST["graph_template_id"], true);
}
/* so we get redirected to the correct page, not '&local_graph_id=0' */
$_POST["local_graph_id"] = $local_graph_id;
}
function graph_diff_save() {
include_once ("include/utility_functions.php");
if ($_POST["type"] == "1") {
$intrusive = true;
}elseif ($_POST["type"] == "2") {
$intrusive = false;
}
change_graph_template($_POST["local_graph_id"], $_POST["graph_template_id"], $intrusive);
}
function graph_diff() {
global $colors;
include("include/config_arrays.php");
@@ -760,19 +734,14 @@ function graph_diff() {
</table>
<br>
<table style="background-color: #ffffff; border: 1px solid #aaaaaa;" width="98%" align="center">
<tr>
<td colspan="2" align="right">
<?php form_save_button("save", "graphs.php?action=graph_edit&local_graph_id=" . $_GET["local_graph_id"]);?>
</td>
</tr>
</table>
<input type="hidden" name="action" value="save">
<input type="hidden" name="save_component_graph_diff" value="1">
<input type="hidden" name="local_graph_id" value="<?php print $_GET["local_graph_id"];?>">
<input type="hidden" name="graph_template_id" value="<?php print $_GET["graph_template_id"];?>">
</form>
<?php
form_save_button("graphs.php?action=graph_edit&local_graph_id=" . $_GET["local_graph_id"]);
}
function graph_remove() {
@@ -870,16 +839,7 @@ function graph_edit() {
end_box();
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "graphs.php");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("graphs.php");
}
function graph() {
+80 -95
View File
@@ -29,13 +29,10 @@ include_once ("include/functions.php");
include_once ("include/config_arrays.php");
include_once ('include/form.php');
$row_counter = 0;
switch ($_REQUEST["action"]) {
case 'save':
$redirect_location = form_save();
form_save();
header ("Location: $redirect_location"); exit;
break;
case 'new_graphs':
include_once ("include/top_header.php");
@@ -70,15 +67,75 @@ switch ($_REQUEST["action"]) {
-------------------------- */
function form_save() {
include_once ("include/utility_functions.php");
include_once ("include/snmp_functions.php");
if (isset($_POST["save_component_host"])) {
host_save();
return "host.php";
}elseif (isset($_POST["save_component_new_graphs"])) {
host_new_graphs_save();
return "host.php?action=edit&id=" . $_POST["host_id"];
$save["id"] = $_POST["id"];
$save["host_template_id"] = $_POST["host_template_id"];
$save["description"] = form_input_validate($_POST["description"], "description", "", false, 3);
$save["hostname"] = form_input_validate($_POST["hostname"], "hostname", "", true, 3);
$save["management_ip"] = form_input_validate($_POST["management_ip"], "management_ip", "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$", false, 3);
$save["snmp_community"] = form_input_validate($_POST["snmp_community"], "snmp_community", "", true, 3);
$save["snmp_version"] = form_input_validate($_POST["snmp_version"], "snmp_version", "", true, 3);
$save["snmp_username"] = form_input_validate($_POST["snmp_username"], "snmp_username", "", true, 3);;
$save["snmp_password"] = form_input_validate($_POST["snmp_password"], "snmp_password", "", true, 3);
if (!is_error_message()) {
$host_id = sql_save($save, "host");
if ($host_id) {
raise_message(1);
/* push out relavant fields to data sources using this host */
push_out_host($host_id);
}else{
raise_message(2);
}
if (isset($_POST["add_y"])) {
db_execute("replace into host_snmp_query (host_id,snmp_query_id) values ($host_id," . $_POST["snmp_query_id"] . ")");
/* recache snmp data */
query_snmp_host($host_id, $_POST["snmp_query_id"]);
header ("Location: host.php?action=edit&id=" . $host_id);
exit;
}
/* summarize the 'create graph from host template/snmp index' stuff into an array */
while (list($var, $val) = each($_POST)) {
if (preg_match('/^cg_\d+$/', $var)) {
$graph_template_id = preg_replace('/^cg_(\d+)$/', "\\1", $var);
$selected_graphs["cg"][$graph_template_id][$graph_template_id] = true;
}elseif (preg_match('/^sg_\d+_\d+_\d+$/', $var)) {
$graph_template_id = preg_replace('/^sg_(\d+)_(\d+)_(\d+)$/', "\\1", $var);
$snmp_query_id = preg_replace('/^sg_(\d+)_(\d+)_(\d+)$/', "\\2", $var);
$snmp_index = preg_replace('/^sg_(\d+)_(\d+)_(\d+)$/', "\\3", $var);
$selected_graphs["sg"][$snmp_query_id][$graph_template_id][$snmp_index] = true;
}
}
if (isset($selected_graphs)) {
host_new_graphs($host_id, $_POST["host_template_id"], $selected_graphs);
exit;
}
}
if (is_error_message()) {
header ("Location: host.php?action=edit&id=" . (empty($host_id) ? $_POST["id"] : $host_id));
}else{
header ("Location: host.php");
}
}
if (isset($_POST["save_component_new_graphs"])) {
host_new_graphs_save();
header ("Location: host.php?action=edit&id=" . $_POST["host_id"]);
}
}
/* ---------------------
@@ -273,7 +330,7 @@ function host_new_graphs_save() {
while (list($var, $val) = each($_POST)) {
if (preg_match("/^g_(\d+)_(\d+)_(\d+)_(\w+)/", $var, $matches)) { /* 1: snmp_query_id, 2: graph_template_id, 3: (opt) snmp index, 4: field_name */
if (empty($matches[4])) { /* ALL new graphs */
if (empty($matches[3])) { /* ALL new graphs */
db_execute("update graph_templates_graph set " . $matches[4] . "='$val' where " . (empty($matches[1]) ? "local_graph_id=" . $new_graph_templates["cg"]{$matches[2]} : array_to_sql_or(split(":", $new_graph_templates["sg"]{$matches[1]}{$matches[2]}),"local_graph_id")));
}else{ /* only new graphs for this snmp_index */
db_execute("update graph_templates_graph set " . $matches[4] . "='$val' where local_graph_id=" . $new_graph_index_to_local{$matches[1]}{$matches[3]});
@@ -323,69 +380,14 @@ function host_new_graphs_save() {
}
function host_save() {
include_once ("include/utility_functions.php");
include_once ("include/snmp_functions.php");
$save["id"] = $_POST["id"];
$save["host_template_id"] = $_POST["host_template_id"];
$save["description"] = $_POST["description"];
$save["hostname"] = $_POST["hostname"];
$save["management_ip"] = $_POST["management_ip"];
$save["snmp_community"] = $_POST["snmp_community"];
$save["snmp_version"] = $_POST["snmp_version"];
$save["snmp_username"] = $_POST["snmp_username"];
$save["snmp_password"] = $_POST["snmp_password"];
$host_id = sql_save($save, "host");
if ($host_id) {
/* push out relavant fields to data sources using this host */
push_out_host($host_id);
}
while (list($var, $val) = each($_POST)) {
if (preg_match('/^cg_\d+$/', $var)) {
$graph_template_id = preg_replace('/^cg_(\d+)$/', "\\1", $var);
$selected_graphs["cg"][$graph_template_id][$graph_template_id] = true;
}elseif (preg_match('/^sg_\d+_\d+_\d+$/', $var)) {
$graph_template_id = preg_replace('/^sg_(\d+)_(\d+)_(\d+)$/', "\\1", $var);
$snmp_query_id = preg_replace('/^sg_(\d+)_(\d+)_(\d+)$/', "\\2", $var);
$snmp_index = preg_replace('/^sg_(\d+)_(\d+)_(\d+)$/', "\\3", $var);
$selected_graphs["sg"][$snmp_query_id][$graph_template_id][$snmp_index] = true;
}
}
if (isset($_POST["add_y"])) {
db_execute("replace into host_snmp_query (host_id,snmp_query_id) values ($host_id," . $_POST["snmp_query_id"] . ")");
/* recache snmp data */
query_snmp_host($host_id, $_POST["snmp_query_id"]);
header("Location: host.php?action=edit&id=" . $host_id);
exit;
}
if (isset($selected_graphs)) {
host_new_graphs($host_id, $_POST["host_template_id"], $selected_graphs);
exit;
}
if ($host_id) {
raise_message(1);
}else{
raise_message(2);
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit;
}
}
function host_new_graphs($host_id, $host_template_id, $selected_graphs_array) {
include_once ("include/xml_functions.php");
include_once ("include/top_header.php");
global $colors, $paths, $row_counter, $struct_graph, $struct_data_source, $struct_graph_item, $struct_data_source_item;
global $colors, $paths, $struct_graph, $row_counter, $struct_data_source, $struct_graph_item, $struct_data_source_item;
print "<form method='post' action='host.php'>\n";
@@ -428,7 +430,7 @@ function host_new_graphs($host_id, $host_template_id, $selected_graphs_array) {
if (sizeof($fields) > 0) {
foreach ($fields as $field) {
print " <tr bgcolor='#" . $colors["form_alternate2"] . "'>
print " <tr bgcolor='#" . $colors["form_alternate1"] . "'>
<td width='50%'>
<font class='textEditTitle'>" . $field["name"] . " -> " . $field["field_name"] . "</font><br>
When these graphs are created, the following data input field will be filled with data from
@@ -499,7 +501,7 @@ function host_new_graphs($host_id, $host_template_id, $selected_graphs_array) {
entry here might might 20 graphs... so we can't automatically fill in the
values */
if ((!empty($snmp_query_id)) && ($snmp_queries["suggested_values"][0]["graph"][0][$field_name])) {
print "<tr bgcolor='#" . $colors["form_alternate2"] . "'>";
print "<tr bgcolor='#" . $colors["form_alternate1"] . "'>";
print "<td><strong>" . $struct_graph[$field_name]["title"] . "</strong></td>";
print "<td><em>Using Suggested Values</em> (see XML file)</td>";
print "</td></tr>\n";
@@ -528,7 +530,7 @@ function host_new_graphs($host_id, $host_template_id, $selected_graphs_array) {
$field_name = $item["column_name"];
form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],0);
print "<tr bgcolor='#" . $colors["form_alternate1"] . "'>";
print " <td width='50%'>
<font class='textEditTitle'>" . $graph_input["name"] . "</font>";
@@ -560,7 +562,7 @@ function host_new_graphs($host_id, $host_template_id, $selected_graphs_array) {
values */
if ((!empty($snmp_query_id)) && (isset($snmp_queries["suggested_values"][0]{"ds_" . $data_template["data_source_name"]}[0][$field_name]))) {
print "<tr bgcolor='#" . $colors["form_alternate2"] . "'>";
print "<tr bgcolor='#" . $colors["form_alternate1"] . "'>";
print "<td><strong>" . $struct_data_source[$field_name]["title"] . "</strong></td>";
print "<td><em>Using Suggested Values</em> (see XML file)</td>";
print "</td></tr>\n";
@@ -582,16 +584,17 @@ function host_new_graphs($host_id, $host_template_id, $selected_graphs_array) {
if (sizeof($data_template_items) > 0) {
foreach ($data_template_items as $data_template_item) {
reset($struct_data_source_item);
$row_counter = 0;
$drew_items = false;
while (list($field_name, $field_array) = each($struct_data_source_item)) {
if ($data_template_item{"t_" . $field_name} == "on") {
if ($drew_items == false) {
print "<tr><td colspan='2' bgcolor='#" . $colors["header_panel"] . "'><span style='font-size: 10px; color: white;'><strong>Data Source Item</strong> - " . $data_template_item["data_source_name"] . " - [Template: " . $data_template["data_template_name"] . "]</span></td></tr>";
//print "<tr><td colspan='2' bgcolor='#" . $colors["header_panel"] . "'><span style='font-size: 10px; color: white;'><strong>Data Source Item</strong> - " . $data_template_item["data_source_name"] . " - [Template: " . $data_template["data_template_name"] . "]</span></td></tr>";
}
$row_counter = 1;
draw_templated_row($field_array, "di_" . $snmp_query_id . "_" . $graph_template_id . "_" . $data_template["data_template_id"] . "_" . $data_template_item["id"] . "_" . $field_name, $data_template_item[$field_name]);
$row_counter = 0; $drew_items = true;
$drew_items = true;
}
}
}
@@ -608,16 +611,7 @@ function host_new_graphs($host_id, $host_template_id, $selected_graphs_array) {
form_hidden_box("save_component_new_graphs","1","");
print "<input type='hidden' name='selected_graphs_array' value='" . serialize($selected_graphs_array) . "'>\n";
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "host.php?action=edit&id=$host_id");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("host.php?action=edit&id=$host_id");
include_once ("include/bottom_footer.php");
}
@@ -841,16 +835,7 @@ function host_edit() {
}
}
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "host.php");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("host.php");
}
function host() {
+35 -45
View File
@@ -30,9 +30,8 @@ include_once ('include/form.php');
switch ($_REQUEST["action"]) {
case 'save':
$redirect_location = form_save();
form_save();
header ("Location: $redirect_location"); exit;
break;
case 'remove':
template_remove();
@@ -61,9 +60,40 @@ switch ($_REQUEST["action"]) {
function form_save() {
if (isset($_POST["save_component_template"])) {
template_save();
$save["id"] = $_POST["id"];
$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
return "host_templates.php";
if (!is_error_message()) {
$host_template_id = sql_save($save, "host_template");
if ($host_template_id) {
raise_message(1);
db_execute ("delete from host_template_data_template where host_template_id=$host_template_id");
db_execute ("delete from host_template_graph_template where host_template_id=$host_template_id");
while (list($var, $val) = each($_POST)) {
if (eregi("^gt_", $var)) {
db_execute ("replace into host_template_graph_template (host_template_id,graph_template_id,suggested_values) values($host_template_id," . substr($var, 3) . ",'" . $_POST{"ogt_suggested_values_" . substr($var, 3)} . "')");
}elseif (eregi("^odt_suggested_values_", $var)) {
$data_template_id = ereg_replace("^odt_suggested_values_([0-9]+)_[0-9]+$", "\\1", $var);
$graph_template_id = ereg_replace("^odt_suggested_values_[0-9]+_([0-9]+)$", "\\1", $var);
if (!empty($val)) {
db_execute ("replace into host_template_data_template (host_template_id,data_template_id,graph_template_id,suggested_values) values($host_template_id,$data_template_id,$graph_template_id,'$val')");
}
}
}
}else{
raise_message(2);
}
}
if (is_error_message()) {
header ("Location: host_templates.php?action=edit&id=" . (empty($host_template_id) ? $_POST["id"] : $host_template_id));
}else{
header ("Location: host_templates.php");
}
}
}
@@ -86,37 +116,6 @@ function template_remove() {
}
}
function template_save() {
$save["id"] = $_POST["id"];
$save["name"] = $_POST["name"];
$host_template_id = sql_save($save, "host_template");
if ($host_template_id) {
raise_message(1);
}else{
raise_message(2);
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit;
}
db_execute ("delete from host_template_data_template where host_template_id=$host_template_id");
db_execute ("delete from host_template_graph_template where host_template_id=$host_template_id");
while (list($var, $val) = each($_POST)) {
if (eregi("^gt_", $var)) {
db_execute ("replace into host_template_graph_template (host_template_id,graph_template_id,suggested_values) values($host_template_id," . substr($var, 3) . ",'" . $_POST{"ogt_suggested_values_" . substr($var, 3)} . "')");
}elseif (eregi("^odt_suggested_values_", $var)) {
$data_template_id = ereg_replace("^odt_suggested_values_([0-9]+)_[0-9]+$", "\\1", $var);
$graph_template_id = ereg_replace("^odt_suggested_values_[0-9]+_([0-9]+)$", "\\1", $var);
if (!empty($val)) {
db_execute ("replace into host_template_data_template (host_template_id,data_template_id,graph_template_id,suggested_values) values($host_template_id,$data_template_id,$graph_template_id,'$val')");
}
}
}
}
function template_edit() {
global $colors;
@@ -244,16 +243,7 @@ function template_edit() {
form_hidden_id("id",$_GET["id"]);
form_hidden_box("save_component_template","1","");
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "host_templates.php");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("host_templates.php");
}
function template() {
+35 -38
View File
@@ -31,9 +31,8 @@ include_once ('include/form.php');
switch ($_REQUEST["action"]) {
case 'save':
$redirect_location = form_save();
form_save();
header ("Location: $redirect_location"); exit;
break;
case 'remove':
rra_remove();
@@ -62,7 +61,36 @@ switch ($_REQUEST["action"]) {
function form_save() {
if (isset($_POST["save_component_rra"])) {
return rra_save();
$save["id"] = $_POST["id"];
$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
$save["x_files_factor"] = form_input_validate($_POST["x_files_factor"], "x_files_factor", "^[0-9]+(\.[0-9])?$", false, 3);
$save["steps"] = form_input_validate($_POST["steps"], "steps", "^[0-9]*$", false, 3);
$save["rows"] = form_input_validate($_POST["rows"], "rows", "^[0-9]*$", false, 3);
if (!is_error_message()) {
$rra_id = sql_save($save, "rra");
if ($rra_id) {
raise_message(1);
db_execute("delete from rra_cf where rra_id=$rra_id");
for ($i=0; ($i < count($_POST["consolidation_function_id"])); $i++) {
db_execute("insert into rra_cf (rra_id,consolidation_function_id)
values ($rra_id," . $_POST["consolidation_function_id"][$i] . ")");
}
}else{
raise_message(2);
}
}
if (is_error_message()) {
header ("Location: rra.php?action=edit&id=" . (empty($rra_id) ? $_POST["id"] : $rra_id));
}else{
header ("Location: rra.php");
}
}
}
@@ -71,28 +99,7 @@ function form_save() {
------------------- */
function rra_save() {
$save["id"] = $_POST["id"];
$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
$save["x_files_factor"] = form_input_validate($_POST["x_files_factor"], "x_files_factor", "^[0-9]+(\.[0-9])?$", false, 3);
$save["steps"] = form_input_validate($_POST["steps"], "steps", "^[0-9]*$", false, 3);
$save["rows"] = form_input_validate($_POST["rows"], "rows", "^[0-9]*$", false, 3);
if (!is_error_message()) {
$rra_id = sql_save($save, "rra");
db_execute("delete from rra_cf where rra_id=$rra_id");
for ($i=0; ($i < count($_POST["consolidation_function_id"])); $i++) {
db_execute("insert into rra_cf (rra_id,consolidation_function_id)
values ($rra_id," . $_POST["consolidation_function_id"][$i] . ")");
}
}
if (is_error_message()) {
return "rra.php?action=edit&id=" . $_POST["id"];
}else{
return "rra.php";
}
}
function rra_remove() {
@@ -111,8 +118,6 @@ function rra_remove() {
function rra_edit() {
global $colors, $consolidation_functions;
display_output_messages();
if (isset($_GET["id"])) {
$rra = db_fetch_row("select * from rra where id=" . $_GET["id"]);
$header_label = "[edit: " . $rra["name"] . "]";
@@ -166,25 +171,17 @@ function rra_edit() {
</tr>
<?php
end_box();
form_hidden_id("id",$_GET["id"]);
form_hidden_box("save_component_rra","1","");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right" background="images/blue_line.gif">
<?php form_save_button("save", "rra.php");?>
</form>
</td>
</tr>
<?php
end_box();
form_save_button("rra.php");
}
function rra() {
global $colors;
display_output_messages();
start_box("<strong>Round Robin Archives</strong>", "98%", $colors["header"], "3", "center", "rra.php?action=edit");
print "<tr bgcolor='#" . $colors["header_panel"] . "'>";
+56 -71
View File
@@ -30,9 +30,8 @@ include_once ('include/functions.php');
switch ($_REQUEST["action"]) {
case 'save':
$redirect_location = form_save();
form_save();
header ("Location: $redirect_location"); exit;
break;
case 'item_movedown':
item_movedown();
@@ -82,12 +81,60 @@ switch ($_REQUEST["action"]) {
-------------------------- */
function form_save() {
include_once("include/tree_functions.php");
if (isset($_POST["save_component_tree"])) {
tree_save();
return "tree.php";
$save["id"] = $_POST["id"];
$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
if (!is_error_message()) {
$tree_id = sql_save($save, "graph_tree");
if ($tree_id) {
raise_message(1);
}else{
raise_message(2);
}
}
if (is_error_message()) {
header ("Location: tree.php?action=edit&id=" . (empty($tree_id) ? $_POST["id"] : $tree_id));
}else{
header ("Location: tree.php");
}
}elseif (isset($_POST["save_component_tree_item"])) {
item_save();
return "tree.php?action=edit&id=" . $_POST["graph_tree_id"];
if (empty($_POST["id"])) {
/* new/save - generate new order key */
$order_key = get_next_tree_id(db_fetch_cell("select order_key from graph_tree_items where id=" . $_POST["parent_item_id"]),"graph_tree_items","order_key");
}else{
/* edit/save - use old order_key */
$order_key = db_fetch_cell("select order_key from graph_tree_items where id=" . $_POST["id"]);
}
$save["id"] = $_POST["id"];
$save["graph_tree_id"] = $_POST["graph_tree_id"];
$save["title"] = form_input_validate($_POST["title"], "title", "", true, 3);
$save["order_key"] = $order_key;
$save["local_graph_id"] = form_input_validate($_POST["local_graph_id"], "local_graph_id", "", true, 3);
$save["rra_id"] = form_input_validate($_POST["rra_id"], "rra_id", "", true, 3);
if (!is_error_message()) {
$tree_item_id = sql_save($save, "graph_tree_items");
if ($tree_item_id) {
raise_message(1);
reparent_branch($_POST["parent_item_id"], $_POST["id"]);
}else{
raise_message(2);
}
}
if (is_error_message()) {
header ("Location: tree.php?action=item_edit&tree_item_id=" . (empty($tree_item_id) ? $_POST["id"] : $tree_item_id) . "&tree_id=" . $_POST["graph_tree_id"]);
}else{
header ("Location: tree.php?action=edit&id=" . $_POST["graph_tree_id"]);
}
}
}
@@ -167,16 +214,7 @@ function item_edit() {
form_hidden_id("graph_tree_id",$_GET["tree_id"]);
form_hidden_box("save_component_tree_item","1","");
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "tree.php?action=edit&id=" . $_GET["tree_id"]);?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("tree.php?action=edit&id=" . $_GET["tree_id"]);
}
function item_moveup() {
@@ -193,35 +231,6 @@ function item_movedown() {
if ($order_key > 0) { branch_down($order_key, 'graph_tree_items', 'order_key', ''); }
}
function item_save() {
include_once("include/tree_functions.php");
if (empty($_POST["id"])) {
/* new/save - generate new order key */
$order_key = get_next_tree_id(db_fetch_cell("select order_key from graph_tree_items where id=" . $_POST["parent_item_id"]),"graph_tree_items","order_key");
}else{
/* edit/save - use old order_key */
$order_key = db_fetch_cell("select order_key from graph_tree_items where id=" . $_POST["id"]);
}
$save["id"] = $_POST["id"];
$save["graph_tree_id"] = $_POST["graph_tree_id"];
$save["title"] = $_POST["title"];
$save["order_key"] = $order_key;
$save["local_graph_id"] = $_POST["local_graph_id"];
$save["rra_id"] = $_POST["rra_id"];
if (sql_save($save, "graph_tree_items")) {
raise_message(1);
reparent_branch($_POST["parent_item_id"], $_POST["id"]);
}else{
raise_message(2);
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit;
}
}
function item_remove() {
include_once("include/tree_functions.php");
@@ -244,22 +253,7 @@ function item_remove() {
Tree Functions
--------------------- */
function tree_save() {
$save["id"] = $_POST["id"];
$save["name"] = $_POST["name"];
if (sql_save($save, "graph_tree")) {
raise_message(1);
}else{
raise_message(2);
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit;
}
}
function tree_remove() {
global $config;
if ((read_config_option("remove_verification") == "on") && ($_GET["confirm"] != "yes")) {
include ('include/top_header.php');
form_confirm("Are You Sure?", "Are you sure you want to delete the tree <strong>'" . db_fetch_cell("select name from graph_tree where id=" . $_GET["id"]) . "'</strong>?", getenv("HTTP_REFERER"), "tree.php?action=remove&id=" . $_GET["id"]);
@@ -275,7 +269,7 @@ function tree_remove() {
function tree_edit() {
include_once("include/tree_view_functions.php");
global $colors, $cdef_item_types;
global $colors;
start_box("<strong>Trees [edit]</strong>", "98%", $colors["header"], "3", "center", "");
@@ -306,16 +300,7 @@ function tree_edit() {
form_hidden_box("save_component_tree","1","");
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "tree.php");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("tree.php");
}
function tree() {
+150 -175
View File
@@ -30,14 +30,13 @@ include_once ("include/form.php");
switch ($_REQUEST["action"]) {
case 'save':
$redirect_location = form_save();
form_save();
header ("Location: $redirect_location"); exit;
break;
case 'user_remove':
user_remove();
header ("Location: user_auth.php");
header ("Location: user_admin.php");
break;
case 'graph_config_edit':
include_once ("include/top_header.php");
@@ -94,22 +93,83 @@ function draw_user_form_select() {
-------------------------- */
function form_save() {
global $config;
/* user management save */
if (isset($_POST["save_component_user"])) {
if (($_POST["password"] == "") && ($_POST["password_confirm"] == "")) {
$password = db_fetch_cell("select password from user where id=" . $_POST["id"]);
}else{
$password = "PASSWORD('" . $_POST["password"] . "')";
}
/* check to make sure the passwords match; if not error */
if ($_POST["password"] != $_POST["password_confirm"]) {
$array_error_fields = unserialize($_SESSION["sess_error_fields"]);
$array_error_fields["password"] = "password";
$array_error_fields["password_confirm"] = "password_confirm";
$_SESSION["sess_error_fields"] = serialize($array_error_fields);
raise_message(4);
}
form_input_validate($_POST["password"], "password", "" . $_POST["password_confirm"] . "", true, 4);
form_input_validate($_POST["password_confirm"], "password_confirm", "" . $_POST["password"] . "", true, 4);
$save["id"] = $_POST["id"];
$save["username"] = form_input_validate($_POST["username"], "username", "^[A-Za-z_0-9]+$", false, 3);
$save["full_name"] = form_input_validate($_POST["full_name"], "full_name", "", true, 3);
$save["password"] = $password;
$save["must_change_password"] = form_input_validate($_POST["must_change_password"], "must_change_password", "", true, 3);
$save["show_tree"] = form_input_validate($_POST["show_tree"], "show_tree", "", true, 3);
$save["show_list"] = form_input_validate($_POST["show_list"], "show_list", "", true, 3);
$save["show_preview"] = form_input_validate($_POST["show_preview"], "show_preview", "", true, 3);
$save["graph_settings"] = form_input_validate($_POST["graph_settings"], "graph_settings", "", true, 3);
$save["login_opts"] = form_input_validate($_POST["login_opts"], "login_opts", "", true, 3);
$save["graph_policy"] = form_input_validate($_POST["graph_policy"], "graph_policy", "", true, 3);
if (!is_error_message()) {
$user_id = sql_save($save, "user");
if ($user_id) {
raise_message(1);
}else{
raise_message(2);
}
db_execute("delete from user_auth_realm where user_id=$user_id");
while (list($var, $val) = each($_POST)) {
if (eregi("^[section]", $var)) {
if (substr($var, 0, 7) == "section") {
db_execute ("replace into user_auth_realm (user_id,realm_id) values($user_id," . substr($var, 7) . ")");
}
}
}
}
}
if ((isset($_POST["save_component_user"])) && (isset($_POST["save_component_graph_perms"])) && (isset($_POST["save_component_graph_config"]))) {
user_save();
graph_perms_save();
/* graph_config_save(); */
return "user_admin.php?action=user_edit&id=" . $_POST["user_id"];
}elseif (isset($_POST["save_component_user"])) {
user_save();
return "user_admin.php";
}elseif (isset($_POST["save_component_graph_perms"])) {
graph_perms_save();
return "user_admin.php";
}elseif (isset($_POST["save_component_graph_config"])) {
/* graph_config_save(); */
return "user_admin.php";
/* graph permissions */
if ((isset($_POST["save_component_graph_perms"])) && (!is_error_message())) {
db_execute ("delete from user_auth_graph where user_id=$user_id");
db_execute ("delete from user_auth_tree where user_id=$user_id");
reset($_POST);
while (list($var, $val) = each($_POST)) {
if (eregi("^[graph|tree]", $var)) {
if (substr($var, 0, 5) == "graph") {
db_execute ("replace into user_auth_graph (user_id,local_graph_id) values($user_id," . substr($var, 5) . ")");
}elseif (substr($var, 0, 4) == "tree") {
db_execute ("replace into user_auth_tree (user_id,tree_id) values($user_id," . substr($var, 4) . ")");
}
}
}
}
/* redirect to the appropriate page */
if ((empty($_POST["id"])) || (is_error_message())) {
header ("Location: user_admin.php?action=user_edit&id=" . (empty($user_id) ? $_POST["id"] : $user_id));
}else{
header ("Location: user_admin.php");
}
}
@@ -117,25 +177,8 @@ function form_save() {
Graph Permissions
-------------------------- */
function graph_perms_save() {
db_execute ("delete from user_auth_graph where user_id=" . $_POST["user_id"]);
db_execute ("delete from user_auth_tree where user_id=" . $_POST["user_id"]);
reset($_POST);
while (list($var, $val) = each($_POST)) {
if (eregi("^[graph|tree]", $var)) {
if (substr($var, 0, 5) == "graph") {
db_execute ("replace into user_auth_graph (user_id,local_graph_id) values(" . $_POST["user_id"] . "," . substr($var, 5) . ")");
}elseif (substr($var, 0, 4) == "tree") {
db_execute ("replace into user_auth_tree (user_id,tree_id) values(" . $_POST["user_id"] . "," . substr($var, 4) . ")");
}
}
}
}
function graph_perms_edit() {
global $colors, $config;
global $colors;
if (isset($_GET["id"])) {
$graph_policy = db_fetch_cell("select graph_policy from user where id=" . $_GET["id"]);
@@ -145,33 +188,28 @@ function graph_perms_edit() {
}elseif ($graph_policy == "2") {
$graph_policy_text = "ALLOWED";
}
}else{
unset($user);
}
$header_label = "[edit: " . db_fetch_cell("select username from user where id=" . $_GET["id"]) . "]";
if (read_config_option("full_view_user_admin") == "") {
start_box("<strong>User Management [edit]</strong>", "98%", $colors["header"], "3", "center", "");
start_box("<strong>User Management</strong> $header_label", "98%", $colors["header"], "3", "center", "");
draw_user_form_select();
end_box();
}
if ($graph_policy == "1") {
$graph_policy_text = "Select the graphs you want to <strong>DENY</strong> this user from.";
} elseif ($graph_policy == "2") {
$graph_policy_text = "Select the graphs you want <strong>ALLOW</strong> this user to view.";
}
$header_label = "<strong>Graph Permissions</strong> [policy: " . (($graph_policy == "1") ? "ALLOW" : "DENY") . "]";
start_box($graph_policy_text, "98%", $colors["header"], "3", "center", "");
start_box($header_label, "98%", $colors["header"], "3", "center", "");
$graphs = db_fetch_assoc("select
user_auth_graph.user_id,
graph_templates_graph.local_graph_id,
graph_templates_graph.title
from graph_templates_graph
left join user_auth_graph on (graph_templates_graph.local_graph_id=user_auth_graph.local_graph_id and user_auth_graph.user_id=" . $_GET["id"] . ")
left join user_auth_graph on (graph_templates_graph.local_graph_id=user_auth_graph.local_graph_id and user_auth_graph.user_id=" . (empty($_GET["id"]) ? "0" : $_GET["id"]) . ")
where graph_templates_graph.local_graph_id > 0
order by graph_templates_graph.title");
$rows = sizeof($graphs);
?>
<form method="post" action="user_admin.php">
@@ -181,27 +219,26 @@ function graph_perms_edit() {
<table width="100%">
<tr>
<td align="top" width="50%">
<?php
if (sizeof($graphs) > 0) {
foreach ($graphs as $graph) {
if ($graph["user_id"] == "") {
$old_value = "";
}else{
$old_value = "on";
}
$column1 = floor(($rows / 2) + ($rows % 2));
if ($i == $column1) {
print "</td><td valign='top' width='50%'>";
}
form_base_checkbox("graph" . $graph["id"], $old_value, $graph["title"], "", $_GET["id"], true);
$i++;
}
}
?>
<?php
if (sizeof($graphs) > 0) {
foreach ($graphs as $graph) {
if ($graph["user_id"] == "") {
$old_value = "";
}else{
$old_value = "on";
}
$column1 = floor((sizeof($graphs) / 2) + (sizeof($graphs) % 2));
if ($i == $column1) {
print "</td><td valign='top' width='50%'>";
}
form_base_checkbox("graph" . $graph["local_graph_id"], $old_value, $graph["title"], "", $_GET["id"], true);
$i++;
}
}
?>
</td>
</tr>
</table>
@@ -215,16 +252,7 @@ function graph_perms_edit() {
form_hidden_box("save_component_graph_perms","1","");
if (read_config_option("full_view_user_admin") == "") {
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "user_admin.php");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("user_admin.php");
}
}
@@ -238,8 +266,10 @@ function graph_config_edit() {
global $colors, $tabs_graphs, $settings_graphs;
$header_label = "[edit: " . db_fetch_cell("select username from user where id=" . $_GET["id"]) . "]";
if (read_config_option("full_view_user_admin") == "") {
start_box("<strong>User Management [edit]</strong>", "98%", $colors["header"], "3", "center", "");
start_box("<strong>User Management</strong> $header_label", "98%", $colors["header"], "3", "center", "");
draw_user_form_select();
end_box();
}
@@ -253,7 +283,7 @@ function graph_config_edit() {
?>
<tr>
<td colspan="2" bgcolor="#<?php print $colors["header"];?>">
<span class="textHeaderDark"><?php print $tabs_graphs[$tab_short_name];?></span>
<span class="textHeaderDark"><strong>Graph Settings</strong> [<?php print $tabs_graphs[$tab_short_name];?>]</span>
</td>
</tr>
<?php
@@ -264,7 +294,7 @@ function graph_config_edit() {
foreach (array_keys($settings_graphs) as $setting) {
/* make sure to skip group members here; only parents are allowed */
if (($settings_graphs[$setting]["method"] != "internal") && ($settings_graphs[$setting]["tab"] == $tab_short_name)) {
++$i;
form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i);
/* draw the acual header and textbox on the form */
@@ -285,6 +315,8 @@ function graph_config_edit() {
break;
}
++$i;
print "</tr>\n";
}
@@ -299,62 +331,14 @@ function graph_config_edit() {
form_hidden_id("user_id",$_GET["id"]);
form_hidden_box("save_component_graph_config","1","");
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "user_admin.php");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("user_admin.php");
}
/* --------------------------
User Administration
-------------------------- */
function user_save() {
/* only change password when user types one */
if ($_POST["password"] != $_POST["confirm"]) {
$passwords_do_not_match = true;
}elseif (($_POST["password"] == "") && ($_POST["confirm"] == "")) {
$password = db_fetch_cell("select password from user where id=" . $_POST["id"]);
}else{
$password = "PASSWORD('" . $_POST["password"] . "')";
}
if ($passwords_do_not_match != true) {
$save["id"] = $_POST["id"];
$save["username"] = $_POST["username"];
$save["full_name"] = $_POST["full_name"];
$save["password"] = $password;
$save["must_change_password"] = $_POST["must_change_password"];
$save["show_tree"] = $_POST["show_tree"];
$save["show_list"] = $_POST["show_list"];
$save["show_preview"] = $_POST["show_preview"];
$save["graph_settings"] = $_POST["graph_settings"];
$save["login_opts"] = $_POST["login_opts"];
$save["graph_policy"] = $_POST["graph_policy"];
$user_id = sql_save($save, "user");
db_execute("delete from user_auth_realm where user_id=$user_id");
while (list($var, $val) = each($_POST)) {
if (eregi("^[section]", $var)) {
if (substr($var, 0, 7) == "section") {
db_execute ("replace into user_auth_realm (user_id,realm_id) values($user_id," . substr($var, 7) . ")");
}
}
}
}
}
function user_remove() {
global $config;
if ((read_config_option("remove_verification") == "on") && ($_GET["confirm"] != "yes")) {
include ('include/top_header.php');
form_confirm("Are You Sure?", "Are you sure you want to delete the user <strong>'" . db_fetch_cell("select username from user where id=" . $_GET["id"]) . "'</strong>?", getenv("HTTP_REFERER"), "user_admin.php?action=user_remove&id=" . $_GET["id"]);
@@ -373,21 +357,22 @@ function user_remove() {
}
function user_edit() {
global $colors, $config;
global $colors;
if (isset($_GET["id"])) {
$user = db_fetch_row("select * from user where id=" . $_GET["id"]);
$header_label = "[edit: " . $user["username"] . "]";
}else{
unset($user);
$header_label = "[new]";
}
if (read_config_option("full_view_user_admin") == "") {
start_box("<strong>User Management [edit]</strong>", "98%", $colors["header"], "3", "center", "");
start_box("<strong>User Management</strong> $header_label", "98%", $colors["header"], "3", "center", "");
draw_user_form_select();
end_box();
}
start_box("User Configuration", "98%", $colors["header"], "3", "center", "");
start_box("<strong>User Management</strong> $header_label", "98%", $colors["header"], "3", "center", "");
?>
<form method="post" action="user_admin.php">
@@ -396,7 +381,7 @@ function user_edit() {
form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],0); ?>
<td width="50%">
<font class="textEditTitle">User Name</font><br>
The login name for this user.
</td>
<?php form_text_box('username',$user["username"],"","");?>
</tr>
@@ -404,7 +389,7 @@ function user_edit() {
<?php form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],1); ?>
<td width="50%">
<font class="textEditTitle">Full Name</font><br>
A more descriptive name for this user, that can include spaces or special characters.
</td>
<?php form_text_box('full_name',$user["full_name"],"","");?>
</tr>
@@ -412,18 +397,18 @@ function user_edit() {
<?php form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],0); ?>
<td width="50%">
<font class="textEditTitle">Password</font><br>
Enter the password for this user twice. Remember that passwords are case sensitive!
</td>
<td>
<?php form_base_password_box("password","","","","40");?><br>
<?php form_base_password_box("confirm","","","","40");?>
<?php form_base_password_box("password_confirm","","","","40");?>
</td>
</tr>
<?php form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],1); ?>
<td width="50%">
<font class="textEditTitle">Account Options</font><br>
Set any user account-specific options here.
</td>
<td>
<?php
@@ -436,7 +421,7 @@ function user_edit() {
<?php form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],0); ?>
<td width="50%">
<font class="textEditTitle">Graph Options</font><br>
Set any graph-specific options here.
</td>
<td>
<?php
@@ -477,14 +462,14 @@ function user_edit() {
<?php
end_box();
start_box("User Permissions", "98%", $colors["header"], "3", "center", "");
start_box("<strong>Realm Permissions</strong>", "98%", $colors["header"], "3", "center", "");
$realms = db_fetch_assoc("select
user_auth_realm.user_id,
user_realm.id,
user_realm.name
from user_realm
left join user_auth_realm on (user_realm.id=user_auth_realm.realm_id and user_auth_realm.user_id=" . $_GET["id"] . ")
left join user_auth_realm on (user_realm.id=user_auth_realm.realm_id and user_auth_realm.user_id=" . (empty($_GET["id"]) ? "0" : $_GET["id"]) . ")
order by user_realm.name");
?>
@@ -494,28 +479,27 @@ function user_edit() {
<table width="100%">
<tr>
<td align="top" width="50%">
<?php
if (sizeof($realms) > 0) {
foreach ($realms as $realm) {
if ($realm["user_id"] == "") {
$old_value = "";
}else{
$old_value = "on";
}
$column1 = floor((sizeof($realms) / 2) + (sizeof($realms) % 2));
if ($i == $column1) {
print "</td><td valign='top' width='50%'>";
}
form_base_checkbox("section" . $realm["id"], $old_value, $realm["name"], "", $_GET["id"], true);
$i++;
}
}
?>
<?php
if (sizeof($realms) > 0) {
foreach ($realms as $realm) {
if ($realm["user_id"] == "") {
$old_value = "";
}else{
$old_value = "on";
}
$column1 = floor((sizeof($realms) / 2) + (sizeof($realms) % 2));
if ($i == $column1) {
print "</td><td valign='top' width='50%'>";
}
form_base_checkbox("section" . $realm["id"], $old_value, $realm["name"], "", $_GET["id"], true);
$i++;
}
}
?>
</td>
</tr>
</table>
@@ -529,22 +513,13 @@ function user_edit() {
form_hidden_box("save_component_user","1","");
if (read_config_option("full_view_user_admin") == "") {
start_box("", "98%", $colors["header"], "3", "center", "");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right">
<?php form_save_button("save", "user_admin.php");?>
</td>
</tr>
</form>
<?php
end_box();
form_save_button("user_admin.php");
}
if (read_config_option("full_view_user_admin") == "on") {
graph_perms_edit();
graph_config_edit();
}
}
}
function user() {