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
|
<?/*
+-------------------------------------------------------------------------+
| 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 = "Add/Edit Data Sources"; include ('auth/include/auth.php');
include ('include/config.php');
include_once ("include/functions.php");
include ("include/database.php");
include_once ('include/form.php');
switch ($action) {
case 'save':
/* ok, first pull out all 'input' values so we know how much to save */
$sql_id = mysql_query("select d.srcid, f.id, f.inputoutput, f.dataname from rrd_ds d left
join src_fields f on d.srcid=f.srcid where d.id=$id and f.inputoutput=\"in\"",$cnn_id);
$rows = mysql_num_rows($sql_id);
while ($i < $rows) {
/* then, check and see if this value already exists */
$sql_id_get = mysql_query("select id from src_data where fieldid=" . mysql_result($sql_id, $i, "id")
. " and dsid=$id",$cnn_id);
/* use id 0 if it doesn't; previd if it does */
if (mysql_num_rows($sql_id_get)==0) {
$new_id = 0;
}else{
$new_id = mysql_result($sql_id_get, 0, "id");
}
/* save the data into the src_data table */
$sql_id_save = mysql_query("replace into src_data (id,fieldid,dsid,value) values
($new_id," . mysql_result($sql_id, $i, "id") . ",$id,\"" .
${mysql_result($sql_id, $i, "dataname")} . "\")",$cnn_id);
$i++;
}
header ("Location: ds.php");
break;
default:
include_once ('include/rrd_functions.php');
include_once ("include/top_header.php");
$sql_id = mysql_query("select * from src_fields where srcid=$did and inputoutput=\"in\" order by name",$cnn_id);
$rows = mysql_num_rows($sql_id); $i = 0;
DrawFormHeader("rrdtool Data Source Configuration",false,false);
DrawFormPreformatedText($color_panel, GetCronPath($id) . "\n" . rrdtool_function_update($id, "", true));
while ($i < $rows) {
$sql_id_data = mysql_query("select * from src_data where dsid=$id and fieldid=" . mysql_result($sql_id, $i, "id"),$cnn_id);
DrawMatrixRowBegin();
DrawMatrixCustom("<td bgcolor=\"#$color_panel\"><strong>" . mysql_result($sql_id, $i, "name") . "</strong></td>");
DrawMatrixRowEnd();
if (mysql_num_rows($sql_id_data) != 0) {
$old_value = htmlspecialchars(mysql_result($sql_id_data, 0, "value"));
}else{
$old_value = "";
}
DrawFormItemTextBox(mysql_result($sql_id, $i, "dataname"),$old_value,"","");
$i++;
}
DrawFormSaveButton();
DrawFormItemHiddenIDField("id",$id);
DrawFormFooter();
include_once ("include/bottom_footer.php");
break;
} ?>
|