<?php
// ----------------------------------------------------------------------
// Copyright (C) 2007 by GREGORY LE BRAS
// ----------------------------------------------------------------------
// LICENSE
//
// This file is part of ODCNMS - Open DataCenter Network Management System
//
// ODCNMS 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.
//
// Foobar 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 Foobar; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// ----------------------------------------------------------------------
// Original Author of file: GREGORY LE BRAS - http://www.odcnms.org/
// ----------------------------------------------------------------------
?>
<?php
if (!isset($edit))
{
$request=mysql_query("SELECT * FROM $name_table_users WHERE id=\"$_GET[id]\"") or die ("ERROR!");
while($tmp_request=mysql_fetch_array($request))
{
?>
<form method="post" action="index.php?include=administration&page=user&action=edit&edit=ok&id=<?php echo $id;?>" name="edit_user">
<fieldset class="form">
<legend><img src="images/edit.gif" alt="Edit" align="top"> <?php echo TXT_EDIT; ?> <?php echo TXT_USER; ?></legend>
<label><?php echo TXT_USERNAME; ?></label>
<input type="text" name="username" size="50" value="<?php echo $tmp_request['username']; ?>"><br>
<label><?php echo TXT_STATUS; ?></label>
<select name="administrator">
<?php
switch ($tmp_request['administrator'])
{
case '0':
echo "<option value=\"0\" selected>".TXT_SIMPLE_USER."</option><option value=\"1\">".TXT_ADMINISTRATOR."</option><option value=\"2\">".TXT_SUPER." ".TXT_ADMINISTRATOR."</option>";
break;
case '1':
echo "<option value=\"0\">".TXT_SIMPLE_USER."</option><option value=\"1\" selected>".TXT_ADMINISTRATOR."</option><option value=\"2\">".TXT_SUPER." ".TXT_ADMINISTRATOR."</option>";
break;
case '2':
echo "<option value=\"0\">".TXT_SIMPLE_USER."</option><option value=\"1\">".TXT_ADMINISTRATOR."</option><option value=\"2\" selected>".TXT_SUPER." ".TXT_ADMINISTRATOR."</option>";
break;
}
?>
</select>
<?php
if ($radius_authentication=="0")
{
?>
<label><?php echo TXT_RESET_PASSWORD; ?></label>
<select name="reset_password"><option value="0"><?php echo TXT_NO; ?></option><option value="1"><?php echo TXT_YES; ?></option></select><br><br>
<?php
}
else
{
echo "<br><br>";
}
?>
<input type="submit" name="submit" value="<?php echo TXT_EDIT; ?>"> <input type="button" value="<?php echo TXT_BACK; ?>" onClick="javascript:history.go(-1);">
</fieldset>
</form>
<script language="JavaScript" type="text/javascript">
var frmvalidator = new Validator("edit_user");
frmvalidator.addValidation("username","req","Please enter the name of the user");
frmvalidator.addValidation("username","maxlen=255",
"Max length for Name is 255");
</script>
<?php
}
}
else if ($edit=="ok")
{
if (($radius_authentication=="0") && ($reset_password=="1"))
{
$md5password = md5($username);
$query=mysql_query("UPDATE $name_table_users SET username=\"$username\", password=\"$md5password\", administrator=\"$administrator\" WHERE id=$id");
}
else
{
$query=mysql_query("UPDATE $name_table_users SET username=\"$username\", administrator=\"$administrator\" WHERE id=$id");
}
if(!$query)
{
echo "<center><div id=\"status\" style=\"color:red\"><img src=\"images/warning.png\" alt=\"WARNING\"><br><br>";
echo TXT_DATABASE_ERROR;
echo "</div><br><a href=\"javascript:history.go(-2);\">";
echo TXT_BACK;
echo "</a></center>";
}
else
{
echo "<center><div id=\"status\" style=\"color:green\"><img src=\"images/info.png\" alt=\"INFO\"><br><br>";
echo TXT_SUCCESSFULLY_EDIT_USER;
echo "</div><br><a href=\"javascript:history.go(-2);\">";
echo TXT_BACK;
echo "</a></center>";
}
}
?>