diff --git a/classes/class_collages.php b/classes/class_collages.php
new file mode 100644
index 00000000..9f22e86e
--- /dev/null
+++ b/classes/class_collages.php
@@ -0,0 +1,33 @@
+
+class Collages {
+ public static function get_comment_count($CollageID) {
+ global $DB, $Cache;
+ $NumComments = $Cache->get_value('collage_comments_'.$CollageID);
+ if ($NumComments === false) {
+ $DB->query("SELECT COUNT(ID) FROM collages_comments WHERE CollageID = '$CollageID'");
+ list($NumComments) = $DB->next_record();
+ $Cache->cache_value('collage_comments_'.$CollageID, $NumComments, 0);
+ }
+ return $NumComments;
+ }
+
+ public static function get_comment_catalogue($CollageID, $CatalogueID) {
+ global $DB, $Cache;
+ $Catalogue = $Cache->get_value('collage_comments_'.$CollageID.'_catalogue_'.$CatalogueID);
+ if ($Catalogue === false) {
+ $CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
+ $DB->query("
+ SELECT
+ ID,
+ UserID,
+ Time,
+ Body
+ FROM collages_comments
+ WHERE CollageID = '$CollageID'
+ LIMIT $CatalogueLimit");
+ $Catalogue = $DB->to_array(false, MYSQLI_ASSOC);
+ $Cache->cache_value('collage_comments_'.$CollageID.'_catalogue_'.$CatalogueID, $Catalogue, 0);
+ }
+ return $Catalogue;
+ }
+}
\ No newline at end of file
diff --git a/classes/class_requests.php b/classes/class_requests.php
index edd3086a..e9d86ab9 100644
--- a/classes/class_requests.php
+++ b/classes/class_requests.php
@@ -105,7 +105,7 @@ public static function get_requests($RequestIDs, $Return = true) {
$Requests = $DB->to_array();
foreach ($Requests as $Request) {
unset($NotFound[$Request['ID']]);
- $Request['Tags'] = get_request_tags($Request['ID']);
+ $Request['Tags'] = self::get_tags($Request['ID']);
$Found[$Request['ID']] = $Request;
$Cache->cache_value('request_'.$Request['ID'], $Request, 0);
}
@@ -117,5 +117,122 @@ public static function get_requests($RequestIDs, $Return = true) {
}
}
+ public static function get_comment_count($RequestID) {
+ global $Cache, $DB;
+ $NumComments = $Cache->get_value('request_comments_'.$RequestID);
+ if ($NumComments === false) {
+ $DB->query("SELECT COUNT(ID) FROM requests_comments WHERE RequestID = '$RequestID'");
+ list($NumComments) = $DB->next_record();
+ $Cache->cache_value('request_comments_'.$RequestID, $NumComments, 0);
+ }
+ return $NumComments;
+ }
+
+ public static function get_comment_catalogue($RequestID, $CatalogueID) {
+ global $Cache, $DB;
+ $Catalogue = $Cache->get_value('request_comments_'.$RequestID.'_catalogue_'.$CatalogueID);
+ if ($Catalogue === false) {
+ $CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
+ $DB->query("
+ SELECT
+ c.ID,
+ c.AuthorID,
+ c.AddedTime,
+ c.Body,
+ c.EditedUserID,
+ c.EditedTime,
+ u.Username
+ FROM requests_comments as c
+ LEFT JOIN users_main AS u ON u.ID=c.EditedUserID
+ WHERE c.RequestID = '$RequestID'
+ ORDER BY c.ID
+ LIMIT $CatalogueLimit");
+ $Catalogue = $DB->to_array(false,MYSQLI_ASSOC);
+ $Cache->cache_value('request_comments_'.$RequestID.'_catalogue_'.$CatalogueID, $Catalogue, 0);
+ }
+ return $Catalogue;
+ }
+
+ public static function get_artists($RequestID) {
+ global $Cache, $DB;
+ $Artists = $Cache->get_value('request_artists_'.$RequestID);
+ if (is_array($Artists)) {
+ $Results = $Artists;
+ } else {
+ $Results = array();
+ $DB->query("
+ SELECT
+ ra.ArtistID,
+ aa.Name,
+ ra.Importance
+ FROM requests_artists AS ra
+ JOIN artists_alias AS aa ON ra.AliasID = aa.AliasID
+ WHERE ra.RequestID = $RequestID
+ ORDER BY ra.Importance ASC, aa.Name ASC;");
+
+ $ArtistRaw = $DB->to_array();
+ foreach ($ArtistRaw as $ArtistRow) {
+ list($ArtistID, $ArtistName, $ArtistImportance) = $ArtistRow;
+ $Results[$ArtistImportance][] = array('id' => $ArtistID, 'name' => $ArtistName);
+ }
+ $Cache->cache_value('request_artists_'.$RequestID, $Results);
+ }
+ return $Results;
+ }
+
+ public static function get_tags($RequestID) {
+ global $DB;
+ $DB->query("
+ SELECT
+ rt.TagID,
+ t.Name
+ FROM requests_tags AS rt
+ JOIN tags AS t ON rt.TagID=t.ID
+ WHERE rt.RequestID = $RequestID
+ ORDER BY rt.TagID ASC");
+ $Tags = $DB->to_array();
+ $Results = array();
+ foreach ($Tags as $TagsRow) {
+ list($TagID, $TagName) = $TagsRow;
+ $Results[$TagID]= $TagName;
+ }
+ return $Results;
+ }
+
+ public static function get_votes_array($RequestID) {
+ global $Cache, $DB;
+
+ $RequestVotes = $Cache->get_value('request_votes_'.$RequestID);
+ if (!is_array($RequestVotes)) {
+ $DB->query("
+ SELECT
+ rv.UserID,
+ rv.Bounty,
+ u.Username
+ FROM requests_votes as rv
+ LEFT JOIN users_main AS u ON u.ID=rv.UserID
+ WHERE rv.RequestID = $RequestID
+ ORDER BY rv.Bounty DESC");
+ if ($DB->record_count() < 1) {
+ error(0);
+ } else {
+ $Votes = $DB->to_array();
+
+ $RequestVotes = array();
+ $RequestVotes['TotalBounty'] = array_sum($DB->collect('Bounty'));
+
+ foreach ($Votes as $Vote) {
+ list($UserID, $Bounty, $Username) = $Vote;
+ $VoteArray = array();
+ $VotesArray[] = array('UserID' => $UserID, 'Username' => $Username, 'Bounty' => $Bounty);
+ }
+
+ $RequestVotes['Voters'] = $VotesArray;
+ $Cache->cache_value('request_votes_'.$RequestID, $RequestVotes);
+ }
+ }
+ return $RequestVotes;
+ }
+
}
?>
diff --git a/classes/script_start.php b/classes/script_start.php
index ce7af932..0da14b09 100644
--- a/classes/script_start.php
+++ b/classes/script_start.php
@@ -98,6 +98,9 @@
case 'Bookmarks':
$FileName = 'bookmarks.class';
break;
+ case 'Collages':
+ $FileName = 'class_collages';
+ break;
case 'Format':
$FileName = 'class_format';
break;
diff --git a/sections/ajax/artist.php b/sections/ajax/artist.php
index 1a1a6229..13898656 100644
--- a/sections/ajax/artist.php
+++ b/sections/ajax/artist.php
@@ -4,7 +4,6 @@ function compare($X, $Y) {
return($Y['count'] - $X['count']);
}
-include(SERVER_ROOT.'/sections/requests/functions.php');
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
$Text = new TEXT;
diff --git a/sections/ajax/bookmarks/index.php b/sections/ajax/bookmarks/index.php
index ae3a1b6d..4ac10e8d 100644
--- a/sections/ajax/bookmarks/index.php
+++ b/sections/ajax/bookmarks/index.php
@@ -17,7 +17,6 @@
require(SERVER_ROOT.'/sections/ajax/collages/browse.php');
break;
case 'requests':
- include(SERVER_ROOT.'/sections/requests/functions.php');
$_GET['type'] = 'bookmarks';
require(SERVER_ROOT.'/sections/ajax/requests/requests.php');
break;
diff --git a/sections/ajax/request.php b/sections/ajax/request.php
index e527cf83..b39588a7 100644
--- a/sections/ajax/request.php
+++ b/sections/ajax/request.php
@@ -10,7 +10,6 @@
* This is the page that displays the request to the end user after being created.
*/
-include(SERVER_ROOT.'/sections/requests/functions.php');
include(SERVER_ROOT.'/classes/class_text.php');
$Text = new TEXT;
@@ -43,7 +42,7 @@
//Do we need to get artists?
if ($CategoryName == 'Music') {
- $ArtistForm = get_request_artists($RequestID);
+ $ArtistForm = Requests::get_artists($RequestID);
$ArtistName = Artists::display_artists($ArtistForm, false, true);
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
@@ -79,7 +78,7 @@
}
//Votes time
-$RequestVotes = get_votes_array($RequestID);
+$RequestVotes = Requests::get_votes_array($RequestID);
$VoteCount = count($RequestVotes['Voters']);
$ProjectCanEdit = (check_perms('project_team') && !$IsFilled && (($CategoryID == 0) || ($CategoryName == 'Music' && $Year == 0)));
$UserCanEdit = (!$IsFilled && $LoggedUser['ID'] == $RequestorID && $VoteCount < 2);
diff --git a/sections/ajax/requests.php b/sections/ajax/requests.php
index 960dc821..6105161f 100644
--- a/sections/ajax/requests.php
+++ b/sections/ajax/requests.php
@@ -1,7 +1,5 @@
-include(SERVER_ROOT.'/sections/requests/functions.php');
-
$Queries = array();
$OrderWays = array('year', 'votes', 'bounty', 'created', 'lastvote', 'filled');
@@ -309,7 +307,7 @@
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber,
$ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled) = $Request;
- $RequestVotes = get_votes_array($RequestID);
+ $RequestVotes = Requests::get_votes_array($RequestID);
$VoteCount = count($RequestVotes['Voters']);
@@ -321,7 +319,7 @@
$JsonArtists = array();
if ($CategoryName == 'Music') {
- $ArtistForm = get_request_artists($RequestID);
+ $ArtistForm = Requests::get_artists($RequestID);
$JsonArtists = array_values($ArtistForm);
}
diff --git a/sections/ajax/user.php b/sections/ajax/user.php
index 76ef873c..3fdf0c08 100644
--- a/sections/ajax/user.php
+++ b/sections/ajax/user.php
@@ -3,8 +3,6 @@
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
$Text = new TEXT;
-require(SERVER_ROOT.'/sections/requests/functions.php');
-
if (empty($_GET['id']) || !is_numeric($_GET['id'])) {
json_die("failure", "bad id parameter");
}
diff --git a/sections/artist/artist.php b/sections/artist/artist.php
index ca41d962..42da67f6 100644
--- a/sections/artist/artist.php
+++ b/sections/artist/artist.php
@@ -9,8 +9,6 @@ function compare($X, $Y) {
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
$Text = new TEXT;
-include(SERVER_ROOT.'/sections/requests/functions.php');
-
// Similar artist map
include(SERVER_ROOT.'/classes/class_artists_similar.php');
@@ -738,7 +736,7 @@ function compare($X, $Y) {
$CategoryName = $Categories[$CategoryID - 1];
if ($CategoryName == 'Music') {
- $ArtistForm = get_request_artists($RequestID);
+ $ArtistForm = Requests::get_artists($RequestID);
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
$FullName = $ArtistLink."$Title [$Year]";
} elseif ($CategoryName == 'Audiobooks' || $CategoryName == 'Comedy') {
@@ -749,7 +747,7 @@ function compare($X, $Y) {
$Row = ($Row == 'a') ? 'b' : 'a';
- $Tags = get_request_tags($RequestID);
+ $Tags = Requests::get_tags($RequestID);
$ReqTagList = array();
foreach ($Tags as $TagID => $TagName) {
$ReqTagList[] = "'.display_str($TagName).'';
diff --git a/sections/bookmarks/index.php b/sections/bookmarks/index.php
index e7abec41..155ea6b8 100644
--- a/sections/bookmarks/index.php
+++ b/sections/bookmarks/index.php
@@ -61,7 +61,6 @@
require(SERVER_ROOT.'/sections/collages/browse.php');
break;
case 'requests':
- include(SERVER_ROOT.'/sections/requests/functions.php');
$_GET['type'] = 'bookmarks';
require(SERVER_ROOT.'/sections/requests/requests.php');
break;
diff --git a/sections/collages/add_comment.php b/sections/collages/add_comment.php
index c9eb32ca..926d12a1 100644
--- a/sections/collages/add_comment.php
+++ b/sections/collages/add_comment.php
@@ -10,13 +10,25 @@
error('Your posting privileges have been removed'); // Should this be logged?
}
+$DB->query("
+ SELECT
+ CEIL((
+ SELECT COUNT(ID)+1
+ FROM collages_comments
+ WHERE CollageID='".db_string($CollageID)."')/".TORRENT_COMMENTS_PER_PAGE."
+ ) AS Pages");
+list($Pages) = $DB->next_record();
+
$DB->query("INSERT INTO collages_comments
(CollageID, Body, UserID, Time)
VALUES
('$CollageID', '".db_string($_POST['body'])."', '$LoggedUser[ID]', '".sqltime()."')");
-$Cache->delete_value('collage_'.$CollageID.'_catalogue_0');
+$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
+
$Cache->delete_value('collage_'.$CollageID);
+$Cache->delete_value('collage_comments_'.$CollageID.'_catalogue_'.$CatalogueID);
+$Cache->increment('collage_comments_'.$CollageID);
header('Location: collages.php?id='.$CollageID);
?>
diff --git a/sections/collages/all_comments.php b/sections/collages/all_comments.php
index b861f9cb..2f88f942 100644
--- a/sections/collages/all_comments.php
+++ b/sections/collages/all_comments.php
@@ -19,33 +19,28 @@
error(0);
}
-list($Page,$Limit) = Format::page_limit(POSTS_PER_PAGE);
+// gets the amount of comments for this collage
+$NumComments = Collages::get_comment_count($CollageID);
+
+if (isset($_GET['postid']) && is_number($_GET['postid']) && $NumComments > TORRENT_COMMENTS_PER_PAGE) {
+ $DB->query("SELECT COUNT(ID) FROM collages_comments WHERE CollageID = $CollageID AND ID <= $_GET[postid]");
+ list($PostNum) = $DB->next_record();
+ list($Page, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $PostNum);
+} else {
+ list($Page, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $NumComments);
+}
//Get the cache catalogue
-$CatalogueID = floor((POSTS_PER_PAGE*$Page-POSTS_PER_PAGE)/THREAD_CATALOGUE);
-$CatalogueLimit=$CatalogueID*THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
+$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
+$CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
//---------- Get some data to start processing
// Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page
-if (!list($Catalogue,$Posts) = $Cache->get_value('collage_'.$CollageID.'_catalogue_'.$CatalogueID)) {
- $DB->query("
- SELECT SQL_CALC_FOUND_ROWS
- ID,
- UserID,
- Time,
- Body
- FROM collages_comments
- WHERE CollageID = '$CollageID'
- LIMIT $CatalogueLimit");
- $Catalogue = $DB->to_array();
- $DB->query("SELECT FOUND_ROWS()");
- list($Posts) = $DB->next_record();
- $Cache->cache_value('collage_'.$CollageID.'_catalogue_'.$CatalogueID, array($Catalogue,$Posts), 0);
-}
+$Catalogue = Collages::get_comment_catalogue($CollageID, $CatalogueID);
//This is a hybrid to reduce the catalogue down to the page elements: We use the page limit % catalogue
-$Thread = array_slice($Catalogue, ((POSTS_PER_PAGE * $Page - POSTS_PER_PAGE) % THREAD_CATALOGUE), POSTS_PER_PAGE, true);
+$Thread = array_slice($Catalogue, ((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) % THREAD_CATALOGUE), TORRENT_COMMENTS_PER_PAGE, true);
$DB->query("SELECT Name FROM collages WHERE ID='$CollageID'");
list($Name) = $DB->next_record();
@@ -61,7 +56,7 @@
-$Pages = Format::get_pages($Page, $Posts, POSTS_PER_PAGE, 9);
+$Pages = Format::get_pages($Page, $NumComments, TORRENT_COMMENTS_PER_PAGE, 9);
echo $Pages;
?>
@@ -70,7 +65,7 @@
//---------- Begin printing
foreach ($Thread as $Post) {
- list($PostID, $AuthorID, $AddedTime, $Body) = $Post;
+ list($PostID, $AuthorID, $AddedTime, $Body) = array_values($Post);
list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID));
?>
diff --git a/sections/collages/delete_comment.php b/sections/collages/delete_comment.php
index 1c12e7a3..09dc3ca7 100644
--- a/sections/collages/delete_comment.php
+++ b/sections/collages/delete_comment.php
@@ -15,11 +15,27 @@
error(403);
}
-$DB->query("SELECT CollageID FROM collages_comments WHERE ID='$PostID'");
-list($CollageID) = $DB->next_record();
+// Get number of pages
+// $Pages = number of pages in the thread
+// $Page = which page the post is on
+$DB->query("SELECT
+ CollageID,
+ CEIL(COUNT(ID)/" . TORRENT_COMMENTS_PER_PAGE . ") AS Pages,
+ CEIL(SUM(IF(ID<='$PostID',1,0))/" . TORRENT_COMMENTS_PER_PAGE . ") AS Page
+ FROM collages_comments
+ WHERE CollageID=(SELECT CollageID FROM collages_comments WHERE ID='$PostID')
+ GROUP BY CollageID");
+list($CollageID, $Pages, $Page) = $DB->next_record();
$DB->query("DELETE FROM collages_comments WHERE ID='$PostID'");
$Cache->delete_value('collage_'.$CollageID);
-$Cache->delete_value('collage_'.$CollageID.'_catalogue_0'); //Because these never exceed 500 posts, and I'm really tired right now.
+$Cache->increment_value('collage_comments_'.$CollageID, -1);
+
+//We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
+$ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
+$LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
+for ($i = $ThisCatalogue; $i <= $LastCatalogue; $i++) {
+ $Cache->delete('collage_comments_'.$CollageID.'_catalogue_'.$i);
+}
?>
diff --git a/sections/collages/takeedit_comment.php b/sections/collages/takeedit_comment.php
index d886dc7f..8f1c81c6 100644
--- a/sections/collages/takeedit_comment.php
+++ b/sections/collages/takeedit_comment.php
@@ -51,8 +51,8 @@
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
-$CatalogueID = floor((POSTS_PER_PAGE * $PageNum - POSTS_PER_PAGE) / THREAD_CATALOGUE);
-$Cache->delete_value('collage_'.$CollageID.'_catalogue_'.$CatalogueID);
+$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $PageNum - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
+$Cache->delete_value('collage_comments_'.$CollageID.'_catalogue_'.$CatalogueID);
$DB->query("
INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
diff --git a/sections/comments/requestcomments.php b/sections/comments/requestcomments.php
index 5ee1546e..04b8ca77 100644
--- a/sections/comments/requestcomments.php
+++ b/sections/comments/requestcomments.php
@@ -1,8 +1,4 @@
- 0) {
while (list($UserID, $RequestID, $Title, $PostID, $Body, $AddedTime, $EditedTime, $EditorID) = $DB->next_record()) {
- $Artists = get_request_artists($RequestID);
+ $Artists = Requests::get_artists($RequestID);
$permalink = "requests.php?action=view&id=$RequestID&postid=$PostID#post$PostID";
$postheader = " on " . Artists::display_artists($Artists) . " $Title";
comment_body($UserID, $PostID, $postheader, $permalink, $Body, $EditorID, $AddedTime, $EditedTime);
diff --git a/sections/requests/functions.php b/sections/requests/functions.php
deleted file mode 100644
index 9c5755dc..00000000
--- a/sections/requests/functions.php
+++ /dev/null
@@ -1,85 +0,0 @@
-
-enforce_login();
-function get_request_artists($RequestID) {
- global $Cache, $DB;
- $Artists = $Cache->get_value('request_artists_'.$RequestID);
- if (is_array($Artists)) {
- $Results = $Artists;
- } else {
- $Results = array();
- $DB->query("
- SELECT
- ra.ArtistID,
- aa.Name,
- ra.Importance
- FROM requests_artists AS ra
- JOIN artists_alias AS aa ON ra.AliasID = aa.AliasID
- WHERE ra.RequestID = ".$RequestID."
- ORDER BY ra.Importance ASC, aa.Name ASC;");
-
- $ArtistRaw = $DB->to_array();
- foreach ($ArtistRaw as $ArtistRow) {
- list($ArtistID, $ArtistName, $ArtistImportance) = $ArtistRow;
- $Results[$ArtistImportance][] = array('id' => $ArtistID, 'name' => $ArtistName);
- }
- $Cache->cache_value('request_artists_'.$RequestID, $Results);
- }
- return $Results;
-}
-
-function get_request_tags($RequestID) {
- global $DB;
- $DB->query("
- SELECT
- rt.TagID,
- t.Name
- FROM requests_tags AS rt
- JOIN tags AS t ON rt.TagID=t.ID
- WHERE rt.RequestID = ".$RequestID."
- ORDER BY rt.TagID ASC");
- $Tags = $DB->to_array();
- $Results = array();
- foreach ($Tags as $TagsRow) {
- list($TagID, $TagName) = $TagsRow;
- $Results[$TagID]= $TagName;
- }
- return $Results;
-}
-
-function get_votes_array($RequestID) {
- global $Cache, $DB;
-
- $RequestVotes = $Cache->get_value('request_votes_'.$RequestID);
- if (!is_array($RequestVotes)) {
- $DB->query("
- SELECT
- rv.UserID,
- rv.Bounty,
- u.Username
- FROM requests_votes as rv
- LEFT JOIN users_main AS u ON u.ID=rv.UserID
- WHERE rv.RequestID = ".$RequestID."
- ORDER BY rv.Bounty DESC");
- if ($DB->record_count() < 1) {
- error(0);
- } else {
- $Votes = $DB->to_array();
-
- $RequestVotes = array();
- $RequestVotes['TotalBounty'] = array_sum($DB->collect('Bounty'));
-
- foreach ($Votes as $Vote) {
- list($UserID, $Bounty, $Username) = $Vote;
- $VoteArray = array();
- $VotesArray[] = array('UserID' => $UserID,
- 'Username' => $Username,
- 'Bounty' => $Bounty);
- }
-
- $RequestVotes['Voters'] = $VotesArray;
- $Cache->cache_value('request_votes_'.$RequestID, $RequestVotes);
- }
- }
- return $RequestVotes;
-}
-?>
diff --git a/sections/requests/index.php b/sections/requests/index.php
index b1a7d41d..ad500618 100644
--- a/sections/requests/index.php
+++ b/sections/requests/index.php
@@ -1,6 +1,5 @@
enforce_login();
-include(SERVER_ROOT.'/sections/requests/functions.php');
$RequestTax = 0.1;
diff --git a/sections/requests/new_edit.php b/sections/requests/new_edit.php
index c09ba9bf..35edb86c 100644
--- a/sections/requests/new_edit.php
+++ b/sections/requests/new_edit.php
@@ -32,7 +32,7 @@
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $RecordLabel,
$ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled, $GroupID, $OCLC) = $Request;
- $VoteArray = get_votes_array($RequestID);
+ $VoteArray = Requests::get_votes_array($RequestID);
$VoteCount = count($VoteArray['Voters']);
$NeedCue = (strpos($LogCue, 'Cue') !== false);
@@ -55,7 +55,7 @@
}
if ($CategoryName == 'Music') {
- $ArtistForm = get_request_artists($RequestID);
+ $ArtistForm = Requests::get_artists($RequestID);
$BitrateArray = array();
if ($BitrateList == 'Any') {
diff --git a/sections/requests/request.php b/sections/requests/request.php
index a8b103e9..4e439408 100644
--- a/sections/requests/request.php
+++ b/sections/requests/request.php
@@ -37,7 +37,7 @@
//Do we need to get artists?
if ($CategoryName == 'Music') {
- $ArtistForm = get_request_artists($RequestID);
+ $ArtistForm = Requests::get_artists($RequestID);
$ArtistName = Artists::display_artists($ArtistForm, false, true);
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
@@ -73,7 +73,7 @@
}
//Votes time
-$RequestVotes = get_votes_array($RequestID);
+$RequestVotes = Requests::get_votes_array($RequestID);
$VoteCount = count($RequestVotes['Voters']);
$ProjectCanEdit = (check_perms('project_team') && !$IsFilled && (($CategoryID == 0) || ($CategoryName == 'Music' && $Year == 0)));
$UserCanEdit = (!$IsFilled && $LoggedUser['ID'] == $RequestorID && $VoteCount < 2);
@@ -462,15 +462,7 @@
-$Results = $Cache->get_value('request_comments_'.$RequestID);
-if ($Results === false) {
- $DB->query("SELECT
- COUNT(c.ID)
- FROM requests_comments as c
- WHERE c.RequestID = '$RequestID'");
- list($Results) = $DB->next_record();
- $Cache->cache_value('request_comments_'.$RequestID, $Results, 0);
-}
+$Results = Requests::get_comment_count($RequestID);
if (isset($_GET['postid']) && is_number($_GET['postid']) && $Results > TORRENT_COMMENTS_PER_PAGE) {
$DB->query("SELECT COUNT(ID) FROM requests_comments WHERE RequestID = $RequestID AND ID <= $_GET[postid]");
@@ -482,29 +474,11 @@
//Get the cache catalogue
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE*$Page-TORRENT_COMMENTS_PER_PAGE)/THREAD_CATALOGUE);
-$CatalogueLimit=$CatalogueID*THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
//---------- Get some data to start processing
// Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page
-$Catalogue = $Cache->get_value('request_comments_'.$RequestID.'_catalogue_'.$CatalogueID);
-if ($Catalogue === false) {
- $DB->query("SELECT
- c.ID,
- c.AuthorID,
- c.AddedTime,
- c.Body,
- c.EditedUserID,
- c.EditedTime,
- u.Username
- FROM requests_comments as c
- LEFT JOIN users_main AS u ON u.ID=c.EditedUserID
- WHERE c.RequestID = '$RequestID'
- ORDER BY c.ID
- LIMIT $CatalogueLimit");
- $Catalogue = $DB->to_array(false,MYSQLI_ASSOC);
- $Cache->cache_value('request_comments_'.$RequestID.'_catalogue_'.$CatalogueID, $Catalogue, 0);
-}
+$Catalogue = Requests::get_comment_catalogue($RequestID, $CatalogueID);
//This is a hybrid to reduce the catalogue down to the page elements: We use the page limit % catalogue
$Thread = array_slice($Catalogue,((TORRENT_COMMENTS_PER_PAGE*$Page-TORRENT_COMMENTS_PER_PAGE)%THREAD_CATALOGUE),TORRENT_COMMENTS_PER_PAGE,true);
diff --git a/sections/requests/requests.php b/sections/requests/requests.php
index 13f49329..b6d61dca 100644
--- a/sections/requests/requests.php
+++ b/sections/requests/requests.php
@@ -596,7 +596,7 @@
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $RecordLabel,
$ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled) = $Request;
- $RequestVotes = get_votes_array($RequestID);
+ $RequestVotes = Requests::get_votes_array($RequestID);
$VoteCount = count($RequestVotes['Voters']);
@@ -609,7 +609,7 @@
$IsFilled = ($TorrentID != 0);
if ($CategoryName == 'Music') {
- $ArtistForm = get_request_artists($RequestID);
+ $ArtistForm = Requests::get_artists($RequestID);
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
$FullName = $ArtistLink."$Title [$Year]";
} elseif ($CategoryName == 'Audiobooks' || $CategoryName == 'Comedy') {
diff --git a/sections/requests/requests.php.presphinx b/sections/requests/requests.php.presphinx
index 2e1fc848..ae70ba18 100644
--- a/sections/requests/requests.php.presphinx
+++ b/sections/requests/requests.php.presphinx
@@ -420,7 +420,7 @@ foreach ($Categories as $CatKey => $CatName) {
$IsFilled = ($TorrentID != 0);
if ($CategoryName == "Music") {
- $ArtistForm = get_request_artists($RequestID);
+ $ArtistForm = Requests::get_artists($RequestID);
$ArtistLink = display_artists($ArtistForm, true, true);
$FullName = $ArtistLink."".$Title." [".$Year."]";
} elseif ($CategoryName == 'Audiobooks' || $CategoryName == 'Comedy') {
@@ -431,7 +431,7 @@ foreach ($Categories as $CatKey => $CatName) {
$Row = ($Row == 'a') ? 'b' : 'a';
- $Tags = get_request_tags($RequestID);
+ $Tags = Requests::get_tags($RequestID);
?>
diff --git a/sections/requests/takedelete.php b/sections/requests/takedelete.php
index cd7f6941..1223d585 100644
--- a/sections/requests/takedelete.php
+++ b/sections/requests/takedelete.php
@@ -27,7 +27,7 @@
//Do we need to get artists?
if ($CategoryName == 'Music') {
- $ArtistForm = get_request_artists($RequestID);
+ $ArtistForm = Requests::get_artists($RequestID);
$ArtistName = Artists::display_artists($ArtistForm, false, true);
$FullName = $ArtistName.$Title;
} else {
diff --git a/sections/requests/takefill.php b/sections/requests/takefill.php
index a8e471d0..419e0869 100644
--- a/sections/requests/takefill.php
+++ b/sections/requests/takefill.php
@@ -171,7 +171,7 @@
WHERE ID = $RequestID");
if ($CategoryName == 'Music') {
- $ArtistForm = get_request_artists($RequestID);
+ $ArtistForm = Requests::get_artists($RequestID);
$ArtistName = Artists::display_artists($ArtistForm, false, true);
$FullName = $ArtistName.$Title;
} else {
@@ -185,7 +185,7 @@
Misc::send_pm($VoterID, 0, "The request \"$FullName\" has been filled", 'One of your requests — [url=https://'.SSL_SITE_URL.'/requests.php?action=view&id='.$RequestID.']'.$FullName.'[/url] — has been filled. You can view it here: [url]https://'.SSL_SITE_URL.'/torrents.php?torrentid='.$TorrentID.'[/url]');
}
-$RequestVotes = get_votes_array($RequestID);
+$RequestVotes = Requests::get_votes_array($RequestID);
Misc::write_log("Request $RequestID (".$FullName.") was filled by user $FillerID (".$FillerUsername.") with the torrent $TorrentID for a ".Format::get_size($RequestVotes['TotalBounty']).' bounty.');
// Give bounty
diff --git a/sections/requests/takenew_edit.php b/sections/requests/takenew_edit.php
index 2f80dbdb..541bcd1b 100644
--- a/sections/requests/takenew_edit.php
+++ b/sections/requests/takenew_edit.php
@@ -33,7 +33,7 @@
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $RecordLabel,
$ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled, $GroupID, $OCLC) = $Request;
- $VoteArray = get_votes_array($RequestID);
+ $VoteArray = Requests::get_votes_array($RequestID);
$VoteCount = count($VoteArray['Voters']);
$IsFilled = !empty($TorrentID);
diff --git a/sections/requests/takeunfill.php b/sections/requests/takeunfill.php
index b5894c8e..800625e2 100644
--- a/sections/requests/takeunfill.php
+++ b/sections/requests/takeunfill.php
@@ -38,14 +38,14 @@
$CategoryName = $Categories[$CategoryID - 1];
if ($CategoryName == 'Music') {
- $ArtistForm = get_request_artists($RequestID);
+ $ArtistForm = Requests::get_artists($RequestID);
$ArtistName = Artists::display_artists($ArtistForm, false, true);
$FullName = $ArtistName.$Title;
} else {
$FullName = $Title;
}
-$RequestVotes = get_votes_array($RequestID);
+$RequestVotes = Requests::get_votes_array($RequestID);
if ($RequestVotes['TotalBounty'] > $Uploaded) {
// If we can't take it all out of upload, zero that out and add whatever is left as download.
diff --git a/sections/requests/takevote.php b/sections/requests/takevote.php
index bb095b35..7cfb057a 100644
--- a/sections/requests/takevote.php
+++ b/sections/requests/takevote.php
@@ -52,7 +52,7 @@
$Cache->delete_value('request_'.$RequestID);
$Cache->delete_value('request_votes_'.$RequestID);
- $ArtistForm = get_request_artists($RequestID);
+ $ArtistForm = Requests::get_artists($RequestID);
foreach ($ArtistForm as $Importance) {
foreach ($Importance as $Artist) {
$Cache->delete_value('artists_requests_'.$Artist['id']);
diff --git a/sections/torrents/details.php b/sections/torrents/details.php
index 4a8e1c51..326d73a8 100644
--- a/sections/torrents/details.php
+++ b/sections/torrents/details.php
@@ -619,7 +619,7 @@ function filelist($Str) {
| Bounty |
foreach ($Requests as $Request) {
- $RequestVotes = get_votes_array($Request['ID']);
+ $RequestVotes = Requests::get_votes_array($Request['ID']);
if ($Request['BitrateList'] != "") {
$BitrateString = implode(", ", explode("|", $Request['BitrateList']));
diff --git a/sections/torrents/functions.php b/sections/torrents/functions.php
index cc301c6b..9135c6e5 100644
--- a/sections/torrents/functions.php
+++ b/sections/torrents/functions.php
@@ -1,6 +1,4 @@
-include(SERVER_ROOT.'/sections/requests/functions.php'); // get_request_tags()
-
function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProperties = true, $ApiCall = false) {
global $Cache, $DB;
if (!$RevisionID) {
diff --git a/sections/upload/upload.php b/sections/upload/upload.php
index 5703989c..0be5f34c 100644
--- a/sections/upload/upload.php
+++ b/sections/upload/upload.php
@@ -50,7 +50,6 @@
$Properties['RequestID'] = $_GET['requestid'];
}
} elseif (empty($Properties) && !empty($_GET['requestid']) && is_number($_GET['requestid'])) {
- include(SERVER_ROOT.'/sections/requests/functions.php');
$DB->query('
SELECT
r.ID AS RequestID,
@@ -67,8 +66,8 @@
list($Properties) = $DB->to_array(false,MYSQLI_BOTH);
$UploadForm = $Categories[$Properties['CategoryID'] - 1];
$Properties['CategoryName'] = $Categories[$Properties['CategoryID'] - 1];
- $Properties['Artists'] = get_request_artists($_GET['requestid']);
- $Properties['TagList'] = implode(', ', get_request_tags($_GET['requestid']));
+ $Properties['Artists'] = Requests::get_artists($_GET['requestid']);
+ $Properties['TagList'] = implode(', ', Requests::get_tags($_GET['requestid']));
}
if (!empty($ArtistForm)) {
diff --git a/sections/user/user.php b/sections/user/user.php
index 86101fc3..6640b706 100644
--- a/sections/user/user.php
+++ b/sections/user/user.php
@@ -3,8 +3,6 @@
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
$Text = new TEXT;
-include(SERVER_ROOT.'/sections/requests/functions.php');
-
if (empty($_GET['id']) || !is_numeric($_GET['id']))
error(404);
@@ -720,7 +718,7 @@ function check_paranoia_here($Setting) {
$CategoryName = $Categories[$CategoryID - 1];
if ($CategoryName == 'Music') {
- $ArtistForm = get_request_artists($RequestID);
+ $ArtistForm = Requests::get_artists($RequestID);
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
$FullName = $ArtistLink."$Title [$Year]";
} elseif ($CategoryName == 'Audiobooks' || $CategoryName == 'Comedy') {