<?
// Wriiten by Spike^ekipS <spike@spikeekips.net>

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";

$Site = new Site;
$Site->init("domain", "_GET");

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

if (! $_POST["no"]) goprev();
if (! $_POST["forum_name"]) {
	$_SESSION["tmp"]["msg"]["content"] = $string["error19"];
	goprev();
}

if ($_POST["forum_type"] != "1" and $_POST["forum_type"] != "0") {
	$forum_type = "0";
} else {
	$forum_type = $_POST["forum_type"];
}

$message_size_limit = $_POST["forum_message_size_limit"] * 1000000;

if ($message_size_limit > $_SESSION["config_message_size_limit"]) {
	$message_size_limit = $_SESSION["config_message_size_limit"];
}

$Site->DB->transaction_start(true);
$Site->DB->execute_query(
	sprintf("update forum_priv
		set
			name='%s',
			message_size_limit = '%s',
			forum_type='%s'
		where no = '%s'",
			escape_string($_POST["forum_name"]),
			$message_size_limit,
			$forum_type,
			$_POST["no"]
	)
);

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

$url = sprintf("Location: %s/domain?mode=forum_info&id=%s",
	$_SESSION["user_www_url"], $_POST["forum_id"]);

if ($retval) {
	if ($Site->DB->result_affected) {
		$_SESSION["tmp"]["msg"]["content"] = $string["msg"];
	} else {
		$_SESSION["tmp"]["msg"]["content"] = $string["msg2"];
	}

	$_SESSION["tmp"]["msg"]["type"] = "2";

	$Site->end1();

	Header($url);
	exit;
} else {
	$_SESSION["tmp"]["msg"]["content"] = $string["msg1"];
	$Site->end1();

	goprev();
}

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

mysql> desc forum_priv;
+--------------------+------------------+------+-----+---------+----------------+
| Field              | Type             | Null | Key | Default | Extra          |
+--------------------+------------------+------+-----+---------+----------------+
| no                 | int(11)          |      | PRI | NULL    | auto_increment |
| id                 | varchar(10)      |      |     | 0       |                |
| name               | varchar(30)      | YES  |     | NULL    |                |
| createdTime        | int(10) unsigned | YES  |     | 0       |                |
| message_size_limit | int(10) unsigned | YES  |     | 5000000 |                |
| forum_type         | set('0','1')     |      |     | 1       |                |
| domain_id          | varchar(10)      |      |     | 0       |                |
+--------------------+------------------+------+-----+---------+----------------+

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

Changelog
---------

Usage
-----

*/

?>
