[feladat @ 122]
Fixing a number of 'division by zero' errors introduced changeset:121. Changed from constant to a normal variable. May need to be reviewed in a future cleanup.
<?php
/* PowerAdmin, a friendly web-based admin tool for PowerDNS.
* See <https://rejo.zenger.nl/poweradmin> for more details.
*
* Copyright 2007, 2008 Rejo Zenger <rejo@zenger.nl>
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
require_once("inc/toolkit.inc.php");
if($_POST["commit"])
{
if($_POST["username"] && $_POST["level"] && $_POST["fullname"])
{
if(!isset($_POST["active"]))
{
$active = 0;
}
else
{
$active = 1;
}
if(edit_user($_POST["number"], $_POST["username"], $_POST["fullname"], $_POST["email"], $_POST["level"], $_POST["description"], $active, $_POST["password"]))
{
clean_page("users.php");
}
else
{
error("Error editting user!");
}
}
}
include_once("inc/header.inc.php");
if (!level(10))
{
error("You do not have the required access level.");
}
?>
<h2><?php echo _('Edit user'); ?> "<?php echo get_fullname_from_userid($_GET["id"]) ?>"</h2>
<?php
$r = array();
$r = get_user_info($_GET["id"]);
?>
<form method="post">
<input type="HIDDEN" name="number" value="<?php echo $_GET["id"] ?>">
<table>
<tr>
<td class="n"><?php echo _('User name'); ?>:</td>
<td class="n"><input type="text" class="input" name="username" value="<?php echo $r["username"]?>"></td>
</tr>
<tr>
<td class="n"><?php echo _('Full name'); ?>:</td>
<td class="n"><input type="text" class="input" name="fullname" value="<?php echo $r["fullname"]?>"></td>
</tr>
<tr>
<td class="n"><?php echo _('Password'); ?>:</td>
<td class="n"><input type="password" class="input" name="password" value=""></td>
</tr>
<tr>
<td class="n"><?php echo _('E-mail'); ?>:</td>
<td class="n"><input type="text" class="input" name="email" value="<?php echo $r["email"]?>"></td>
</tr>
<tr>
<td class="n"><?php echo _('User level'); ?>:</td>
<td class="n">
<select name="level">
<option value="1" <?php if($r["level"] == 1) { echo "selectED"; } ?>>1 (<?php echo _('Normal user'); ?>)</option>
<option value="5" <?php if($r["level"] == 5) { echo "selectED"; } ?>>5 (<?php echo _('Administrator'); ?>)</option>
<option value="10" <?php if($r["level"] == 10) { echo "selectED"; } ?>>10 (<?php echo _('Administrator w/ user admin rights'); ?>)</option>
</select>
</td>
</tr>
<tr>
<td class="n"><?php echo _('Description'); ?>:</td>
<td class="n">
<textarea rows="6" cols="30" class="inputarea" name="description"><?php echo $r["description"]?></textarea>
</td>
</tr>
<tr>
<td class="n"><?php echo _('Active'); ?>:</td>
<td class="n"><input type="checkbox" name="active" value="1" <?php if($r["active"]) { ?>CHECKED<?php } ?>></td>
</tr>
<tr>
<td class="n"> </td>
<td class="n"><input type="submit" class="button" name="commit" value="<?php echo _('Commit changes'); ?>"></td>
</tr>
</table>
</form>
<?php
include_once("inc/footer.inc.php");
?>