include "prepend.inc.php"; // ====================================================================================================== // DETERMINE CONTEXT: REQUESTED FORUM/GROUP // ====================================================================================================== // security test if (!$u_id) { force_login(); } else if (!is_allowed(ACCESS_ADMIN)) { include "accessdenied.php"; } // establish group info if ($g > 0) { $r = query ("select * from groups where groupid=" . $g . ";"); $g_info = mysql_fetch_array($r, MYSQL_ASSOC) or die ("Error accessing database for group id=" . $g); } // ====================================================================================================== // PROCESS FORM RESULTS // ====================================================================================================== $forumcount = 0; while (isset($_POST["edit_forum_id_" . ++$forumcount])) { // get information $forumid = $_POST["edit_forum_id_" . $forumcount]; $forumtitle = $_POST["edit_forum_title_" . $forumcount]; $forumdescription = $_POST["edit_forum_description_" . $forumcount]; $forumpurgedays = $_POST["edit_forum_purgedays_" . $forumcount]; $forumtopicsort = $_POST["edit_forum_topicsort_" . $forumcount]; if ($_POST["edit_forum_allowhtml_" . $forumcount]) { // force to integer $forumallowhtml = 1; } else { $forumallowhtml = 0; } $forumdelete = $_POST["edit_forum_delete_" . $forumcount]; // create new forum if (!$forumid) { if ($forumtitle) { $q = 'insert into forums set title="' . sqlsafe($forumtitle) . '",'; if ($forumdescription) { $q .= ' description="' . sqlsafe($forumdescription) . '",'; } $q .= ' purgetime=' . $forumpurgedays . ','; $q .= ' defaulttopicsort=' . $forumtopicsort . ','; $q .= ' allowhtml=' . $forumallowhtml . ','; $q .= ' ownergroupid=' . $g . ';'; $r = query($q) or die ('Error installing new forum with query:
' . $q); } else if ($forumdescription) { noteerror('Forum #' . $forumcount . ' must have a title.'); } // delete forum } elseif ($forumdelete) { // get topic list of message forum $r = query ('select * from topics where ownerforumid=' . $forumid . ';') or die ('Error listing topics in forum.'); $topiccount = 0; while ($topicinfo = mysql_fetch_array($r, MYSQL_ASSOC)) { $topiclist[] = $topicinfo; $topiccount++; } // go through list of topics, deleting all messages thereof if ($topiccount) { while (list($key,$topicinfo) = each($topiclist)) { $r = query ('delete from messages where ownertopicid=' . $topicinfo["topicid"] . ';') or die ('Error deleting messages in forum'); } } // delete topics $r = query ('delete from topics where ownerforumid=' . $forumid . ';') or die ('Error deleting topics in forum'); // delete forum $r = query ('delete from forums where forumid=' . $forumid . ';') or die ('Error deleting forum.'); // edit forum } else { if ($forumtitle) { $q = 'update forums set title="' . sqlsafe($forumtitle) . '",'; $q .= ' description="' . sqlsafe($forumdescription) . '",'; $q .= ' purgetime=' . $forumpurgedays . ','; $q .= ' defaulttopicsort=' . $forumtopicsort . ','; $q .= ' allowhtml=' . $forumallowhtml; $q .= ' where forumid=' . $forumid . ';'; $r = query($q) or die ('Error updating message forum with query:
' . $q); } else { noteerror('Forum #' . $forumcount . ' must have a title.'); } } } // ====================================================================================================== // BEGIN VISIBLE PAGE // ====================================================================================================== function masthead_editforums () { global $g, $BGCOLOUR_LIGHT, $BGCOLOUR_DARK; masthead_group_search('g'); if ($g) { print '
Title | Description | Message Duration (days)* | Sort Topics By |
* HTML code is supported in this field.
';
$footnote .= '
** Topics with no new messages can be deleted automatically from a forum. A nonzero value in this field indicates the number of days a topic must remain inactive before being deleted. A zero in this field indicates that the forum will perform no automatic deletions.
';
$footnote .= '
*** Allowing HTML code in a message forum is an invitation to disaster if the forum has unlimited access. Do not check this if anyone on the internet can post to this forum.
';
print highlighttext($footnote);
?>