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
|
<?/*
+-------------------------------------------------------------------------+
| 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/ |
+-------------------------------------------------------------------------+
*/?>
<? header("Cache-control: no-cache");
include ('include/database.php');
$section = "User Administration"; include ('auth/include/auth.php');
include ('include/config.php');
switch ($action) {
case 'save':
mysql_query ("delete from auth_graph where userid=$id",$cnn_id);
mysql_query ("delete from auth_graph_hierarchy where userid=$id",$cnn_id);
if(isset($HTTP_POST_VARS)) {
while(list($var, $val) = each($HTTP_POST_VARS)) {
if (($var != "id") && ($var != "action")) {
if (substr($var, 0, 5) == "graph") {
mysql_query ("replace into auth_graph (userid,graphid) values($id," . substr($var, 5) . ")",$cnn_id);
}elseif (substr($var, 0, 4) == "tree") {
mysql_query ("replace into auth_graph_hierarchy (userid,hierarchyid) values($id," . substr($var, 4) . ")",$cnn_id);
}
}
$i++;
}
}
header('Location: user_admin.php'); exit;
break;
default:
include_once ('include/form.php');
include_once ('include/top_header.php');
/* ------------------- GRAPH PERMISSIONS ------------------- */
/* find out what default policy this user has */
$sql_id_user = mysql_query("select graphpolicy from auth_users where id=$id", $cnn_id);
if (mysql_result($sql_id_user, 0, "graphpolicy") == "1") {
$policy_display = "Select the graphs you want to <strong>DENY</strong> this user from.";
}elseif (mysql_result($sql_id_user, 0, "graphpolicy") == "2") {
$policy_display = "Select the graphs you want <strong>ALLOW</strong> this user to view.";
}
$sql_id = mysql_query("select
ag.userid,
g.id, g.title
from rrd_graph g
left join auth_graph ag on (g.id=ag.graphid and ag.userid=$id)
order by g.title", $cnn_id);
$rows = mysql_num_rows($sql_id); $i = 0;
DrawFormHeader("Individual Graph Permissions","",false);
DrawFormItem("", $policy_display);
DrawMatrixCustom("<td width=\"100%\">");
DrawMatrixTableBegin("100%");
DrawMatrixRowBegin();
DrawMatrixCustom("<td valign=\"top\" width=\"50%\">");
while ($i < $rows) {
if (mysql_result($sql_id, $i, "userid") == "") {
$old_value = "";
}else{
$old_value = "on";
}
$column1 = floor(($rows / 2) + ($rows % 2));
if ($i == $column1) {
?></td><td valign="top" width="50%"><?
}
DrawStrippedFormItemCheckBox("graph" . mysql_result($sql_id, $i, "id"), $old_value, mysql_result($sql_id, $i, "title"),"");
$i++;
}
DrawMatrixCustom("</td>");
DrawMatrixRowEnd();
DrawMatrixTableEnd();
/* ------------------- GRAPH HIERARCHIES ------------------- */
if (mysql_result($sql_id_user, 0, "graphpolicy") == "1") {
$policy_display = "Select the graph hierarchies that you want to <strong>HIDE</strong> from this user.";
}elseif (mysql_result($sql_id_user, 0, "graphpolicy") == "2") {
$policy_display = "Select the graph hierarchies that you want to <strong>ALLOW</strong> this user to view.";
}
$sql_id = mysql_query("select
agh.userid,
gh.id, gh.name
from graph_hierarchy gh
left join auth_graph_hierarchy agh on (gh.id=agh.hierarchyid and agh.userid=$id)
order by gh.name", $cnn_id);
$rows = mysql_num_rows($sql_id); $i = 0;
DrawFormItem("", $policy_display);
DrawMatrixCustom("<td width=\"100%\">");
DrawMatrixTableBegin("100%");
DrawMatrixRowBegin();
DrawMatrixCustom("<td valign=\"top\" width=\"50%\">");
while ($i < $rows) {
if (mysql_result($sql_id, $i, "userid") == "") {
$old_value = "";
}else{
$old_value = "on";
}
$column1 = floor(($rows / 2) + ($rows % 2));
if ($i == $column1) {
?></td><td valign="top" width="50%"><?
}
DrawStrippedFormItemCheckBox("tree" . mysql_result($sql_id, $i, "id"), $old_value, mysql_result($sql_id, $i, "name"),"");
$i++;
}
DrawMatrixCustom("</td>");
DrawMatrixRowEnd();
DrawMatrixTableEnd();
DrawFormSaveButton();
DrawFormItemHiddenIDField("id",$id);
DrawFormFooter();
break;
} ?>
|