[feladat @ 84]
Bugfix. The function zone_count() now also counts zones an owner has
only partial access to, not just those zones the owner has full access
to. This fixes just the count, the zones a user has partial access to
are not (yet!) shown in the "list zones" page.
Bugfix. In the zone listing the "edit" button is now show for users
with access level 1. Untill now they were presented an overview of the
zones they could change, but there was no link for them to actually
edit the zone.
Bugfix. Some of the buttons in the "edit zone" interface that are of
no use to a user with access level 1 have been hidden.
Bugfix. Make sure a user with access level 1 with only partial access
to a zone cannot add new records to that zone. Only the zone owner
should be able to add new record.
Bugfix. If a user with access level 1 edits a record in a zone he has
only partial access to, an error was shown because of call to a non-
existing function in the PEAR:MDB2. This bug was most likely
introduced while migrating from PEAR:DB to PEAR:MDB2.
Bugfix. A user with access level 1 was able to delete all records of a
zone he has only partial access to. Some additional checks have been
added.
Bugfix. If a user with accees level 1 has partial access to one or
more zones starting with a certain character, but did not own at least
one entire zone starting with the same character, the character wasn't
clickable in the "list zone" page.
Interface. If no record or zone id is given for delete_record.php or
delete_domain.php, don't just die but echo a nice message. The i18n
files have not yet been updated to reflect this change.
Interface. If no master IP is given in delete_supermaster.php, don't
just die but echo a nice message. The i18n files have not yet been
updated to reflect this change.
[All fixes by Peter Beernink.]
<?
session_start();
if (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] == "logout")
{
logout();
}
// If a user had just entered his/her login && password, store them in our session.
if(isset($_POST["authenticate"]))
{
$_SESSION["userpwd"] = $_POST["password"];
$_SESSION["userlogin"] = $_POST["username"];
}
// Check if the session hasnt expired yet.
if ((isset($_SESSION["userid"])) && ($_SESSION["lastmod"] != "") && ((time() - $_SESSION["lastmod"]) > $EXPIRE))
{
logout( _('Session expired, please login again.'),"error");
}
// If the session hasn't expired yet, give our session a fresh new timestamp.
$_SESSION["lastmod"] = time();
if(isset($_SESSION["userlogin"]) && isset($_SESSION["userpwd"]))
{
//Username and password are set, lets try to authenticate.
$result = $db->query("SELECT id, fullname, level FROM users WHERE username='". $_SESSION["userlogin"] ."' AND password='". md5($_SESSION["userpwd"]) ."' AND active=1");
if($result->numRows() == 1)
{
$rowObj = $result->fetchRow();
$_SESSION["userid"] = $rowObj["id"];
$_SESSION["name"] = $rowObj["fullname"];
$_SESSION["level"] = $rowObj["level"];
if($_POST["authenticate"])
{
//If a user has just authenticated, redirect him to index with timestamp, so post-data gets lost.
session_write_close();
clean_page("index.php");
exit;
}
}
else
{
//Authentication failed, retry.
auth( _('Authentication failed!'),"error");
}
}
else
{
//No username and password set, show auth form (again).
auth();
}
/*
* Print the login form.
*/
function auth($msg="",$type="success")
{
include_once('inc/header.inc.php');
if ( $msg )
{
print "<div class=\"$type\">$msg</div>\n";
}
?>
<h2><? echo _('Login'); ?></h2>
<?
?>
<form method="post" action="<? echo $_SERVER["PHP_SELF"] ?>">
<table border="0">
<tr>
<td class="n"><? echo _('Login'); ?>:</td>
<td class="n"><input type="text" class="input" name="username"></td>
</tr>
<tr>
<td class="n"><? echo _('Password'); ?>:</td>
<td class="n"><input type="password" class="input" name="password"></td>
</tr>
<tr>
<td class="n"> </td>
<td class="n">
<input type="submit" name="authenticate" class="button" value=" <? echo _('Login'); ?> ">
</td>
</tr>
</table>
</form>
<?
include_once('inc/footer.inc.php');
exit;
}
/*
* Logout the user and kickback to login form.
*/
function logout($msg="")
{
if ( $msg == "" ) {
$msg = _('You have logged out.');
$type = "success";
};
unset($_SESSION["userid"]);
unset($_SESSION["name"]);
unset($_SESSION["level"]);;
session_destroy();
session_write_close();
auth($msg, $type);
exit;
}
?>