2011-03-28 14:21:28 +00:00
|
|
|
<?
|
|
|
|
|
|
|
|
enforce_login();
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!empty($LoggedUser['DisableForums'])) {
|
2011-03-28 14:21:28 +00:00
|
|
|
error(403);
|
|
|
|
}
|
|
|
|
|
2011-05-15 12:06:04 +00:00
|
|
|
include(SERVER_ROOT.'/sections/forums/functions.php');
|
2012-02-13 08:00:23 +00:00
|
|
|
|
|
|
|
// Replace the old hard-coded forum categories
|
|
|
|
unset($ForumCats);
|
|
|
|
$ForumCats = $Cache->get_value('forums_categories');
|
|
|
|
if ($ForumCats === false) {
|
2013-04-19 08:00:55 +00:00
|
|
|
$DB->query('SELECT ID, Name FROM forums_categories');
|
2012-02-13 08:00:23 +00:00
|
|
|
$ForumCats = array();
|
2013-04-19 08:00:55 +00:00
|
|
|
while (list($ID, $Name) = $DB->next_record()) {
|
2012-02-13 08:00:23 +00:00
|
|
|
$ForumCats[$ID] = $Name;
|
|
|
|
}
|
|
|
|
$Cache->cache_value('forums_categories', $ForumCats, 0); //Inf cache.
|
|
|
|
}
|
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
//This variable contains all our lovely forum data
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!$Forums = $Cache->get_value('forums_list')) {
|
|
|
|
$DB->query('
|
|
|
|
SELECT
|
|
|
|
f.ID,
|
|
|
|
f.CategoryID,
|
|
|
|
f.Name,
|
|
|
|
f.Description,
|
|
|
|
f.MinClassRead,
|
|
|
|
f.MinClassWrite,
|
|
|
|
f.MinClassCreate,
|
|
|
|
f.NumTopics,
|
|
|
|
f.NumPosts,
|
|
|
|
f.LastPostID,
|
|
|
|
f.LastPostAuthorID,
|
|
|
|
f.LastPostTopicID,
|
|
|
|
f.LastPostTime,
|
|
|
|
COUNT(sr.ThreadID) AS SpecificRules,
|
|
|
|
t.Title,
|
|
|
|
t.IsLocked,
|
|
|
|
t.IsSticky
|
2011-03-28 14:21:28 +00:00
|
|
|
FROM forums AS f
|
2013-04-19 08:00:55 +00:00
|
|
|
JOIN forums_categories AS fc ON fc.ID = f.CategoryID
|
|
|
|
LEFT JOIN forums_topics as t ON t.ID = f.LastPostTopicID
|
|
|
|
LEFT JOIN forums_specific_rules AS sr ON sr.ForumID = f.ID
|
2011-03-28 14:21:28 +00:00
|
|
|
GROUP BY f.ID
|
2013-04-19 08:00:55 +00:00
|
|
|
ORDER BY fc.Sort, fc.Name, f.CategoryID, f.Sort');
|
2011-03-28 14:21:28 +00:00
|
|
|
$Forums = $DB->to_array('ID', MYSQLI_ASSOC, false);
|
2013-04-19 08:00:55 +00:00
|
|
|
foreach ($Forums as $ForumID => $Forum) {
|
|
|
|
if (count($Forum['SpecificRules'])) {
|
|
|
|
$DB->query('SELECT ThreadID FROM forums_specific_rules WHERE ForumID = '.$ForumID);
|
2011-03-28 14:21:28 +00:00
|
|
|
$ThreadIDs = $DB->collect('ThreadID');
|
|
|
|
$Forums[$ForumID]['SpecificRules'] = $ThreadIDs;
|
|
|
|
}
|
|
|
|
}
|
2011-05-28 08:00:05 +00:00
|
|
|
unset($ForumID, $Forum);
|
2011-03-28 14:21:28 +00:00
|
|
|
$Cache->cache_value('forums_list', $Forums, 0); //Inf cache.
|
|
|
|
}
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!empty($_POST['action'])) {
|
2011-03-28 14:21:28 +00:00
|
|
|
switch ($_POST['action']) {
|
|
|
|
case 'reply':
|
|
|
|
require(SERVER_ROOT.'/sections/forums/take_reply.php');
|
|
|
|
break;
|
|
|
|
case 'new':
|
|
|
|
require(SERVER_ROOT.'/sections/forums/take_new_thread.php');
|
|
|
|
break;
|
|
|
|
case 'mod_thread':
|
|
|
|
require(SERVER_ROOT.'/sections/forums/mod_thread.php');
|
|
|
|
break;
|
|
|
|
case 'poll_mod':
|
|
|
|
require(SERVER_ROOT.'/sections/forums/poll_mod.php');
|
|
|
|
break;
|
|
|
|
case 'add_poll_option':
|
|
|
|
require(SERVER_ROOT.'/sections/forums/add_poll_option.php');
|
2013-04-19 08:00:55 +00:00
|
|
|
break;
|
|
|
|
case 'warn':
|
|
|
|
require(SERVER_ROOT.'/sections/forums/warn.php');
|
|
|
|
break;
|
2012-08-27 08:00:24 +00:00
|
|
|
case 'take_warn':
|
2013-04-19 08:00:55 +00:00
|
|
|
require(SERVER_ROOT.'/sections/forums/take_warn.php');
|
|
|
|
break;
|
2013-04-20 08:01:01 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
default:
|
|
|
|
error(0);
|
|
|
|
}
|
2013-04-19 08:00:55 +00:00
|
|
|
} elseif (!empty($_GET['action'])) {
|
2011-03-28 14:21:28 +00:00
|
|
|
switch ($_GET['action']) {
|
|
|
|
case 'viewforum':
|
|
|
|
// Page that lists all the topics in a forum
|
|
|
|
require(SERVER_ROOT.'/sections/forums/forum.php');
|
|
|
|
break;
|
|
|
|
case 'viewthread':
|
|
|
|
case 'viewtopic':
|
2013-02-22 08:00:24 +00:00
|
|
|
// Page that displays threads
|
2011-03-28 14:21:28 +00:00
|
|
|
require(SERVER_ROOT.'/sections/forums/thread.php');
|
|
|
|
break;
|
|
|
|
case 'ajax_get_edit':
|
|
|
|
// Page that switches edits for mods
|
|
|
|
require(SERVER_ROOT.'/sections/forums/ajax_get_edit.php');
|
|
|
|
break;
|
|
|
|
case 'new':
|
|
|
|
// Create a new thread
|
|
|
|
require(SERVER_ROOT.'/sections/forums/newthread.php');
|
|
|
|
break;
|
|
|
|
case 'takeedit':
|
|
|
|
// Edit posts
|
|
|
|
require(SERVER_ROOT.'/sections/forums/takeedit.php');
|
|
|
|
break;
|
|
|
|
case 'get_post':
|
|
|
|
// Get posts
|
|
|
|
require(SERVER_ROOT.'/sections/forums/get_post.php');
|
|
|
|
break;
|
|
|
|
case 'delete':
|
|
|
|
// Delete posts
|
|
|
|
require(SERVER_ROOT.'/sections/forums/delete.php');
|
|
|
|
break;
|
|
|
|
case 'catchup':
|
|
|
|
// Catchup
|
|
|
|
require(SERVER_ROOT.'/sections/forums/catchup.php');
|
|
|
|
break;
|
|
|
|
case 'search':
|
|
|
|
// Search posts
|
|
|
|
require(SERVER_ROOT.'/sections/forums/search.php');
|
|
|
|
break;
|
|
|
|
case 'change_vote':
|
|
|
|
// Change poll vote
|
|
|
|
require(SERVER_ROOT.'/sections/forums/change_vote.php');
|
|
|
|
break;
|
2011-07-13 08:00:06 +00:00
|
|
|
case 'delete_poll_option':
|
|
|
|
require(SERVER_ROOT.'/sections/forums/delete_poll_option.php');
|
|
|
|
break;
|
2011-03-28 14:21:28 +00:00
|
|
|
case 'sticky_post':
|
|
|
|
require(SERVER_ROOT.'/sections/forums/sticky_post.php');
|
|
|
|
break;
|
|
|
|
case 'edit_rules':
|
|
|
|
require(SERVER_ROOT.'/sections/forums/edit_rules.php');
|
|
|
|
break;
|
2012-09-14 08:00:34 +00:00
|
|
|
case 'thread_subscribe':
|
|
|
|
break;
|
|
|
|
case 'warn':
|
|
|
|
require(SERVER_ROOT.'/sections/forums/warn.php');
|
|
|
|
break;
|
|
|
|
case 'forum_subscribe':
|
|
|
|
include('subscribe.php');
|
2012-09-12 08:00:27 +00:00
|
|
|
break;
|
2011-03-28 14:21:28 +00:00
|
|
|
default:
|
|
|
|
error(404);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
require(SERVER_ROOT.'/sections/forums/main.php');
|
|
|
|
}
|
|
|
|
|