<?

include_once "./setting.php";
include_once $global["root"] . "/include/handle.php";
include_once $global["root"] . "/include/print_array.php";

include_once $global["root"] . "/lib/Site.php";
include_once $global["root"] . "/lib/Authentication_Mail.php";

$Site = new Site;
$Site->init("mail");

include_once $global["lang"] . "/" . $_SESSION["config_lang"] . ".php";

extract($_POST);

while (list($i, $j) = each($_POST)) {
	if (! ereg("^acc_", $i)) continue;

	if ($i == "acc_timeout") $j = $j * 60; // timeout in DB is second value.

	$a[] = sprintf("%s = '%s'", ereg_replace("^acc_","", $i), $j);
}

$Site->DB->transaction_start(true);

$SQL_UPDATE_USER_PRIV =
	"update user_priv set %s where id = '%s' and name = '%s' and domain = '%s'";

$Site->DB->query(sprintf($SQL_UPDATE_USER_PRIV,
		implode(", ", $a), $_SESSION["config_id"], $_POST["name"], $_POST["domain"]));

$retval = $Site->DB->retval;
$Site->DB->close();

if ($retval) {
	// reassign session value.
	$Auth = new Authentication_Mail($_POST["name"] . "@" . $_POST["domain"]);
	$Auth->assign();

	$url = "Location: " . $_SESSION["user_www_url"] . "/mail?mode=control";
	$Site->end1();

	Header($url);
	exit;
} else {
	$Site->end1();
	goprev();
}

/*
Description
-----------

Author
------
 Spike^ekipS <spike@spikeekips.net>

Changelog
---------

Usage
-----

*/

?>
