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() {
if ($this->QueryID) {
return mysqli_num_rows($this->QueryID);

View File

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

View File

@ -16,7 +16,10 @@ function compare($X, $Y) {
if (!is_number($UserID)) {
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();
} else {
$UserID = $LoggedUser['ID'];

View File

@ -19,7 +19,10 @@
if (isset($_GET['topicid']) && is_number($_GET['topicid'])) {
$ThreadID = $_GET['topicid'];
} 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();
if ($ThreadID) {
//Redirect postid to threadid when necessary.
@ -84,7 +87,7 @@
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
if (!$Catalogue = $Cache->get_value('thread_'.$ThreadID.'_catalogue_'.$CatalogueID)) {
if (!$Catalogue = $Cache->get_value("thread_$ThreadID"."_catalogue_$CatalogueID")) {
$DB->query("
SELECT
p.ID,
@ -97,14 +100,14 @@
WHERE p.TopicID = '$ThreadID'
AND p.ID != '".$ThreadInfo['StickyPostID']."'
LIMIT $CatalogueLimit");
$Catalogue = $DB->to_array(false,MYSQLI_ASSOC);
$Catalogue = $DB->to_array(false, MYSQLI_ASSOC);
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);
if ($_GET['updatelastread'] != '0') {
if ($_GET['updatelastread'] !== '0') {
$LastPost = end($Thread);
$LastPost = $LastPost['ID'];
reset($Thread);
@ -116,8 +119,8 @@
$DB->query("
SELECT PostID
FROM forums_last_read_topics
WHERE UserID='$LoggedUser[ID]'
AND TopicID='$ThreadID'");
WHERE UserID = '$LoggedUser[ID]'
AND TopicID = '$ThreadID'");
list($LastRead) = $DB->next_record();
if ($LastRead < $LastPost) {
$DB->query("
@ -125,7 +128,7 @@
(UserID, TopicID, PostID)
VALUES
('$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,
'authorName' => $Username,
'paranoia' => $Paranoia,
'artist' => ($Artist == 1),
'donor' => ($Donor == 1),
'warned' => ($Warned != '0000-00-00 00:00:00'),
'artist' => ($Artist === '1'),
'donor' => ($Donor === '1'),
'warned' => ($Warned !== '0000-00-00 00:00:00'),
'avatar' => $Avatar,
'enabled' => (($Enabled == 2) ? false : true),
'enabled' => (($Enabled === '2') ? false : true),
'userTitle' => $UserTitle
),

View File

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

View File

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

View File

@ -43,7 +43,7 @@
if ($CloneRedirect != 0) {
$DB->query("
UPDATE artists_alias
SET ArtistID = '$ArtistID', Redirect=0
SET ArtistID = '$ArtistID', Redirect = 0
WHERE AliasID = '$CloneAliasID'");
Misc::write_log("Redirection for the alias $CloneAliasID ($DBAliasName) for the artist $ArtistID was removed by user $LoggedUser[ID] ($LoggedUser[Username])");
} else {
@ -72,8 +72,10 @@
}
}
$DB->query("
INSERT INTO artists_alias(ArtistID, Name, Redirect, UserID)
VALUES ($ArtistID, '$DBAliasName', $Redirect, ".$LoggedUser['ID'].')');
INSERT INTO artists_alias
(ArtistID, Name, Redirect, UserID)
VALUES
($ArtistID, '$DBAliasName', $Redirect, ".$LoggedUser['ID'].')');
$AliasID = $DB->inserted_id();
$DB->query("
@ -82,7 +84,7 @@
WHERE ArtistID = $ArtistID");
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']);
?>

View File

@ -27,32 +27,34 @@
SQL template:
SELECT
CASE
WHEN t.Format='MP3' AND t.Encoding='V0 (VBR)' THEN 1
WHEN t.Format='MP3' AND t.Encoding='V2 (VBR)' THEN 2
ELSE 100
WHEN t.Format = 'MP3' AND t.Encoding = 'V0 (VBR)'
THEN 1
WHEN t.Format = 'MP3' AND t.Encoding = 'V2 (VBR)'
THEN 2
ELSE 100
END AS Rank,
t.GroupID,
t.Media,
t.Format,
t.Encoding,
IF(t.Year=0,tg.Year,t.Year),
IF(t.Year = 0, tg.Year, t.Year),
tg.Name,
a.Name,
t.Size
FROM torrents AS t
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'
LEFT JOIN torrents_files AS f ON t.ID=f.TorrentID
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'
LEFT JOIN torrents_files AS f ON t.ID = f.TorrentID
ORDER BY t.GroupID ASC, Rank DESC, t.Seeders ASC
*/
if (
!isset($_REQUEST['artistid']) ||
!isset($_REQUEST['preference']) ||
!is_number($_REQUEST['preference']) ||
!is_number($_REQUEST['artistid']) ||
$_REQUEST['preference'] > 2 ||
count($_REQUEST['list']) == 0
!isset($_REQUEST['artistid'])
|| !isset($_REQUEST['preference'])
|| !is_number($_REQUEST['preference'])
|| !is_number($_REQUEST['artistid'])
|| $_REQUEST['preference'] > 2
|| count($_REQUEST['list']) == 0
) {
error(0);
}
@ -66,73 +68,84 @@
$ArtistID = $_REQUEST['artistid'];
$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);
$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()) {
error(404);
}
$Releases = $DB->to_array('GroupID', MYSQLI_ASSOC, false);
$GroupIDs = array_keys($Releases);
$SQL = "SELECT CASE ";
$SQL = 'SELECT CASE ';
foreach ($_REQUEST['list'] as $Priority => $Selection) {
if (!is_number($Priority)) {
continue;
}
$SQL .= "WHEN ";
$SQL .= 'WHEN ';
switch ($Selection) {
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 '02': $SQL .= "t.Format='MP3' AND t.Encoding='256 (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 '11': $SQL .= "t.Format='MP3' AND t.Encoding='V2 (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 '20': $SQL .= "t.Format='MP3' AND t.Encoding='320'"; break;
case '21': $SQL .= "t.Format='MP3' AND t.Encoding='256'"; break;
case '22': $SQL .= "t.Format='MP3' AND t.Encoding='224'"; 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 '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 '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 '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 '37': $SQL .= "t.Format='FLAC' AND t.Encoding='Lossless'"; break;
case '40': $SQL .= "t.Format='DTS'"; break;
case '42': $SQL .= "t.Format='AAC' AND t.Encoding='320'"; 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 '45': $SQL .= "t.Format='AAC' AND t.Encoding='q5'"; break;
case '46': $SQL .= "t.Format='AAC' AND t.Encoding='192'"; 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 '02': $SQL .= "t.Format = 'MP3' AND t.Encoding = '256 (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 '11': $SQL .= "t.Format = 'MP3' AND t.Encoding = 'V2 (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 '20': $SQL .= "t.Format = 'MP3' AND t.Encoding = '320'"; break;
case '21': $SQL .= "t.Format = 'MP3' AND t.Encoding = '256'"; break;
case '22': $SQL .= "t.Format = 'MP3' AND t.Encoding = '224'"; 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 '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 '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 '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 '37': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless'"; break;
case '40': $SQL .= "t.Format = 'DTS'"; break;
case '42': $SQL .= "t.Format = 'AAC' AND t.Encoding = '320'"; 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 '45': $SQL .= "t.Format = 'AAC' AND t.Encoding = 'q5'"; break;
case '46': $SQL .= "t.Format = 'AAC' AND t.Encoding = '192'"; break;
default: error(0);
}
$SQL .= " THEN $Priority ";
}
$SQL .= "ELSE 100 END AS Rank,
t.GroupID,
t.ID AS TorrentID,
t.Media,
t.Format,
t.Encoding,
tg.ReleaseType,
IF(t.RemasterYear=0,tg.Year,t.RemasterYear) AS Year,
tg.Name,
t.Size
$SQL .= "
ELSE 100
END AS Rank,
t.GroupID,
t.ID AS TorrentID,
t.Media,
t.Format,
t.Encoding,
tg.ReleaseType,
IF(t.RemasterYear = 0, tg.Year, t.RemasterYear) AS Year,
tg.Name,
t.Size
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";
$DownloadsQ = $DB->query($SQL);
$Collector = new TorrentsDL($DownloadsQ, $ArtistName);
while (list($Downloads, $GroupIDs) = $Collector->get_downloads('GroupID')) {
$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)) {
// Query failed. Let's not create a broken zip archive
foreach ($GroupIDs as $GroupID) {
@ -153,9 +166,9 @@
if ($Releases[$GroupID]['Importance'] == 1) {
$ReleaseTypeName = $ReleaseTypes[$Download['ReleaseType']];
} else if ($Releases[$GroupID]['Importance'] == 2) {
$ReleaseTypeName = "Guest Appearance";
$ReleaseTypeName = 'Guest Appearance';
} else if ($Releases[$GroupID]['Importance'] == 3) {
$ReleaseTypeName = "Remixed By";
$ReleaseTypeName = 'Remixed By';
}
$Collector->add_file($TorrentFile, $Download, $ReleaseTypeName);
unset($Download);

View File

@ -9,21 +9,39 @@
}
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 {
$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);
$DB->query("SELECT Name FROM artists_alias 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);
list($ID, $Artists) = $DB->next_record(MYSQLI_NUM, false);
$DB->query("
SELECT Name
FROM artists_alias
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 == '|') {
$DB->query("DELETE FROM users_notify_filters WHERE ID=$ID");
$DB->query("
DELETE FROM users_notify_filters
WHERE ID = $ID");
} 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_artists_'.$LoggedUser['ID']);

View File

@ -1,23 +1,23 @@
<?
<?php
/****************************************************************
*--------------[ Rename artist ]-----------------------------*
* This page handles the backend of the 'rename artist' *
* feature. It is quite resource intensive, which is okay *
* since it's rarely used. *
* *
* If there is no artist with the target name, it simply *
* renames the artist. However, if there is an artist with the *
* target name, things gut funky - the artists must be merged, *
* along with their torrents. *
* *
* In the event of a merger, the description of THE TARGET *
* ARTIST will be used as the description of the final result. *
* The same applies for torrents. *
* *
* Tags are not merged along with the torrents. *
* Neither are similar artists. *
* *
* We can add these features eventually. *
* This page handles the backend of the 'rename artist' *
* feature. It is quite resource intensive, which is okay *
* since it's rarely used. *
* *
* If there is no artist with the target name, it simply *
* renames the artist. However, if there is an artist with the *
* target name, things gut funky - the artists must be merged, *
* along with their torrents. *
* *
* In the event of a merger, the description of THE TARGET *
* ARTIST will be used as the description of the final result. *
* The same applies for torrents. *
* *
* Tags are not merged along with the torrents. *
* Neither are similar artists. *
* *
* We can add these features eventually. *
****************************************************************/
authorize();
@ -33,7 +33,10 @@
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()) {
error(404);
}
@ -45,8 +48,8 @@
$DB->query("
SELECT AliasID
FROM artists_alias
WHERE Name='".db_string($OldName)."'
AND ArtistID='$ArtistID'");
WHERE Name = '".db_string($OldName)."'
AND ArtistID = '$ArtistID'");
list($OldAliasID) = $DB->next_record(MYSQLI_NUM, false);
if (!$OldAliasID) {
error('Could not find old alias ID');
@ -58,34 +61,58 @@
WHERE name LIKE '".db_string($NewName, true)."'");
list($TargetAliasID, $TargetArtistID) = $DB->next_record(MYSQLI_NUM, false);
if (!$TargetAliasID || $TargetAliasID==$OldAliasID) {
if (!$TargetAliasID || $TargetAliasID == $OldAliasID) {
// no merge, just rename
$DB->query("
INSERT INTO artists_alias (ArtistID, Name, Redirect, UserID)
VALUES ($ArtistID, '".db_string($NewName)."', '0', '$LoggedUser[ID]')");
INSERT INTO artists_alias
(ArtistID, Name, Redirect, UserID)
VALUES
($ArtistID, '".db_string($NewName)."', '0', '$LoggedUser[ID]')");
$TargetAliasID = $DB->inserted_id();
$DB->query("UPDATE artists_alias SET Redirect='$TargetAliasID' WHERE AliasID='$OldAliasID'");
$DB->query("UPDATE artists_group SET Name='".db_string($NewName)."' WHERE ArtistID='$ArtistID'");
$DB->query("
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');
$DB->query("UPDATE IGNORE torrents_artists SET AliasID='$TargetAliasID' WHERE AliasID='$OldAliasID'");
$DB->query("DELETE FROM torrents_artists WHERE AliasID='$OldAliasID'");
$DB->query("
UPDATE IGNORE torrents_artists
SET AliasID = '$TargetAliasID'
WHERE AliasID = '$OldAliasID'");
$DB->query("
DELETE FROM torrents_artists
WHERE AliasID = '$OldAliasID'");
if (!empty($Groups)) {
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);
}
}
$DB->query("SELECT RequestID FROM requests_artists WHERE AliasID='$OldAliasID'");
$DB->query("
SELECT RequestID
FROM requests_artists
WHERE AliasID = '$OldAliasID'");
$Requests = $DB->collect('RequestID');
$DB->query("UPDATE IGNORE requests_artists SET AliasID='$TargetAliasID' WHERE AliasID='$OldAliasID'");
$DB->query("DELETE FROM requests_artists WHERE AliasID='$OldAliasID'");
$DB->query("
UPDATE IGNORE requests_artists
SET AliasID = '$TargetAliasID'
WHERE AliasID = '$OldAliasID'");
$DB->query("
DELETE FROM requests_artists
WHERE AliasID = '$OldAliasID'");
if (!empty($Requests)) {
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);
}
}
@ -94,69 +121,100 @@
} else { // Merge stuff
$DB->query("
UPDATE artists_alias
SET Redirect='$TargetAliasID', ArtistID='$TargetArtistID'
WHERE AliasID='$OldAliasID'");
$DB->query("UPDATE artists_alias SET Redirect='0' WHERE AliasID='$TargetAliasID'");
SET Redirect = '$TargetAliasID', ArtistID = '$TargetArtistID'
WHERE AliasID = '$OldAliasID'");
$DB->query("
UPDATE artists_alias
SET Redirect = '0'
WHERE AliasID = '$TargetAliasID'");
if ($ArtistID != $TargetArtistID) {
$DB->query("UPDATE artists_alias SET ArtistID='$TargetArtistID' WHERE ArtistID='$ArtistID'");
$DB->query("DELETE FROM artists_group WHERE ArtistID='$ArtistID'");
$DB->query("
UPDATE artists_alias
SET ArtistID = '$TargetArtistID'
WHERE ArtistID = '$ArtistID'");
$DB->query("
DELETE FROM artists_group
WHERE ArtistID = '$ArtistID'");
} 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');
$DB->query("
UPDATE IGNORE torrents_artists
SET AliasID='$TargetAliasID', ArtistID='$TargetArtistID'
WHERE AliasID='$OldAliasID'");
$DB->query("DELETE FROM torrents_artists WHERE AliasID='$OldAliasID'");
SET AliasID = '$TargetAliasID', ArtistID = '$TargetArtistID'
WHERE AliasID = '$OldAliasID'");
$DB->query("
DELETE FROM torrents_artists
WHERE AliasID = '$OldAliasID'");
if (!empty($Groups)) {
foreach ($Groups as $GroupID) {
$Cache->delete_value('groups_artists_'.$GroupID);
$Cache->delete_value("groups_artists_$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');
$DB->query("
UPDATE IGNORE requests_artists
SET AliasID='$TargetAliasID', ArtistID='$TargetArtistID'
WHERE AliasID='$OldAliasID'");
$DB->query("DELETE FROM requests_artists WHERE AliasID='$OldAliasID'");
SET AliasID = '$TargetAliasID', ArtistID = '$TargetArtistID'
WHERE AliasID = '$OldAliasID'");
$DB->query("
DELETE FROM requests_artists
WHERE AliasID = '$OldAliasID'");
if (!empty($Requests)) {
foreach ($Requests as $RequestID) {
$Cache->delete_value('request_artists_'.$RequestID);
$Cache->delete_value("request_artists_$RequestID");
Requests::update_sphinx_requests($RequestID);
}
}
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');
$DB->query("
UPDATE IGNORE torrents_artists
SET ArtistID='$TargetArtistID'
WHERE ArtistID='$ArtistID'");
$DB->query("DELETE FROM torrents_artists WHERE ArtistID='$ArtistID'");
SET ArtistID = '$TargetArtistID'
WHERE ArtistID = '$ArtistID'");
$DB->query("
DELETE FROM torrents_artists
WHERE ArtistID = '$ArtistID'");
if (!empty($Groups)) {
foreach ($Groups as $GroupID) {
$Cache->delete_value('groups_artists_'.$GroupID);
$Cache->delete_value("groups_artists_$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');
$DB->query("
UPDATE IGNORE requests_artists
SET ArtistID='$TargetArtistID'
WHERE ArtistID='$ArtistID'");
$DB->query("DELETE FROM requests_artists WHERE ArtistID='$ArtistID'");
SET ArtistID = '$TargetArtistID'
WHERE ArtistID = '$ArtistID'");
$DB->query("
DELETE FROM requests_artists
WHERE ArtistID = '$ArtistID'");
if (!empty($Requests)) {
foreach ($Requests as $RequestID) {
$Cache->delete_value('request_artists_'.$RequestID);
$Cache->delete_value("request_artists_$RequestID");
Requests::update_sphinx_requests($RequestID);
}
}
@ -164,16 +222,19 @@
}
// 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()) {
$Cache->delete_value('torrents_details_'.$GroupID);
$Cache->delete_value("torrents_details_$GroupID");
}
$Cache->delete_value('artist_'.$ArtistID);
$Cache->delete_value('artist_'.$TargetArtistID);
$Cache->delete_value('artists_requests_'.$TargetArtistID);
$Cache->delete_value('artists_requests_'.$ArtistID);
$Cache->delete_value("artist_$ArtistID");
$Cache->delete_value("artist_$TargetArtistID");
$Cache->delete_value("artists_requests_$TargetArtistID");
$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);
}
$UserID = $_GET['userid'];
$Sneaky = ($UserID != $LoggedUser['ID']);
$Sneaky = ($UserID !== $LoggedUser['ID']);
if (!is_number($UserID)) {
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();
} else {
$UserID = $LoggedUser['ID'];
}
$Sneaky = ($UserID != $LoggedUser['ID']);
$Sneaky = ($UserID !== $LoggedUser['ID']);
//$ArtistList = Bookmarks::all_bookmarks('artist', $UserID);
$DB->query('
$DB->query("
SELECT ag.ArtistID, ag.Name
FROM bookmarks_artists AS ba
INNER JOIN artists_group AS ag ON ba.ArtistID = ag.ArtistID
WHERE ba.UserID = '.$UserID.'
ORDER BY ag.Name');
WHERE ba.UserID = $UserID
ORDER BY ag.Name");
$ArtistList = $DB->to_array();
$Title = ($Sneaky) ? "$Username's bookmarked artists" : 'Your bookmarked artists';
View::show_header($Title,'browse');
View::show_header($Title, 'browse');
?>
<div class="thin">
@ -59,7 +62,7 @@
<?
$Row = 'a';
foreach ($ArtistList as $Artist) {
$Row = ($Row == 'a') ? 'b' : 'a';
$Row = ($Row === 'a') ? 'b' : 'a';
list($ArtistID, $Name) = $Artist;
?>
<tr class="row<?=$Row?> bookmark_<?=$ArtistID?>">
@ -72,13 +75,13 @@
$DB->query("
SELECT ID, Artists
FROM users_notify_filters
WHERE UserID='$LoggedUser[ID]'
AND Label='Artist notifications'
WHERE UserID = '$LoggedUser[ID]'
AND Label = 'Artist notifications'
LIMIT 1");
$Notify = $DB->next_record(MYSQLI_ASSOC);
$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>
<?
@ -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>
</td>
</tr>

View File

@ -8,7 +8,10 @@
if (!is_number($UserID)) {
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();
} else {
$UserID = $LoggedUser['ID'];

View File

@ -24,10 +24,22 @@
case 'remove_snatched':
authorize();
$DB->query("CREATE TEMPORARY TABLE snatched_groups_temp (GroupID int PRIMARY KEY)");
$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);
$DB->query("
CREATE TEMPORARY TABLE snatched_groups_temp
(GroupID int PRIMARY KEY)");
$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');
die();
break;
@ -40,11 +52,11 @@
case 'torrents':
require(SERVER_ROOT.'/sections/bookmarks/edit_torrents.php');
break;
default : error(404);
default:
error(404);
}
break;
case 'view':
if (empty($_REQUEST['type'])) {
$_REQUEST['type'] = 'torrents';
@ -57,7 +69,7 @@
require(SERVER_ROOT.'/sections/bookmarks/artists.php');
break;
case 'collages':
$_GET['bookmarks'] = 1;
$_GET['bookmarks'] = '1';
require(SERVER_ROOT.'/sections/collages/browse.php');
break;
case 'requests':
@ -68,6 +80,7 @@
error(404);
}
break;
default:
error(404);
}

View File

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

View File

@ -1,5 +1,5 @@
<?
ini_set('max_execution_time',600);
<?php
ini_set('max_execution_time', 600);
set_time_limit(0);
//~~~~~~~~~~~ Main bookmarks page ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
@ -16,13 +16,16 @@ function compare($X, $Y) {
if (!is_number($UserID)) {
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();
} else {
$UserID = $LoggedUser['ID'];
}
$Sneaky = $UserID != $LoggedUser['ID'];
$Sneaky = $UserID !== $LoggedUser['ID'];
$Title = $Sneaky ? "$Username's bookmarked torrents" : 'Your bookmarked torrents';
// Loop through the result set, building up $Collage and $TorrentTable
@ -44,7 +47,7 @@ function compare($X, $Y) {
if ($Artists) {
foreach ($Artists as $Artist) {
if (!isset($ArtistCount[$Artist['id']])) {
$ArtistCount[$Artist['id']] = array('name'=>$Artist['name'], 'count'=>1);
$ArtistCount[$Artist['id']] = array('name' => $Artist['name'], 'count' => 1);
} else {
$ArtistCount[$Artist['id']]['count']++;
}
@ -58,13 +61,13 @@ function compare($X, $Y) {
unset($ExtendedArtists[3]);
$DisplayName = Artists::display_artists($ExtendedArtists);
} elseif (count($Artists) > 0) {
$DisplayName = Artists::display_artists(array('1'=>$Artists));
$DisplayName = Artists::display_artists(array('1' => $Artists));
} else {
$DisplayName = '';
}
$DisplayName .= '<a href="torrents.php?id='.$GroupID.'" title="View Torrent" dir="ltr">'.$GroupName.'</a>';
if ($GroupYear > 0) {
$DisplayName = $DisplayName . " [$GroupYear]";
$DisplayName = "$DisplayName [$GroupYear]";
}
if ($GroupVanityHouse) {
$DisplayName .= ' [<abbr title="This is a Vanity House release">VH</abbr>]';
@ -75,12 +78,12 @@ function compare($X, $Y) {
ob_start();
if (count($Torrents) > 1 || $GroupCategoryID == 1) {
// Grouped torrents
$ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1);
$ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1);
?>
<tr class="group discog<?=$SnatchedGroupClass?>" id="group_<?=$GroupID?>">
<td class="center">
<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>
</td>
<td class="center">
@ -89,10 +92,10 @@ function compare($X, $Y) {
<td colspan="5">
<strong><?=$DisplayName?></strong>
<span style="text-align: right;" class="float_right">
<? if (!$Sneaky) { ?>
<? if (!$Sneaky) { ?>
<a href="#group_<?=$GroupID?>" class="brackets remove_bookmark" title="Remove bookmark" onclick="Unbookmark('torrent', <?=$GroupID?>, '');return false;">Unbookmark</a>
<br />
<? } ?>
<? } ?>
<?=time_diff($AddedTime);?>
</span>
<div class="tags"><?=$TorrentTags->format()?></div>
@ -115,12 +118,17 @@ function compare($X, $Y) {
}
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
if ($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear ||
$Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber || $FirstUnknown || $Torrent['Media'] != $LastMedia) {
if (
$Torrent['RemasterTitle'] != $LastRemasterTitle
|| $Torrent['RemasterYear'] != $LastRemasterYear
|| $Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel
|| $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber
|| $FirstUnknown
|| $Torrent['Media'] != $LastMedia
) {
$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>
</tr>
<?
@ -131,7 +139,7 @@ function compare($X, $Y) {
$LastRemasterCatalogueNumber = $Torrent['RemasterCatalogueNumber'];
$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">
<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)) { ?>
@ -158,9 +166,9 @@ function compare($X, $Y) {
if ($Torrent['IsSnatched']) {
$DisplayName .= ' ' . Format::torrent_label('Snatched!');
}
if ($Torrent['FreeTorrent'] == '1') {
if ($Torrent['FreeTorrent'] === '1') {
$DisplayName .= ' ' . Format::torrent_label('Freeleech!');
} elseif ($Torrent['FreeTorrent'] == '2') {
} elseif ($Torrent['FreeTorrent'] === '2') {
$DisplayName .= ' ' . Format::torrent_label('Neutral leech!');
} elseif ($Torrent['PersonalFL']) {
$DisplayName .= ' ' . Format::torrent_label('Personal Freeleech!');
@ -183,9 +191,9 @@ function compare($X, $Y) {
</span>
<strong><?=$DisplayName?></strong>
<div class="tags"><?=$TorrentTags->format()?></div>
<? if (!$Sneaky) { ?>
<? if (!$Sneaky) { ?>
<span class="float_right float_clear"><a href="#group_<?=$GroupID?>" class="brackets remove_bookmark" title="Remove bookmark" onclick="Unbookmark('torrent', <?=$GroupID?>, '');return false;">Unbookmark</a></span>
<? } ?>
<? } ?>
<span class="float_right float_clear"><?=time_diff($AddedTime);?></span>
</td>
@ -196,7 +204,7 @@ function compare($X, $Y) {
</tr>
<?
}
$TorrentTable.= ob_get_clean();
$TorrentTable .= ob_get_clean();
// Album art
@ -208,11 +216,11 @@ function compare($X, $Y) {
unset($ExtendedArtists[3]);
$DisplayName .= Artists::display_artists($ExtendedArtists, false);
} elseif (count($Artists) > 0) {
$DisplayName .= Artists::display_artists(array('1'=>$Artists), false);
$DisplayName .= Artists::display_artists(array('1' => $Artists), false);
}
$DisplayName .= $GroupName;
if ($GroupYear > 0) {
$DisplayName = $DisplayName . " [$GroupYear]";
$DisplayName = "$DisplayName [$GroupYear]";
}
?>
<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();
for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) {
$Groups = array_slice($Collage, $i * $CollageCovers, $CollageCovers);
@ -257,7 +265,7 @@ function compare($X, $Y) {
<? } ?>
</div>
</div>
<? if (count($TorrentList) == 0) { ?>
<? if (count($TorrentList) === 0) { ?>
<div class="box pad" align="center">
<h2>You have not bookmarked any torrents.</h2>
</div>
@ -271,7 +279,9 @@ function compare($X, $Y) {
<div class="head"><strong>Stats</strong></div>
<ul class="stats nobullet">
<li>Torrents: <?=$NumGroups?></li>
<? if (count($ArtistCount) > 0) { ?> <li>Artists: <?=count($ArtistCount)?></li> <? } ?>
<? if (count($ArtistCount) > 0) { ?>
<li>Artists: <?=count($ArtistCount)?></li>
<? } ?>
</ul>
</div>
<div class="box box_tags">
@ -305,7 +315,7 @@ function compare($X, $Y) {
</div>
<div class="main_column">
<?
if ($CollageCovers != 0) { ?>
if ($CollageCovers !== 0) { ?>
<div id="coverart" class="box">
<div class="head" id="coverhead"><strong>Cover art</strong></div>
<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="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++) { ?>
<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="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>
<script type="text/javascript">
collageShow.init(<?=json_encode($CollagePages)?>);

View File

@ -23,7 +23,11 @@
$NumComments = Collages::get_comment_count($CollageID);
if (isset($_GET['postid']) && is_number($_GET['postid']) && $NumComments > TORRENT_COMMENTS_PER_PAGE) {
$DB->query("SELECT COUNT(ID) FROM collages_comments WHERE CollageID = $CollageID AND ID <= $_GET[postid]");
$DB->query("
SELECT COUNT(ID)
FROM collages_comments
WHERE CollageID = $CollageID
AND ID <= $_GET[postid]");
list($PostNum) = $DB->next_record();
list($Page, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $PostNum);
} else {
@ -42,11 +46,14 @@
//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);
$DB->query("SELECT Name FROM collages WHERE ID='$CollageID'");
$DB->query("
SELECT Name
FROM collages
WHERE ID = '$CollageID'");
list($Name) = $DB->next_record();
// 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="header">
@ -80,7 +87,7 @@
<span style="float: left;"><a href="#post<?=$PostID?>">#<?=$PostID?></a>
<?=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 ($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> <? } ?>
</span>
<span id="bar<?=$PostID?>" style="float: right;">
@ -102,7 +109,8 @@
</td>
</tr>
</table>
<? }
<?
}
if (!$ThreadInfo['IsLocked'] || check_perms('site_moderate_forums')) {
if ($ThreadInfo['MinClassWrite'] <= $LoggedUser['Class'] && !$LoggedUser['DisablePosting']) {

View File

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

View File

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

View File

@ -18,24 +18,31 @@
// Get number of pages
// $Pages = number of pages in the thread
// $Page = which page the post is on
$DB->query("SELECT
CollageID,
CEIL(COUNT(ID)/" . TORRENT_COMMENTS_PER_PAGE . ") AS Pages,
CEIL(SUM(IF(ID<='$PostID',1,0))/" . TORRENT_COMMENTS_PER_PAGE . ") AS Page
$DB->query("
SELECT
CollageID,
CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Pages,
CEIL(SUM(IF(ID <= '$PostID', 1, 0)) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
FROM collages_comments
WHERE CollageID=(SELECT CollageID FROM collages_comments WHERE ID='$PostID')
WHERE CollageID = (
SELECT CollageID
FROM collages_comments
WHERE ID = '$PostID'
)
GROUP BY CollageID");
list($CollageID, $Pages, $Page) = $DB->next_record();
$DB->query("DELETE FROM collages_comments WHERE ID='$PostID'");
$DB->query("
DELETE FROM collages_comments
WHERE ID = '$PostID'");
$Cache->delete_value('collage_'.$CollageID);
$Cache->increment_value('collage_comments_'.$CollageID, -1);
$Cache->delete_value("collage_$CollageID");
$Cache->increment_value("collage_comments_$CollageID", -1);
//We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
$ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
$LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
for ($i = $ThisCatalogue; $i <= $LastCatalogue; $i++) {
$Cache->delete_value('collage_comments_'.$CollageID.'_catalogue_'.$i);
$Cache->delete_value("collage_comments_$CollageID"."_catalogue_$i");
}
?>

View File

@ -26,33 +26,35 @@
SQL template:
SELECT
CASE
WHEN t.Format='MP3' AND t.Encoding='V0 (VBR)' THEN 1
WHEN t.Format='MP3' AND t.Encoding='V2 (VBR)' THEN 2
ELSE 100
WHEN t.Format = 'MP3' AND t.Encoding = 'V0 (VBR)'
THEN 1
WHEN t.Format = 'MP3' AND t.Encoding = 'V2 (VBR)'
THEN 2
ELSE 100
END AS Rank,
t.GroupID,
t.Media,
t.Format,
t.Encoding,
IF(t.Year=0,tg.Year,t.Year),
IF(t.Year = 0, tg.Year, t.Year),
tg.Name,
a.Name,
t.Size
FROM torrents AS t
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'
LEFT JOIN artists_group AS a ON a.ArtistID=tg.ArtistID
LEFT JOIN torrents_files AS f ON t.ID=f.TorrentID
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'
LEFT JOIN artists_group AS a ON a.ArtistID = tg.ArtistID
LEFT JOIN torrents_files AS f ON t.ID = f.TorrentID
ORDER BY t.GroupID ASC, Rank DESC, t.Seeders ASC
*/
if (
!isset($_REQUEST['collageid']) ||
!isset($_REQUEST['preference']) ||
!is_number($_REQUEST['preference']) ||
!is_number($_REQUEST['collageid']) ||
$_REQUEST['preference'] > 2 ||
count($_REQUEST['list']) == 0
!isset($_REQUEST['collageid'])
|| !isset($_REQUEST['preference'])
|| !is_number($_REQUEST['preference'])
|| !is_number($_REQUEST['collageid'])
|| $_REQUEST['preference'] > 2
|| count($_REQUEST['list']) === 0
) {
error(0);
}
@ -66,59 +68,64 @@
$CollageID = $_REQUEST['collageid'];
$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);
$SQL = "SELECT CASE ";
$SQL = 'SELECT CASE ';
foreach ($_REQUEST['list'] as $Priority => $Selection) {
if (!is_number($Priority)) {
continue;
}
$SQL .= "WHEN ";
$SQL .= 'WHEN ';
switch ($Selection) {
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 '02': $SQL .= "t.Format='MP3' AND t.Encoding='256 (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 '11': $SQL .= "t.Format='MP3' AND t.Encoding='V2 (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 '20': $SQL .= "t.Format='MP3' AND t.Encoding='320'"; break;
case '21': $SQL .= "t.Format='MP3' AND t.Encoding='256'"; break;
case '22': $SQL .= "t.Format='MP3' AND t.Encoding='224'"; 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 '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 '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 '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 '37': $SQL .= "t.Format='FLAC' AND t.Encoding='Lossless'"; break;
case '40': $SQL .= "t.Format='DTS'"; break;
case '42': $SQL .= "t.Format='AAC' AND t.Encoding='320'"; 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 '45': $SQL .= "t.Format='AAC' AND t.Encoding='q5'"; break;
case '46': $SQL .= "t.Format='AAC' AND t.Encoding='192'"; 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 '02': $SQL .= "t.Format = 'MP3' AND t.Encoding = '256 (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 '11': $SQL .= "t.Format = 'MP3' AND t.Encoding = 'V2 (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 '20': $SQL .= "t.Format = 'MP3' AND t.Encoding = '320'"; break;
case '21': $SQL .= "t.Format = 'MP3' AND t.Encoding = '256'"; break;
case '22': $SQL .= "t.Format = 'MP3' AND t.Encoding = '224'"; 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 '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 '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 '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 '37': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless'"; break;
case '40': $SQL .= "t.Format = 'DTS'"; break;
case '42': $SQL .= "t.Format = 'AAC' AND t.Encoding = '320'"; 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 '45': $SQL .= "t.Format = 'AAC' AND t.Encoding = 'q5'"; break;
case '46': $SQL .= "t.Format = 'AAC' AND t.Encoding = '192'"; break;
default: error(0);
}
$SQL .= " THEN $Priority ";
}
$SQL .= "ELSE 100 END AS Rank,
t.GroupID,
t.ID AS TorrentID,
t.Media,
t.Format,
t.Encoding,
IF(t.RemasterYear=0,tg.Year,t.RemasterYear) AS Year,
tg.Name,
t.Size
$SQL .= "
ELSE 100
END AS Rank,
t.GroupID,
t.ID AS TorrentID,
t.Media,
t.Format,
t.Encoding,
IF(t.RemasterYear = 0, tg.Year, t.RemasterYear) AS Year,
tg.Name,
t.Size
FROM torrents AS t
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 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'
ORDER BY t.GroupID ASC, Rank DESC, t.$Preference";
$DownloadsQ = $DB->query($SQL);
@ -126,7 +133,10 @@
while (list($Downloads, $GroupIDs) = $Collector->get_downloads('GroupID')) {
$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)) {
// Query failed. Let's not create a broken zip archive
foreach ($GroupIDs as $GroupID) {

View File

@ -4,12 +4,15 @@
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();
if ($CategoryID == 0 && $UserID != $LoggedUser['ID'] && !check_perms('site_collages_delete')) {
if ($CategoryID === '0' && $UserID !== $LoggedUser['ID'] && !check_perms('site_collages_delete')) {
error(403);
}
if ($CategoryID != array_search(ARTIST_COLLAGE, $CollageCats)) {
if ($CategoryID !== array_search(ARTIST_COLLAGE, $CollageCats)) {
error(403);
}
@ -21,15 +24,15 @@
um.Username,
ca.Sort
FROM collages_artists AS ca
JOIN artists_group AS ag ON ag.ArtistID=ca.ArtistID
LEFT JOIN users_main AS um ON um.ID=ca.UserID
WHERE ca.CollageID='$CollageID'
JOIN artists_group AS ag ON ag.ArtistID = ca.ArtistID
LEFT JOIN users_main AS um ON um.ID = ca.UserID
WHERE ca.CollageID = '$CollageID'
ORDER BY ca.Sort");
$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>
<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>
<table id="manage_collage_table">
<thead>
@ -68,7 +71,6 @@
</thead>
<tbody>
<?
$Number = 0;
foreach ($Artists as $Artist) {
$Number++;

View File

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

View File

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

View File

@ -1,4 +1,4 @@
<?
<?php
authorize();
include(SERVER_ROOT.'/classes/validate.class.php');
@ -8,25 +8,36 @@
$P = db_array($_POST);
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 {
// Get a collage name and make sure it's unique
$name = $LoggedUser['Username']."'s personal collage";
$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;
while ($DB->has_results()) {
$P['name'] = db_string($name." no. $i");
$DB->query("SELECT ID FROM collages WHERE Name='".$P['name']."'");
$P['name'] = db_string("$name no. $i");
$DB->query("
SELECT ID
FROM collages
WHERE Name = '".$P['name']."'");
$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);
if ($P['category'] == '0') {
$DB->query("SELECT COUNT(ID) FROM collages WHERE UserID='$LoggedUser[ID]' AND CategoryID='0' AND Deleted='0'");
if ($P['category'] === '0') {
$DB->query("
SELECT COUNT(ID)
FROM collages
WHERE UserID = '$LoggedUser[ID]'
AND CategoryID = '0'
AND Deleted = '0'");
list($CollageCount) = $DB->next_record();
if (($CollageCount >= $LoggedUser['Permissions']['MaxCollages']) || !check_perms('site_collages_personal')) {
$Err = 'You may not create a personal collage.';
@ -36,11 +47,14 @@
}
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()) {
list($ID, $Deleted) = $DB->next_record();
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 {
$Err = "That collection already exists: <a href=\"/collages.php?id=$ID\">$ID</a>.";
}
@ -64,20 +78,20 @@
die();
}
$TagList = explode(',',$_POST['tags']);
foreach ($TagList as $ID=>$Tag) {
$TagList = explode(',', $_POST['tags']);
foreach ($TagList as $ID => $Tag) {
$TagList[$ID] = Misc::sanitize_tag($Tag);
}
$TagList = implode(' ',$TagList);
$TagList = implode(' ', $TagList);
$DB->query("INSERT INTO collages
(Name, Description, UserID, TagList, CategoryID)
$DB->query("
INSERT INTO collages
(Name, Description, UserID, TagList, CategoryID)
VALUES
('$P[name]', '$P[description]', $LoggedUser[ID], '$TagList', '$P[category]')");
('$P[name]', '$P[description]', $LoggedUser[ID], '$TagList', '$P[category]')");
$CollageID = $DB->inserted_id();
$Cache->delete_value('collage_'.$CollageID);
Misc::write_log("Collage ".$CollageID." (".$_POST['name'].") was created by ".$LoggedUser['Username']);
header('Location: collages.php?id='.$CollageID);
$Cache->delete_value("collage_$CollageID");
Misc::write_log("Collage $CollageID (".$_POST['name'].') was created by '.$LoggedUser['Username']);
header("Location: collages.php?id=$CollageID");
?>

View File

@ -7,10 +7,13 @@
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);
if (!check_perms('site_collages_delete') && $UserID != $LoggedUser['ID']) {
if (!check_perms('site_collages_delete') && $UserID !== $LoggedUser['ID']) {
error(403);
}
@ -19,23 +22,35 @@
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()) {
$Cache->delete_value('torrents_details_'.$GroupID);
$Cache->delete_value('torrent_collages_'.$GroupID);
$Cache->delete_value('torrent_collages_personal_'.$GroupID);
$Cache->delete_value("torrents_details_$GroupID");
$Cache->delete_value("torrent_collages_$GroupID");
$Cache->delete_value("torrent_collages_personal_$GroupID");
}
//Personal collages have CategoryID 0
if ($CategoryID == 0) {
$DB->query("DELETE FROM collages WHERE ID='$CollageID'");
$DB->query("DELETE FROM collages_torrents WHERE CollageID='$CollageID'");
$DB->query("DELETE FROM collages_comments WHERE CollageID='$CollageID'");
if ($CategoryID === '0') {
$DB->query("
DELETE FROM collages
WHERE ID = '$CollageID'");
$DB->query("
DELETE FROM collages_torrents
WHERE CollageID = '$CollageID'");
$DB->query("
DELETE FROM collages_comments
WHERE CollageID = '$CollageID'");
} 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');

View File

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

View File

@ -28,7 +28,7 @@
$DB->query($sql);
$Donations = $DB->to_array(false,MYSQLI_NUM);
$DB->query("SELECT FOUND_ROWS()");
$DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record();
if (empty($_GET['search']) && !isset($_GET['page']) && !$DonationTimeline = $Cache->get_value('donation_timeline')) {
@ -40,7 +40,7 @@
ORDER BY Time DESC
LIMIT 1, 18");
$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) {
list($Label, $Amount) = $Entry;
$Area->add($Label, $Amount);
@ -51,7 +51,7 @@
$Area->lines(2);
$Area->generate();
$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 File

@ -9,7 +9,9 @@
if (!empty($_POST['invitekey']) && check_perms('users_edit_invites')) {
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'])) {
@ -29,12 +31,15 @@
FROM invites as i
JOIN users_main AS um ON um.ID = i.InviterID ";
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);
$DB->query("SELECT FOUND_ROWS()");
$DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record();
$DB->set_query_id($RS);
@ -78,7 +83,7 @@
<?
$Row = 'b';
while (list($UserID, $IP, $InviteKey, $Expires, $Email) = $DB->next_record()) {
$Row = ($Row == 'b') ? 'a' : 'b';
$Row = $Row === 'b' ? 'a' : 'b';
?>
<tr class="row<?=$Row?>">
<td><?=Users::format_username($UserID, true, true, true, true)?></td>

View File

@ -38,9 +38,10 @@
i.Donor,
i.Warned,
i.JoinDate,
( SELECT COUNT(h1.UserID)
(
SELECT COUNT(h1.UserID)
FROM users_history_ips AS h1
WHERE h1.IP=m.IP
WHERE h1.IP = m.IP
) AS Uses,
im.ID,
im.IP,
@ -54,12 +55,13 @@
ii.Donor,
ii.Warned,
ii.JoinDate,
( SELECT COUNT(h2.UserID)
(
SELECT COUNT(h2.UserID)
FROM users_history_ips AS h2
WHERE h2.IP=im.IP
WHERE h2.IP = im.IP
) AS InviterUses
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_info AS ii ON i.Inviter = ii.UserID
WHERE";
@ -68,9 +70,11 @@
} else {
$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);
$DB->query("SELECT FOUND_ROWS()");
$DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record();
$DB->set_query_id($QueryID);
?>
@ -104,7 +108,7 @@
</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()) {
$Row = ($IP == $InviterIP) ? 'a' : 'b';
$Row = $IP === $InviterIP ? 'a' : 'b';
?>
<tr class="row<?=$Row?>">
<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,
m.RequiredRatio
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'
AND m.Enabled = '1'
ORDER BY i.RatioWatchEnds ASC
LIMIT $Limit");
$DB->query("SELECT FOUND_ROWS()");
$DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record();
$DB->query("
SELECT COUNT(UserID)
@ -63,7 +63,7 @@
</tr>
<?
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?>">
@ -74,7 +74,7 @@
<td><?=number_format($RequiredRatio, 2)?></td>
<td><? if (($Downloaded * $RequiredRatio) > $Uploaded) { echo Format::get_size(($Downloaded * $RequiredRatio) - $Uploaded);} ?></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(strtotime($Joined), strtotime($RatioWatchEnds))?></td>
</tr>
@ -83,8 +83,11 @@
<div class="linkbox">
<? echo $Pages; ?>
</div>
<? } else { ?>
<?
} else { ?>
<h2 align="center">There are currently no users on ratio watch.</h2>
<? }
<?
}
View::show_footer();
?>

View File

@ -7,14 +7,14 @@
if (!isset($_GET['page'])) {
if (!list($Labels, $InFlow, $OutFlow, $Max) = $Cache->get_value('users_timeline')) {
$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
GROUP BY Month
ORDER BY JoinDate DESC
LIMIT 1, 12");
$TimelineIn = array_reverse($DB->to_array());
$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
GROUP BY Month
ORDER BY BanDate DESC
@ -54,7 +54,7 @@
SELECT
SQL_CALC_FOUND_ROWS
j.Date,
DATE_FORMAT(j.Date,'%Y-%m') AS Month,
DATE_FORMAT(j.Date, '%Y-%m') AS Month,
CASE ISNULL(j.Flow)
WHEN 0 THEN j.Flow
ELSE '0'
@ -73,42 +73,42 @@
END AS Inactivity
FROM (
SELECT
DATE_FORMAT(JoinDate,'%Y-%m-%d') AS Date,
DATE_FORMAT(JoinDate, '%Y-%m-%d') AS Date,
COUNT(UserID) AS Flow
FROM users_info
WHERE JoinDate != '0000-00-00 00:00:00'
GROUP BY Date
FROM users_info
WHERE JoinDate != '0000-00-00 00:00:00'
GROUP BY Date
) AS j
LEFT JOIN (
SELECT
DATE_FORMAT(BanDate,'%Y-%m-%d') AS Date,
DATE_FORMAT(BanDate, '%Y-%m-%d') AS Date,
COUNT(UserID) AS Flow
FROM users_info
WHERE BanDate != '0000-00-00 00:00:00'
FROM users_info
WHERE BanDate != '0000-00-00 00:00:00'
AND BanReason = '1'
GROUP BY Date
) AS m ON j.Date=m.Date
GROUP BY Date
) AS m ON j.Date = m.Date
LEFT JOIN (
SELECT
DATE_FORMAT(BanDate,'%Y-%m-%d') AS Date,
DATE_FORMAT(BanDate, '%Y-%m-%d') AS Date,
COUNT(UserID) AS Flow
FROM users_info
WHERE BanDate != '0000-00-00 00:00:00'
FROM users_info
WHERE BanDate != '0000-00-00 00:00:00'
AND BanReason = '2'
GROUP BY Date
) AS r ON j.Date=r.Date
GROUP BY Date
) AS r ON j.Date = r.Date
LEFT JOIN (
SELECT
DATE_FORMAT(BanDate,'%Y-%m-%d') AS Date,
DATE_FORMAT(BanDate, '%Y-%m-%d') AS Date,
COUNT(UserID) AS Flow
FROM users_info
WHERE BanDate != '0000-00-00 00:00:00'
FROM users_info
WHERE BanDate != '0000-00-00 00:00:00'
AND BanReason = '3'
GROUP BY Date
) AS i ON j.Date=i.Date
GROUP BY Date
) AS i ON j.Date = i.Date
ORDER BY j.Date DESC
LIMIT $Limit");
$DB->query("SELECT FOUND_ROWS()");
$DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record();
View::show_header('User Flow');
@ -138,8 +138,8 @@
</tr>
<?
while (list($Date, $Month, $Joined, $Manual, $Ratio, $Inactivity) = $DB->next_record()) {
$TotalOut = $Ratio + $Inactivity + $Manual;
$TotalGrowth = $Joined - $TotalOut;
$TotalOut = $Ratio + $Inactivity + $Manual;
$TotalGrowth = $Joined - $TotalOut;
?>
<tr class="rowb">
<td><?=$Date?></td>