2006-03-27 05:37:27 +02:00
|
|
|
|
<?php
|
2006-07-11 16:14:09 +02:00
|
|
|
|
// Pandora - the Free monitoring system
|
|
|
|
|
// ====================================
|
|
|
|
|
// Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com
|
2007-10-12 18:27:50 +02:00
|
|
|
|
// Copyright (c) 2005-2006 Artica Soluciones Tecnol<6F>gicas S.L, info@artica.es
|
2006-07-11 16:14:09 +02:00
|
|
|
|
// Copyright (c) 2004-2006 Raul Mateos Martin, raulofpandora@gmail.com
|
|
|
|
|
// 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.
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2006-03-27 05:37:27 +02:00
|
|
|
|
|
|
|
|
|
// Load global vars
|
|
|
|
|
require("include/config.php");
|
2006-07-11 16:14:09 +02:00
|
|
|
|
|
2006-03-27 05:37:27 +02:00
|
|
|
|
if (comprueba_login() == 0)
|
|
|
|
|
if (give_acl($id_user, 0, "UM")==1) {
|
|
|
|
|
// Init. vars
|
|
|
|
|
$comentarios = "";
|
|
|
|
|
$direccion = "";
|
|
|
|
|
$telefono = "";
|
|
|
|
|
$password = "";
|
|
|
|
|
$id_usuario_mio = "";
|
|
|
|
|
$nombre_real = "";
|
|
|
|
|
$nivel = 0;
|
|
|
|
|
// Default is create mode (creacion)
|
|
|
|
|
$modo = "creacion";
|
|
|
|
|
|
|
|
|
|
if (isset($_GET["borrar_grupo"])){ // if modified some parameter
|
|
|
|
|
$grupo= entrada_limpia($_GET["borrar_grupo"]);
|
|
|
|
|
$query_del2="DELETE FROM tusuario_perfil WHERE id_up = ".$grupo;
|
|
|
|
|
$resq1=mysql_query($query_del2);
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-09 17:22:28 +02:00
|
|
|
|
if (isset($_GET["id_usuario_mio"])){ // if any parameter changed
|
2006-03-27 05:37:27 +02:00
|
|
|
|
$modo="edicion";
|
|
|
|
|
$id_usuario_mio = entrada_limpia($_GET["id_usuario_mio"]);
|
2006-10-09 17:22:28 +02:00
|
|
|
|
// Read user data to include in form
|
2006-03-27 05:37:27 +02:00
|
|
|
|
$query1="SELECT * FROM tusuario WHERE id_usuario = '".$id_usuario_mio."'";
|
|
|
|
|
$resq1=mysql_query($query1);
|
|
|
|
|
$rowdup=mysql_fetch_array($resq1);
|
|
|
|
|
if (!$rowdup)
|
|
|
|
|
{
|
|
|
|
|
echo "<h3 class='error'>".$lang_label["user_error"]."</h3>";
|
|
|
|
|
echo "</table>";
|
|
|
|
|
include ("general/footer.php");
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
$password=$rowdup["password"];
|
|
|
|
|
$comentarios=$rowdup["comentarios"];
|
|
|
|
|
$direccion=$rowdup["direccion"];
|
|
|
|
|
$telefono=$rowdup["telefono"];
|
|
|
|
|
$nivel =$rowdup["nivel"];
|
|
|
|
|
$nombre_real=$rowdup["nombre_real"];
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-09 17:22:28 +02:00
|
|
|
|
// Edit user
|
2006-03-27 05:37:27 +02:00
|
|
|
|
if (isset ($_POST["edicion"])){
|
2006-10-09 17:22:28 +02:00
|
|
|
|
// We do it
|
2006-03-27 05:37:27 +02:00
|
|
|
|
if (isset ($_POST["pass1"])){
|
|
|
|
|
$nombre = entrada_limpia($_POST["nombre"]);
|
|
|
|
|
$nombre_real=entrada_limpia($_POST["nombre_real"]);
|
|
|
|
|
$nombre_viejo = entrada_limpia($_POST["id_usuario_antiguo"]);
|
|
|
|
|
$password = entrada_limpia($_POST["pass1"]);
|
|
|
|
|
$password2 = entrada_limpia($_POST["pass2"]);
|
|
|
|
|
if ($password <> $password2){
|
|
|
|
|
echo "<h3 class='error'>".$lang_label["pass_nomatch"]."</h3>";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (isset($_POST["nivel"]))
|
|
|
|
|
$nivel = entrada_limpia($_POST["nivel"]);
|
|
|
|
|
$direccion = entrada_limpia($_POST["direccion"]);
|
|
|
|
|
$telefono = entrada_limpia($_POST["telefono"]);
|
|
|
|
|
$comentarios = entrada_limpia($_POST["comentarios"]);
|
|
|
|
|
|
|
|
|
|
if (dame_password($nombre_viejo)!=$password){
|
|
|
|
|
$password=md5($password);
|
2006-07-11 16:48:04 +02:00
|
|
|
|
$sql = "UPDATE tusuario SET nombre_real ='".$nombre_real."', id_usuario ='".$nombre."', password = '".$password."', telefono ='".$telefono."', direccion ='".$direccion." ', nivel = '".$nivel."', comentarios = '".$comentarios."' WHERE id_usuario = '".$nombre_viejo."'";
|
2006-03-27 05:37:27 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
2006-07-11 16:48:04 +02:00
|
|
|
|
$sql = "UPDATE tusuario SET nombre_real ='".$nombre_real."', id_usuario ='".$nombre."', telefono ='".$telefono."', direccion ='".$direccion." ', nivel = '".$nivel."', comentarios = '".$comentarios."' WHERE id_usuario = '".$nombre_viejo."'";
|
2006-03-27 05:37:27 +02:00
|
|
|
|
$resq2=mysql_query($sql);
|
|
|
|
|
|
2006-10-09 17:22:28 +02:00
|
|
|
|
// Add group
|
2006-03-27 05:37:27 +02:00
|
|
|
|
if (isset($_POST["grupo"]))
|
|
|
|
|
if ($_POST["grupo"] <> ""){
|
|
|
|
|
$grupo = $_POST["grupo"];
|
|
|
|
|
$perfil = $_POST["perfil"];
|
|
|
|
|
$id_usuario_edit = $_SESSION["id_usuario"];
|
|
|
|
|
$sql = "INSERT INTO tusuario_perfil (id_usuario,id_perfil,id_grupo,assigned_by) VALUES ('".$nombre."',$perfil,$grupo,'".$id_usuario_edit."')";
|
|
|
|
|
// echo "DEBUG:".$sql;
|
|
|
|
|
$resq2=mysql_query($sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$query1="SELECT * FROM tusuario WHERE id_usuario = '".$nombre."'";
|
|
|
|
|
$id_usuario_mio = $nombre;
|
|
|
|
|
$resq1=mysql_query($query1);
|
|
|
|
|
$rowdup=mysql_fetch_array($resq1);
|
|
|
|
|
$password=$rowdup["password"];
|
|
|
|
|
$comentarios=$rowdup["comentarios"];
|
|
|
|
|
$direccion=$rowdup["direccion"];
|
|
|
|
|
$telefono=$rowdup["telefono"];
|
|
|
|
|
$nivel = $rowdup["nivel"];
|
|
|
|
|
$nombre_real=$rowdup["nombre_real"];
|
|
|
|
|
$modo ="edicion";
|
|
|
|
|
echo "<h3 class='suc'>".$lang_label["update_user_ok"]."</h3>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "<h3 class='error'>".$lang_label["update_user_no"]."</h3>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create user
|
|
|
|
|
if (isset($_GET["nuevo_usuario"])){
|
|
|
|
|
// Get data from POST
|
|
|
|
|
$nombre = entrada_limpia($_POST["nombre"]);
|
|
|
|
|
$password = entrada_limpia($_POST["pass1"]);
|
|
|
|
|
$password2 = entrada_limpia($_POST["pass2"]);
|
|
|
|
|
$nombre_real=entrada_limpia($_POST["nombre_real"]);
|
|
|
|
|
if ($password <> $password2){
|
|
|
|
|
echo "<h3 class='error'>".$lang_label["pass_nomatch"]."</h3>";
|
|
|
|
|
}
|
|
|
|
|
$direccion = entrada_limpia($_POST["direccion"]);
|
|
|
|
|
$telefono = entrada_limpia($_POST["telefono"]);
|
|
|
|
|
$comentarios = entrada_limpia($_POST["comentarios"]);
|
|
|
|
|
if (isset($_POST["nivel"]))
|
|
|
|
|
$nivel = entrada_limpia($_POST["nivel"]);
|
|
|
|
|
$password=md5($password);
|
|
|
|
|
$ahora = date("Y/m/d H:i:s");
|
2006-07-11 16:14:09 +02:00
|
|
|
|
$sql_insert = "INSERT INTO tusuario (id_usuario,direccion,password,telefono,fecha_registro,nivel,comentarios, nombre_real) VALUES ('".$nombre."','".$direccion."','".$password."','".$telefono."','".$ahora."','".$nivel."','".$comentarios."','".$nombre_real."')";
|
2006-03-27 05:37:27 +02:00
|
|
|
|
$resq1=mysql_query($sql_insert);
|
|
|
|
|
if (! $resq1)
|
|
|
|
|
echo "<h3 class='error'>".$lang_label["create_user_no"]."</h3>";
|
|
|
|
|
else {
|
|
|
|
|
echo "<h3 class='suc'>".$lang_label["create_user_ok"]."</h3>";
|
|
|
|
|
}
|
|
|
|
|
$id_usuario_mio = $nombre;
|
|
|
|
|
$modo ="edicion";
|
|
|
|
|
}
|
2007-05-27 04:55:55 +02:00
|
|
|
|
echo "<h2>".$lang_label["user_management"]." > ";
|
2006-03-27 05:37:27 +02:00
|
|
|
|
if (isset($_GET["alta"])){
|
2007-10-12 18:27:50 +02:00
|
|
|
|
if ($_GET["alta"]==1){
|
|
|
|
|
echo $lang_label["create_user"];
|
|
|
|
|
}
|
2006-03-27 05:37:27 +02:00
|
|
|
|
}
|
|
|
|
|
if (isset($_GET["id_usuario_mio"]) OR isset($_GET["nuevo_usuario"])){
|
2007-10-12 18:27:50 +02:00
|
|
|
|
echo $lang_label["update_user"];
|
2006-03-27 05:37:27 +02:00
|
|
|
|
}
|
2007-10-12 18:27:50 +02:00
|
|
|
|
echo "</h2>";
|
2006-03-27 05:37:27 +02:00
|
|
|
|
|
|
|
|
|
?>
|
2007-06-13 Raul Mateos <raulofpandora@gmail.com>
* godmode/menu.php, operation/menu.php, include/pandora.css, include/op.css,
include/god.css: Updated with styles to avoid top and bottom border.
* godmode/groups/group_list.php, godmode/users/*.php, operation/users/*.php,
godmode/servers/*.php, operation/snmpconsole/snmp_alert.php,
godmode/reporting/map_builder.php, operation/messages/message.php:
Removed old raya style and changed to new style.
* include/languages/language_en.php: Changed some typing error.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@509 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2007-06-13 21:14:05 +02:00
|
|
|
|
<table width='500' cellpadding='4' cellspacing='4' class='databox_color'>
|
2006-03-27 05:37:27 +02:00
|
|
|
|
<?php
|
|
|
|
|
if (isset($_GET["alta"]))
|
2007-06-06 18:23:24 +02:00
|
|
|
|
echo '<form name="new_user" method="post" action="index.php?sec=gusuarios&sec2=godmode/users/configure_user&nuevo_usuario=1">';
|
2006-03-27 05:37:27 +02:00
|
|
|
|
else
|
2007-06-06 18:23:24 +02:00
|
|
|
|
echo '<form name="user_mod" method="post" action="index.php?sec=gusuarios&sec2=godmode/users/configure_user&id_usuario_mio='.$id_usuario_mio.'">';
|
2006-03-27 05:37:27 +02:00
|
|
|
|
?>
|
2007-06-06 18:23:24 +02:00
|
|
|
|
<tr>
|
|
|
|
|
<td class="datos"><?php echo $lang_label["id_user"] ?></td>
|
|
|
|
|
<td class="datos"><input type="text" name="nombre" value="<?php echo $id_usuario_mio ?>"></td>
|
2006-07-04 12:10:21 +02:00
|
|
|
|
<tr><td class="datos2"><?php echo $lang_label["real_name"] ?>
|
2007-06-06 18:23:24 +02:00
|
|
|
|
<td class="datos2"><input type="text" name="nombre_real" value="<?php echo $nombre_real ?>"></td>
|
2006-03-27 05:37:27 +02:00
|
|
|
|
<tr><td class="datos"><?php echo $lang_label["password"] ?>
|
2007-06-06 18:23:24 +02:00
|
|
|
|
<td class="datos"><input type="password" name="pass1" value="<?php echo $password ?>"></td>
|
|
|
|
|
<tr><td class="datos2"><?php echo $lang_label["password"] ?> - <?php echo $lang_label["confirmation"] ?></td>
|
|
|
|
|
<td class="datos2"><input type="password" name="pass2" value="<?php echo $password ?>"></td>
|
|
|
|
|
<tr><td class="datos">E-Mail</td>
|
|
|
|
|
<td class="datos"><input type="text" name="direccion" size="40" value="<?php echo $direccion ?>"></td>
|
|
|
|
|
<tr><td class="datos2"><?php echo $lang_label["telefono"] ?></td>
|
|
|
|
|
<td class="datos2"><input type="text" name="telefono" value="<?php echo $telefono ?>"></td>
|
|
|
|
|
<tr><td class="datos"><?php echo $lang_label["global_profile"] ?></td>
|
2006-03-27 05:37:27 +02:00
|
|
|
|
|
|
|
|
|
<td class="datos">
|
|
|
|
|
<?php if ($nivel == "1"){
|
|
|
|
|
echo $lang_label["administrator"].'<input type="radio" class="chk" name="nivel" value="1" checked><a href="#" class="tip"> <span>'.$help_label["users_msg1"].'</span></a> ';
|
|
|
|
|
echo $lang_label["normal_user"].'<input type="radio" class="chk" name="nivel" value="0"><a href="#" class="tip"> <span>'.$help_label["users_msg2"].'</span></a>';
|
|
|
|
|
} else {
|
|
|
|
|
echo $lang_label["administrator"].'<input type="radio" class="chk" name="nivel" value="1"><a href="#" class="tip"> <span>'.$help_label["users_msg1"].'</span></a> ';
|
|
|
|
|
echo $lang_label["normal_user"].'<input type="radio" class="chk" name="nivel" value="0" checked><a href="#" class="tip"> <span>'.$help_label["users_msg2"].'</span></a>';
|
|
|
|
|
}
|
|
|
|
|
?>
|
2007-06-06 18:23:24 +02:00
|
|
|
|
<tr><td class="datos2" colspan="2"><?php echo $lang_label["comments"] ?></td>
|
|
|
|
|
<tr><td class="datos" colspan="2">
|
|
|
|
|
<textarea name="comentarios" cols="60" rows="4"><?php echo $comentarios ?></textarea>
|
|
|
|
|
</td></tr>
|
2006-03-27 05:37:27 +02:00
|
|
|
|
|
|
|
|
|
<?php
|
2006-10-09 17:22:28 +02:00
|
|
|
|
if ($modo == "edicion") { // Only show groups for existing users
|
|
|
|
|
// Combo for group
|
2006-03-27 05:37:27 +02:00
|
|
|
|
echo '<input type="hidden" name="edicion" value="1">';
|
|
|
|
|
echo '<input type="hidden" name="id_usuario_antiguo" value="'.$id_usuario_mio.'">';
|
|
|
|
|
|
2007-06-06 18:23:24 +02:00
|
|
|
|
echo '<tr><td class="datos2">'.$lang_label["group_avail"].'</td>
|
|
|
|
|
<td class="datos2">
|
|
|
|
|
<select name="grupo" class="w155">';
|
2006-03-27 05:37:27 +02:00
|
|
|
|
echo "<option value=''>".$lang_label["none"];
|
|
|
|
|
$sql1='SELECT * FROM tgrupo ORDER BY nombre';
|
|
|
|
|
$result=mysql_query($sql1);
|
|
|
|
|
while ($row=mysql_fetch_array($result)){
|
2007-06-06 18:23:24 +02:00
|
|
|
|
echo "<option value='".$row["id_grupo"]."'>".$row["nombre"]."</option>";
|
2006-03-27 05:37:27 +02:00
|
|
|
|
}
|
|
|
|
|
echo '</select>';
|
|
|
|
|
|
2007-06-06 18:23:24 +02:00
|
|
|
|
echo '</td></tr>';
|
|
|
|
|
echo "<tr><td class='datos'>".$lang_label["profiles"]."</td>";
|
|
|
|
|
echo "<td class='datos'>
|
|
|
|
|
<select name='perfil' class='w155'>";
|
2006-07-11 16:14:09 +02:00
|
|
|
|
$sql1='SELECT * FROM tperfil ORDER BY name';
|
2006-03-27 05:37:27 +02:00
|
|
|
|
$result=mysql_query($sql1);
|
|
|
|
|
while ($row=mysql_fetch_array($result)){
|
2007-06-06 18:23:24 +02:00
|
|
|
|
echo "<option value='".$row["id_perfil"]."'>".$row["name"]."</option>";
|
2006-03-27 05:37:27 +02:00
|
|
|
|
}
|
|
|
|
|
echo '</select>';
|
2007-06-06 18:23:24 +02:00
|
|
|
|
echo '</td>';
|
|
|
|
|
echo '</tr></table>';
|
|
|
|
|
echo "<table width=500>";
|
|
|
|
|
echo "<tr><td align='right'>";
|
|
|
|
|
echo "<input name='uptbutton' type='submit' class='sub upd' value='".$lang_label["update"]."'></td></tr></table><br>";
|
2006-03-27 05:37:27 +02:00
|
|
|
|
// Show user profile / groups assigned
|
|
|
|
|
$sql1='SELECT * FROM tusuario_perfil WHERE id_usuario = "'.$id_usuario_mio.'"';
|
|
|
|
|
$result=mysql_query($sql1);
|
2006-07-11 16:14:09 +02:00
|
|
|
|
|
2007-10-12 18:27:50 +02:00
|
|
|
|
echo '<h3>'.$lang_label["listGroupUser"].'</h3>';
|
2007-06-08 11:28:47 +02:00
|
|
|
|
echo "<table width='500' cellpadding='4' cellspacing='4' class='databox'>";
|
2006-03-27 05:37:27 +02:00
|
|
|
|
if (mysql_num_rows($result)){
|
2007-06-08 11:28:47 +02:00
|
|
|
|
echo '<tr>';
|
2006-07-11 16:14:09 +02:00
|
|
|
|
$color=1;
|
2006-03-27 05:37:27 +02:00
|
|
|
|
while ($row=mysql_fetch_array($result)){
|
2006-07-11 16:14:09 +02:00
|
|
|
|
if ($color == 1){
|
|
|
|
|
$tdcolor = "datos";
|
|
|
|
|
$color = 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$tdcolor = "datos2";
|
|
|
|
|
$color = 1;
|
|
|
|
|
}
|
|
|
|
|
echo '<td class="'.$tdcolor.'">';
|
2006-03-27 05:37:27 +02:00
|
|
|
|
echo "<b style='margin-left:10px'>".dame_perfil($row["id_perfil"])."</b> / ";
|
|
|
|
|
echo "<b>".dame_grupo($row["id_grupo"])."</b>";
|
2007-05-27 04:55:55 +02:00
|
|
|
|
echo '<td class="'.$tdcolor.'t"><a href="index.php?sec=gusuarios&sec2=godmode/users/configure_user&id_usuario_mio='.$id_usuario_mio.'&borrar_grupo='.$row["id_up"].' " onClick="if (!confirm(\' '.$lang_label["are_you_sure"].'\')) return false;"><img border=0 src="images/cross.png"></a><tr>';
|
2006-03-27 05:37:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2007-06-08 11:28:47 +02:00
|
|
|
|
else {
|
|
|
|
|
echo '<div class="nf">'.$lang_label["no_profile"].'</div>';
|
|
|
|
|
}
|
2006-03-27 05:37:27 +02:00
|
|
|
|
}
|
|
|
|
|
?>
|
2006-07-11 16:14:09 +02:00
|
|
|
|
|
|
|
|
|
<?php if (isset($_GET["alta"])){
|
2007-06-06 18:23:24 +02:00
|
|
|
|
echo '</tr></table>';
|
|
|
|
|
echo '<table width="500">';
|
|
|
|
|
echo '<tr><td align="right">';
|
|
|
|
|
echo '<input name="crtbutton" type="submit" class="sub wand" value="'.$lang_label["create"].'">';
|
2006-07-11 16:14:09 +02:00
|
|
|
|
}
|
|
|
|
|
?>
|
2006-03-27 05:37:27 +02:00
|
|
|
|
</form>
|
|
|
|
|
</td></tr></table>
|
|
|
|
|
|
|
|
|
|
<?php
|
2006-10-09 17:22:28 +02:00
|
|
|
|
} // end security check
|
2006-03-27 05:37:27 +02:00
|
|
|
|
else {
|
|
|
|
|
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access User Management");
|
|
|
|
|
require ("general/noaccess.php");
|
|
|
|
|
}
|
2006-06-28 19:09:23 +02:00
|
|
|
|
?>
|