/*
+-------------------------------------------------------------------------+
| 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");
$section = "User Administration";
include ('include/auth.php');
include_once ("include/form.php");
if ($form[action]) { $action = $form[action]; } else { $action = $args[action]; }
if ($form[ID]) { $id = $form[ID]; } else { $id = $args[id]; }
$current_script_name = basename($HTTP_SERVER_VARS["SCRIPT_NAME"]);
function draw_user_form_select() {
global $current_script_name, $colors, $args; ?>
}
switch ($action) {
case 'save':
/* only change password when user types on */
if ($form[Password] != $form[Confirm]) {
$passwords_do_not_match = true;
}elseif (($form[Password] == "") && ($form[Confirm] == "")) {
$password = $form[_password];
}else{
$password = "PASSWORD('$form[Password]')";
}
if ($passwords_do_not_match != true) {
$save["ID"] = $form["ID"];
$save["Username"] = $form["Username"];
$save["FullName"] = $form["FullName"];
$save["Password"] = $password;
$save["MustChangePassword"] = $form["MustChangePassword"];
$save["ShowTree"] = $form["ShowTree"];
$save["ShowList"] = $form["ShowList"];
$save["ShowPreview"] = $form["ShowPreview"];
$save["GraphSettings"] = $form["GraphSettings"];
$save["LoginOpts"] = $form["LoginOpts"];
$save["GraphPolicy"] = $form["GraphPolicy"];
sql_save($save, "auth_users");
}
header ("Location: $current_script_name");
break;
case 'remove':
if (($config["remove_verification"]["value"] == "on") && ($confirm != "yes")) {
include_once ('include/top_header.php');
DrawConfirmForm("Are You Sure?", "Are you sure you want to delete this user?", $current_script_name, "?action=remove&id=$id");
exit;
}
if (($config["remove_verification"]["value"] == "") || ($confirm == "yes")) {
db_execute("delete from auth_users where id=$id");
db_execute("delete from auth_acl where userid=$id");
db_execute("delete from auth_hosts where userid=$id");
db_execute("delete from auth_graph where userid=$id");
db_execute("delete from auth_graph_hierarchy where userid=$id");
db_execute("delete from settings_graphs where userid=$id");
db_execute("delete from settings_viewing_tree where userid=$id");
db_execute("delete from settings_graph_tree where userid=$id");
db_execute("delete from settings_ds_tree where userid=$id");
}
header ("Location: $current_script_name");
break;
case 'edit_graph_config':
include_once ("include/functions.php");
include_once ("include/top_header.php");
$title_text = "User Management [edit]";
include_once ("include/top_table_header.php");
if (isset($args[id])) {
$graph_settings = LoadSettingsIntoArray($HTTP_SESSION_VARS["user_id"], $config["guest_user"]["value"]);
}else{
unset($user);
}
draw_user_form_select();
?>
DrawMatrixRowAlternateColorBegin($colors[form_alternate1],$colors[form_alternate2],0); ?>
Height
The height of graphs created in preview mode.
|
Width
The width of graphs created in preview mode.
|
Timespan
The amount of time to represent on a graph created in preview mode (0 uses auto).
|
Default RRA
The default RRA to use when displaying graphs in preview mode.
|
Columns
The number of columns to display graphs in using preview mode.
|
Page Refresh
The number of seconds between automatic page refreshes.
|
Default Graph Hierarchy
The default graph hierarchy to use when displaying graphs in tree mode.
|
View Settings
Options that govern how the graphs are displayed.
|
DrawStrippedFormItemRadioButton("ViewType", $graph_settings[ViewType], "1", "Show a preview of the graph.", "1",true);
DrawStrippedFormItemRadioButton("ViewType", $graph_settings[ViewType], "2", "Show a text-based listing of the graph.", "1",true);
?>
|
|
|
DrawFormItemHiddenIDField("ID",$args[id]);
DrawFormFooter();
include_once ("include/bottom_footer.php");
break;
case 'edit_perms':
include_once ("include/top_header.php");
$title_text = "User Management [edit]";
include_once ("include/top_table_header.php");
if (isset($args[id])) {
$graph_policy = db_fetch_cell("select GraphPolicy from auth_users where id=$args[id]");
if ($graph_policy == "1") {
$graph_policy_text = "DENIED";
}elseif ($graph_policy == "2") {
$graph_policy_text = "ALLOWED";
}
}else{
unset($user);
}
draw_user_form_select();
?>
$perm_graphs = db_fetch_assoc("select rrd_graph.Title from
auth_graph left join rrd_graph on auth_graph.graphid=rrd_graph.id
where auth_graph.userid=$args[id]");
DrawMatrixRowAlternateColorBegin($colors[form_alternate1],$colors[form_alternate2],0); ?>
if (sizeof($perm_graphs) > 0) {
foreach ($perm_graphs as $graph) {
print "$graph[Title] ";
}
}else{
print "No Graphs";
}
?>
|
if ($graph_policy == "1") {
$graph_policy_text = "Select the graphs you want to DENY this user from.";
} elseif ($graph_policy == "2") {
$graph_policy_text = "Select the graphs you want ALLOW this user to view.";
}
$graphs = db_fetch_assoc("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");
$rows = sizeof($graphs);
?>
|
if (sizeof($graphs) > 0) {
foreach ($graphs as $graph) {
if ($graph[UserID] == "") {
$old_value = "";
}else{
$old_value = "on";
}
$column1 = floor(($rows / 2) + ($rows % 2));
if ($i == $column1) {
print " | ";
}
DrawStrippedFormItemCheckBox("graph".$graph[ID], $old_value, $graph[Title],"",true);
$i++;
}
}
?>
|
|
|
|
DrawFormItemHiddenIDField("ID",$args[id]);
DrawFormFooter();
include_once ("include/bottom_footer.php");
break;
case 'edit':
include_once ("include/top_header.php");
$title_text = "User Management [edit]";
include_once ("include/top_table_header.php");
if (isset($args[id])) {
$user = db_fetch_row("select * from auth_users where id=$id");
}else{
unset($user);
}
draw_user_form_select();
?>
DrawMatrixRowAlternateColorBegin($colors[form_alternate1],$colors[form_alternate2],0); ?>
User Name
|
Full Name
|
Password
|
|
// if ($badpass == "true") {
// DrawFormItem("Password","Passwords do not match! Please retype.");
//} else{
// DrawFormItem("Password","");
// }
?>
Account Options
|
DrawStrippedFormItemCheckBox("MustChangePassword",$user[MustChangePassword],"User Must Change Password at Next Login","",true);
DrawStrippedFormItemCheckBox("GraphSettings",$user[GraphSettings],"Allow this User to Keep Custom Graph Settings","on",true);
?>
|
Graph Options
|
DrawStrippedFormItemCheckBox("ShowTree",$user[ShowTree],"User Has Rights to View Tree Mode","on",true);
DrawStrippedFormItemCheckBox("ShowList",$user[ShowList],"User Has Rights to View List Mode","on",true);
DrawStrippedFormItemCheckBox("ShowPreview",$user[ShowPreview],"User Has Rights to View Preview Mode","on",true);
?>
|
Default Policy
The default allow/deny graph policy for this user.
|
DrawFormItemDropDownCustomHeader("GraphPolicy");
DrawFormItemDropDownCustomItem("GraphPolicy","1","Allow",$user[GraphPolicy]);
DrawFormItemDropDownCustomItem("GraphPolicy","2","Deny",$user[GraphPolicy]);
DrawFormItemDropDownCustomFooter();
?>
Login Options
What to do when this user logs in.
|
DrawStrippedFormItemRadioButton("LoginOpts", $user[LoginOpts], "1", "Show the page that user pointed their browser to.","1",true);
DrawStrippedFormItemRadioButton("LoginOpts", $user[LoginOpts], "2", "Show the default console screen.","1",true);
DrawStrippedFormItemRadioButton("LoginOpts", $user[LoginOpts], "3", "Show the default graph screen.","1",true);
?>
|
|
|
DrawFormItemHiddenIDField("ID",$args[id]);
DrawFormItemHiddenTextBox("_password",$user[Password],"");
DrawFormFooter();
include_once ("include/bottom_footer.php");
break;
default:
include_once ("include/top_header.php");
$title_text = "User Management"; $add_text = "$current_script_name?action=edit";
include_once ("include/top_table_header.php");
print "";
DrawMatrixHeaderItem("User Name",$colors[header_text],1);
DrawMatrixHeaderItem("Full Name",$colors[header_text],1);
DrawMatrixHeaderItem("Default Graph Policy",$colors[header_text],2);
print "
";
$user_list = db_fetch_assoc("select ID,Username,FullName,GraphPolicy from auth_users order by Username");
foreach ($user_list as $user) {
DrawMatrixRowAlternateColorBegin($colors[alternate],$colors[light],$i);
?>
|
|
|
|
$i++;
}
include_once ("include/bottom_footer.php");
include_once ("include/bottom_table_footer.php");
break;
}
?>