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
|
<?/*
+-------------------------------------------------------------------------+
| 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 = "User Administration"; include ('auth/include/auth.php');
header("Cache-control: no-cache");
include ('include/database.php');
include ('include/config.php');
include_once ("include/functions.php");
include_once ('include/form.php');
switch ($action) {
case 'save':
$sql_id = mysql_query("select name from settings", $cnn_id);
$rows = mysql_num_rows($sql_id); $i = 0;
while ($i < $rows) {
mysql_query("update settings set value=\"" . ${mysql_result($sql_id, $i, "name")} .
"\" where name=\"" . mysql_result($sql_id, $i, "name") . "\"", $cnn_id);
$i++;
}
header ("Location: settings.php");
break;
default:
include_once ('include/top_header.php');
$sql_id = mysql_query("select * from settings order by name", $cnn_id);
$rows = mysql_num_rows($sql_id); $i = 0;
DrawFormHeader("cacti Settings","",false);
while ($i < $rows) {
/* split appart the 'method' on the ':' */
$setting_method = split(":",mysql_result($sql_id, $i, "method"));
/* make sure to skip group members here; only parents are allowed */
if ($setting_method[1] != "group") {
/* draw the acual header and textbox on the form */
DrawFormItem(mysql_result($sql_id, $i, "friendlyname"),mysql_result($sql_id, $i, "description"));
/* choose what kind of item this is */
switch ($setting_method[0]) {
case 'textbox':
DrawFormItemTextBox(mysql_result($sql_id, $i, "name"),mysql_result($sql_id, $i, "value"),"","");
break;
case 'checkbox':
DrawFormItemCheckBox(mysql_result($sql_id, $i, "name"),mysql_result($sql_id, $i, "value"),mysql_result($sql_id, $i, "description"),"");
break;
case 'group':
/* use 'o' for the internal group counter...remeber we can have unlimited items
under each item (hence the group). */
$o = 1; $first = " WHERE"; $sql_where = "";
/* loop through each item in the group to create the OR SQL where clause */
while ($o < count($setting_method)) {
$sql_where .= "$first name=\"$setting_method[$o]\"";
$first = " OR";
$o++;
}
/* pass the SQL where clause create above to MySQL */
$sql_id_group = mysql_query("select * from settings $sql_where", $cnn_id);
$rows_group = mysql_num_rows($sql_id_group); $o = 0;
/* loop through the resultset and draw each item in the group */
while ($o < $rows_group) {
/* once again split apart the 'method' for this group item */
$setting_method_group = split(":",mysql_result($sql_id_group, $o, "method"));
switch ($setting_method_group[0]) {
case 'textbox':
DrawFormItemTextBox(mysql_result($sql_id_group, $o, "name"),mysql_result($sql_id_group, $o, "value"),"","");
break;
case 'checkbox':
DrawFormItemCheckBox(mysql_result($sql_id_group, $o, "name"),mysql_result($sql_id_group, $o, "value"),mysql_result($sql_id_group, $o, "description"),"");
break;
}
$o++;
}
break;
}
}
$i++;
}
DrawFormSaveButton();
DrawFormFooter();
include_once ("include/bottom_footer.php");
break;
} ?>
|