Empty commit

This commit is contained in:
Git 2013-07-13 08:00:46 +00:00
parent 633a1b6b43
commit 8f5fb0f429
31 changed files with 780 additions and 513 deletions

View File

@ -294,6 +294,10 @@ function close() {
} }
} }
/*
* returns an integer with the number of rows found
* returns a string if the number of rows found exceeds MAXINT
*/
function record_count() { function record_count() {
if ($this->QueryID) { if ($this->QueryID) {
return mysqli_num_rows($this->QueryID); return mysqli_num_rows($this->QueryID);

View File

@ -21,7 +21,10 @@
); );
die(); die();
} }
$DB->query("SELECT Username FROM users_main WHERE ID='$UserID'"); $DB->query("
SELECT Username
FROM users_main
WHERE ID = '$UserID'");
list($Username) = $DB->next_record(); list($Username) = $DB->next_record();
} else { } else {
$UserID = $LoggedUser['ID']; $UserID = $LoggedUser['ID'];
@ -31,11 +34,11 @@
//$ArtistList = Bookmarks::all_bookmarks('artist', $UserID); //$ArtistList = Bookmarks::all_bookmarks('artist', $UserID);
$DB->query(' $DB->query("
SELECT ag.ArtistID, ag.Name SELECT ag.ArtistID, ag.Name
FROM bookmarks_artists AS ba FROM bookmarks_artists AS ba
INNER JOIN artists_group AS ag ON ba.ArtistID = ag.ArtistID INNER JOIN artists_group AS ag ON ba.ArtistID = ag.ArtistID
WHERE ba.UserID = '.$UserID); WHERE ba.UserID = $UserID");
$ArtistList = $DB->to_array(); $ArtistList = $DB->to_array();

View File

@ -16,7 +16,10 @@ function compare($X, $Y) {
if (!is_number($UserID)) { if (!is_number($UserID)) {
error(404); error(404);
} }
$DB->query("SELECT Username FROM users_main WHERE ID='$UserID'"); $DB->query("
SELECT Username
FROM users_main
WHERE ID = '$UserID'");
list($Username) = $DB->next_record(); list($Username) = $DB->next_record();
} else { } else {
$UserID = $LoggedUser['ID']; $UserID = $LoggedUser['ID'];

View File

@ -19,7 +19,10 @@
if (isset($_GET['topicid']) && is_number($_GET['topicid'])) { if (isset($_GET['topicid']) && is_number($_GET['topicid'])) {
$ThreadID = $_GET['topicid']; $ThreadID = $_GET['topicid'];
} elseif (isset($_GET['postid']) && is_number($_GET['postid'])) { } elseif (isset($_GET['postid']) && is_number($_GET['postid'])) {
$DB->query("SELECT TopicID FROM forums_posts WHERE ID = $_GET[postid]"); $DB->query("
SELECT TopicID
FROM forums_posts
WHERE ID = $_GET[postid]");
list($ThreadID) = $DB->next_record(); list($ThreadID) = $DB->next_record();
if ($ThreadID) { if ($ThreadID) {
//Redirect postid to threadid when necessary. //Redirect postid to threadid when necessary.
@ -84,7 +87,7 @@
list($CatalogueID,$CatalogueLimit) = Format::catalogue_limit($Page, $PerPage, THREAD_CATALOGUE); list($CatalogueID,$CatalogueLimit) = Format::catalogue_limit($Page, $PerPage, THREAD_CATALOGUE);
// Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page // Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page
if (!$Catalogue = $Cache->get_value('thread_'.$ThreadID.'_catalogue_'.$CatalogueID)) { if (!$Catalogue = $Cache->get_value("thread_$ThreadID"."_catalogue_$CatalogueID")) {
$DB->query(" $DB->query("
SELECT SELECT
p.ID, p.ID,
@ -97,14 +100,14 @@
WHERE p.TopicID = '$ThreadID' WHERE p.TopicID = '$ThreadID'
AND p.ID != '".$ThreadInfo['StickyPostID']."' AND p.ID != '".$ThreadInfo['StickyPostID']."'
LIMIT $CatalogueLimit"); LIMIT $CatalogueLimit");
$Catalogue = $DB->to_array(false,MYSQLI_ASSOC); $Catalogue = $DB->to_array(false, MYSQLI_ASSOC);
if (!$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) { if (!$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) {
$Cache->cache_value('thread_'.$ThreadID.'_catalogue_'.$CatalogueID, $Catalogue, 0); $Cache->cache_value("thread_$ThreadID"."_catalogue_$CatalogueID", $Catalogue, 0);
} }
} }
$Thread = Format::catalogue_select($Catalogue, $Page, $PerPage, THREAD_CATALOGUE); $Thread = Format::catalogue_select($Catalogue, $Page, $PerPage, THREAD_CATALOGUE);
if ($_GET['updatelastread'] != '0') { if ($_GET['updatelastread'] !== '0') {
$LastPost = end($Thread); $LastPost = end($Thread);
$LastPost = $LastPost['ID']; $LastPost = $LastPost['ID'];
reset($Thread); reset($Thread);
@ -116,8 +119,8 @@
$DB->query(" $DB->query("
SELECT PostID SELECT PostID
FROM forums_last_read_topics FROM forums_last_read_topics
WHERE UserID='$LoggedUser[ID]' WHERE UserID = '$LoggedUser[ID]'
AND TopicID='$ThreadID'"); AND TopicID = '$ThreadID'");
list($LastRead) = $DB->next_record(); list($LastRead) = $DB->next_record();
if ($LastRead < $LastPost) { if ($LastRead < $LastPost) {
$DB->query(" $DB->query("
@ -125,7 +128,7 @@
(UserID, TopicID, PostID) (UserID, TopicID, PostID)
VALUES VALUES
('$LoggedUser[ID]', '$ThreadID', '".db_string($LastPost)."') ('$LoggedUser[ID]', '$ThreadID', '".db_string($LastPost)."')
ON DUPLICATE KEY UPDATE PostID='$LastPost'"); ON DUPLICATE KEY UPDATE PostID = '$LastPost'");
} }
} }
} }
@ -260,11 +263,11 @@
'authorId' => (int) $AuthorID, 'authorId' => (int) $AuthorID,
'authorName' => $Username, 'authorName' => $Username,
'paranoia' => $Paranoia, 'paranoia' => $Paranoia,
'artist' => ($Artist == 1), 'artist' => ($Artist === '1'),
'donor' => ($Donor == 1), 'donor' => ($Donor === '1'),
'warned' => ($Warned != '0000-00-00 00:00:00'), 'warned' => ($Warned !== '0000-00-00 00:00:00'),
'avatar' => $Avatar, 'avatar' => $Avatar,
'enabled' => (($Enabled == 2) ? false : true), 'enabled' => (($Enabled === '2') ? false : true),
'userTitle' => $UserTitle 'userTitle' => $UserTitle
), ),

View File

@ -5,14 +5,12 @@
$Note = $_POST['note']; $Note = $_POST['note'];
if (empty($FriendID) || empty($Type) || empty($ID)) { if (empty($FriendID) || empty($Type) || empty($ID)) {
echo json_encode(array("status" => "error", "response" => "Error.")); echo json_encode(array('status' => 'error', 'response' => 'Error.'));
die(); die();
} }
// Make sure the recipient is on your friends list and not some random dude. // Make sure the recipient is on your friends list and not some random dude.
$DB->query(" $DB->query("
SELECT SELECT f.FriendID, u.Username
f.FriendID,
u.Username
FROM friends AS f FROM friends AS f
RIGHT JOIN users_enable_recommendations AS r RIGHT JOIN users_enable_recommendations AS r
ON r.ID = f.FriendID AND r.Enable = 1 ON r.ID = f.FriendID AND r.Enable = 1
@ -22,7 +20,7 @@
AND f.FriendID = '$FriendID'"); AND f.FriendID = '$FriendID'");
if (!$DB->has_results()) { if (!$DB->has_results()) {
echo json_encode(array("status" => "error", "response" => "Not on friend list.")); echo json_encode(array('status' => 'error', 'response' => 'Not on friend list.'));
die(); die();
} }
@ -33,27 +31,35 @@
$Article = 'a'; $Article = 'a';
switch ($Type) { switch ($Type) {
case 'torrent': case 'torrent':
$Link = "torrents.php?id=".$ID; $Link = "torrents.php?id=$ID";
$DB->query("SELECT Name FROM torrents_group WHERE ID = '$ID'"); $DB->query("
SELECT Name
FROM torrents_group
WHERE ID = '$ID'");
break; break;
case 'artist': case 'artist':
$Article = "an"; $Article = 'an';
$Link = "artist.php?id=".$ID; $Link = "artist.php?id=$ID";
$DB->query("SELECT Name FROM artists_group WHERE ArtistID = '$ID'"); $DB->query("
SELECT Name
FROM artists_group
WHERE ArtistID = '$ID'");
break; break;
case 'collage': case 'collage':
$Link = "collages.php?id=".$ID; $Link = "collages.php?id=$ID";
$DB->query("SELECT Name FROM collages WHERE ID = '$ID'"); $DB->query("
SELECT Name
FROM collages
WHERE ID = '$ID'");
break; break;
} }
list($Name) = $DB->next_record(); list($Name) = $DB->next_record();
$Subject = $LoggedUser['Username'] . " recommended you $Article " . $Type . "!"; $Subject = $LoggedUser['Username'] . " recommended you $Article $Type!";
$Body = $LoggedUser['Username'] . " recommended you the ".$Type." [url=https://".SSL_SITE_URL."/$Link]$Name".'[/url].'; $Body = $LoggedUser['Username'] . " recommended you the $Type [url=https://".SSL_SITE_URL."/$Link]$Name".'[/url].';
if (!empty($Note)) { if (!empty($Note)) {
$Body = $Body . "\n\n". $Note; $Body = "$Body\n\n$Note";
} }
Misc::send_pm($FriendID, $LoggedUser['ID'], $Subject, $Body); Misc::send_pm($FriendID, $LoggedUser['ID'], $Subject, $Body);
echo json_encode(array("status" => "success", "response" => "Sent!")); echo json_encode(array('status' => 'success', 'response' => 'Sent!'));
die(); die();

View File

@ -5,7 +5,7 @@
function error_out($reason = '') { function error_out($reason = '') {
$error = array('status' => 'failure'); $error = array('status' => 'failure');
if ($reason != '') if ($reason !== '')
$error['reason'] = $reason; $error['reason'] = $reason;
print $error; print $error;
die(); die();
@ -41,11 +41,12 @@ function error_out($reason = '') {
$RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0)); $RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0));
$PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1)); $PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1));
} }
$ViewingOwn = ($UserID == $LoggedUser['ID']); $ViewingOwn = ($UserID === $LoggedUser['ID']);
$ShowUnread = ($ViewingOwn && (!isset($_GET['showunread']) || !!$_GET['showunread'])); $ShowUnread = ($ViewingOwn && (!isset($_GET['showunread']) || !!$_GET['showunread']));
$ShowGrouped = ($ViewingOwn && (!isset($_GET['group']) || !!$_GET['group'])); $ShowGrouped = ($ViewingOwn && (!isset($_GET['group']) || !!$_GET['group']));
if ($ShowGrouped) { if ($ShowGrouped) {
$sql = 'SELECT $sql = '
SELECT
SQL_CALC_FOUND_ROWS SQL_CALC_FOUND_ROWS
MAX(p.ID) AS ID MAX(p.ID) AS ID
FROM forums_posts AS p FROM forums_posts AS p
@ -73,17 +74,19 @@ function error_out($reason = '') {
AND ((t.IsLocked=\'0\' OR t.IsSticky=\'1\') AND ((t.IsLocked=\'0\' OR t.IsSticky=\'1\')
AND (l.PostID<t.LastPostID OR l.PostID IS NULL))'; AND (l.PostID<t.LastPostID OR l.PostID IS NULL))';
} }
$sql .= ' $sql .= "
GROUP BY t.ID GROUP BY t.ID
ORDER BY p.ID DESC LIMIT '.$Limit; ORDER BY p.ID DESC
LIMIT $Limit";
$PostIDs = $DB->query($sql); $PostIDs = $DB->query($sql);
$DB->query("SELECT FOUND_ROWS()"); $DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record(); list($Results) = $DB->next_record();
if ($Results > $PerPage * ($Page - 1)) { if ($Results > $PerPage * ($Page - 1)) {
$DB->set_query_id($PostIDs); $DB->set_query_id($PostIDs);
$PostIDs = $DB->collect('ID'); $PostIDs = $DB->collect('ID');
$sql = 'SELECT $sql = "
SELECT
p.ID, p.ID,
p.AddedTime, p.AddedTime,
p.Body, p.Body,
@ -102,16 +105,20 @@ function error_out($reason = '') {
LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID
JOIN forums_topics AS t ON t.ID = p.TopicID JOIN forums_topics AS t ON t.ID = p.TopicID
JOIN forums AS f ON f.ID = t.ForumID JOIN forums AS f ON f.ID = t.ForumID
LEFT JOIN forums_last_read_topics AS l ON l.UserID = '.$UserID.' AND l.TopicID = t.ID LEFT JOIN forums_last_read_topics AS l ON l.UserID = $UserID AND l.TopicID = t.ID
WHERE p.ID IN ('.implode(',',$PostIDs).') WHERE p.ID IN (".implode(',', $PostIDs).')
ORDER BY p.ID DESC'; ORDER BY p.ID DESC';
$Posts = $DB->query($sql); $Posts = $DB->query($sql);
} }
} else { } else {
$sql = 'SELECT $sql = '
SELECT
SQL_CALC_FOUND_ROWS'; SQL_CALC_FOUND_ROWS';
if ($ShowGrouped) { if ($ShowGrouped) {
$sql.=' * FROM (SELECT'; $sql .= '
*
FROM (
SELECT';
} }
$sql .= ' $sql .= '
p.ID, p.ID,
@ -123,11 +130,11 @@ function error_out($reason = '') {
p.TopicID, p.TopicID,
t.Title, t.Title,
t.LastPostID,'; t.LastPostID,';
if ($UserID == $LoggedUser['ID']) { if ($UserID === $LoggedUser['ID']) {
$sql .= ' $sql .= '
l.PostID AS LastRead,'; l.PostID AS LastRead,';
} }
$sql .= ' $sql .= "
t.IsLocked, t.IsLocked,
t.IsSticky t.IsSticky
FROM forums_posts as p FROM forums_posts as p
@ -136,40 +143,46 @@ function error_out($reason = '') {
LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID
JOIN forums_topics AS t ON t.ID = p.TopicID JOIN forums_topics AS t ON t.ID = p.TopicID
JOIN forums AS f ON f.ID = t.ForumID JOIN forums AS f ON f.ID = t.ForumID
LEFT JOIN forums_last_read_topics AS l ON l.UserID = '.$UserID.' AND l.TopicID = t.ID LEFT JOIN forums_last_read_topics AS l ON l.UserID = $UserID AND l.TopicID = t.ID
WHERE p.AuthorID = '.$UserID.' WHERE p.AuthorID = $UserID
AND ((f.MinClassRead <= '.$LoggedUser['Class']; AND ((f.MinClassRead <= ".$LoggedUser['Class'];
if (!empty($RestrictedForums)) { if (!empty($RestrictedForums)) {
$sql.=' $sql .= "
AND f.ID NOT IN (\''.$RestrictedForums.'\')'; AND f.ID NOT IN ('$RestrictedForums')";
} }
$sql .= ')'; $sql .= '
)';
if (!empty($PermittedForums)) { if (!empty($PermittedForums)) {
$sql.=' $sql .= "
OR f.ID IN (\''.$PermittedForums.'\')'; OR f.ID IN ('$PermittedForums')";
} }
$sql .= ')'; $sql .= '
)';
if ($ShowUnread) { if ($ShowUnread) {
$sql.=' $sql .= '
AND ((t.IsLocked=\'0\' OR t.IsSticky=\'1\') AND (l.PostID<t.LastPostID OR l.PostID IS NULL)) '; AND ((t.IsLocked = \'0\' OR t.IsSticky = \'1\')
AND (l.PostID < t.LastPostID OR l.PostID IS NULL)
) ';
} }
$sql .= ' $sql .= '
ORDER BY p.ID DESC'; ORDER BY p.ID DESC';
if ($ShowGrouped) { if ($ShowGrouped) {
$sql.=' $sql .= '
) AS sub ) AS sub
GROUP BY TopicID ORDER BY ID DESC'; GROUP BY TopicID
ORDER BY ID DESC';
} }
$sql.=' LIMIT '.$Limit; $sql .= "
LIMIT $Limit";
$Posts = $DB->query($sql); $Posts = $DB->query($sql);
$DB->query("SELECT FOUND_ROWS()"); $DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record(); list($Results) = $DB->next_record();
$DB->set_query_id($Posts); $DB->set_query_id($Posts);
@ -183,8 +196,8 @@ function error_out($reason = '') {
'threadTitle' => $ThreadTitle, 'threadTitle' => $ThreadTitle,
'lastPostId' => (int) $LastPostID, 'lastPostId' => (int) $LastPostID,
'lastRead' => (int) $LastRead, 'lastRead' => (int) $LastRead,
'locked' => $Locked == 1, 'locked' => $Locked === '1',
'sticky' => $Sticky == 1, 'sticky' => $Sticky === '1',
'addedTime' => $AddedTime, 'addedTime' => $AddedTime,
'body' => $Text->full_format($Body), 'body' => $Text->full_format($Body),
'bbbody' => $Body, 'bbbody' => $Body,
@ -199,7 +212,7 @@ function error_out($reason = '') {
'status' => 'success', 'status' => 'success',
'response' => array( 'response' => array(
'currentPage' => (int) $Page, 'currentPage' => (int) $Page,
'pages' => ceil($Results/$PerPage), 'pages' => ceil($Results / $PerPage),
'threads' => $JsonResults 'threads' => $JsonResults
) )
) )

View File

@ -43,7 +43,7 @@
if ($CloneRedirect != 0) { if ($CloneRedirect != 0) {
$DB->query(" $DB->query("
UPDATE artists_alias UPDATE artists_alias
SET ArtistID = '$ArtistID', Redirect=0 SET ArtistID = '$ArtistID', Redirect = 0
WHERE AliasID = '$CloneAliasID'"); WHERE AliasID = '$CloneAliasID'");
Misc::write_log("Redirection for the alias $CloneAliasID ($DBAliasName) for the artist $ArtistID was removed by user $LoggedUser[ID] ($LoggedUser[Username])"); Misc::write_log("Redirection for the alias $CloneAliasID ($DBAliasName) for the artist $ArtistID was removed by user $LoggedUser[ID] ($LoggedUser[Username])");
} else { } else {
@ -72,8 +72,10 @@
} }
} }
$DB->query(" $DB->query("
INSERT INTO artists_alias(ArtistID, Name, Redirect, UserID) INSERT INTO artists_alias
VALUES ($ArtistID, '$DBAliasName', $Redirect, ".$LoggedUser['ID'].')'); (ArtistID, Name, Redirect, UserID)
VALUES
($ArtistID, '$DBAliasName', $Redirect, ".$LoggedUser['ID'].')');
$AliasID = $DB->inserted_id(); $AliasID = $DB->inserted_id();
$DB->query(" $DB->query("
@ -82,7 +84,7 @@
WHERE ArtistID = $ArtistID"); WHERE ArtistID = $ArtistID");
list($ArtistName) = $DB->next_record(MYSQLI_NUM, false); list($ArtistName) = $DB->next_record(MYSQLI_NUM, false);
Misc::write_log("The alias $AliasID ($DBAliasName) was added to the artist $ArtistID (".db_string($ArtistName).") by user ".$LoggedUser['ID'].' ('.$LoggedUser['Username'].')'); Misc::write_log("The alias $AliasID ($DBAliasName) was added to the artist $ArtistID (".db_string($ArtistName).') by user '.$LoggedUser['ID'].' ('.$LoggedUser['Username'].')');
} }
header('Location: '.$_SERVER['HTTP_REFERER']); header('Location: '.$_SERVER['HTTP_REFERER']);
?> ?>

View File

@ -27,32 +27,34 @@
SQL template: SQL template:
SELECT SELECT
CASE CASE
WHEN t.Format='MP3' AND t.Encoding='V0 (VBR)' THEN 1 WHEN t.Format = 'MP3' AND t.Encoding = 'V0 (VBR)'
WHEN t.Format='MP3' AND t.Encoding='V2 (VBR)' THEN 2 THEN 1
WHEN t.Format = 'MP3' AND t.Encoding = 'V2 (VBR)'
THEN 2
ELSE 100 ELSE 100
END AS Rank, END AS Rank,
t.GroupID, t.GroupID,
t.Media, t.Media,
t.Format, t.Format,
t.Encoding, t.Encoding,
IF(t.Year=0,tg.Year,t.Year), IF(t.Year = 0, tg.Year, t.Year),
tg.Name, tg.Name,
a.Name, a.Name,
t.Size t.Size
FROM torrents AS t FROM torrents AS t
INNER JOIN torrents_group AS tg ON tg.ID=t.GroupID AND tg.CategoryID='1' INNER JOIN torrents_group AS tg ON tg.ID = t.GroupID AND tg.CategoryID = '1'
INNER JOIN artists_group AS a ON a.ArtistID=tg.ArtistID AND a.ArtistID='59721' INNER JOIN artists_group AS a ON a.ArtistID = tg.ArtistID AND a.ArtistID = '59721'
LEFT JOIN torrents_files AS f ON t.ID=f.TorrentID LEFT JOIN torrents_files AS f ON t.ID = f.TorrentID
ORDER BY t.GroupID ASC, Rank DESC, t.Seeders ASC ORDER BY t.GroupID ASC, Rank DESC, t.Seeders ASC
*/ */
if ( if (
!isset($_REQUEST['artistid']) || !isset($_REQUEST['artistid'])
!isset($_REQUEST['preference']) || || !isset($_REQUEST['preference'])
!is_number($_REQUEST['preference']) || || !is_number($_REQUEST['preference'])
!is_number($_REQUEST['artistid']) || || !is_number($_REQUEST['artistid'])
$_REQUEST['preference'] > 2 || || $_REQUEST['preference'] > 2
count($_REQUEST['list']) == 0 || count($_REQUEST['list']) == 0
) { ) {
error(0); error(0);
} }
@ -66,73 +68,84 @@
$ArtistID = $_REQUEST['artistid']; $ArtistID = $_REQUEST['artistid'];
$Preference = $Preferences[$_REQUEST['preference']]; $Preference = $Preferences[$_REQUEST['preference']];
$DB->query("SELECT Name FROM artists_group WHERE ArtistID='$ArtistID'"); $DB->query("
SELECT Name
FROM artists_group
WHERE ArtistID = '$ArtistID'");
list($ArtistName) = $DB->next_record(MYSQLI_NUM, false); list($ArtistName) = $DB->next_record(MYSQLI_NUM, false);
$DB->query("SELECT GroupID, Importance FROM torrents_artists WHERE ArtistID='$ArtistID'"); $DB->query("
SELECT GroupID, Importance
FROM torrents_artists
WHERE ArtistID = '$ArtistID'");
if (!$DB->has_results()) { if (!$DB->has_results()) {
error(404); error(404);
} }
$Releases = $DB->to_array('GroupID', MYSQLI_ASSOC, false); $Releases = $DB->to_array('GroupID', MYSQLI_ASSOC, false);
$GroupIDs = array_keys($Releases); $GroupIDs = array_keys($Releases);
$SQL = "SELECT CASE "; $SQL = 'SELECT CASE ';
foreach ($_REQUEST['list'] as $Priority => $Selection) { foreach ($_REQUEST['list'] as $Priority => $Selection) {
if (!is_number($Priority)) { if (!is_number($Priority)) {
continue; continue;
} }
$SQL .= "WHEN "; $SQL .= 'WHEN ';
switch ($Selection) { switch ($Selection) {
case '00': $SQL .= "t.Format='MP3' AND t.Encoding='V0 (VBR)'"; break; case '00': $SQL .= "t.Format = 'MP3' AND t.Encoding = 'V0 (VBR)'"; break;
case '01': $SQL .= "t.Format='MP3' AND t.Encoding='APX (VBR)'"; break; case '01': $SQL .= "t.Format = 'MP3' AND t.Encoding = 'APX (VBR)'"; break;
case '02': $SQL .= "t.Format='MP3' AND t.Encoding='256 (VBR)'"; break; case '02': $SQL .= "t.Format = 'MP3' AND t.Encoding = '256 (VBR)'"; break;
case '03': $SQL .= "t.Format='MP3' AND t.Encoding='V1 (VBR)'"; break; case '03': $SQL .= "t.Format = 'MP3' AND t.Encoding = 'V1 (VBR)'"; break;
case '10': $SQL .= "t.Format='MP3' AND t.Encoding='224 (VBR)'"; break; case '10': $SQL .= "t.Format = 'MP3' AND t.Encoding = '224 (VBR)'"; break;
case '11': $SQL .= "t.Format='MP3' AND t.Encoding='V2 (VBR)'"; break; case '11': $SQL .= "t.Format = 'MP3' AND t.Encoding = 'V2 (VBR)'"; break;
case '12': $SQL .= "t.Format='MP3' AND t.Encoding='APS (VBR)'"; break; case '12': $SQL .= "t.Format = 'MP3' AND t.Encoding = 'APS (VBR)'"; break;
case '13': $SQL .= "t.Format='MP3' AND t.Encoding='192 (VBR)'"; break; case '13': $SQL .= "t.Format = 'MP3' AND t.Encoding = '192 (VBR)'"; break;
case '20': $SQL .= "t.Format='MP3' AND t.Encoding='320'"; break; case '20': $SQL .= "t.Format = 'MP3' AND t.Encoding = '320'"; break;
case '21': $SQL .= "t.Format='MP3' AND t.Encoding='256'"; break; case '21': $SQL .= "t.Format = 'MP3' AND t.Encoding = '256'"; break;
case '22': $SQL .= "t.Format='MP3' AND t.Encoding='224'"; break; case '22': $SQL .= "t.Format = 'MP3' AND t.Encoding = '224'"; break;
case '23': $SQL .= "t.Format='MP3' AND t.Encoding='192'"; break; case '23': $SQL .= "t.Format = 'MP3' AND t.Encoding = '192'"; break;
case '30': $SQL .= "t.Format='FLAC' AND t.Encoding='24bit Lossless' AND t.Media='Vinyl'"; break; case '30': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'Vinyl'"; break;
case '31': $SQL .= "t.Format='FLAC' AND t.Encoding='24bit Lossless' AND t.Media='DVD'"; break; case '31': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'DVD'"; break;
case '32': $SQL .= "t.Format='FLAC' AND t.Encoding='24bit Lossless' AND t.Media='SACD'"; break; case '32': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'SACD'"; break;
case '33': $SQL .= "t.Format='FLAC' AND t.Encoding='24bit Lossless' AND t.Media='WEB'"; break; case '33': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'WEB'"; break;
case '34': $SQL .= "t.Format='FLAC' AND t.Encoding='Lossless' AND HasLog='1' AND LogScore='100' AND HasCue='1'"; break; case '34': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless' AND HasLog = '1' AND LogScore = '100' AND HasCue = '1'"; break;
case '35': $SQL .= "t.Format='FLAC' AND t.Encoding='Lossless' AND HasLog='1' AND LogScore='100'"; break; case '35': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless' AND HasLog = '1' AND LogScore = '100'"; break;
case '36': $SQL .= "t.Format='FLAC' AND t.Encoding='Lossless' AND HasLog='1'"; break; case '36': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless' AND HasLog = '1'"; break;
case '37': $SQL .= "t.Format='FLAC' AND t.Encoding='Lossless'"; break; case '37': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless'"; break;
case '40': $SQL .= "t.Format='DTS'"; break; case '40': $SQL .= "t.Format = 'DTS'"; break;
case '42': $SQL .= "t.Format='AAC' AND t.Encoding='320'"; break; case '42': $SQL .= "t.Format = 'AAC' AND t.Encoding = '320'"; break;
case '43': $SQL .= "t.Format='AAC' AND t.Encoding='256'"; break; case '43': $SQL .= "t.Format = 'AAC' AND t.Encoding = '256'"; break;
case '44': $SQL .= "t.Format='AAC' AND t.Encoding='q5.5'"; break; case '44': $SQL .= "t.Format = 'AAC' AND t.Encoding = 'q5.5'"; break;
case '45': $SQL .= "t.Format='AAC' AND t.Encoding='q5'"; break; case '45': $SQL .= "t.Format = 'AAC' AND t.Encoding = 'q5'"; break;
case '46': $SQL .= "t.Format='AAC' AND t.Encoding='192'"; break; case '46': $SQL .= "t.Format = 'AAC' AND t.Encoding = '192'"; break;
default: error(0); default: error(0);
} }
$SQL .= " THEN $Priority "; $SQL .= " THEN $Priority ";
} }
$SQL .= "ELSE 100 END AS Rank, $SQL .= "
t.GroupID, ELSE 100
t.ID AS TorrentID, END AS Rank,
t.Media, t.GroupID,
t.Format, t.ID AS TorrentID,
t.Encoding, t.Media,
tg.ReleaseType, t.Format,
IF(t.RemasterYear=0,tg.Year,t.RemasterYear) AS Year, t.Encoding,
tg.Name, tg.ReleaseType,
t.Size IF(t.RemasterYear = 0, tg.Year, t.RemasterYear) AS Year,
tg.Name,
t.Size
FROM torrents AS t FROM torrents AS t
JOIN torrents_group AS tg ON tg.ID=t.GroupID AND tg.CategoryID='1' AND tg.ID IN (".implode(',',$GroupIDs).") JOIN torrents_group AS tg ON tg.ID = t.GroupID AND tg.CategoryID = '1' AND tg.ID IN (".implode(',', $GroupIDs).")
ORDER BY t.GroupID ASC, Rank DESC, t.$Preference"; ORDER BY t.GroupID ASC, Rank DESC, t.$Preference";
$DownloadsQ = $DB->query($SQL); $DownloadsQ = $DB->query($SQL);
$Collector = new TorrentsDL($DownloadsQ, $ArtistName); $Collector = new TorrentsDL($DownloadsQ, $ArtistName);
while (list($Downloads, $GroupIDs) = $Collector->get_downloads('GroupID')) { while (list($Downloads, $GroupIDs) = $Collector->get_downloads('GroupID')) {
$Artists = Artists::get_artists($GroupIDs); $Artists = Artists::get_artists($GroupIDs);
$TorrentFilesQ = $DB->query("SELECT TorrentID, File FROM torrents_files WHERE TorrentID IN (".implode(',', array_keys($GroupIDs)).")", false); $TorrentFilesQ = $DB->query("
SELECT TorrentID, File
FROM torrents_files
WHERE TorrentID IN (".implode(',', array_keys($GroupIDs)).')', false);
if (is_int($TorrentFilesQ)) { if (is_int($TorrentFilesQ)) {
// Query failed. Let's not create a broken zip archive // Query failed. Let's not create a broken zip archive
foreach ($GroupIDs as $GroupID) { foreach ($GroupIDs as $GroupID) {
@ -153,9 +166,9 @@
if ($Releases[$GroupID]['Importance'] == 1) { if ($Releases[$GroupID]['Importance'] == 1) {
$ReleaseTypeName = $ReleaseTypes[$Download['ReleaseType']]; $ReleaseTypeName = $ReleaseTypes[$Download['ReleaseType']];
} else if ($Releases[$GroupID]['Importance'] == 2) { } else if ($Releases[$GroupID]['Importance'] == 2) {
$ReleaseTypeName = "Guest Appearance"; $ReleaseTypeName = 'Guest Appearance';
} else if ($Releases[$GroupID]['Importance'] == 3) { } else if ($Releases[$GroupID]['Importance'] == 3) {
$ReleaseTypeName = "Remixed By"; $ReleaseTypeName = 'Remixed By';
} }
$Collector->add_file($TorrentFile, $Download, $ReleaseTypeName); $Collector->add_file($TorrentFile, $Download, $ReleaseTypeName);
unset($Download); unset($Download);

View File

@ -9,21 +9,39 @@
} }
if (($Notify = $Cache->get_value('notify_artists_'.$LoggedUser['ID'])) === false) { if (($Notify = $Cache->get_value('notify_artists_'.$LoggedUser['ID'])) === false) {
$DB->query("SELECT ID, Artists FROM users_notify_filters WHERE Label='Artist notifications' AND UserID='$LoggedUser[ID]' ORDER BY ID LIMIT 1"); $DB->query("
SELECT ID, Artists
FROM users_notify_filters
WHERE Label = 'Artist notifications'
AND UserID = '$LoggedUser[ID]'
ORDER BY ID
LIMIT 1");
} else { } else {
$DB->query("SELECT ID, Artists FROM users_notify_filters WHERE ID='$Notify[ID]'"); $DB->query("
SELECT ID, Artists
FROM users_notify_filters
WHERE ID = '$Notify[ID]'");
} }
list($ID,$Artists) = $DB->next_record(MYSQLI_NUM, FALSE); list($ID, $Artists) = $DB->next_record(MYSQLI_NUM, false);
$DB->query("SELECT Name FROM artists_alias WHERE ArtistID = '$ArtistID' AND Redirect=0"); $DB->query("
while (list($Alias) = $DB->next_record(MYSQLI_NUM, FALSE)) { SELECT Name
while (stripos($Artists, '|'.$Alias.'|') !== false) { FROM artists_alias
$Artists = str_ireplace('|'.$Alias.'|', '|', $Artists); WHERE ArtistID = '$ArtistID'
AND Redirect = 0");
while (list($Alias) = $DB->next_record(MYSQLI_NUM, false)) {
while (stripos($Artists, "|$Alias|") !== false) {
$Artists = str_ireplace("|$Alias|", '|', $Artists);
} }
} }
if ($Artists == '|') { if ($Artists == '|') {
$DB->query("DELETE FROM users_notify_filters WHERE ID=$ID"); $DB->query("
DELETE FROM users_notify_filters
WHERE ID = $ID");
} else { } else {
$DB->query("UPDATE users_notify_filters SET Artists='".db_string($Artists)."' WHERE ID='$ID'"); $DB->query("
UPDATE users_notify_filters
SET Artists = '".db_string($Artists)."'
WHERE ID = '$ID'");
} }
$Cache->delete_value('notify_filters_'.$LoggedUser['ID']); $Cache->delete_value('notify_filters_'.$LoggedUser['ID']);
$Cache->delete_value('notify_artists_'.$LoggedUser['ID']); $Cache->delete_value('notify_artists_'.$LoggedUser['ID']);

View File

@ -1,4 +1,4 @@
<? <?php
/**************************************************************** /****************************************************************
*--------------[ Rename artist ]-----------------------------* *--------------[ Rename artist ]-----------------------------*
* This page handles the backend of the 'rename artist' * * This page handles the backend of the 'rename artist' *
@ -33,7 +33,10 @@
error(403); error(403);
} }
$DB->query("SELECT Name FROM artists_group WHERE ArtistID='$ArtistID'"); $DB->query("
SELECT Name
FROM artists_group
WHERE ArtistID = '$ArtistID'");
if (!$DB->has_results()) { if (!$DB->has_results()) {
error(404); error(404);
} }
@ -45,8 +48,8 @@
$DB->query(" $DB->query("
SELECT AliasID SELECT AliasID
FROM artists_alias FROM artists_alias
WHERE Name='".db_string($OldName)."' WHERE Name = '".db_string($OldName)."'
AND ArtistID='$ArtistID'"); AND ArtistID = '$ArtistID'");
list($OldAliasID) = $DB->next_record(MYSQLI_NUM, false); list($OldAliasID) = $DB->next_record(MYSQLI_NUM, false);
if (!$OldAliasID) { if (!$OldAliasID) {
error('Could not find old alias ID'); error('Could not find old alias ID');
@ -58,34 +61,58 @@
WHERE name LIKE '".db_string($NewName, true)."'"); WHERE name LIKE '".db_string($NewName, true)."'");
list($TargetAliasID, $TargetArtistID) = $DB->next_record(MYSQLI_NUM, false); list($TargetAliasID, $TargetArtistID) = $DB->next_record(MYSQLI_NUM, false);
if (!$TargetAliasID || $TargetAliasID==$OldAliasID) { if (!$TargetAliasID || $TargetAliasID == $OldAliasID) {
// no merge, just rename // no merge, just rename
$DB->query(" $DB->query("
INSERT INTO artists_alias (ArtistID, Name, Redirect, UserID) INSERT INTO artists_alias
VALUES ($ArtistID, '".db_string($NewName)."', '0', '$LoggedUser[ID]')"); (ArtistID, Name, Redirect, UserID)
VALUES
($ArtistID, '".db_string($NewName)."', '0', '$LoggedUser[ID]')");
$TargetAliasID = $DB->inserted_id(); $TargetAliasID = $DB->inserted_id();
$DB->query("UPDATE artists_alias SET Redirect='$TargetAliasID' WHERE AliasID='$OldAliasID'"); $DB->query("
$DB->query("UPDATE artists_group SET Name='".db_string($NewName)."' WHERE ArtistID='$ArtistID'"); UPDATE artists_alias
SET Redirect = '$TargetAliasID'
WHERE AliasID = '$OldAliasID'");
$DB->query("
UPDATE artists_group
SET Name = '".db_string($NewName)."'
WHERE ArtistID = '$ArtistID'");
$DB->query("SELECT GroupID FROM torrents_artists WHERE AliasID='$OldAliasID'"); $DB->query("
SELECT GroupID
FROM torrents_artists
WHERE AliasID = '$OldAliasID'");
$Groups = $DB->collect('GroupID'); $Groups = $DB->collect('GroupID');
$DB->query("UPDATE IGNORE torrents_artists SET AliasID='$TargetAliasID' WHERE AliasID='$OldAliasID'"); $DB->query("
$DB->query("DELETE FROM torrents_artists WHERE AliasID='$OldAliasID'"); UPDATE IGNORE torrents_artists
SET AliasID = '$TargetAliasID'
WHERE AliasID = '$OldAliasID'");
$DB->query("
DELETE FROM torrents_artists
WHERE AliasID = '$OldAliasID'");
if (!empty($Groups)) { if (!empty($Groups)) {
foreach ($Groups as $GroupID) { foreach ($Groups as $GroupID) {
$Cache->delete_value('groups_artists_'.$GroupID); // Delete group artist cache $Cache->delete_value("groups_artists_$GroupID"); // Delete group artist cache
Torrents::update_hash($GroupID); Torrents::update_hash($GroupID);
} }
} }
$DB->query("SELECT RequestID FROM requests_artists WHERE AliasID='$OldAliasID'"); $DB->query("
SELECT RequestID
FROM requests_artists
WHERE AliasID = '$OldAliasID'");
$Requests = $DB->collect('RequestID'); $Requests = $DB->collect('RequestID');
$DB->query("UPDATE IGNORE requests_artists SET AliasID='$TargetAliasID' WHERE AliasID='$OldAliasID'"); $DB->query("
$DB->query("DELETE FROM requests_artists WHERE AliasID='$OldAliasID'"); UPDATE IGNORE requests_artists
SET AliasID = '$TargetAliasID'
WHERE AliasID = '$OldAliasID'");
$DB->query("
DELETE FROM requests_artists
WHERE AliasID = '$OldAliasID'");
if (!empty($Requests)) { if (!empty($Requests)) {
foreach ($Requests as $RequestID) { foreach ($Requests as $RequestID) {
$Cache->delete_value('request_artists_'.$RequestID); // Delete request artist cache $Cache->delete_value("request_artists_$RequestID"); // Delete request artist cache
Requests::update_sphinx_requests($RequestID); Requests::update_sphinx_requests($RequestID);
} }
} }
@ -94,69 +121,100 @@
} else { // Merge stuff } else { // Merge stuff
$DB->query(" $DB->query("
UPDATE artists_alias UPDATE artists_alias
SET Redirect='$TargetAliasID', ArtistID='$TargetArtistID' SET Redirect = '$TargetAliasID', ArtistID = '$TargetArtistID'
WHERE AliasID='$OldAliasID'"); WHERE AliasID = '$OldAliasID'");
$DB->query("UPDATE artists_alias SET Redirect='0' WHERE AliasID='$TargetAliasID'"); $DB->query("
UPDATE artists_alias
SET Redirect = '0'
WHERE AliasID = '$TargetAliasID'");
if ($ArtistID != $TargetArtistID) { if ($ArtistID != $TargetArtistID) {
$DB->query("UPDATE artists_alias SET ArtistID='$TargetArtistID' WHERE ArtistID='$ArtistID'"); $DB->query("
$DB->query("DELETE FROM artists_group WHERE ArtistID='$ArtistID'"); UPDATE artists_alias
SET ArtistID = '$TargetArtistID'
WHERE ArtistID = '$ArtistID'");
$DB->query("
DELETE FROM artists_group
WHERE ArtistID = '$ArtistID'");
} else { } else {
$DB->query("UPDATE artists_group SET Name='".db_string($NewName)."' WHERE ArtistID='$ArtistID'"); $DB->query("
UPDATE artists_group
SET Name = '".db_string($NewName)."'
WHERE ArtistID = '$ArtistID'");
} }
$DB->query("SELECT GroupID FROM torrents_artists WHERE AliasID='$OldAliasID'"); $DB->query("
SELECT GroupID
FROM torrents_artists
WHERE AliasID = '$OldAliasID'");
$Groups = $DB->collect('GroupID'); $Groups = $DB->collect('GroupID');
$DB->query(" $DB->query("
UPDATE IGNORE torrents_artists UPDATE IGNORE torrents_artists
SET AliasID='$TargetAliasID', ArtistID='$TargetArtistID' SET AliasID = '$TargetAliasID', ArtistID = '$TargetArtistID'
WHERE AliasID='$OldAliasID'"); WHERE AliasID = '$OldAliasID'");
$DB->query("DELETE FROM torrents_artists WHERE AliasID='$OldAliasID'"); $DB->query("
DELETE FROM torrents_artists
WHERE AliasID = '$OldAliasID'");
if (!empty($Groups)) { if (!empty($Groups)) {
foreach ($Groups as $GroupID) { foreach ($Groups as $GroupID) {
$Cache->delete_value('groups_artists_'.$GroupID); $Cache->delete_value("groups_artists_$GroupID");
Torrents::update_hash($GroupID); Torrents::update_hash($GroupID);
} }
} }
$DB->query("SELECT RequestID FROM requests_artists WHERE AliasID='$OldAliasID'"); $DB->query("
SELECT RequestID
FROM requests_artists
WHERE AliasID = '$OldAliasID'");
$Requests = $DB->collect('RequestID'); $Requests = $DB->collect('RequestID');
$DB->query(" $DB->query("
UPDATE IGNORE requests_artists UPDATE IGNORE requests_artists
SET AliasID='$TargetAliasID', ArtistID='$TargetArtistID' SET AliasID = '$TargetAliasID', ArtistID = '$TargetArtistID'
WHERE AliasID='$OldAliasID'"); WHERE AliasID = '$OldAliasID'");
$DB->query("DELETE FROM requests_artists WHERE AliasID='$OldAliasID'"); $DB->query("
DELETE FROM requests_artists
WHERE AliasID = '$OldAliasID'");
if (!empty($Requests)) { if (!empty($Requests)) {
foreach ($Requests as $RequestID) { foreach ($Requests as $RequestID) {
$Cache->delete_value('request_artists_'.$RequestID); $Cache->delete_value("request_artists_$RequestID");
Requests::update_sphinx_requests($RequestID); Requests::update_sphinx_requests($RequestID);
} }
} }
if ($ArtistID != $TargetArtistID) { if ($ArtistID != $TargetArtistID) {
$DB->query("SELECT GroupID FROM torrents_artists WHERE ArtistID='$ArtistID'"); $DB->query("
SELECT GroupID
FROM torrents_artists
WHERE ArtistID = '$ArtistID'");
$Groups = $DB->collect('GroupID'); $Groups = $DB->collect('GroupID');
$DB->query(" $DB->query("
UPDATE IGNORE torrents_artists UPDATE IGNORE torrents_artists
SET ArtistID='$TargetArtistID' SET ArtistID = '$TargetArtistID'
WHERE ArtistID='$ArtistID'"); WHERE ArtistID = '$ArtistID'");
$DB->query("DELETE FROM torrents_artists WHERE ArtistID='$ArtistID'"); $DB->query("
DELETE FROM torrents_artists
WHERE ArtistID = '$ArtistID'");
if (!empty($Groups)) { if (!empty($Groups)) {
foreach ($Groups as $GroupID) { foreach ($Groups as $GroupID) {
$Cache->delete_value('groups_artists_'.$GroupID); $Cache->delete_value("groups_artists_$GroupID");
Torrents::update_hash($GroupID); Torrents::update_hash($GroupID);
} }
} }
$DB->query("SELECT RequestID FROM requests_artists WHERE ArtistID='$ArtistID'"); $DB->query("
SELECT RequestID
FROM requests_artists
WHERE ArtistID = '$ArtistID'");
$Requests = $DB->collect('RequestID'); $Requests = $DB->collect('RequestID');
$DB->query(" $DB->query("
UPDATE IGNORE requests_artists UPDATE IGNORE requests_artists
SET ArtistID='$TargetArtistID' SET ArtistID = '$TargetArtistID'
WHERE ArtistID='$ArtistID'"); WHERE ArtistID = '$ArtistID'");
$DB->query("DELETE FROM requests_artists WHERE ArtistID='$ArtistID'"); $DB->query("
DELETE FROM requests_artists
WHERE ArtistID = '$ArtistID'");
if (!empty($Requests)) { if (!empty($Requests)) {
foreach ($Requests as $RequestID) { foreach ($Requests as $RequestID) {
$Cache->delete_value('request_artists_'.$RequestID); $Cache->delete_value("request_artists_$RequestID");
Requests::update_sphinx_requests($RequestID); Requests::update_sphinx_requests($RequestID);
} }
} }
@ -164,16 +222,19 @@
} }
// Clear torrent caches // Clear torrent caches
$DB->query("SELECT GroupID FROM torrents_artists WHERE ArtistID='$ArtistID'"); $DB->query("
SELECT GroupID
FROM torrents_artists
WHERE ArtistID = '$ArtistID'");
while (list($GroupID) = $DB->next_record()) { while (list($GroupID) = $DB->next_record()) {
$Cache->delete_value('torrents_details_'.$GroupID); $Cache->delete_value("torrents_details_$GroupID");
} }
$Cache->delete_value('artist_'.$ArtistID); $Cache->delete_value("artist_$ArtistID");
$Cache->delete_value('artist_'.$TargetArtistID); $Cache->delete_value("artist_$TargetArtistID");
$Cache->delete_value('artists_requests_'.$TargetArtistID); $Cache->delete_value("artists_requests_$TargetArtistID");
$Cache->delete_value('artists_requests_'.$ArtistID); $Cache->delete_value("artists_requests_$ArtistID");
header('Location: artist.php?id='.$TargetArtistID); header("Location: artist.php?id=$TargetArtistID");
?> ?>

View File

@ -5,32 +5,35 @@
error(403); error(403);
} }
$UserID = $_GET['userid']; $UserID = $_GET['userid'];
$Sneaky = ($UserID != $LoggedUser['ID']); $Sneaky = ($UserID !== $LoggedUser['ID']);
if (!is_number($UserID)) { if (!is_number($UserID)) {
error(404); error(404);
} }
$DB->query("SELECT Username FROM users_main WHERE ID='$UserID'"); $DB->query("
SELECT Username
FROM users_main
WHERE ID = '$UserID'");
list($Username) = $DB->next_record(); list($Username) = $DB->next_record();
} else { } else {
$UserID = $LoggedUser['ID']; $UserID = $LoggedUser['ID'];
} }
$Sneaky = ($UserID != $LoggedUser['ID']); $Sneaky = ($UserID !== $LoggedUser['ID']);
//$ArtistList = Bookmarks::all_bookmarks('artist', $UserID); //$ArtistList = Bookmarks::all_bookmarks('artist', $UserID);
$DB->query(' $DB->query("
SELECT ag.ArtistID, ag.Name SELECT ag.ArtistID, ag.Name
FROM bookmarks_artists AS ba FROM bookmarks_artists AS ba
INNER JOIN artists_group AS ag ON ba.ArtistID = ag.ArtistID INNER JOIN artists_group AS ag ON ba.ArtistID = ag.ArtistID
WHERE ba.UserID = '.$UserID.' WHERE ba.UserID = $UserID
ORDER BY ag.Name'); ORDER BY ag.Name");
$ArtistList = $DB->to_array(); $ArtistList = $DB->to_array();
$Title = ($Sneaky) ? "$Username's bookmarked artists" : 'Your bookmarked artists'; $Title = ($Sneaky) ? "$Username's bookmarked artists" : 'Your bookmarked artists';
View::show_header($Title,'browse'); View::show_header($Title, 'browse');
?> ?>
<div class="thin"> <div class="thin">
@ -59,7 +62,7 @@
<? <?
$Row = 'a'; $Row = 'a';
foreach ($ArtistList as $Artist) { foreach ($ArtistList as $Artist) {
$Row = ($Row == 'a') ? 'b' : 'a'; $Row = ($Row === 'a') ? 'b' : 'a';
list($ArtistID, $Name) = $Artist; list($ArtistID, $Name) = $Artist;
?> ?>
<tr class="row<?=$Row?> bookmark_<?=$ArtistID?>"> <tr class="row<?=$Row?> bookmark_<?=$ArtistID?>">
@ -72,13 +75,13 @@
$DB->query(" $DB->query("
SELECT ID, Artists SELECT ID, Artists
FROM users_notify_filters FROM users_notify_filters
WHERE UserID='$LoggedUser[ID]' WHERE UserID = '$LoggedUser[ID]'
AND Label='Artist notifications' AND Label = 'Artist notifications'
LIMIT 1"); LIMIT 1");
$Notify = $DB->next_record(MYSQLI_ASSOC); $Notify = $DB->next_record(MYSQLI_ASSOC);
$Cache->cache_value('notify_artists_'.$LoggedUser['ID'], $Notify, 0); $Cache->cache_value('notify_artists_'.$LoggedUser['ID'], $Notify, 0);
} }
if (stripos($Notify['Artists'], '|'.$Name.'|') === false) { if (stripos($Notify['Artists'], "|$Name|") === false) {
?> ?>
<a href="artist.php?action=notify&amp;artistid=<?=$ArtistID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Notify of new uploads</a> <a href="artist.php?action=notify&amp;artistid=<?=$ArtistID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Notify of new uploads</a>
<? <?
@ -89,7 +92,7 @@
} }
} }
?> ?>
<a href="#" id="bookmarklink_artist_<?=$ArtistID?>" onclick="Unbookmark('artist', <?=$ArtistID?>,'Bookmark');return false;" class="brackets">Remove bookmark</a> <a href="#" id="bookmarklink_artist_<?=$ArtistID?>" onclick="Unbookmark('artist', <?=$ArtistID?>, 'Bookmark'); return false;" class="brackets">Remove bookmark</a>
</span> </span>
</td> </td>
</tr> </tr>

View File

@ -8,7 +8,10 @@
if (!is_number($UserID)) { if (!is_number($UserID)) {
error(404); error(404);
} }
$DB->query("SELECT Username FROM users_main WHERE ID='$UserID'"); $DB->query("
SELECT Username
FROM users_main
WHERE ID = '$UserID'");
list($Username) = $DB->next_record(); list($Username) = $DB->next_record();
} else { } else {
$UserID = $LoggedUser['ID']; $UserID = $LoggedUser['ID'];

View File

@ -24,10 +24,22 @@
case 'remove_snatched': case 'remove_snatched':
authorize(); authorize();
$DB->query("CREATE TEMPORARY TABLE snatched_groups_temp (GroupID int PRIMARY KEY)"); $DB->query("
$DB->query("INSERT INTO snatched_groups_temp SELECT DISTINCT GroupID FROM torrents AS t JOIN xbt_snatched AS s ON s.fid=t.ID WHERE s.uid='$LoggedUser[ID]'"); CREATE TEMPORARY TABLE snatched_groups_temp
$DB->query("DELETE b FROM bookmarks_torrents AS b JOIN snatched_groups_temp AS s USING(GroupID) WHERE b.UserID='$LoggedUser[ID]'"); (GroupID int PRIMARY KEY)");
$Cache->delete_value('bookmarks_group_ids_' . $UserID); $DB->query("
INSERT INTO snatched_groups_temp
SELECT DISTINCT GroupID
FROM torrents AS t
JOIN xbt_snatched AS s ON s.fid = t.ID
WHERE s.uid = '$LoggedUser[ID]'");
$DB->query("
DELETE b
FROM bookmarks_torrents AS b
JOIN snatched_groups_temp AS s
USING(GroupID)
WHERE b.UserID = '$LoggedUser[ID]'");
$Cache->delete_value("bookmarks_group_ids_$UserID");
header('Location: bookmarks.php'); header('Location: bookmarks.php');
die(); die();
break; break;
@ -40,11 +52,11 @@
case 'torrents': case 'torrents':
require(SERVER_ROOT.'/sections/bookmarks/edit_torrents.php'); require(SERVER_ROOT.'/sections/bookmarks/edit_torrents.php');
break; break;
default : error(404); default:
error(404);
} }
break; break;
case 'view': case 'view':
if (empty($_REQUEST['type'])) { if (empty($_REQUEST['type'])) {
$_REQUEST['type'] = 'torrents'; $_REQUEST['type'] = 'torrents';
@ -57,7 +69,7 @@
require(SERVER_ROOT.'/sections/bookmarks/artists.php'); require(SERVER_ROOT.'/sections/bookmarks/artists.php');
break; break;
case 'collages': case 'collages':
$_GET['bookmarks'] = 1; $_GET['bookmarks'] = '1';
require(SERVER_ROOT.'/sections/collages/browse.php'); require(SERVER_ROOT.'/sections/collages/browse.php');
break; break;
case 'requests': case 'requests':
@ -68,6 +80,7 @@
error(404); error(404);
} }
break; break;
default: default:
error(404); error(404);
} }

View File

@ -1,4 +1,4 @@
<? <?php
authorize(); authorize();
if (!Bookmarks::can_bookmark($_GET['type'])) { if (!Bookmarks::can_bookmark($_GET['type'])) {
@ -15,14 +15,17 @@
$DB->query(" $DB->query("
DELETE FROM $Table DELETE FROM $Table
WHERE UserID='".$LoggedUser['ID']."' WHERE UserID = '".$LoggedUser['ID']."'
AND $Col='".db_string($_GET['id'])."'"); AND $Col = '".db_string($_GET['id'])."'");
$Cache->delete_value('bookmarks_'.$Type.'_'.$UserID); $Cache->delete_value("bookmarks_$Type"."_$UserID");
if ($Type === 'torrent') { if ($Type === 'torrent') {
$Cache->delete_value('bookmarks_group_ids_' . $UserID); $Cache->delete_value("bookmarks_group_ids_$UserID");
} elseif ($Type === 'request') { } elseif ($Type === 'request') {
$DB->query("SELECT UserID FROM $Table WHERE $Col='".db_string($_GET['id'])."'"); $DB->query("
SELECT UserID
FROM $Table
WHERE $Col = '".db_string($_GET['id'])."'");
$Bookmarkers = $DB->collect('UserID'); $Bookmarkers = $DB->collect('UserID');
$SS->UpdateAttributes('requests requests_delta', array('bookmarker'), array($_GET['id'] => array($Bookmarkers)), true); $SS->UpdateAttributes('requests requests_delta', array('bookmarker'), array($_GET['id'] => array($Bookmarkers)), true);
} }

View File

@ -1,5 +1,5 @@
<? <?php
ini_set('max_execution_time',600); ini_set('max_execution_time', 600);
set_time_limit(0); set_time_limit(0);
//~~~~~~~~~~~ Main bookmarks page ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// //~~~~~~~~~~~ Main bookmarks page ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
@ -16,13 +16,16 @@ function compare($X, $Y) {
if (!is_number($UserID)) { if (!is_number($UserID)) {
error(404); error(404);
} }
$DB->query("SELECT Username FROM users_main WHERE ID='$UserID'"); $DB->query("
SELECT Username
FROM users_main
WHERE ID = '$UserID'");
list($Username) = $DB->next_record(); list($Username) = $DB->next_record();
} else { } else {
$UserID = $LoggedUser['ID']; $UserID = $LoggedUser['ID'];
} }
$Sneaky = $UserID != $LoggedUser['ID']; $Sneaky = $UserID !== $LoggedUser['ID'];
$Title = $Sneaky ? "$Username's bookmarked torrents" : 'Your bookmarked torrents'; $Title = $Sneaky ? "$Username's bookmarked torrents" : 'Your bookmarked torrents';
// Loop through the result set, building up $Collage and $TorrentTable // Loop through the result set, building up $Collage and $TorrentTable
@ -44,7 +47,7 @@ function compare($X, $Y) {
if ($Artists) { if ($Artists) {
foreach ($Artists as $Artist) { foreach ($Artists as $Artist) {
if (!isset($ArtistCount[$Artist['id']])) { if (!isset($ArtistCount[$Artist['id']])) {
$ArtistCount[$Artist['id']] = array('name'=>$Artist['name'], 'count'=>1); $ArtistCount[$Artist['id']] = array('name' => $Artist['name'], 'count' => 1);
} else { } else {
$ArtistCount[$Artist['id']]['count']++; $ArtistCount[$Artist['id']]['count']++;
} }
@ -58,13 +61,13 @@ function compare($X, $Y) {
unset($ExtendedArtists[3]); unset($ExtendedArtists[3]);
$DisplayName = Artists::display_artists($ExtendedArtists); $DisplayName = Artists::display_artists($ExtendedArtists);
} elseif (count($Artists) > 0) { } elseif (count($Artists) > 0) {
$DisplayName = Artists::display_artists(array('1'=>$Artists)); $DisplayName = Artists::display_artists(array('1' => $Artists));
} else { } else {
$DisplayName = ''; $DisplayName = '';
} }
$DisplayName .= '<a href="torrents.php?id='.$GroupID.'" title="View Torrent" dir="ltr">'.$GroupName.'</a>'; $DisplayName .= '<a href="torrents.php?id='.$GroupID.'" title="View Torrent" dir="ltr">'.$GroupName.'</a>';
if ($GroupYear > 0) { if ($GroupYear > 0) {
$DisplayName = $DisplayName . " [$GroupYear]"; $DisplayName = "$DisplayName [$GroupYear]";
} }
if ($GroupVanityHouse) { if ($GroupVanityHouse) {
$DisplayName .= ' [<abbr title="This is a Vanity House release">VH</abbr>]'; $DisplayName .= ' [<abbr title="This is a Vanity House release">VH</abbr>]';
@ -75,12 +78,12 @@ function compare($X, $Y) {
ob_start(); ob_start();
if (count($Torrents) > 1 || $GroupCategoryID == 1) { if (count($Torrents) > 1 || $GroupCategoryID == 1) {
// Grouped torrents // Grouped torrents
$ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1); $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1);
?> ?>
<tr class="group discog<?=$SnatchedGroupClass?>" id="group_<?=$GroupID?>"> <tr class="group discog<?=$SnatchedGroupClass?>" id="group_<?=$GroupID?>">
<td class="center"> <td class="center">
<div title="View" id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents"> <div title="View" id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
<a href="#" class="show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event)" title="Collapse this group. Hold &quot;Ctrl&quot; while clicking to collape all groups on this page."></a> <a href="#" class="show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event);" title="Collapse this group. Hold &quot;Ctrl&quot; while clicking to collape all groups on this page."></a>
</div> </div>
</td> </td>
<td class="center"> <td class="center">
@ -115,12 +118,17 @@ function compare($X, $Y) {
} }
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : ''; $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
if ($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear || if (
$Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber || $FirstUnknown || $Torrent['Media'] != $LastMedia) { $Torrent['RemasterTitle'] != $LastRemasterTitle
|| $Torrent['RemasterYear'] != $LastRemasterYear
|| $Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel
|| $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber
|| $FirstUnknown
|| $Torrent['Media'] != $LastMedia
) {
$EditionID++; $EditionID++;
?> ?>
<tr class="group_torrent groupid_<?=$GroupID?> edition<?=$SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1 ? ' hidden' : '')?>"> <tr class="group_torrent groupid_<?=$GroupID?> edition<?=$SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1 ? ' hidden' : '')?>">
<td colspan="7" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?=$GroupID?>, <?=$EditionID?>, this, event)" title="Collapse this edition. Hold &quot;Ctrl&quot; while clicking to collapse all editions in this torrent group.">&minus;</a> <?=Torrents::edition_string($Torrent, $Group)?></strong></td> <td colspan="7" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?=$GroupID?>, <?=$EditionID?>, this, event)" title="Collapse this edition. Hold &quot;Ctrl&quot; while clicking to collapse all editions in this torrent group.">&minus;</a> <?=Torrents::edition_string($Torrent, $Group)?></strong></td>
</tr> </tr>
<? <?
@ -131,7 +139,7 @@ function compare($X, $Y) {
$LastRemasterCatalogueNumber = $Torrent['RemasterCatalogueNumber']; $LastRemasterCatalogueNumber = $Torrent['RemasterCatalogueNumber'];
$LastMedia = $Torrent['Media']; $LastMedia = $Torrent['Media'];
?> ?>
<tr class="group_torrent torrent_row groupid_<?=$GroupID?> edition_<?=$EditionID?><?=$SnatchedTorrentClass . $SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1 ? ' hidden' : '')?>"> <tr class="group_torrent torrent_row groupid_<?=$GroupID?> edition_<?=$EditionID?><?=$SnatchedTorrentClass . $SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1 ? ' hidden' : '')?>">
<td colspan="3"> <td colspan="3">
<span>[ <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a> <span>[ <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
<? if (Torrents::can_use_token($Torrent)) { ?> <? if (Torrents::can_use_token($Torrent)) { ?>
@ -158,9 +166,9 @@ function compare($X, $Y) {
if ($Torrent['IsSnatched']) { if ($Torrent['IsSnatched']) {
$DisplayName .= ' ' . Format::torrent_label('Snatched!'); $DisplayName .= ' ' . Format::torrent_label('Snatched!');
} }
if ($Torrent['FreeTorrent'] == '1') { if ($Torrent['FreeTorrent'] === '1') {
$DisplayName .= ' ' . Format::torrent_label('Freeleech!'); $DisplayName .= ' ' . Format::torrent_label('Freeleech!');
} elseif ($Torrent['FreeTorrent'] == '2') { } elseif ($Torrent['FreeTorrent'] === '2') {
$DisplayName .= ' ' . Format::torrent_label('Neutral leech!'); $DisplayName .= ' ' . Format::torrent_label('Neutral leech!');
} elseif ($Torrent['PersonalFL']) { } elseif ($Torrent['PersonalFL']) {
$DisplayName .= ' ' . Format::torrent_label('Personal Freeleech!'); $DisplayName .= ' ' . Format::torrent_label('Personal Freeleech!');
@ -196,7 +204,7 @@ function compare($X, $Y) {
</tr> </tr>
<? <?
} }
$TorrentTable.= ob_get_clean(); $TorrentTable .= ob_get_clean();
// Album art // Album art
@ -208,11 +216,11 @@ function compare($X, $Y) {
unset($ExtendedArtists[3]); unset($ExtendedArtists[3]);
$DisplayName .= Artists::display_artists($ExtendedArtists, false); $DisplayName .= Artists::display_artists($ExtendedArtists, false);
} elseif (count($Artists) > 0) { } elseif (count($Artists) > 0) {
$DisplayName .= Artists::display_artists(array('1'=>$Artists), false); $DisplayName .= Artists::display_artists(array('1' => $Artists), false);
} }
$DisplayName .= $GroupName; $DisplayName .= $GroupName;
if ($GroupYear > 0) { if ($GroupYear > 0) {
$DisplayName = $DisplayName . " [$GroupYear]"; $DisplayName = "$DisplayName [$GroupYear]";
} }
?> ?>
<li class="image_group_<?=$GroupID?>"> <li class="image_group_<?=$GroupID?>">
@ -229,7 +237,7 @@ function compare($X, $Y) {
} }
$CollageCovers = isset($LoggedUser['CollageCovers']) ? $LoggedUser['CollageCovers'] : 25; $CollageCovers = isset($LoggedUser['CollageCovers']) ? (int)$LoggedUser['CollageCovers'] : 25;
$CollagePages = array(); $CollagePages = array();
for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) { for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) {
$Groups = array_slice($Collage, $i * $CollageCovers, $CollageCovers); $Groups = array_slice($Collage, $i * $CollageCovers, $CollageCovers);
@ -257,7 +265,7 @@ function compare($X, $Y) {
<? } ?> <? } ?>
</div> </div>
</div> </div>
<? if (count($TorrentList) == 0) { ?> <? if (count($TorrentList) === 0) { ?>
<div class="box pad" align="center"> <div class="box pad" align="center">
<h2>You have not bookmarked any torrents.</h2> <h2>You have not bookmarked any torrents.</h2>
</div> </div>
@ -271,7 +279,9 @@ function compare($X, $Y) {
<div class="head"><strong>Stats</strong></div> <div class="head"><strong>Stats</strong></div>
<ul class="stats nobullet"> <ul class="stats nobullet">
<li>Torrents: <?=$NumGroups?></li> <li>Torrents: <?=$NumGroups?></li>
<? if (count($ArtistCount) > 0) { ?> <li>Artists: <?=count($ArtistCount)?></li> <? } ?> <? if (count($ArtistCount) > 0) { ?>
<li>Artists: <?=count($ArtistCount)?></li>
<? } ?>
</ul> </ul>
</div> </div>
<div class="box box_tags"> <div class="box box_tags">
@ -305,7 +315,7 @@ function compare($X, $Y) {
</div> </div>
<div class="main_column"> <div class="main_column">
<? <?
if ($CollageCovers != 0) { ?> if ($CollageCovers !== 0) { ?>
<div id="coverart" class="box"> <div id="coverart" class="box">
<div class="head" id="coverhead"><strong>Cover art</strong></div> <div class="head" id="coverhead"><strong>Cover art</strong></div>
<ul class="collage_images" id="collage_page0"> <ul class="collage_images" id="collage_page0">
@ -321,11 +331,11 @@ function compare($X, $Y) {
<span id="firstpage" class="invisible"><a href="#" class="pageslink" onclick="collageShow.page(0, this); return false;">&lt;&lt; First</a> | </span> <span id="firstpage" class="invisible"><a href="#" class="pageslink" onclick="collageShow.page(0, this); return false;">&lt;&lt; First</a> | </span>
<span id="prevpage" class="invisible"><a href="#" id="prevpage" class="pageslink" onclick="collageShow.prevPage(); return false;">&lt; Prev</a> | </span> <span id="prevpage" class="invisible"><a href="#" id="prevpage" class="pageslink" onclick="collageShow.prevPage(); return false;">&lt; Prev</a> | </span>
<? for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) { ?> <? for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) { ?>
<span id="pagelink<?=$i?>" class="<?=(($i > 4) ? 'hidden' : '')?><?=(($i == 0) ? ' selected' : '')?>"><a href="#" class="pageslink" onclick="collageShow.page(<?=$i?>, this); return false;"><?=($CollageCovers * $i + 1)?>-<?=min($NumGroups, $CollageCovers * ($i + 1))?></a><?=(($i != ceil($NumGroups / $CollageCovers) - 1) ? ' | ' : '')?></span> <span id="pagelink<?=$i?>" class="<?=(($i > 4) ? 'hidden' : '')?><?=(($i === 0) ? ' selected' : '')?>"><a href="#" class="pageslink" onclick="collageShow.page(<?=$i?>, this); return false;"><?=($CollageCovers * $i + 1)?>-<?=min($NumGroups, $CollageCovers * ($i + 1))?></a><?=(($i !== ceil($NumGroups / $CollageCovers) - 1) ? ' | ' : '')?></span>
<? } ?> <? } ?>
<span id="nextbar" class="<?=(($NumGroups / $CollageCovers > 5) ? 'hidden' : '')?>"> | </span> <span id="nextbar" class="<?=(($NumGroups / $CollageCovers > 5) ? 'hidden' : '')?>"> | </span>
<span id="nextpage"><a href="#" class="pageslink" onclick="collageShow.nextPage(); return false;">Next &gt;</a></span> <span id="nextpage"><a href="#" class="pageslink" onclick="collageShow.nextPage(); return false;">Next &gt;</a></span>
<span id="lastpage" class="<?=(ceil($NumGroups / $CollageCovers) == 2 ? 'invisible' : '')?>"> | <a href="#" id="lastpage" class="pageslink" onclick="collageShow.page(<?=(ceil($NumGroups / $CollageCovers) - 1)?>, this); return false;">Last &gt;&gt;</a></span> <span id="lastpage" class="<?=(ceil($NumGroups / $CollageCovers) === 2 ? 'invisible' : '')?>"> | <a href="#" id="lastpage" class="pageslink" onclick="collageShow.page(<?=(ceil($NumGroups / $CollageCovers) - 1)?>, this); return false;">Last &gt;&gt;</a></span>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
collageShow.init(<?=json_encode($CollagePages)?>); collageShow.init(<?=json_encode($CollagePages)?>);

View File

@ -23,7 +23,11 @@
$NumComments = Collages::get_comment_count($CollageID); $NumComments = Collages::get_comment_count($CollageID);
if (isset($_GET['postid']) && is_number($_GET['postid']) && $NumComments > TORRENT_COMMENTS_PER_PAGE) { 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]"); $DB->query("
SELECT COUNT(ID)
FROM collages_comments
WHERE CollageID = $CollageID
AND ID <= $_GET[postid]");
list($PostNum) = $DB->next_record(); list($PostNum) = $DB->next_record();
list($Page, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $PostNum); list($Page, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $PostNum);
} else { } else {
@ -42,11 +46,14 @@
//This is a hybrid to reduce the catalogue down to the page elements: We use the page limit % catalogue //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); $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'"); $DB->query("
SELECT Name
FROM collages
WHERE ID = '$CollageID'");
list($Name) = $DB->next_record(); list($Name) = $DB->next_record();
// Start printing // Start printing
View::show_header('Comments for collage '.$Name, 'comments,bbcode'); View::show_header("Comments for collage $Name", 'comments,bbcode');
?> ?>
<div class="thin"> <div class="thin">
<div class="header"> <div class="header">
@ -80,7 +87,7 @@
<span style="float: left;"><a href="#post<?=$PostID?>">#<?=$PostID?></a> <span style="float: left;"><a href="#post<?=$PostID?>">#<?=$PostID?></a>
<?=Users::format_username($AuthorID, true, true, true, true, true)?> <?=time_diff($AddedTime)?> <?=Users::format_username($AuthorID, true, true, true, true, true)?> <?=time_diff($AddedTime)?>
<? if (!$ThreadInfo['IsLocked']) { ?> - <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$Username?>');" class="brackets">Quote</a><? } <? if (!$ThreadInfo['IsLocked']) { ?> - <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$Username?>');" class="brackets">Quote</a><? }
if ($AuthorID == $LoggedUser['ID'] || check_perms('site_moderate_forums')) { ?> - <a href="#post<?=$PostID?>" onclick="Edit_Form('<?=$PostID?>');" class="brackets">Edit</a><? } if ($AuthorID === $LoggedUser['ID'] || check_perms('site_moderate_forums')) { ?> - <a href="#post<?=$PostID?>" onclick="Edit_Form('<?=$PostID?>');" class="brackets">Edit</a><? }
if (check_perms('site_moderate_forums')) { ?> - <a href="#post<?=$PostID?>" onclick="Delete('<?=$PostID?>');" class="brackets">Delete</a> <? } ?> if (check_perms('site_moderate_forums')) { ?> - <a href="#post<?=$PostID?>" onclick="Delete('<?=$PostID?>');" class="brackets">Delete</a> <? } ?>
</span> </span>
<span id="bar<?=$PostID?>" style="float: right;"> <span id="bar<?=$PostID?>" style="float: right;">
@ -102,7 +109,8 @@
</td> </td>
</tr> </tr>
</table> </table>
<? } <?
}
if (!$ThreadInfo['IsLocked'] || check_perms('site_moderate_forums')) { if (!$ThreadInfo['IsLocked'] || check_perms('site_moderate_forums')) {
if ($ThreadInfo['MinClassWrite'] <= $LoggedUser['Class'] && !$LoggedUser['DisablePosting']) { if ($ThreadInfo['MinClassWrite'] <= $LoggedUser['Class'] && !$LoggedUser['DisablePosting']) {

View File

@ -9,8 +9,8 @@
$OrderVals = array('Time', 'Name', 'Subscribers', 'Torrents', 'Updated'); $OrderVals = array('Time', 'Name', 'Subscribers', 'Torrents', 'Updated');
$WayVals = array('Ascending', 'Descending'); $WayVals = array('Ascending', 'Descending');
$OrderTable = array('Time'=>'ID', 'Name'=>'c.Name', 'Subscribers'=> 'c.Subscribers', 'Torrents'=>'NumTorrents', 'Updated' => 'c.Updated'); $OrderTable = array('Time' => 'ID', 'Name' => 'c.Name', 'Subscribers' => 'c.Subscribers', 'Torrents' => 'NumTorrents', 'Updated' => 'c.Updated');
$WayTable = array('Ascending'=>'ASC', 'Descending'=>'DESC'); $WayTable = array('Ascending' => 'ASC', 'Descending' => 'DESC');
// Are we searching in bodies, or just names? // Are we searching in bodies, or just names?
if (!empty($_GET['type'])) { if (!empty($_GET['type'])) {
@ -30,15 +30,15 @@
} }
if (!empty($_GET['tags'])) { if (!empty($_GET['tags'])) {
$Tags = explode(',',db_string(trim($_GET['tags']))); $Tags = explode(',', db_string(trim($_GET['tags'])));
foreach ($Tags as $ID=>$Tag) { foreach ($Tags as $ID => $Tag) {
$Tags[$ID] = Misc::sanitize_tag($Tag); $Tags[$ID] = Misc::sanitize_tag($Tag);
} }
} }
if (!empty($_GET['cats'])) { if (!empty($_GET['cats'])) {
$Categories = $_GET['cats']; $Categories = $_GET['cats'];
foreach ($Categories as $Cat=>$Accept) { foreach ($Categories as $Cat => $Accept) {
if (empty($CollageCats[$Cat]) || !$Accept) { if (empty($CollageCats[$Cat]) || !$Accept) {
unset($Categories[$Cat]); unset($Categories[$Cat]);
} }
@ -95,7 +95,7 @@
$SQL .= "%'"; $SQL .= "%'";
} }
if (isset($_GET['tags_type']) && $_GET['tags_type'] == 0) { // Any if (isset($_GET['tags_type']) && $_GET['tags_type'] === '0') { // Any
$_GET['tags_type'] = 0; $_GET['tags_type'] = 0;
} else { // All } else { // All
$_GET['tags_type'] = 1; $_GET['tags_type'] = 1;
@ -103,7 +103,7 @@
if (!empty($Tags)) { if (!empty($Tags)) {
$SQL.= " AND (TagList LIKE '%"; $SQL.= " AND (TagList LIKE '%";
if ($_GET['tags_type'] == 0) { if ($_GET['tags_type'] === '0') {
$SQL .= implode("%' OR TagList LIKE '%", $Tags); $SQL .= implode("%' OR TagList LIKE '%", $Tags);
} else { } else {
$SQL .= implode("%' AND TagList LIKE '%", $Tags); $SQL .= implode("%' AND TagList LIKE '%", $Tags);
@ -125,18 +125,21 @@
if (!check_paranoia('collagecontribs', $User['Paranoia'], $UserClass, $UserID)) { if (!check_paranoia('collagecontribs', $User['Paranoia'], $UserClass, $UserID)) {
error(403); error(403);
} }
$DB->query("SELECT DISTINCT CollageID FROM collages_torrents WHERE UserID = $UserID"); $DB->query("
SELECT DISTINCT CollageID
FROM collages_torrents
WHERE UserID = $UserID");
$CollageIDs = $DB->collect('CollageID'); $CollageIDs = $DB->collect('CollageID');
if (empty($CollageIDs)) { if (empty($CollageIDs)) {
$SQL .= " AND 0"; $SQL .= " AND 0";
} else { } else {
$SQL .= " AND c.ID IN(".db_string(implode(',', $CollageIDs)).")"; $SQL .= " AND c.ID IN(".db_string(implode(',', $CollageIDs)).')';
} }
} else { } else {
if (!check_paranoia('collages', $User['Paranoia'], $UserClass, $UserID)) { if (!check_paranoia('collages', $User['Paranoia'], $UserClass, $UserID)) {
error(403); error(403);
} }
$SQL .= " AND UserID='".$_GET['userid']."'"; $SQL .= " AND UserID = '".$_GET['userid']."'";
} }
$Categories[] = 0; $Categories[] = 0;
} }
@ -145,7 +148,7 @@
$SQL .= " AND CategoryID IN(".db_string(implode(',', $Categories)).')'; $SQL .= " AND CategoryID IN(".db_string(implode(',', $Categories)).')';
} }
if ($_GET['action'] == 'mine') { if ($_GET['action'] === 'mine') {
$SQL = $BaseSQL; $SQL = $BaseSQL;
$SQL .= " $SQL .= "
AND c.UserID = '".$LoggedUser['ID']."' AND c.UserID = '".$LoggedUser['ID']."'
@ -185,14 +188,14 @@
<td class="label">Tags (comma-separated):</td> <td class="label">Tags (comma-separated):</td>
<td> <td>
<input type="text" id="tags" name="tags" size="70" value="<?=(!empty($_GET['tags']) ? display_str($_GET['tags']) : '')?>"<? Users::has_autocomplete_enabled('other'); ?> />&nbsp; <input type="text" id="tags" name="tags" size="70" value="<?=(!empty($_GET['tags']) ? display_str($_GET['tags']) : '')?>"<? Users::has_autocomplete_enabled('other'); ?> />&nbsp;
<input type="radio" name="tags_type" id="tags_type0" value="0"<?Format::selected('tags_type',0,'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp; <input type="radio" name="tags_type" id="tags_type0" value="0"<?Format::selected('tags_type', 0, 'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
<input type="radio" name="tags_type" id="tags_type1" value="1"<?Format::selected('tags_type',1,'checked')?> /><label for="tags_type1"> All</label> <input type="radio" name="tags_type" id="tags_type1" value="1"<?Format::selected('tags_type', 1, 'checked')?> /><label for="tags_type1"> All</label>
</td> </td>
</tr> </tr>
<tr id="categories"> <tr id="categories">
<td class="label">Categories:</td> <td class="label">Categories:</td>
<td> <td>
<? foreach ($CollageCats as $ID=>$Cat) { ?> <? foreach ($CollageCats as $ID => $Cat) { ?>
<input type="checkbox" value="1" name="cats[<?=$ID?>]" id="cats_<?=$ID?>"<? if (in_array($ID, $Categories)) { echo ' checked="checked"'; } ?> /> <input type="checkbox" value="1" name="cats[<?=$ID?>]" id="cats_<?=$ID?>"<? if (in_array($ID, $Categories)) { echo ' checked="checked"'; } ?> />
<label for="cats_<?=$ID?>"><?=$Cat?></label>&nbsp;&nbsp; <label for="cats_<?=$ID?>"><?=$Cat?></label>&nbsp;&nbsp;
<? } ?> <? } ?>
@ -201,8 +204,8 @@
<tr id="search_name_description"> <tr id="search_name_description">
<td class="label">Search in:</td> <td class="label">Search in:</td>
<td> <td>
<input type="radio" name="type" value="c.name" <? if ($Type == 'c.name') { echo 'checked="checked" '; } ?>/> Names&nbsp;&nbsp; <input type="radio" name="type" value="c.name" <? if ($Type === 'c.name') { echo 'checked="checked" '; } ?>/> Names&nbsp;&nbsp;
<input type="radio" name="type" value="description" <? if ($Type == 'description') { echo 'checked="checked" '; } ?>/> Descriptions <input type="radio" name="type" value="description" <? if ($Type === 'description') { echo 'checked="checked" '; } ?>/> Descriptions
</td> </td>
</tr> </tr>
<tr id="order_by"> <tr id="order_by">
@ -210,12 +213,12 @@
<td> <td>
<select name="order_by" class="ft_order_by"> <select name="order_by" class="ft_order_by">
<? foreach ($OrderVals as $Cur) { ?> <? foreach ($OrderVals as $Cur) { ?>
<option value="<?=$Cur?>"<? if (isset($_GET['order_by']) && $_GET['order_by'] == $Cur || (!isset($_GET['order_by']) && $Cur == 'Time')) { echo ' selected="selected"'; } ?>><?=$Cur?></option> <option value="<?=$Cur?>"<? if (isset($_GET['order_by']) && $_GET['order_by'] === $Cur || (!isset($_GET['order_by']) && $Cur === 'Time')) { echo ' selected="selected"'; } ?>><?=$Cur?></option>
<? } ?> <? } ?>
</select> </select>
<select name="order_way" class="ft_order_way"> <select name="order_way" class="ft_order_way">
<? foreach ($WayVals as $Cur) { ?> <? foreach ($WayVals as $Cur) { ?>
<option value="<?=$Cur?>"<? if (isset($_GET['order_way']) && $_GET['order_way'] == $Cur || (!isset($_GET['order_way']) && $Cur == 'Descending')) { echo ' selected="selected"'; } ?>><?=$Cur?></option> <option value="<?=$Cur?>"<? if (isset($_GET['order_way']) && $_GET['order_way'] === $Cur || (!isset($_GET['order_way']) && $Cur === 'Descending')) { echo ' selected="selected"'; } ?>><?=$Cur?></option>
<? } ?> <? } ?>
</select> </select>
</td> </td>
@ -244,7 +247,7 @@
AND Deleted = '0'"); AND Deleted = '0'");
$CollageCount = $DB->record_count(); $CollageCount = $DB->record_count();
if ($CollageCount == 1) { if ($CollageCount === 1) {
list($CollageID) = $DB->next_record(); list($CollageID) = $DB->next_record();
?> ?>
<a href="collages.php?id=<?=$CollageID?>" class="brackets">Personal collage</a> <a href="collages.php?id=<?=$CollageID?>" class="brackets">Personal collage</a>
@ -278,7 +281,7 @@
echo $Pages; echo $Pages;
?> ?>
</div> </div>
<? if (count($Collages) == 0) { ?> <? if (count($Collages) === 0) { ?>
<div class="box pad" align="center"> <div class="box pad" align="center">
<? if ($BookmarkView) { ?> <? if ($BookmarkView) { ?>
<h2>You have not bookmarked any collages.</h2> <h2>You have not bookmarked any collages.</h2>
@ -304,7 +307,7 @@
$Row = 'a'; // For the pretty colours $Row = 'a'; // For the pretty colours
foreach ($Collages as $Collage) { foreach ($Collages as $Collage) {
list($ID, $Name, $NumTorrents, $TagList, $CategoryID, $UserID, $Subscribers, $Updated) = $Collage; list($ID, $Name, $NumTorrents, $TagList, $CategoryID, $UserID, $Subscribers, $Updated) = $Collage;
$Row = ($Row == 'a') ? 'b' : 'a'; $Row = ($Row === 'a') ? 'b' : 'a';
$TorrentTags = new Tags($TagList); $TorrentTags = new Tags($TagList);
//Print results //Print results

View File

@ -1,5 +1,5 @@
<? <?php
ini_set('max_execution_time',600); ini_set('max_execution_time', 600);
//~~~~~~~~~~~ Main collage page ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// //~~~~~~~~~~~ Main collage page ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
@ -18,12 +18,15 @@ function compare($X, $Y) {
error(0); error(0);
} }
$Data = $Cache->get_value('collage_'.$CollageID); $Data = $Cache->get_value("collage_$CollageID");
if ($Data) { if ($Data) {
list($K, list($Name, $Description, , , $CommentList, $Deleted, $CollageCategoryID, $CreatorID, $Locked, $MaxGroups, $MaxGroupsPerUser, $Updated, $Subscribers)) = each($Data); list($K, list($Name, $Description, , , $CommentList, $Deleted, $CollageCategoryID, $CreatorID, $Locked, $MaxGroups, $MaxGroupsPerUser, $Updated, $Subscribers)) = each($Data);
} else { } else {
$DB->query("SELECT Name, Description, UserID, Deleted, CategoryID, Locked, MaxGroups, MaxGroupsPerUser, Updated, Subscribers FROM collages WHERE ID='$CollageID'"); $DB->query("
SELECT Name, Description, UserID, Deleted, CategoryID, Locked, MaxGroups, MaxGroupsPerUser, Updated, Subscribers
FROM collages
WHERE ID = '$CollageID'");
if ($DB->has_results()) { if ($DB->has_results()) {
list($Name, $Description, $CreatorID, $Deleted, $CollageCategoryID, $Locked, $MaxGroups, $MaxGroupsPerUser, $Updated, $Subscribers) = $DB->next_record(); list($Name, $Description, $CreatorID, $Deleted, $CollageCategoryID, $Locked, $MaxGroups, $MaxGroupsPerUser, $Updated, $Subscribers) = $DB->next_record();
$TorrentList = ''; $TorrentList = '';
@ -33,22 +36,25 @@ function compare($X, $Y) {
} }
} }
if ($Deleted == '1') { if ($Deleted === '1') {
header('Location: log.php?search=Collage+'.$CollageID); header("Location: log.php?search=Collage+$CollageID");
die(); die();
} }
if ($CollageCategoryID == 0 && !check_perms('site_collages_delete')) { if ($CollageCategoryID === '0' && !check_perms('site_collages_delete')) {
if (!check_perms('site_collages_personal') || $CreatorID != $LoggedUser['ID']) { if (!check_perms('site_collages_personal') || $CreatorID !== $LoggedUser['ID']) {
$PreventAdditions = true; $PreventAdditions = true;
} }
} }
//Handle subscriptions //Handle subscriptions
if (($CollageSubscriptions = $Cache->get_value('collage_subs_user_'.$LoggedUser['ID'])) === false) { if (($CollageSubscriptions = $Cache->get_value('collage_subs_user_'.$LoggedUser['ID'])) === false) {
$DB->query("SELECT CollageID FROM users_collage_subs WHERE UserID = '$LoggedUser[ID]'"); $DB->query("
SELECT CollageID
FROM users_collage_subs
WHERE UserID = '$LoggedUser[ID]'");
$CollageSubscriptions = $DB->collect(0); $CollageSubscriptions = $DB->collect(0);
$Cache->cache_value('collage_subs_user_'.$LoggedUser['ID'],$CollageSubscriptions,0); $Cache->cache_value('collage_subs_user_'.$LoggedUser['ID'], $CollageSubscriptions, 0);
} }
if (empty($CollageSubscriptions)) { if (empty($CollageSubscriptions)) {
@ -58,9 +64,13 @@ function compare($X, $Y) {
if (in_array($CollageID, $CollageSubscriptions)) { if (in_array($CollageID, $CollageSubscriptions)) {
$Cache->delete_value('collage_subs_user_new_'.$LoggedUser['ID']); $Cache->delete_value('collage_subs_user_new_'.$LoggedUser['ID']);
} }
$DB->query("UPDATE users_collage_subs SET LastVisit=NOW() WHERE UserID = ".$LoggedUser['ID']." AND CollageID=$CollageID"); $DB->query("
UPDATE users_collage_subs
SET LastVisit = NOW()
WHERE UserID = ".$LoggedUser['ID']."
AND CollageID = $CollageID");
if ($CollageCategoryID == array_search(ARTIST_COLLAGE, $CollageCats)) { if ($CollageCategoryID === array_search(ARTIST_COLLAGE, $CollageCats)) {
include(SERVER_ROOT.'/sections/collages/artist_collage.php'); include(SERVER_ROOT.'/sections/collages/artist_collage.php');
} else { } else {
include(SERVER_ROOT.'/sections/collages/torrent_collage.php'); include(SERVER_ROOT.'/sections/collages/torrent_collage.php');

View File

@ -18,24 +18,31 @@
// Get number of pages // Get number of pages
// $Pages = number of pages in the thread // $Pages = number of pages in the thread
// $Page = which page the post is on // $Page = which page the post is on
$DB->query("SELECT $DB->query("
SELECT
CollageID, CollageID,
CEIL(COUNT(ID)/" . TORRENT_COMMENTS_PER_PAGE . ") AS Pages, CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Pages,
CEIL(SUM(IF(ID<='$PostID',1,0))/" . TORRENT_COMMENTS_PER_PAGE . ") AS Page CEIL(SUM(IF(ID <= '$PostID', 1, 0)) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
FROM collages_comments FROM collages_comments
WHERE CollageID=(SELECT CollageID FROM collages_comments WHERE ID='$PostID') WHERE CollageID = (
SELECT CollageID
FROM collages_comments
WHERE ID = '$PostID'
)
GROUP BY CollageID"); GROUP BY CollageID");
list($CollageID, $Pages, $Page) = $DB->next_record(); list($CollageID, $Pages, $Page) = $DB->next_record();
$DB->query("DELETE FROM collages_comments WHERE ID='$PostID'"); $DB->query("
DELETE FROM collages_comments
WHERE ID = '$PostID'");
$Cache->delete_value('collage_'.$CollageID); $Cache->delete_value("collage_$CollageID");
$Cache->increment_value('collage_comments_'.$CollageID, -1); $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 //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); $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); $LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
for ($i = $ThisCatalogue; $i <= $LastCatalogue; $i++) { for ($i = $ThisCatalogue; $i <= $LastCatalogue; $i++) {
$Cache->delete_value('collage_comments_'.$CollageID.'_catalogue_'.$i); $Cache->delete_value("collage_comments_$CollageID"."_catalogue_$i");
} }
?> ?>

View File

@ -26,33 +26,35 @@
SQL template: SQL template:
SELECT SELECT
CASE CASE
WHEN t.Format='MP3' AND t.Encoding='V0 (VBR)' THEN 1 WHEN t.Format = 'MP3' AND t.Encoding = 'V0 (VBR)'
WHEN t.Format='MP3' AND t.Encoding='V2 (VBR)' THEN 2 THEN 1
WHEN t.Format = 'MP3' AND t.Encoding = 'V2 (VBR)'
THEN 2
ELSE 100 ELSE 100
END AS Rank, END AS Rank,
t.GroupID, t.GroupID,
t.Media, t.Media,
t.Format, t.Format,
t.Encoding, t.Encoding,
IF(t.Year=0,tg.Year,t.Year), IF(t.Year = 0, tg.Year, t.Year),
tg.Name, tg.Name,
a.Name, a.Name,
t.Size t.Size
FROM torrents AS t FROM torrents AS t
INNER JOIN collages_torrents AS c ON t.GroupID=c.GroupID AND c.CollageID='8' INNER JOIN collages_torrents AS c ON t.GroupID = c.GroupID AND c.CollageID = '8'
INNER JOIN torrents_group AS tg ON tg.ID=t.GroupID AND tg.CategoryID='1' INNER JOIN torrents_group AS tg ON tg.ID = t.GroupID AND tg.CategoryID = '1'
LEFT JOIN artists_group AS a ON a.ArtistID=tg.ArtistID LEFT JOIN artists_group AS a ON a.ArtistID = tg.ArtistID
LEFT JOIN torrents_files AS f ON t.ID=f.TorrentID LEFT JOIN torrents_files AS f ON t.ID = f.TorrentID
ORDER BY t.GroupID ASC, Rank DESC, t.Seeders ASC ORDER BY t.GroupID ASC, Rank DESC, t.Seeders ASC
*/ */
if ( if (
!isset($_REQUEST['collageid']) || !isset($_REQUEST['collageid'])
!isset($_REQUEST['preference']) || || !isset($_REQUEST['preference'])
!is_number($_REQUEST['preference']) || || !is_number($_REQUEST['preference'])
!is_number($_REQUEST['collageid']) || || !is_number($_REQUEST['collageid'])
$_REQUEST['preference'] > 2 || || $_REQUEST['preference'] > 2
count($_REQUEST['list']) == 0 || count($_REQUEST['list']) === 0
) { ) {
error(0); error(0);
} }
@ -66,59 +68,64 @@
$CollageID = $_REQUEST['collageid']; $CollageID = $_REQUEST['collageid'];
$Preference = $Preferences[$_REQUEST['preference']]; $Preference = $Preferences[$_REQUEST['preference']];
$DB->query("SELECT Name FROM collages WHERE ID='$CollageID'"); $DB->query("
SELECT Name
FROM collages
WHERE ID = '$CollageID'");
list($CollageName) = $DB->next_record(MYSQLI_NUM, false); list($CollageName) = $DB->next_record(MYSQLI_NUM, false);
$SQL = "SELECT CASE "; $SQL = 'SELECT CASE ';
foreach ($_REQUEST['list'] as $Priority => $Selection) { foreach ($_REQUEST['list'] as $Priority => $Selection) {
if (!is_number($Priority)) { if (!is_number($Priority)) {
continue; continue;
} }
$SQL .= "WHEN "; $SQL .= 'WHEN ';
switch ($Selection) { switch ($Selection) {
case '00': $SQL .= "t.Format='MP3' AND t.Encoding='V0 (VBR)'"; break; case '00': $SQL .= "t.Format = 'MP3' AND t.Encoding = 'V0 (VBR)'"; break;
case '01': $SQL .= "t.Format='MP3' AND t.Encoding='APX (VBR)'"; break; case '01': $SQL .= "t.Format = 'MP3' AND t.Encoding = 'APX (VBR)'"; break;
case '02': $SQL .= "t.Format='MP3' AND t.Encoding='256 (VBR)'"; break; case '02': $SQL .= "t.Format = 'MP3' AND t.Encoding = '256 (VBR)'"; break;
case '03': $SQL .= "t.Format='MP3' AND t.Encoding='V1 (VBR)'"; break; case '03': $SQL .= "t.Format = 'MP3' AND t.Encoding = 'V1 (VBR)'"; break;
case '10': $SQL .= "t.Format='MP3' AND t.Encoding='224 (VBR)'"; break; case '10': $SQL .= "t.Format = 'MP3' AND t.Encoding = '224 (VBR)'"; break;
case '11': $SQL .= "t.Format='MP3' AND t.Encoding='V2 (VBR)'"; break; case '11': $SQL .= "t.Format = 'MP3' AND t.Encoding = 'V2 (VBR)'"; break;
case '12': $SQL .= "t.Format='MP3' AND t.Encoding='APS (VBR)'"; break; case '12': $SQL .= "t.Format = 'MP3' AND t.Encoding = 'APS (VBR)'"; break;
case '13': $SQL .= "t.Format='MP3' AND t.Encoding='192 (VBR)'"; break; case '13': $SQL .= "t.Format = 'MP3' AND t.Encoding = '192 (VBR)'"; break;
case '20': $SQL .= "t.Format='MP3' AND t.Encoding='320'"; break; case '20': $SQL .= "t.Format = 'MP3' AND t.Encoding = '320'"; break;
case '21': $SQL .= "t.Format='MP3' AND t.Encoding='256'"; break; case '21': $SQL .= "t.Format = 'MP3' AND t.Encoding = '256'"; break;
case '22': $SQL .= "t.Format='MP3' AND t.Encoding='224'"; break; case '22': $SQL .= "t.Format = 'MP3' AND t.Encoding = '224'"; break;
case '23': $SQL .= "t.Format='MP3' AND t.Encoding='192'"; break; case '23': $SQL .= "t.Format = 'MP3' AND t.Encoding = '192'"; break;
case '30': $SQL .= "t.Format='FLAC' AND t.Encoding='24bit Lossless' AND t.Media='Vinyl'"; break; case '30': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'Vinyl'"; break;
case '31': $SQL .= "t.Format='FLAC' AND t.Encoding='24bit Lossless' AND t.Media='DVD'"; break; case '31': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'DVD'"; break;
case '32': $SQL .= "t.Format='FLAC' AND t.Encoding='24bit Lossless' AND t.Media='SACD'"; break; case '32': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'SACD'"; break;
case '33': $SQL .= "t.Format='FLAC' AND t.Encoding='24bit Lossless' AND t.Media='WEB'"; break; case '33': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'WEB'"; break;
case '34': $SQL .= "t.Format='FLAC' AND t.Encoding='Lossless' AND HasLog='1' AND LogScore='100' AND HasCue='1'"; break; case '34': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless' AND HasLog = '1' AND LogScore = '100' AND HasCue = '1'"; break;
case '35': $SQL .= "t.Format='FLAC' AND t.Encoding='Lossless' AND HasLog='1' AND LogScore='100'"; break; case '35': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless' AND HasLog = '1' AND LogScore = '100'"; break;
case '36': $SQL .= "t.Format='FLAC' AND t.Encoding='Lossless' AND HasLog='1'"; break; case '36': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless' AND HasLog = '1'"; break;
case '37': $SQL .= "t.Format='FLAC' AND t.Encoding='Lossless'"; break; case '37': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless'"; break;
case '40': $SQL .= "t.Format='DTS'"; break; case '40': $SQL .= "t.Format = 'DTS'"; break;
case '42': $SQL .= "t.Format='AAC' AND t.Encoding='320'"; break; case '42': $SQL .= "t.Format = 'AAC' AND t.Encoding = '320'"; break;
case '43': $SQL .= "t.Format='AAC' AND t.Encoding='256'"; break; case '43': $SQL .= "t.Format = 'AAC' AND t.Encoding = '256'"; break;
case '44': $SQL .= "t.Format='AAC' AND t.Encoding='q5.5'"; break; case '44': $SQL .= "t.Format = 'AAC' AND t.Encoding = 'q5.5'"; break;
case '45': $SQL .= "t.Format='AAC' AND t.Encoding='q5'"; break; case '45': $SQL .= "t.Format = 'AAC' AND t.Encoding = 'q5'"; break;
case '46': $SQL .= "t.Format='AAC' AND t.Encoding='192'"; break; case '46': $SQL .= "t.Format = 'AAC' AND t.Encoding = '192'"; break;
default: error(0); default: error(0);
} }
$SQL .= " THEN $Priority "; $SQL .= " THEN $Priority ";
} }
$SQL .= "ELSE 100 END AS Rank, $SQL .= "
t.GroupID, ELSE 100
t.ID AS TorrentID, END AS Rank,
t.Media, t.GroupID,
t.Format, t.ID AS TorrentID,
t.Encoding, t.Media,
IF(t.RemasterYear=0,tg.Year,t.RemasterYear) AS Year, t.Format,
tg.Name, t.Encoding,
t.Size IF(t.RemasterYear = 0, tg.Year, t.RemasterYear) AS Year,
tg.Name,
t.Size
FROM torrents AS t FROM torrents AS t
INNER JOIN collages_torrents AS c ON t.GroupID=c.GroupID AND c.CollageID='$CollageID' INNER JOIN collages_torrents AS c ON t.GroupID = c.GroupID AND c.CollageID = '$CollageID'
INNER JOIN torrents_group AS tg ON tg.ID=t.GroupID AND tg.CategoryID='1' INNER JOIN torrents_group AS tg ON tg.ID = t.GroupID AND tg.CategoryID = '1'
ORDER BY t.GroupID ASC, Rank DESC, t.$Preference"; ORDER BY t.GroupID ASC, Rank DESC, t.$Preference";
$DownloadsQ = $DB->query($SQL); $DownloadsQ = $DB->query($SQL);
@ -126,7 +133,10 @@
while (list($Downloads, $GroupIDs) = $Collector->get_downloads('GroupID')) { while (list($Downloads, $GroupIDs) = $Collector->get_downloads('GroupID')) {
$Artists = Artists::get_artists($GroupIDs); $Artists = Artists::get_artists($GroupIDs);
$TorrentFilesQ = $DB->query("SELECT TorrentID, File FROM torrents_files WHERE TorrentID IN (".implode(',', array_keys($GroupIDs)).")", false); $TorrentFilesQ = $DB->query("
SELECT TorrentID, File
FROM torrents_files
WHERE TorrentID IN (".implode(',', array_keys($GroupIDs)).')', false);
if (is_int($TorrentFilesQ)) { if (is_int($TorrentFilesQ)) {
// Query failed. Let's not create a broken zip archive // Query failed. Let's not create a broken zip archive
foreach ($GroupIDs as $GroupID) { foreach ($GroupIDs as $GroupID) {

View File

@ -4,12 +4,15 @@
error(0); error(0);
} }
$DB->query("SELECT Name, UserID, CategoryID FROM collages WHERE ID='$CollageID'"); $DB->query("
SELECT Name, UserID, CategoryID
FROM collages
WHERE ID = '$CollageID'");
list($Name, $UserID, $CategoryID) = $DB->next_record(); list($Name, $UserID, $CategoryID) = $DB->next_record();
if ($CategoryID == 0 && $UserID != $LoggedUser['ID'] && !check_perms('site_collages_delete')) { if ($CategoryID === '0' && $UserID !== $LoggedUser['ID'] && !check_perms('site_collages_delete')) {
error(403); error(403);
} }
if ($CategoryID != array_search(ARTIST_COLLAGE, $CollageCats)) { if ($CategoryID !== array_search(ARTIST_COLLAGE, $CollageCats)) {
error(403); error(403);
} }
@ -21,15 +24,15 @@
um.Username, um.Username,
ca.Sort ca.Sort
FROM collages_artists AS ca FROM collages_artists AS ca
JOIN artists_group AS ag ON ag.ArtistID=ca.ArtistID JOIN artists_group AS ag ON ag.ArtistID = ca.ArtistID
LEFT JOIN users_main AS um ON um.ID=ca.UserID LEFT JOIN users_main AS um ON um.ID = ca.UserID
WHERE ca.CollageID='$CollageID' WHERE ca.CollageID = '$CollageID'
ORDER BY ca.Sort"); ORDER BY ca.Sort");
$Artists = $DB->to_array('ArtistID', MYSQLI_ASSOC); $Artists = $DB->to_array('ArtistID', MYSQLI_ASSOC);
View::show_header('Manage collage '.$Name, 'jquery-ui,jquery.tablesorter.min,sort'); View::show_header("Manage collage $Name", 'jquery-ui,jquery.tablesorter.min,sort');
?> ?>
@ -54,7 +57,7 @@
</table> </table>
<div class="drag_drop_save hidden"> <div class="drag_drop_save hidden">
<input type="button" name="submit" value="Save All Changes" title="Save your changes." class="save_sortable_collage" /> <input type="button" name="submit" value="Save All Changes" title="Save your changes" class="save_sortable_collage" />
</div> </div>
<table id="manage_collage_table"> <table id="manage_collage_table">
<thead> <thead>
@ -68,7 +71,6 @@
</thead> </thead>
<tbody> <tbody>
<? <?
$Number = 0; $Number = 0;
foreach ($Artists as $Artist) { foreach ($Artists as $Artist) {
$Number++; $Number++;

View File

@ -7,12 +7,15 @@
error(404); error(404);
} }
$DB->query("SELECT UserID, CategoryID FROM collages WHERE ID='$CollageID'"); $DB->query("
SELECT UserID, CategoryID
FROM collages
WHERE ID = '$CollageID'");
list($UserID, $CategoryID) = $DB->next_record(); list($UserID, $CategoryID) = $DB->next_record();
if ($CategoryID == 0 && $UserID != $LoggedUser['ID'] && !check_perms('site_collages_delete')) { if ($CategoryID === '0' && $UserID !== $LoggedUser['ID'] && !check_perms('site_collages_delete')) {
error(403); error(403);
} }
if ($CategoryID != array_search(ARTIST_COLLAGE, $CollageCats)) { if ($CategoryID !== array_search(ARTIST_COLLAGE, $CollageCats)) {
error(403); error(403);
} }
@ -21,12 +24,18 @@
error(404); error(404);
} }
if ($_POST['submit'] == 'Remove') { if ($_POST['submit'] === 'Remove') {
$DB->query("DELETE FROM collages_artists WHERE CollageID='$CollageID' AND ArtistID='$ArtistID'"); $DB->query("
DELETE FROM collages_artists
WHERE CollageID = '$CollageID'
AND ArtistID = '$ArtistID'");
$Rows = $DB->affected_rows(); $Rows = $DB->affected_rows();
$DB->query("UPDATE collages SET NumTorrents=NumTorrents-$Rows WHERE ID='$CollageID'"); $DB->query("
$Cache->delete_value('artists_collages_'.$ArtistID); UPDATE collages
$Cache->delete_value('artists_collages_personal_'.$ArtistID); SET NumTorrents = NumTorrents - $Rows
WHERE ID = '$CollageID'");
$Cache->delete_value("artists_collages_$ArtistID");
$Cache->delete_value("artists_collages_personal_$ArtistID");
} elseif (isset($_POST['drag_drop_collage_sort_order'])) { } elseif (isset($_POST['drag_drop_collage_sort_order'])) {
@parse_str($_POST['drag_drop_collage_sort_order'], $Series); @parse_str($_POST['drag_drop_collage_sort_order'], $Series);
@ -40,9 +49,12 @@
} }
} }
$SQL = 'INSERT INTO collages_artists (ArtistID, Sort, CollageID) VALUES ' $SQL = '
. implode(', ', $SQL) INSERT INTO collages_artists
. ' ON DUPLICATE KEY UPDATE Sort = VALUES (Sort)'; (ArtistID, Sort, CollageID)
VALUES
' . implode(', ', $SQL) . '
ON DUPLICATE KEY UPDATE Sort = VALUES (Sort)';
$DB->query($SQL); $DB->query($SQL);
} }
@ -54,10 +66,10 @@
} }
$DB->query(" $DB->query("
UPDATE collages_artists UPDATE collages_artists
SET Sort='$Sort' SET Sort = '$Sort'
WHERE CollageID='$CollageID' WHERE CollageID = '$CollageID'
AND ArtistID='$ArtistID'"); AND ArtistID = '$ArtistID'");
} }
$Cache->delete_value('collage_'.$CollageID); $Cache->delete_value("collage_$CollageID");
header('Location: collages.php?action=manage_artists&collageid='.$CollageID); header("Location: collages.php?action=manage_artists&collageid=$CollageID");

View File

@ -7,9 +7,12 @@
error(404); error(404);
} }
$DB->query("SELECT UserID, CategoryID FROM collages WHERE ID='$CollageID'"); $DB->query("
SELECT UserID, CategoryID
FROM collages
WHERE ID = '$CollageID'");
list($UserID, $CategoryID) = $DB->next_record(); list($UserID, $CategoryID) = $DB->next_record();
if ($CategoryID == 0 && $UserID != $LoggedUser['ID'] && !check_perms('site_collages_delete')) { if ($CategoryID === '0' && $UserID !== $LoggedUser['ID'] && !check_perms('site_collages_delete')) {
error(403); error(403);
} }
@ -19,13 +22,19 @@
error(404); error(404);
} }
if ($_POST['submit'] == 'Remove') { if ($_POST['submit'] === 'Remove') {
$DB->query("DELETE FROM collages_torrents WHERE CollageID='$CollageID' AND GroupID='$GroupID'"); $DB->query("
DELETE FROM collages_torrents
WHERE CollageID = '$CollageID'
AND GroupID = '$GroupID'");
$Rows = $DB->affected_rows(); $Rows = $DB->affected_rows();
$DB->query("UPDATE collages SET NumTorrents=NumTorrents-$Rows WHERE ID='$CollageID'"); $DB->query("
$Cache->delete_value('torrents_details_'.$GroupID); UPDATE collages
$Cache->delete_value('torrent_collages_'.$GroupID); SET NumTorrents = NumTorrents - $Rows
$Cache->delete_value('torrent_collages_personal_'.$GroupID); WHERE ID = '$CollageID'");
$Cache->delete_value("torrents_details_$GroupID");
$Cache->delete_value("torrent_collages_$GroupID");
$Cache->delete_value("torrent_collages_personal_$GroupID");
} elseif (isset($_POST['drag_drop_collage_sort_order'])) { } elseif (isset($_POST['drag_drop_collage_sort_order'])) {
@parse_str($_POST['drag_drop_collage_sort_order'], $Series); @parse_str($_POST['drag_drop_collage_sort_order'], $Series);
@ -39,9 +48,12 @@
} }
} }
$SQL = 'INSERT INTO collages_torrents (GroupID, Sort, CollageID) VALUES ' $SQL = '
. implode(', ', $SQL) INSERT INTO collages_torrents
. ' ON DUPLICATE KEY UPDATE Sort = VALUES (Sort)'; (GroupID, Sort, CollageID)
VALUES
' . implode(', ', $SQL) . '
ON DUPLICATE KEY UPDATE Sort = VALUES (Sort)';
$DB->query($SQL); $DB->query($SQL);
} }
@ -51,8 +63,12 @@
if (!is_number($Sort)) { if (!is_number($Sort)) {
error(404); error(404);
} }
$DB->query("UPDATE collages_torrents SET Sort='$Sort' WHERE CollageID='$CollageID' AND GroupID='$GroupID'"); $DB->query("
UPDATE collages_torrents
SET Sort = '$Sort'
WHERE CollageID = '$CollageID'
AND GroupID = '$GroupID'");
} }
$Cache->delete_value('collage_'.$CollageID); $Cache->delete_value("collage_$CollageID");
header('Location: collages.php?action=manage&collageid='.$CollageID); header("Location: collages.php?action=manage&collageid=$CollageID");

View File

@ -1,4 +1,4 @@
<? <?php
authorize(); authorize();
include(SERVER_ROOT.'/classes/validate.class.php'); include(SERVER_ROOT.'/classes/validate.class.php');
@ -8,25 +8,36 @@
$P = db_array($_POST); $P = db_array($_POST);
if ($P['category'] > 0 || check_perms('site_collages_renamepersonal')) { if ($P['category'] > 0 || check_perms('site_collages_renamepersonal')) {
$Val->SetFields('name', '1','string','The name must be between 3 and 100 characters',array('maxlength'=>100, 'minlength'=>3)); $Val->SetFields('name', '1', 'string', 'The name must be between 3 and 100 characters', array('maxlength' => 100, 'minlength' => 3));
} else { } else {
// Get a collage name and make sure it's unique // Get a collage name and make sure it's unique
$name = $LoggedUser['Username']."'s personal collage"; $name = $LoggedUser['Username']."'s personal collage";
$P['name'] = db_string($name); $P['name'] = db_string($name);
$DB->query("SELECT ID FROM collages WHERE Name='".$P['name']."'"); $DB->query("
SELECT ID
FROM collages
WHERE Name = '".$P['name']."'");
$i = 2; $i = 2;
while ($DB->has_results()) { while ($DB->has_results()) {
$P['name'] = db_string($name." no. $i"); $P['name'] = db_string("$name no. $i");
$DB->query("SELECT ID FROM collages WHERE Name='".$P['name']."'"); $DB->query("
SELECT ID
FROM collages
WHERE Name = '".$P['name']."'");
$i++; $i++;
} }
} }
$Val->SetFields('description', '1','string','The description must be at least 10 characters',array('maxlength'=>65535, 'minlength'=>10)); $Val->SetFields('description', '1', 'string', 'The description must be at least 10 characters', array('maxlength' => 65535, 'minlength' => 10));
$Err = $Val->ValidateForm($_POST); $Err = $Val->ValidateForm($_POST);
if ($P['category'] == '0') { if ($P['category'] === '0') {
$DB->query("SELECT COUNT(ID) FROM collages WHERE UserID='$LoggedUser[ID]' AND CategoryID='0' AND Deleted='0'"); $DB->query("
SELECT COUNT(ID)
FROM collages
WHERE UserID = '$LoggedUser[ID]'
AND CategoryID = '0'
AND Deleted = '0'");
list($CollageCount) = $DB->next_record(); list($CollageCount) = $DB->next_record();
if (($CollageCount >= $LoggedUser['Permissions']['MaxCollages']) || !check_perms('site_collages_personal')) { if (($CollageCount >= $LoggedUser['Permissions']['MaxCollages']) || !check_perms('site_collages_personal')) {
$Err = 'You may not create a personal collage.'; $Err = 'You may not create a personal collage.';
@ -36,11 +47,14 @@
} }
if (!$Err) { if (!$Err) {
$DB->query("SELECT ID,Deleted FROM collages WHERE Name='$P[name]'"); $DB->query("
SELECT ID, Deleted
FROM collages
WHERE Name = '$P[name]'");
if ($DB->has_results()) { if ($DB->has_results()) {
list($ID, $Deleted) = $DB->next_record(); list($ID, $Deleted) = $DB->next_record();
if ($Deleted) { if ($Deleted) {
$Err = "That collection already exists but needs to be recovered; please <a href=\"staffpm.php\">contact</a> the staff team!"; $Err = 'That collection already exists but needs to be recovered; please <a href="staffpm.php">contact</a> the staff team!';
} else { } else {
$Err = "That collection already exists: <a href=\"/collages.php?id=$ID\">$ID</a>."; $Err = "That collection already exists: <a href=\"/collages.php?id=$ID\">$ID</a>.";
} }
@ -64,20 +78,20 @@
die(); die();
} }
$TagList = explode(',',$_POST['tags']); $TagList = explode(',', $_POST['tags']);
foreach ($TagList as $ID=>$Tag) { foreach ($TagList as $ID => $Tag) {
$TagList[$ID] = Misc::sanitize_tag($Tag); $TagList[$ID] = Misc::sanitize_tag($Tag);
} }
$TagList = implode(' ',$TagList); $TagList = implode(' ', $TagList);
$DB->query("INSERT INTO collages $DB->query("
INSERT INTO collages
(Name, Description, UserID, TagList, CategoryID) (Name, Description, UserID, TagList, CategoryID)
VALUES VALUES
('$P[name]', '$P[description]', $LoggedUser[ID], '$TagList', '$P[category]')"); ('$P[name]', '$P[description]', $LoggedUser[ID], '$TagList', '$P[category]')");
$CollageID = $DB->inserted_id(); $CollageID = $DB->inserted_id();
$Cache->delete_value('collage_'.$CollageID); $Cache->delete_value("collage_$CollageID");
Misc::write_log("Collage ".$CollageID." (".$_POST['name'].") was created by ".$LoggedUser['Username']); Misc::write_log("Collage $CollageID (".$_POST['name'].') was created by '.$LoggedUser['Username']);
header('Location: collages.php?id='.$CollageID); header("Location: collages.php?id=$CollageID");
?> ?>

View File

@ -7,10 +7,13 @@
error(404); error(404);
} }
$DB->query("SELECT Name, CategoryID, UserID FROM collages WHERE ID='$CollageID'"); $DB->query("
SELECT Name, CategoryID, UserID
FROM collages
WHERE ID = '$CollageID'");
list($Name, $CategoryID, $UserID) = $DB->next_record(MYSQLI_NUM, false); list($Name, $CategoryID, $UserID) = $DB->next_record(MYSQLI_NUM, false);
if (!check_perms('site_collages_delete') && $UserID != $LoggedUser['ID']) { if (!check_perms('site_collages_delete') && $UserID !== $LoggedUser['ID']) {
error(403); error(403);
} }
@ -19,23 +22,35 @@
error('You must enter a reason!'); error('You must enter a reason!');
} }
$DB->query("SELECT GroupID FROM collages_torrents WHERE CollageID='$CollageID'"); $DB->query("
SELECT GroupID
FROM collages_torrents
WHERE CollageID = '$CollageID'");
while (list($GroupID) = $DB->next_record()) { while (list($GroupID) = $DB->next_record()) {
$Cache->delete_value('torrents_details_'.$GroupID); $Cache->delete_value("torrents_details_$GroupID");
$Cache->delete_value('torrent_collages_'.$GroupID); $Cache->delete_value("torrent_collages_$GroupID");
$Cache->delete_value('torrent_collages_personal_'.$GroupID); $Cache->delete_value("torrent_collages_personal_$GroupID");
} }
//Personal collages have CategoryID 0 //Personal collages have CategoryID 0
if ($CategoryID == 0) { if ($CategoryID === '0') {
$DB->query("DELETE FROM collages WHERE ID='$CollageID'"); $DB->query("
$DB->query("DELETE FROM collages_torrents WHERE CollageID='$CollageID'"); DELETE FROM collages
$DB->query("DELETE FROM collages_comments WHERE CollageID='$CollageID'"); WHERE ID = '$CollageID'");
$DB->query("
DELETE FROM collages_torrents
WHERE CollageID = '$CollageID'");
$DB->query("
DELETE FROM collages_comments
WHERE CollageID = '$CollageID'");
} else { } else {
$DB->query("UPDATE collages SET Deleted = '1' WHERE ID='$CollageID'"); $DB->query("
UPDATE collages
SET Deleted = '1'
WHERE ID = '$CollageID'");
} }
Misc::write_log("Collage $CollageID ($Name) was deleted by ".$LoggedUser['Username'].': '.$Reason); Misc::write_log("Collage $CollageID ($Name) was deleted by ".$LoggedUser['Username'].": $Reason");
$Cache->delete_value('collage_'.$CollageID); $Cache->delete_value("collage_$CollageID");
header('Location: collages.php'); header('Location: collages.php');

View File

@ -21,9 +21,9 @@
} }
if (!check_perms('site_view_full_log')) { if (!check_perms('site_view_full_log')) {
if ($Search) { if ($Search) {
$sql.=' AND '; $sql .= ' AND ';
} else { } else {
$sql.=' WHERE '; $sql .= ' WHERE ';
} }
$sql .= " Time>'".time_minus(3600 * 24 * 28)."' "; $sql .= " Time>'".time_minus(3600 * 24 * 28)."' ";
} }
@ -33,7 +33,7 @@
LIMIT $Limit"; LIMIT $Limit";
$Log = $DB->query($sql); $Log = $DB->query($sql);
$DB->query("SELECT FOUND_ROWS()"); $DB->query('SELECT FOUND_ROWS()');
list($NumResults) = $DB->next_record(); list($NumResults) = $DB->next_record();
$TotalMatches = $NumResults; $TotalMatches = $NumResults;
$DB->set_query_id($Log); $DB->set_query_id($Log);

View File

@ -28,7 +28,7 @@
$DB->query($sql); $DB->query($sql);
$Donations = $DB->to_array(false,MYSQLI_NUM); $Donations = $DB->to_array(false,MYSQLI_NUM);
$DB->query("SELECT FOUND_ROWS()"); $DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record(); list($Results) = $DB->next_record();
if (empty($_GET['search']) && !isset($_GET['page']) && !$DonationTimeline = $Cache->get_value('donation_timeline')) { if (empty($_GET['search']) && !isset($_GET['page']) && !$DonationTimeline = $Cache->get_value('donation_timeline')) {
@ -40,7 +40,7 @@
ORDER BY Time DESC ORDER BY Time DESC
LIMIT 1, 18"); LIMIT 1, 18");
$Timeline = array_reverse($DB->to_array()); $Timeline = array_reverse($DB->to_array());
$Area = new AREA_GRAPH(880, 160, array('Break'=>1)); $Area = new AREA_GRAPH(880, 160, array('Break' => 1));
foreach ($Timeline as $Entry) { foreach ($Timeline as $Entry) {
list($Label, $Amount) = $Entry; list($Label, $Amount) = $Entry;
$Area->add($Label, $Amount); $Area->add($Label, $Amount);
@ -51,7 +51,7 @@
$Area->lines(2); $Area->lines(2);
$Area->generate(); $Area->generate();
$DonationTimeline = $Area->url(); $DonationTimeline = $Area->url();
$Cache->cache_value('donation_timeline',$DonationTimeline,mktime(0,0,0,date('n') + 1, 2)); $Cache->cache_value('donation_timeline', $DonationTimeline, mktime(0, 0, 0, date('n') + 1, 2));
} }
View::show_header('Donation log'); View::show_header('Donation log');

View File

@ -9,7 +9,9 @@
if (!empty($_POST['invitekey']) && check_perms('users_edit_invites')) { if (!empty($_POST['invitekey']) && check_perms('users_edit_invites')) {
authorize(); authorize();
$DB->query("DELETE FROM invites WHERE InviteKey='".db_string($_POST['invitekey'])."'"); $DB->query("
DELETE FROM invites
WHERE InviteKey = '".db_string($_POST['invitekey'])."'");
} }
if (!empty($_GET['search'])) { if (!empty($_GET['search'])) {
@ -29,12 +31,15 @@
FROM invites as i FROM invites as i
JOIN users_main AS um ON um.ID = i.InviterID "; JOIN users_main AS um ON um.ID = i.InviterID ";
if ($Search) { if ($Search) {
$sql .= "WHERE i.Email LIKE '%$Search%' "; $sql .= "
WHERE i.Email LIKE '%$Search%' ";
} }
$sql .= "ORDER BY i.Expires DESC LIMIT $Limit"; $sql .= "
ORDER BY i.Expires DESC
LIMIT $Limit";
$RS = $DB->query($sql); $RS = $DB->query($sql);
$DB->query("SELECT FOUND_ROWS()"); $DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record(); list($Results) = $DB->next_record();
$DB->set_query_id($RS); $DB->set_query_id($RS);
@ -78,7 +83,7 @@
<? <?
$Row = 'b'; $Row = 'b';
while (list($UserID, $IP, $InviteKey, $Expires, $Email) = $DB->next_record()) { while (list($UserID, $IP, $InviteKey, $Expires, $Email) = $DB->next_record()) {
$Row = ($Row == 'b') ? 'a' : 'b'; $Row = $Row === 'b' ? 'a' : 'b';
?> ?>
<tr class="row<?=$Row?>"> <tr class="row<?=$Row?>">
<td><?=Users::format_username($UserID, true, true, true, true)?></td> <td><?=Users::format_username($UserID, true, true, true, true)?></td>

View File

@ -38,9 +38,10 @@
i.Donor, i.Donor,
i.Warned, i.Warned,
i.JoinDate, i.JoinDate,
( SELECT COUNT(h1.UserID) (
SELECT COUNT(h1.UserID)
FROM users_history_ips AS h1 FROM users_history_ips AS h1
WHERE h1.IP=m.IP WHERE h1.IP = m.IP
) AS Uses, ) AS Uses,
im.ID, im.ID,
im.IP, im.IP,
@ -54,12 +55,13 @@
ii.Donor, ii.Donor,
ii.Warned, ii.Warned,
ii.JoinDate, ii.JoinDate,
( SELECT COUNT(h2.UserID) (
SELECT COUNT(h2.UserID)
FROM users_history_ips AS h2 FROM users_history_ips AS h2
WHERE h2.IP=im.IP WHERE h2.IP = im.IP
) AS InviterUses ) AS InviterUses
FROM users_main AS m FROM users_main AS m
LEFT JOIN users_info AS i ON i.UserID=m.ID LEFT JOIN users_info AS i ON i.UserID = m.ID
LEFT JOIN users_main AS im ON i.Inviter = im.ID LEFT JOIN users_main AS im ON i.Inviter = im.ID
LEFT JOIN users_info AS ii ON i.Inviter = ii.UserID LEFT JOIN users_info AS ii ON i.Inviter = ii.UserID
WHERE"; WHERE";
@ -68,9 +70,11 @@
} else { } else {
$RS .= " i.JoinDate > '".time_minus(3600 * 24 * 3)."'"; $RS .= " i.JoinDate > '".time_minus(3600 * 24 * 3)."'";
} }
$RS .= " ORDER BY i.Joindate DESC LIMIT $Limit"; $RS .= "
ORDER BY i.Joindate DESC
LIMIT $Limit";
$QueryID = $DB->query($RS); $QueryID = $DB->query($RS);
$DB->query("SELECT FOUND_ROWS()"); $DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record(); list($Results) = $DB->next_record();
$DB->set_query_id($QueryID); $DB->set_query_id($QueryID);
?> ?>
@ -104,7 +108,7 @@
</tr> </tr>
<? <?
while (list($UserID, $IP, $IPCC, $Email, $Username, $PermissionID, $Uploaded, $Downloaded, $Enabled, $Donor, $Warned, $Joined, $Uses, $InviterID, $InviterIP, $InviterIPCC, $InviterEmail, $InviterUsername, $InviterPermissionID, $InviterUploaded, $InviterDownloaded, $InviterEnabled, $InviterDonor, $InviterWarned, $InviterJoined, $InviterUses) = $DB->next_record()) { while (list($UserID, $IP, $IPCC, $Email, $Username, $PermissionID, $Uploaded, $Downloaded, $Enabled, $Donor, $Warned, $Joined, $Uses, $InviterID, $InviterIP, $InviterIPCC, $InviterEmail, $InviterUsername, $InviterPermissionID, $InviterUploaded, $InviterDownloaded, $InviterEnabled, $InviterDonor, $InviterWarned, $InviterJoined, $InviterUses) = $DB->next_record()) {
$Row = ($IP == $InviterIP) ? 'a' : 'b'; $Row = $IP === $InviterIP ? 'a' : 'b';
?> ?>
<tr class="row<?=$Row?>"> <tr class="row<?=$Row?>">
<td><?=Users::format_username($UserID, true, true, true, true)?><br /><?=Users::format_username($InviterID, true, true, true, true)?></td> <td><?=Users::format_username($UserID, true, true, true, true)?><br /><?=Users::format_username($InviterID, true, true, true, true)?></td>

View File

@ -22,12 +22,12 @@
i.RatioWatchDownload, i.RatioWatchDownload,
m.RequiredRatio m.RequiredRatio
FROM users_main AS m FROM users_main AS m
LEFT JOIN users_info AS i ON i.UserID=m.ID LEFT JOIN users_info AS i ON i.UserID = m.ID
WHERE i.RatioWatchEnds != '0000-00-00 00:00:00' WHERE i.RatioWatchEnds != '0000-00-00 00:00:00'
AND m.Enabled = '1' AND m.Enabled = '1'
ORDER BY i.RatioWatchEnds ASC ORDER BY i.RatioWatchEnds ASC
LIMIT $Limit"); LIMIT $Limit");
$DB->query("SELECT FOUND_ROWS()"); $DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record(); list($Results) = $DB->next_record();
$DB->query(" $DB->query("
SELECT COUNT(UserID) SELECT COUNT(UserID)
@ -63,7 +63,7 @@
</tr> </tr>
<? <?
while (list($UserID, $Username, $Uploaded, $Downloaded, $PermissionID, $Enabled, $Donor, $Warned, $Joined, $RatioWatchEnds, $RatioWatchDownload, $RequiredRatio) = $DB->next_record()) { while (list($UserID, $Username, $Uploaded, $Downloaded, $PermissionID, $Enabled, $Donor, $Warned, $Joined, $RatioWatchEnds, $RatioWatchDownload, $RequiredRatio) = $DB->next_record()) {
$Row = ($Row == 'b') ? 'a' : 'b'; $Row = $Row === 'b' ? 'a' : 'b';
?> ?>
<tr class="row<?=$Row?>"> <tr class="row<?=$Row?>">
@ -74,7 +74,7 @@
<td><?=number_format($RequiredRatio, 2)?></td> <td><?=number_format($RequiredRatio, 2)?></td>
<td><? if (($Downloaded * $RequiredRatio) > $Uploaded) { echo Format::get_size(($Downloaded * $RequiredRatio) - $Uploaded);} ?></td> <td><? if (($Downloaded * $RequiredRatio) > $Uploaded) { echo Format::get_size(($Downloaded * $RequiredRatio) - $Uploaded);} ?></td>
<td><?=Format::get_size($Downloaded - $RatioWatchDownload)?></td> <td><?=Format::get_size($Downloaded - $RatioWatchDownload)?></td>
<td><?=time_diff($Joined,2)?></td> <td><?=time_diff($Joined, 2)?></td>
<td><?=time_diff($RatioWatchEnds)?></td> <td><?=time_diff($RatioWatchEnds)?></td>
<td><?//time_diff(strtotime($Joined), strtotime($RatioWatchEnds))?></td> <td><?//time_diff(strtotime($Joined), strtotime($RatioWatchEnds))?></td>
</tr> </tr>
@ -83,8 +83,11 @@
<div class="linkbox"> <div class="linkbox">
<? echo $Pages; ?> <? echo $Pages; ?>
</div> </div>
<? } else { ?> <?
} else { ?>
<h2 align="center">There are currently no users on ratio watch.</h2> <h2 align="center">There are currently no users on ratio watch.</h2>
<? } <?
}
View::show_footer(); View::show_footer();
?> ?>

View File

@ -7,14 +7,14 @@
if (!isset($_GET['page'])) { if (!isset($_GET['page'])) {
if (!list($Labels, $InFlow, $OutFlow, $Max) = $Cache->get_value('users_timeline')) { if (!list($Labels, $InFlow, $OutFlow, $Max) = $Cache->get_value('users_timeline')) {
$DB->query(" $DB->query("
SELECT DATE_FORMAT(JoinDate,'%b \'%y') AS Month, COUNT(UserID) SELECT DATE_FORMAT(JoinDate, '%b \'%y') AS Month, COUNT(UserID)
FROM users_info FROM users_info
GROUP BY Month GROUP BY Month
ORDER BY JoinDate DESC ORDER BY JoinDate DESC
LIMIT 1, 12"); LIMIT 1, 12");
$TimelineIn = array_reverse($DB->to_array()); $TimelineIn = array_reverse($DB->to_array());
$DB->query(" $DB->query("
SELECT DATE_FORMAT(BanDate,'%b \'%y') AS Month, COUNT(UserID) SELECT DATE_FORMAT(BanDate, '%b \'%y') AS Month, COUNT(UserID)
FROM users_info FROM users_info
GROUP BY Month GROUP BY Month
ORDER BY BanDate DESC ORDER BY BanDate DESC
@ -54,7 +54,7 @@
SELECT SELECT
SQL_CALC_FOUND_ROWS SQL_CALC_FOUND_ROWS
j.Date, j.Date,
DATE_FORMAT(j.Date,'%Y-%m') AS Month, DATE_FORMAT(j.Date, '%Y-%m') AS Month,
CASE ISNULL(j.Flow) CASE ISNULL(j.Flow)
WHEN 0 THEN j.Flow WHEN 0 THEN j.Flow
ELSE '0' ELSE '0'
@ -73,7 +73,7 @@
END AS Inactivity END AS Inactivity
FROM ( FROM (
SELECT SELECT
DATE_FORMAT(JoinDate,'%Y-%m-%d') AS Date, DATE_FORMAT(JoinDate, '%Y-%m-%d') AS Date,
COUNT(UserID) AS Flow COUNT(UserID) AS Flow
FROM users_info FROM users_info
WHERE JoinDate != '0000-00-00 00:00:00' WHERE JoinDate != '0000-00-00 00:00:00'
@ -81,34 +81,34 @@
) AS j ) AS j
LEFT JOIN ( LEFT JOIN (
SELECT SELECT
DATE_FORMAT(BanDate,'%Y-%m-%d') AS Date, DATE_FORMAT(BanDate, '%Y-%m-%d') AS Date,
COUNT(UserID) AS Flow COUNT(UserID) AS Flow
FROM users_info FROM users_info
WHERE BanDate != '0000-00-00 00:00:00' WHERE BanDate != '0000-00-00 00:00:00'
AND BanReason = '1' AND BanReason = '1'
GROUP BY Date GROUP BY Date
) AS m ON j.Date=m.Date ) AS m ON j.Date = m.Date
LEFT JOIN ( LEFT JOIN (
SELECT SELECT
DATE_FORMAT(BanDate,'%Y-%m-%d') AS Date, DATE_FORMAT(BanDate, '%Y-%m-%d') AS Date,
COUNT(UserID) AS Flow COUNT(UserID) AS Flow
FROM users_info FROM users_info
WHERE BanDate != '0000-00-00 00:00:00' WHERE BanDate != '0000-00-00 00:00:00'
AND BanReason = '2' AND BanReason = '2'
GROUP BY Date GROUP BY Date
) AS r ON j.Date=r.Date ) AS r ON j.Date = r.Date
LEFT JOIN ( LEFT JOIN (
SELECT SELECT
DATE_FORMAT(BanDate,'%Y-%m-%d') AS Date, DATE_FORMAT(BanDate, '%Y-%m-%d') AS Date,
COUNT(UserID) AS Flow COUNT(UserID) AS Flow
FROM users_info FROM users_info
WHERE BanDate != '0000-00-00 00:00:00' WHERE BanDate != '0000-00-00 00:00:00'
AND BanReason = '3' AND BanReason = '3'
GROUP BY Date GROUP BY Date
) AS i ON j.Date=i.Date ) AS i ON j.Date = i.Date
ORDER BY j.Date DESC ORDER BY j.Date DESC
LIMIT $Limit"); LIMIT $Limit");
$DB->query("SELECT FOUND_ROWS()"); $DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record(); list($Results) = $DB->next_record();
View::show_header('User Flow'); View::show_header('User Flow');