1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
<?/*
+-------------------------------------------------------------------------+
| Copyright (C) 2002 Ian Berry |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| cacti: the rrdtool frontend [php-auth, php-tree, php-form] |
+-------------------------------------------------------------------------+
| This code is currently maintained and debugged by Ian Berry, any |
| questions or comments regarding this code should be directed to: |
| - iberry@raxnet.net |
+-------------------------------------------------------------------------+
| - raXnet - http://www.raxnet.net/ |
+-------------------------------------------------------------------------+
*/?>
<? $section = "Data Input"; include ('auth/include/auth.php');
header("Cache-control: no-cache");
include ('include/database.php');
include ('include/config.php');
include_once ('include/form.php');
switch ($action) {
case 'remove':
mysql_query("delete from src_fields where id=$id",$cnn_id);
mysql_query("delete from src_data where fieldid=$id",$cnn_id);
header ("Location: data.php?action=edit&id=$fid");
break;
case 'save':
$sql_id = mysql_query("replace into src_fields (id,srcid,name,dataname,inputoutput,
updaterra) values ($id,$fid,\"$name\",\"$dataname\",\"$inputoutput\",
\"$updaterra\")",$cnn_id);
if ($id == 0) {
$sql_id = mysql_query("select LAST_INSERT_ID()",$cnn_id);
if (mysql_result($sql_id,"",0) != 0) {
$id = mysql_result($sql_id,"",0);
}
/* let me explain, if the user adds a new field and this data input source is
in use by any number of ds's, data collection will fail because of the missing
data corresponding to the newly added field...this is not good, so lets fix it */
$sql_id = mysql_query("select * from rrd_ds where srcid=$fid",$cnn_id);
$rows = mysql_num_rows($sql_id); $i = 0;
while ($i < $rows) {
/* create a null entry in every ds for this field */
$sql_id_save = mysql_query("replace into src_data (id,fieldid,dsid,value) values
(0,$id," . mysql_result($sql_id, $i, "id") . ",\"\")",$cnn_id);
$i++;
}
}
header ("Location: data.php?action=edit&id=$fid");
break;
case 'edit':
include_once ('include/top_header.php');
if ($id != "") {
$sql_id = mysql_query("select * from src_fields where id=$id",$cnn_id);
}
DrawFormHeader("Data Input Source Configuration","",false);
DrawFormItem("Name","The name of this data source; only used by the front end.");
DrawFormItemTextBox("name",$sql_id,"","");
DrawFormItem("Data Name","The name of the data source field used by the frontend to identify each field.");
DrawFormItemTextBox("dataname",$sql_id,"","");
DrawFormItem("Input/Output Field","Whether this field is for output; or requires input to be sent to the program.");
DrawFormItemDropDownCustomHeader("inputoutput");
DrawFormItemDropDownCustomItem("inputoutput","in","Input",$sql_id);
DrawFormItemDropDownCustomItem("inputoutput","out","Output",$sql_id);
DrawFormItemDropDownCustomFooter();
DrawFormItem("Use for RRA","Whether this data source field should be used to update the RRA with; there can only be one of these fields per data input source and it must be an output field.");
DrawFormItemCheckBox("updaterra",$sql_id,"Field Used to Update RRA","");
DrawFormSaveButton();
DrawFormItemHiddenIDField("id",$id);
DrawFormItemHiddenIDField("fid",$fid);
DrawFormFooter();
include_once ("include/bottom_footer.php");
break;
} ?>
|