diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index c8e0ccdf..b1f2e14a 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -1,5 +1,8 @@ CHANGELOG +2013-07-13 by draculesti +Ability to quote locked and trashed threads + 2013-07-08 by alderaan Add "has_results()" function for MySQL class to replace "record_count() === 0" conditional checks diff --git a/sections/ajax/index.php b/sections/ajax/index.php index 2e7440fd..dcac83e3 100644 --- a/sections/ajax/index.php +++ b/sections/ajax/index.php @@ -13,7 +13,7 @@ /* AJAX_LIMIT = array(x,y) = 'x' requests every 'y' seconds. e.g. array(5,10) = 5 requests every 10 seconds */ $AJAX_LIMIT = array(5,10); -$LimitedPages = array('tcomments','user','forum','top10','browse','usersearch','requests','artist','inbox','subscriptions','bookmarks','announcements','notifications','request','better','similar_artists','userhistory','votefavorite','wiki','torrentgroup','news_ajax','user_recents', 'collage'); +$LimitedPages = array('tcomments','user','forum','top10','browse','usersearch','requests','artist','inbox','subscriptions','bookmarks','announcements','notifications','request','better','similar_artists','userhistory','votefavorite','wiki','torrentgroup','news_ajax','user_recents', 'collage', 'raw_bbcode'); // These users aren't rate limited. // This array should contain user IDs. @@ -161,6 +161,9 @@ case 'collage': require(SERVER_ROOT . '/sections/ajax/collage.php'); break; + case 'raw_bbcode': + require(SERVER_ROOT . '/sections/ajax/raw_bbcode.php'); + break; default: // If they're screwing around with the query string json_die("failure"); diff --git a/sections/ajax/raw_bbcode.php b/sections/ajax/raw_bbcode.php new file mode 100644 index 00000000..7a1030dc --- /dev/null +++ b/sections/ajax/raw_bbcode.php @@ -0,0 +1,31 @@ + + +include(SERVER_ROOT . "/sections/forums/functions.php"); + +$PostID = (int) $_POST['postid']; + +if (empty($PostID)) { + json_die("error", "empty postid"); +} + +$DB->query(" + SELECT + t.ForumID, p.Body + FROM forums_posts AS p + JOIN forums_topics AS t + ON p.TopicID = t.ID + WHERE p.ID = '$PostID'"); + +if (!$DB->has_results()) { + json_die("error", "no results"); +} + +list($ForumID, $Body) = $DB->next_record(); +$Forums = get_forums(); +if (!check_forumperm($ForumID)) { + json_die("error", "assholes"); +} + +json_die("success", array("body" => nl2br($Body))); + +?> diff --git a/sections/forums/functions.php b/sections/forums/functions.php index db6dbe3b..3b8e0bbe 100644 --- a/sections/forums/functions.php +++ b/sections/forums/functions.php @@ -94,3 +94,48 @@ function get_forum_info($ForumID) { } return $Forum; } + +function get_forums() { + global $DB, $Cache; + 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 + FROM forums AS f + 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 + GROUP BY f.ID + ORDER BY fc.Sort, fc.Name, f.CategoryID, f.Sort'); + $Forums = $DB->to_array('ID', MYSQLI_ASSOC, false); + foreach ($Forums as $ForumID => $Forum) { + if (count($Forum['SpecificRules'])) { + $DB->query(" + SELECT ThreadID + FROM forums_specific_rules + WHERE ForumID = $ForumID"); + $ThreadIDs = $DB->collect('ThreadID'); + $Forums[$ForumID]['SpecificRules'] = $ThreadIDs; + } + } + unset($ForumID, $Forum); + $Cache->cache_value('forums_list', $Forums, 0); //Inf cache. + } + return $Forums; +} diff --git a/sections/forums/index.php b/sections/forums/index.php index a62c7f66..71260d54 100644 --- a/sections/forums/index.php +++ b/sections/forums/index.php @@ -22,47 +22,7 @@ $Cache->cache_value('forums_categories', $ForumCats, 0); //Inf cache. } -//This variable contains all our lovely forum data -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 - FROM forums AS f - 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 - GROUP BY f.ID - ORDER BY fc.Sort, fc.Name, f.CategoryID, f.Sort'); - $Forums = $DB->to_array('ID', MYSQLI_ASSOC, false); - foreach ($Forums as $ForumID => $Forum) { - if (count($Forum['SpecificRules'])) { - $DB->query(" - SELECT ThreadID - FROM forums_specific_rules - WHERE ForumID = $ForumID"); - $ThreadIDs = $DB->collect('ThreadID'); - $Forums[$ForumID]['SpecificRules'] = $ThreadIDs; - } - } - unset($ForumID, $Forum); - $Cache->cache_value('forums_list', $Forums, 0); //Inf cache. -} +$Forums = get_forums(); if (!empty($_POST['action'])) { switch ($_POST['action']) { diff --git a/sections/forums/thread.php b/sections/forums/thread.php index 219b7b5f..7807731a 100644 --- a/sections/forums/thread.php +++ b/sections/forums/thread.php @@ -455,10 +455,8 @@