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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
<?/*
+-------------------------------------------------------------------------+
| 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 'save':
$sql_id = mysql_query("replace into src (id,name,formatstrin,formatstrout,type) values
($id,\"$name\",\"$formatstrin\",\"$formatstrout\",\"$type\")",$cnn_id);
/* if new save, then return to edit page so user can add data fields... */
if ($id == 0) {
$sql_id = mysql_query("select LAST_INSERT_ID()",$cnn_id);
header("Location: data.php?action=edit&id=" . mysql_result($sql_id,"",0)); exit;
}else{
header("Location: data.php"); exit;
}
break;
case 'remove':
$sql_id = mysql_query("select d.id from src s left join src_fields f on s.id=f.srcid left join src_data d on f.id=d.fieldid where s.id=$id",$cnn_id);
$i = 0;
while ($i < mysql_num_rows($sql_id)) {
mysql_query("delete from src_data where id=" . mysql_result($sql_id, $i, "id"),$cnn_id);
$i++;
}
mysql_query("delete from src_fields where srcid=$id",$cnn_id);
mysql_query("delete from src where id=$id",$cnn_id);
header ("Location: data.php");
break;
case 'edit':
include_once ('include/top_header.php');
if ($id != "") {
$sql_id = mysql_query("select * from src 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("Input String","The data that in sent; which includes the filename and input sources in <> brackets.");
DrawFormItemTextBox("formatstrin",$sql_id,"","");
DrawFormItem("Output String","The data that is returned from the input program; defined as <> brackets.");
DrawFormItemTextBox("formatstrout",$sql_id,"","");
DrawFormSaveButton();
DrawFormItemHiddenIDField("id",$id);
DrawFormItemHiddenTextBox("action","save","");
DrawFormItemHiddenTextBox("type",$sql_id,"");
DrawMatrixCustom("</form>");
/* fields */
if ($id != "") {
DrawMatrixTableBegin("97%");
DrawMatrixRowBegin();
DrawMatrixHeaderTop("Current Data Input Source Fields",$color_dark_bar,"","4");
DrawMatrixHeaderAdd($color_dark_bar,"","data_fields.php?action=edit&fid=$id");
DrawMatrixRowEnd();
DrawMatrixRowBegin();
DrawMatrixHeaderItem("Name",$color_panel,$color_panel_text);
DrawMatrixHeaderItem("Data Name",$color_panel,$color_panel_text);
DrawMatrixHeaderItem("Input/Output",$color_panel,$color_panel_text);
DrawMatrixHeaderItem("Update RRA",$color_panel,$color_panel_text);
DrawMatrixHeaderItem("",$color_panel,$color_panel_text);
DrawMatrixRowEnd();
$sql_id = mysql_query("select * from src_fields where srcid=$id order by name", $cnn_id);
$rows = mysql_num_rows($sql_id); $i = 0;
while ($i < $rows) {
DrawMatrixRowBegin();
switch (mysql_result($sql_id, $i, "inputoutput")) {
case 'in':
$inputoutput = "Input";
break;
case 'out':
$inputoutput = "Output";
break;
}
switch (mysql_result($sql_id, $i, "updaterra")) {
case '':
$updaterra = "No";
break;
case 'on':
$updaterra = "<font color=\"#FF0000\">Yes</font>";
break;
}
DrawMatrixLoopItem($sql_id,"name",$i,html_boolean($config["vis_main_column_bold"]["value"]),"data_fields.php?action=edit&id=" . mysql_result($sql_id, $i, "id") . "&fid=$id");
DrawMatrixLoopItem($sql_id,"dataname",$i,false,"");
DrawMatrixLoopItem($inputoutput,"","",false,"");
DrawMatrixLoopItem($updaterra,"","",false,"");
DrawMatrixLoopItemAction("Remove",$color_panel,"",false,"data_fields.php?action=remove&id=" . mysql_result($sql_id, $i, "id") . "&fid=$id");
DrawMatrixRowEnd();
$i++;
}
DrawMatrixTableEnd();
}
include_once ("include/bottom_footer.php");
break;
default:
include_once ('include/top_header.php');
DrawMatrixTableBegin("97%");
DrawMatrixRowBegin();
DrawMatrixHeaderTop("Current Data Input Sources",$color_dark_bar,"","1");
DrawMatrixHeaderAdd($color_dark_bar,"","data.php?action=edit");
DrawMatrixRowEnd();
DrawMatrixRowBegin();
DrawMatrixHeaderItem("Name",$color_panel,$color_panel_text);
DrawMatrixHeaderItem("",$color_panel,$color_panel_text);
DrawMatrixRowEnd();
$sql_id = mysql_query("select * from src order by name", $cnn_id);
$rows = mysql_num_rows($sql_id); $i = 0;
while ($i < $rows) {
DrawMatrixRowAlternateColorBegin($color_alternate,$color_light,$i);
DrawMatrixLoopItem($sql_id,"name",$i,html_boolean($config["vis_main_column_bold"]["value"]),"data.php?action=edit&id=" . mysql_result($sql_id, $i, "id"));
if (mysql_result($sql_id, $i, "type") == "") {
$matrix_remove = "data.php?action=remove&id=" . mysql_result($sql_id, $i, "id");
}else{
$matrix_remove = "";
}
DrawMatrixLoopItemAction("Remove",$color_panel,"",false,$matrix_remove);
DrawMatrixRowEnd();
$i++;
}
DrawMatrixTableEnd();
include_once ("include/bottom_footer.php");
break;
} ?>
|