Empty commit

This commit is contained in:
Git 2013-07-05 08:00:39 +00:00
parent 888e8708d4
commit 723c05be06
9 changed files with 177 additions and 129 deletions

View File

@ -52,7 +52,7 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
// Make sure there's something in $GroupIDs, otherwise the SQL // Make sure there's something in $GroupIDs, otherwise the SQL
// will break // will break
if (count($GroupIDs) == 0) { if (count($GroupIDs) == 0) {
return array('matches'=>array(),'notfound'=>array()); return array('matches' => array(), 'notfound' => array());
} }
$Found = $NotFound = array_flip($GroupIDs); $Found = $NotFound = array_flip($GroupIDs);
@ -66,7 +66,7 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
} }
} }
$IDs = implode(',',array_flip($NotFound)); $IDs = implode(',', array_flip($NotFound));
/* /*
Changing any of these attributes returned will cause very large, very dramatic site-wide chaos. Changing any of these attributes returned will cause very large, very dramatic site-wide chaos.
@ -113,9 +113,9 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
// Cache it all // Cache it all
foreach ($Found as $GroupID => $GroupInfo) { foreach ($Found as $GroupID => $GroupInfo) {
$Cache->cache_value('torrent_group_'.$GroupID, $Cache->cache_value("torrent_group_$GroupID",
array('ver' => CACHE::GROUP_VERSION, 'd' => $GroupInfo), 0); array('ver' => CACHE::GROUP_VERSION, 'd' => $GroupInfo), 0);
$Cache->cache_value('torrent_group_light_'.$GroupID, $Cache->cache_value("torrent_group_light_$GroupID",
array('ver' => CACHE::GROUP_VERSION, 'd' => $GroupInfo), 0); array('ver' => CACHE::GROUP_VERSION, 'd' => $GroupInfo), 0);
} }
@ -153,7 +153,7 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
} }
} }
$Matches = array('matches'=>$Found, 'notfound'=>array_flip($NotFound)); $Matches = array('matches' => $Found, 'notfound' => array_flip($NotFound));
return $Matches; return $Matches;
} }
@ -235,22 +235,22 @@ public static function delete_torrent($ID, $GroupID = 0, $OcelotReason = -1) {
$DB->query(" $DB->query("
SELECT GroupID, UserID SELECT GroupID, UserID
FROM torrents FROM torrents
WHERE ID='$ID'"); WHERE ID = '$ID'");
list($GroupID, $UploaderID) = $DB->next_record(); list($GroupID, $UploaderID) = $DB->next_record();
} }
if (empty($UserID)) { if (empty($UserID)) {
$DB->query(" $DB->query("
SELECT UserID SELECT UserID
FROM torrents FROM torrents
WHERE ID='$ID'"); WHERE ID = '$ID'");
list($UserID) = $DB->next_record(); list($UserID) = $DB->next_record();
} }
$RecentUploads = $Cache->get_value('recent_uploads_'.$UserID); $RecentUploads = $Cache->get_value("recent_uploads_$UserID");
if (is_array($RecentUploads)) { if (is_array($RecentUploads)) {
foreach ($RecentUploads as $Key => $Recent) { foreach ($RecentUploads as $Key => $Recent) {
if ($Recent['ID'] == $GroupID) { if ($Recent['ID'] == $GroupID) {
$Cache->delete_value('recent_uploads_'.$UserID); $Cache->delete_value("recent_uploads_$UserID");
} }
} }
} }
@ -259,11 +259,11 @@ public static function delete_torrent($ID, $GroupID = 0, $OcelotReason = -1) {
$DB->query(" $DB->query("
SELECT info_hash SELECT info_hash
FROM torrents FROM torrents
WHERE ID = ".$ID); WHERE ID = $ID");
list($InfoHash) = $DB->next_record(MYSQLI_BOTH, false); list($InfoHash) = $DB->next_record(MYSQLI_BOTH, false);
$DB->query(" $DB->query("
DELETE FROM torrents DELETE FROM torrents
WHERE ID = ".$ID); WHERE ID = $ID");
Tracker::update_tracker('delete_torrent', array('info_hash' => rawurlencode($InfoHash), 'id' => $ID, 'reason' => $OcelotReason)); Tracker::update_tracker('delete_torrent', array('info_hash' => rawurlencode($InfoHash), 'id' => $ID, 'reason' => $OcelotReason));
$Cache->decrement('stats_torrent_count'); $Cache->decrement('stats_torrent_count');
@ -271,7 +271,7 @@ public static function delete_torrent($ID, $GroupID = 0, $OcelotReason = -1) {
$DB->query(" $DB->query("
SELECT COUNT(ID) SELECT COUNT(ID)
FROM torrents FROM torrents
WHERE GroupID='$GroupID'"); WHERE GroupID = '$GroupID'");
list($Count) = $DB->next_record(); list($Count) = $DB->next_record();
if ($Count == 0) { if ($Count == 0) {
@ -284,20 +284,20 @@ public static function delete_torrent($ID, $GroupID = 0, $OcelotReason = -1) {
$DB->query(" $DB->query("
SELECT UserID SELECT UserID
FROM users_notify_torrents FROM users_notify_torrents
WHERE TorrentID='$ID'"); WHERE TorrentID = '$ID'");
while (list($UserID) = $DB->next_record()) { while (list($UserID) = $DB->next_record()) {
$Cache->delete_value('notifications_new_'.$UserID); $Cache->delete_value("notifications_new_$UserID");
} }
$DB->query(" $DB->query("
DELETE FROM users_notify_torrents DELETE FROM users_notify_torrents
WHERE TorrentID='$ID'"); WHERE TorrentID = '$ID'");
$DB->query(" $DB->query("
UPDATE reportsv2 UPDATE reportsv2
SET SET
Status='Resolved', Status = 'Resolved',
LastChangeTime='".sqltime()."', LastChangeTime = '".sqltime()."',
ModComment='Report already dealt with (Torrent deleted)' ModComment = 'Report already dealt with (torrent deleted)'
WHERE TorrentID = $ID WHERE TorrentID = $ID
AND Status != 'Resolved'"); AND Status != 'Resolved'");
$Reports = $DB->affected_rows(); $Reports = $DB->affected_rows();
@ -310,31 +310,31 @@ public static function delete_torrent($ID, $GroupID = 0, $OcelotReason = -1) {
WHERE TorrentID = '$ID'"); WHERE TorrentID = '$ID'");
$DB->query(" $DB->query("
DELETE FROM torrents_bad_tags DELETE FROM torrents_bad_tags
WHERE TorrentID = ".$ID); WHERE TorrentID = $ID");
$DB->query(" $DB->query("
DELETE FROM torrents_bad_folders DELETE FROM torrents_bad_folders
WHERE TorrentID = ".$ID); WHERE TorrentID = $ID");
$DB->query(" $DB->query("
DELETE FROM torrents_bad_files DELETE FROM torrents_bad_files
WHERE TorrentID = ".$ID); WHERE TorrentID = $ID");
$DB->query(" $DB->query("
DELETE FROM torrents_cassette_approved DELETE FROM torrents_cassette_approved
WHERE TorrentID = ".$ID); WHERE TorrentID = $ID");
$DB->query(" $DB->query("
DELETE FROM torrents_lossymaster_approved DELETE FROM torrents_lossymaster_approved
WHERE TorrentID = ".$ID); WHERE TorrentID = $ID");
$DB->query(" $DB->query("
DELETE FROM torrents_lossyweb_approved DELETE FROM torrents_lossyweb_approved
WHERE TorrentID = ".$ID); WHERE TorrentID = $ID");
// Tells Sphinx that the group is removed // Tells Sphinx that the group is removed
$DB->query(" $DB->query("
REPLACE INTO sphinx_delta (ID, Time) REPLACE INTO sphinx_delta (ID, Time)
VALUES ($ID, UNIX_TIMESTAMP())"); VALUES ($ID, UNIX_TIMESTAMP())");
$Cache->delete_value('torrent_download_'.$ID); $Cache->delete_value("torrent_download_$ID");
$Cache->delete_value('torrent_group_'.$GroupID); $Cache->delete_value("torrent_group_$GroupID");
$Cache->delete_value('torrents_details_'.$GroupID); $Cache->delete_value("torrents_details_$GroupID");
} }
@ -352,7 +352,7 @@ public static function delete_group($GroupID) {
$DB->query(" $DB->query("
SELECT CategoryID SELECT CategoryID
FROM torrents_group FROM torrents_group
WHERE ID='$GroupID'"); WHERE ID = '$GroupID'");
list($Category) = $DB->next_record(); list($Category) = $DB->next_record();
if ($Category == 1) { if ($Category == 1) {
$Cache->decrement('stats_album_count'); $Cache->decrement('stats_album_count');
@ -365,21 +365,21 @@ public static function delete_group($GroupID) {
$DB->query(" $DB->query("
SELECT CollageID SELECT CollageID
FROM collages_torrents FROM collages_torrents
WHERE GroupID='$GroupID'"); WHERE GroupID = '$GroupID'");
if ($DB->record_count() > 0) { if ($DB->record_count() > 0) {
$CollageIDs = $DB->collect('CollageID'); $CollageIDs = $DB->collect('CollageID');
$DB->query(" $DB->query("
UPDATE collages UPDATE collages
SET NumTorrents=NumTorrents-1 SET NumTorrents = NumTorrents - 1
WHERE ID IN (".implode(', ', $CollageIDs).')'); WHERE ID IN (".implode(', ', $CollageIDs).')');
$DB->query(" $DB->query("
DELETE FROM collages_torrents DELETE FROM collages_torrents
WHERE GroupID='$GroupID'"); WHERE GroupID = '$GroupID'");
foreach ($CollageIDs as $CollageID) { foreach ($CollageIDs as $CollageID) {
$Cache->delete_value('collage_'.$CollageID); $Cache->delete_value("collage_$CollageID");
} }
$Cache->delete_value('torrent_collages_'.$GroupID); $Cache->delete_value("torrent_collages_$GroupID");
} }
// Artists // Artists
@ -387,12 +387,12 @@ public static function delete_group($GroupID) {
$DB->query(" $DB->query("
SELECT ArtistID SELECT ArtistID
FROM torrents_artists FROM torrents_artists
WHERE GroupID = ".$GroupID); WHERE GroupID = $GroupID");
$Artists = $DB->collect('ArtistID'); $Artists = $DB->collect('ArtistID');
$DB->query(" $DB->query("
DELETE FROM torrents_artists DELETE FROM torrents_artists
WHERE GroupID='$GroupID'"); WHERE GroupID = '$GroupID'");
foreach ($Artists as $ArtistID) { foreach ($Artists as $ArtistID) {
if (empty($ArtistID)) { if (empty($ArtistID)) {
@ -402,14 +402,14 @@ public static function delete_group($GroupID) {
$DB->query(" $DB->query("
SELECT COUNT(ag.ArtistID) SELECT COUNT(ag.ArtistID)
FROM artists_group as ag FROM artists_group as ag
LEFT JOIN requests_artists AS ra ON ag.ArtistID=ra.ArtistID LEFT JOIN requests_artists AS ra ON ag.ArtistID = ra.ArtistID
WHERE ra.ArtistID IS NOT NULL WHERE ra.ArtistID IS NOT NULL
AND ag.ArtistID = '$ArtistID'"); AND ag.ArtistID = '$ArtistID'");
list($ReqCount) = $DB->next_record(); list($ReqCount) = $DB->next_record();
$DB->query(" $DB->query("
SELECT COUNT(ag.ArtistID) SELECT COUNT(ag.ArtistID)
FROM artists_group as ag FROM artists_group as ag
LEFT JOIN torrents_artists AS ta ON ag.ArtistID=ta.ArtistID LEFT JOIN torrents_artists AS ta ON ag.ArtistID = ta.ArtistID
WHERE ta.ArtistID IS NOT NULL WHERE ta.ArtistID IS NOT NULL
AND ag.ArtistID = '$ArtistID'"); AND ag.ArtistID = '$ArtistID'");
list($GroupCount) = $DB->next_record(); list($GroupCount) = $DB->next_record();
@ -418,7 +418,7 @@ public static function delete_group($GroupID) {
Artists::delete_artist($ArtistID); Artists::delete_artist($ArtistID);
} else { } else {
//Not the only group, still need to clear cache //Not the only group, still need to clear cache
$Cache->delete_value('artist_groups_'.$ArtistID); $Cache->delete_value("artist_groups_$ArtistID");
} }
} }
@ -426,31 +426,43 @@ public static function delete_group($GroupID) {
$DB->query(" $DB->query("
SELECT ID SELECT ID
FROM requests FROM requests
WHERE GroupID='$GroupID'"); WHERE GroupID = '$GroupID'");
$Requests = $DB->collect('ID'); $Requests = $DB->collect('ID');
$DB->query(" $DB->query("
UPDATE requests UPDATE requests
SET GroupID = NULL SET GroupID = NULL
WHERE GroupID = '$GroupID'"); WHERE GroupID = '$GroupID'");
foreach ($Requests as $RequestID) { foreach ($Requests as $RequestID) {
$Cache->delete_value('request_'.$RequestID); $Cache->delete_value("request_$RequestID");
} }
$DB->query("DELETE FROM torrents_group WHERE ID='$GroupID'"); $DB->query("
$DB->query("DELETE FROM torrents_tags WHERE GroupID='$GroupID'"); DELETE FROM torrents_group
$DB->query("DELETE FROM torrents_tags_votes WHERE GroupID='$GroupID'"); WHERE ID = '$GroupID'");
$DB->query("DELETE FROM torrents_comments WHERE GroupID='$GroupID'"); $DB->query("
$DB->query("DELETE FROM bookmarks_torrents WHERE GroupID='$GroupID'"); DELETE FROM torrents_tags
$DB->query("DELETE FROM wiki_torrents WHERE PageID='$GroupID'"); WHERE GroupID = '$GroupID'");
$DB->query("
DELETE FROM torrents_tags_votes
WHERE GroupID = '$GroupID'");
$DB->query("
DELETE FROM torrents_comments
WHERE GroupID = '$GroupID'");
$DB->query("
DELETE FROM bookmarks_torrents
WHERE GroupID = '$GroupID'");
$DB->query("
DELETE FROM wiki_torrents
WHERE PageID = '$GroupID'");
$Cache->delete_value('torrents_details_'.$GroupID); $Cache->delete_value("torrents_details_$GroupID");
$Cache->delete_value('torrent_group_'.$GroupID); $Cache->delete_value("torrent_group_$GroupID");
$Cache->delete_value('groups_artists_'.$GroupID); $Cache->delete_value("groups_artists_$GroupID");
} }
/** /**
* Update the cache and sphinx delta index to keep everything up to date. * Update the cache and sphinx delta index to keep everything up-to-date.
* *
* @param int $GroupID * @param int $GroupID
*/ */
@ -458,20 +470,20 @@ public static function update_hash($GroupID) {
global $DB, $Cache; global $DB, $Cache;
$DB->query(" $DB->query("
UPDATE torrents_group UPDATE torrents_group
SET TagList=( SET TagList = (
SELECT REPLACE(GROUP_CONCAT(tags.Name SEPARATOR ' '),'.','_') SELECT REPLACE(GROUP_CONCAT(tags.Name SEPARATOR ' '), '.', '_')
FROM torrents_tags AS t FROM torrents_tags AS t
INNER JOIN tags ON tags.ID=t.TagID INNER JOIN tags ON tags.ID = t.TagID
WHERE t.GroupID='$GroupID' WHERE t.GroupID = '$GroupID'
GROUP BY t.GroupID GROUP BY t.GroupID
) )
WHERE ID='$GroupID'"); WHERE ID = '$GroupID'");
// Fetch album vote score // Fetch album vote score
$DB->query(" $DB->query("
SELECT Score SELECT Score
FROM torrents_votes FROM torrents_votes
WHERE GroupID=$GroupID"); WHERE GroupID = $GroupID");
if ($DB->record_count()) { if ($DB->record_count()) {
list($VoteScore) = $DB->next_record(); list($VoteScore) = $DB->next_record();
} else { } else {
@ -482,8 +494,8 @@ public static function update_hash($GroupID) {
$DB->query(" $DB->query("
SELECT GROUP_CONCAT(aa.Name separator ' ') SELECT GROUP_CONCAT(aa.Name separator ' ')
FROM torrents_artists AS ta FROM torrents_artists AS ta
JOIN artists_alias AS aa ON aa.AliasID=ta.AliasID JOIN artists_alias AS aa ON aa.AliasID = ta.AliasID
WHERE ta.GroupID=$GroupID WHERE ta.GroupID = $GroupID
AND ta.Importance IN ('1', '4', '5', '6') AND ta.Importance IN ('1', '4', '5', '6')
GROUP BY ta.GroupID"); GROUP BY ta.GroupID");
if ($DB->record_count()) { if ($DB->record_count()) {
@ -506,8 +518,8 @@ public static function update_hash($GroupID) {
RemasterYear, RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber, RemasterYear, RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber,
REPLACE(FileList, '_', ' ') AS FileList, $VoteScore, '".db_string($ArtistName)."' REPLACE(FileList, '_', ' ') AS FileList, $VoteScore, '".db_string($ArtistName)."'
FROM torrents AS t FROM torrents AS t
JOIN torrents_group AS g ON g.ID=t.GroupID JOIN torrents_group AS g ON g.ID = t.GroupID
WHERE g.ID=$GroupID"); WHERE g.ID = $GroupID");
/* $DB->query(" /* $DB->query("
INSERT INTO sphinx_delta INSERT INTO sphinx_delta
@ -518,16 +530,16 @@ public static function update_hash($GroupID) {
GroupID, GroupID,
GROUP_CONCAT(aa.Name separator ' ') AS ArtistName GROUP_CONCAT(aa.Name separator ' ') AS ArtistName
FROM torrents_artists AS ta FROM torrents_artists AS ta
JOIN artists_alias AS aa ON aa.AliasID=ta.AliasID JOIN artists_alias AS aa ON aa.AliasID = ta.AliasID
WHERE ta.GroupID=$GroupID WHERE ta.GroupID = $GroupID
AND ta.Importance IN ('1', '4', '5', '6') AND ta.Importance IN ('1', '4', '5', '6')
GROUP BY ta.GroupID GROUP BY ta.GroupID
) AS artists ) AS artists
JOIN torrents USING(GroupID) JOIN torrents USING(GroupID)
ON DUPLICATE KEY UPDATE ArtistName=values(ArtistName)"); ON DUPLICATE KEY UPDATE ArtistName = VALUES(ArtistName)");
*/ */
$Cache->delete_value('torrents_details_'.$GroupID); $Cache->delete_value("torrents_details_$GroupID");
$Cache->delete_value('torrent_group_'.$GroupID); $Cache->delete_value("torrent_group_$GroupID");
$ArtistInfo = Artists::get_artist($GroupID); $ArtistInfo = Artists::get_artist($GroupID);
foreach ($ArtistInfo as $Importances => $Importance) { foreach ($ArtistInfo as $Importances => $Importance) {
@ -536,11 +548,11 @@ public static function update_hash($GroupID) {
} }
} }
$Cache->delete_value('groups_artists_'.$GroupID); $Cache->delete_value("groups_artists_$GroupID");
} }
/** /**
* Regenerate a torrent's filelist from its meta data, * Regenerate a torrent's file list from its meta data,
* update the database record and clear relevant cache keys * update the database record and clear relevant cache keys
* *
* @param int $TorrentID * @param int $TorrentID
@ -551,9 +563,9 @@ public static function regenerate_filelist($TorrentID) {
SELECT tg.ID, SELECT tg.ID,
tf.File tf.File
FROM torrents_files AS tf FROM torrents_files AS tf
JOIN torrents AS t ON t.ID=tf.TorrentID JOIN torrents AS t ON t.ID = tf.TorrentID
JOIN torrents_group AS tg ON tg.ID=t.GroupID JOIN torrents_group AS tg ON tg.ID = t.GroupID
WHERE tf.TorrentID = ".$TorrentID); WHERE tf.TorrentID = $TorrentID");
if ($DB->record_count() > 0) { if ($DB->record_count() > 0) {
list($GroupID, $Contents) = $DB->next_record(MYSQLI_NUM, false); list($GroupID, $Contents) = $DB->next_record(MYSQLI_NUM, false);
if (Misc::is_new_torrent($Contents)) { if (Misc::is_new_torrent($Contents)) {
@ -572,7 +584,7 @@ public static function regenerate_filelist($TorrentID) {
UPDATE torrents UPDATE torrents
SET Size = $TotalSize, FilePath = '".db_string($FilePath)."', FileList = '".db_string($FileString)."' SET Size = $TotalSize, FilePath = '".db_string($FilePath)."', FileList = '".db_string($FileString)."'
WHERE ID = $TorrentID"); WHERE ID = $TorrentID");
$Cache->delete_value('torrents_details_'.$GroupID); $Cache->delete_value("torrents_details_$GroupID");
} }
} }
@ -643,36 +655,60 @@ public static function filelist_get_file($File) {
*/ */
public static function torrent_info($Data, $ShowMedia = false, $ShowEdition = false) { public static function torrent_info($Data, $ShowMedia = false, $ShowEdition = false) {
$Info = array(); $Info = array();
if (!empty($Data['Format'])) { $Info[] = $Data['Format']; } if (!empty($Data['Format'])) {
if (!empty($Data['Encoding'])) { $Info[] = $Data['Encoding']; } $Info[] = $Data['Format'];
}
if (!empty($Data['Encoding'])) {
$Info[] = $Data['Encoding'];
}
if (!empty($Data['HasLog'])) { if (!empty($Data['HasLog'])) {
$Str = 'Log'; $Str = 'Log';
if (!empty($Data['LogScore'])) { if (!empty($Data['LogScore'])) {
$Str.=' ('.$Data['LogScore'].'%)'; $Str .= ' ('.$Data['LogScore'].'%)';
} }
$Info[] = $Str; $Info[] = $Str;
} }
if (!empty($Data['HasCue'])) { $Info[] = 'Cue'; } if (!empty($Data['HasCue'])) {
if ($ShowMedia && !empty($Data['Media'])) { $Info[] = $Data['Media']; } $Info[] = 'Cue';
if (!empty($Data['Scene'])) { $Info[] = 'Scene'; } }
if ($ShowMedia && !empty($Data['Media'])) {
$Info[] = $Data['Media'];
}
if (!empty($Data['Scene'])) {
$Info[] = 'Scene';
}
if ($ShowEdition) { if ($ShowEdition) {
$EditionInfo = array(); $EditionInfo = array();
if (!empty($Data['RemasterYear'])) { $EditionInfo[] = $Data['RemasterYear']; } if (!empty($Data['RemasterYear'])) {
if (!empty($Data['RemasterTitle'])) { $EditionInfo[] = $Data['RemasterTitle']; } $EditionInfo[] = $Data['RemasterYear'];
if (count($EditionInfo)) { $Info[] = implode(' ', $EditionInfo); } }
if (!empty($Data['RemasterTitle'])) {
$EditionInfo[] = $Data['RemasterTitle'];
}
if (count($EditionInfo)) {
$Info[] = implode(' ', $EditionInfo);
}
}
if ($Data['IsSnatched']) {
$Info[] = Format::torrent_label('Snatched!');
}
if ($Data['FreeTorrent'] == '1') {
$Info[] = Format::torrent_label('Freeleech!');
}
if ($Data['FreeTorrent'] == '2') {
$Info[] = Format::torrent_label('Neutral Leech!');
}
if ($Data['PersonalFL']) {
$Info[] = Format::torrent_label('Personal Freeleech!');
} }
if ($Data['IsSnatched']) { $Info[] = Format::torrent_label('Snatched!'); }
if ($Data['FreeTorrent'] == '1') { $Info[] = Format::torrent_label('Freeleech!'); }
if ($Data['FreeTorrent'] == '2') { $Info[] = Format::torrent_label('Neutral Leech!'); }
if ($Data['PersonalFL']) { $Info[] = Format::torrent_label('Personal Freeleech!'); }
return implode(' / ', $Info); return implode(' / ', $Info);
} }
/** /**
* Will freeleech / neutralleech / normalise a set of torrents * Will freeleech / neutral leech / normalise a set of torrents
* *
* @param array $TorrentIDs An array of torrents IDs to iterate over * @param array $TorrentIDs An array of torrent IDs to iterate over
* @param int $FreeNeutral 0 = normal, 1 = fl, 2 = nl * @param int $FreeNeutral 0 = normal, 1 = fl, 2 = nl
* @param int $FreeLeechType 0 = Unknown, 1 = Staff picks, 2 = Perma-FL (Toolbox, etc.), 3 = Vanity House * @param int $FreeLeechType 0 = Unknown, 1 = Staff picks, 2 = Perma-FL (Toolbox, etc.), 3 = Vanity House
*/ */
@ -691,14 +727,15 @@ public static function freeleech_torrents($TorrentIDs, $FreeNeutral = 1, $FreeLe
$DB->query(' $DB->query('
SELECT ID, GroupID, info_hash SELECT ID, GroupID, info_hash
FROM torrents FROM torrents
WHERE ID IN ('.implode(', ', $TorrentIDs).') ORDER BY GroupID ASC'); WHERE ID IN ('.implode(', ', $TorrentIDs).')
ORDER BY GroupID ASC');
$Torrents = $DB->to_array(false, MYSQLI_NUM, false); $Torrents = $DB->to_array(false, MYSQLI_NUM, false);
$GroupIDs = $DB->collect('GroupID'); $GroupIDs = $DB->collect('GroupID');
foreach ($Torrents as $Torrent) { foreach ($Torrents as $Torrent) {
list($TorrentID, $GroupID, $InfoHash) = $Torrent; list($TorrentID, $GroupID, $InfoHash) = $Torrent;
Tracker::update_tracker('update_torrent', array('info_hash' => rawurlencode($InfoHash), 'freetorrent' => $FreeNeutral)); Tracker::update_tracker('update_torrent', array('info_hash' => rawurlencode($InfoHash), 'freetorrent' => $FreeNeutral));
$Cache->delete_value('torrent_download_'.$TorrentID); $Cache->delete_value("torrent_download_$TorrentID");
Misc::write_log($LoggedUser['Username']." marked torrent $TorrentID freeleech type $FreeLeechType!"); Misc::write_log($LoggedUser['Username']." marked torrent $TorrentID freeleech type $FreeLeechType!");
Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], "marked as freeleech type $FreeLeechType!", 0); Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], "marked as freeleech type $FreeLeechType!", 0);
} }
@ -749,15 +786,15 @@ public static function has_token($TorrentID) {
static $TokenTorrents; static $TokenTorrents;
$UserID = $LoggedUser['ID']; $UserID = $LoggedUser['ID'];
if (!isset($TokenTorrents)) { if (!isset($TokenTorrents)) {
$TokenTorrents = $Cache->get_value('users_tokens_'.$UserID); $TokenTorrents = $Cache->get_value("users_tokens_$UserID");
if ($TokenTorrents === false) { if ($TokenTorrents === false) {
$DB->query(" $DB->query("
SELECT TorrentID SELECT TorrentID
FROM users_freeleeches FROM users_freeleeches
WHERE UserID=$UserID WHERE UserID = $UserID
AND Expired=0"); AND Expired = 0");
$TokenTorrents = array_fill_keys($DB->collect('TorrentID', false), true); $TokenTorrents = array_fill_keys($DB->collect('TorrentID', false), true);
$Cache->cache_value('users_tokens_'.$UserID, $TokenTorrents); $Cache->cache_value("users_tokens_$UserID", $TokenTorrents);
} }
} }
return isset($TokenTorrents[$TorrentID]); return isset($TokenTorrents[$TorrentID]);
@ -797,7 +834,7 @@ public static function has_snatched($TorrentID, $AllUsers = false) {
if (empty($SnatchedTorrents)) { if (empty($SnatchedTorrents)) {
$SnatchedTorrents = array_fill(0, $Buckets, false); $SnatchedTorrents = array_fill(0, $Buckets, false);
$LastUpdate = $Cache->get_value('users_snatched_'.$UserID.'_lastupdate') ?: 0; $LastUpdate = $Cache->get_value("users_snatched_{$UserID}_lastupdate") ?: 0;
} elseif (isset($SnatchedTorrents[$BucketID][$TorrentID])) { } elseif (isset($SnatchedTorrents[$BucketID][$TorrentID])) {
return true; return true;
} }
@ -807,7 +844,7 @@ public static function has_snatched($TorrentID, $AllUsers = false) {
if ($CurSnatchedTorrents === false) { if ($CurSnatchedTorrents === false) {
$CurTime = time(); $CurTime = time();
// This bucket hasn't been checked before // This bucket hasn't been checked before
$CurSnatchedTorrents = $Cache->get_value('users_snatched_'.$UserID.'_'.$BucketID, true); $CurSnatchedTorrents = $Cache->get_value("users_snatched_{$UserID}_$BucketID", true);
if ($CurSnatchedTorrents === false || $CurTime - $LastUpdate > 1800) { if ($CurSnatchedTorrents === false || $CurTime - $LastUpdate > 1800) {
$Updated = array(); $Updated = array();
if ($CurSnatchedTorrents === false || $LastUpdate == 0) { if ($CurSnatchedTorrents === false || $LastUpdate == 0) {
@ -836,7 +873,7 @@ public static function has_snatched($TorrentID, $AllUsers = false) {
while (list($ID) = $DB->next_record(MYSQLI_NUM, false)) { while (list($ID) = $DB->next_record(MYSQLI_NUM, false)) {
$CurBucketID = $ID & $LastBucket; $CurBucketID = $ID & $LastBucket;
if ($SnatchedTorrents[$CurBucketID] === false) { if ($SnatchedTorrents[$CurBucketID] === false) {
$SnatchedTorrents[$CurBucketID] = $Cache->get_value('users_snatched_'.$UserID.'_'.$CurBucketID, true); $SnatchedTorrents[$CurBucketID] = $Cache->get_value("users_snatched_{$UserID}_$CurBucketID", true);
if ($SnatchedTorrents[$CurBucketID] === false) { if ($SnatchedTorrents[$CurBucketID] === false) {
$SnatchedTorrents[$CurBucketID] = array(); $SnatchedTorrents[$CurBucketID] = array();
} }
@ -847,10 +884,10 @@ public static function has_snatched($TorrentID, $AllUsers = false) {
} }
for ($i = 0; $i < $Buckets; $i++) { for ($i = 0; $i < $Buckets; $i++) {
if ($Updated[$i]) { if ($Updated[$i]) {
$Cache->cache_value('users_snatched_'.$UserID.'_'.$i, $SnatchedTorrents[$i], 0); $Cache->cache_value("users_snatched_{$UserID}_$i", $SnatchedTorrents[$i], 0);
} }
} }
$Cache->cache_value('users_snatched_'.$UserID.'_lastupdate', $CurTime, 0); $Cache->cache_value("users_snatched_{$UserID}_lastupdate", $CurTime, 0);
$LastUpdate = $CurTime; $LastUpdate = $CurTime;
} }
} }
@ -876,9 +913,9 @@ public static function edition_string(array $Torrent, array $Group) {
} }
$EditionName .= $AddExtra . display_str($Torrent['Media']); $EditionName .= $AddExtra . display_str($Torrent['Media']);
} else { } else {
$AddExtra = " / "; $AddExtra = ' / ';
if (!$Torrent['Remastered']) { if (!$Torrent['Remastered']) {
$EditionName = "Original Release"; $EditionName = 'Original Release';
if ($Group['RecordLabel']) { if ($Group['RecordLabel']) {
$EditionName .= $AddExtra . $Group['RecordLabel']; $EditionName .= $AddExtra . $Group['RecordLabel'];
$AddExtra = ' / '; $AddExtra = ' / ';

View File

@ -28,7 +28,7 @@
MaxGroupsPerUser, MaxGroupsPerUser,
Subscribers Subscribers
FROM collages FROM collages
WHERE ID='$CollageID'"; WHERE ID = '$CollageID'";
$DB->query($sql); $DB->query($sql);
if ($DB->record_count() == 0) { if ($DB->record_count() == 0) {

View File

@ -218,5 +218,8 @@
$Cache->update_row(false, array('Posts' => '+1', 'LastPostAuthorID' => $LoggedUser['ID'])); $Cache->update_row(false, array('Posts' => '+1', 'LastPostAuthorID' => $LoggedUser['ID']));
$Cache->commit_transaction(0); $Cache->commit_transaction(0);
header('Location: forums.php?action=viewthread&threadid='.$TopicID);
header("Location: forums.php?action=viewthread&threadid=$TopicID");
die(); die();

View File

@ -270,5 +270,6 @@
} }
} }
Forums::quote_notify($Body, $PostID, 'forums', $TopicID); Forums::quote_notify($Body, $PostID, 'forums', $TopicID);
header('Location: forums.php?action=viewthread&threadid='.$TopicID.'&page='.ceil($ThreadInfo['Posts'] / $PerPage)); header('Location: forums.php?action=viewthread&threadid='.$TopicID.'&page='.ceil($ThreadInfo['Posts'] / $PerPage));
die(); die();

View File

@ -164,7 +164,7 @@
} }
if (($NeedCue || $NeedLog)) { if (($NeedCue || $NeedLog)) {
if (!(empty($_POST['all_media']) && $MediaArray[0] == 0)) { if (empty($_POST['all_media']) && $MediaArray[0] == 0) {
$Err = 'Only CD is allowed as media for FLAC + log/cue requests.'; $Err = 'Only CD is allowed as media for FLAC + log/cue requests.';
} }
} }

View File

@ -1,9 +1,9 @@
<? <?
if (!check_perms("users_mod")) { if (!check_perms('users_mod')) {
error(403); error(403);
} }
View::show_header("BBCode Sandbox", 'bbcode_sandbox'); View::show_header('BBCode Sandbox', 'bbcode_sandbox');
?> ?>
<div class="thin"> <div class="thin">
<textarea id="sandbox" class="wbbarea" style="width: 98%;" onkeyup="resize('sandbox');" name="body" cols="90" rows="8"></textarea> <textarea id="sandbox" class="wbbarea" style="width: 98%;" onkeyup="resize('sandbox');" name="body" cols="90" rows="8"></textarea>

View File

@ -6,8 +6,8 @@
if (isset($_POST['extra_format']) && isset($_POST['extra_bitrate'])) { if (isset($_POST['extra_format']) && isset($_POST['extra_bitrate'])) {
for ($i = 1; $i <= 5; $i++) { for ($i = 1; $i <= 5; $i++) {
if (isset($_FILES['extra_file_' . $i])) { if (isset($_FILES["extra_file_$i"])) {
$ExtraFile = $_FILES['extra_file_' . $i]; $ExtraFile = $_FILES["extra_file_$i"];
$ExtraTorrentName = $ExtraFile['tmp_name']; $ExtraTorrentName = $ExtraFile['tmp_name'];
if (!is_uploaded_file($ExtraTorrentName) || !filesize($ExtraTorrentName)) { if (!is_uploaded_file($ExtraTorrentName) || !filesize($ExtraTorrentName)) {
$Err = 'No extra torrent file uploaded, or file is empty.'; $Err = 'No extra torrent file uploaded, or file is empty.';

View File

@ -11,11 +11,11 @@
HasLog, HasCue, info_hash, FileCount, FileList, FilePath, Size, Time, HasLog, HasCue, info_hash, FileCount, FileList, FilePath, Size, Time,
Description, LogScore, FreeTorrent, FreeLeechType) Description, LogScore, FreeTorrent, FreeLeechType)
VALUES VALUES
($GroupID, $LoggedUser[ID], $T[Media], '$ExtraTorrent[Format]', '$ExtraTorrent[Encoding]', " . ($GroupID, $LoggedUser[ID], $T[Media], '$ExtraTorrent[Format]', '$ExtraTorrent[Encoding]',
"$T[Remastered], $T[RemasterYear], $T[RemasterTitle], $T[RemasterRecordLabel], $T[RemasterCatalogueNumber], " . $T[Remastered], $T[RemasterYear], $T[RemasterTitle], $T[RemasterRecordLabel], $T[RemasterCatalogueNumber],
"$ExtraHasLog, $ExtraHasCue, '".db_string($ExtraTorrent['InfoHash'])."', $ExtraTorrent[NumFiles], " . $ExtraHasLog, $ExtraHasCue, '".db_string($ExtraTorrent['InfoHash'])."', $ExtraTorrent[NumFiles],
"'$ExtraTorrent[FileString]', '$ExtraTorrent[FilePath]', $ExtraTorrent[TotalSize], '".sqltime()."', " . '$ExtraTorrent[FileString]', '$ExtraTorrent[FilePath]', $ExtraTorrent[TotalSize], '".sqltime()."',
"'$ExtraTorrent[TorrentDescription]', $LogScore, '$T[FreeLeech]', '$T[FreeLeechType]')"); '$ExtraTorrent[TorrentDescription]', $LogScore, '$T[FreeLeech]', '$T[FreeLeechType]')");
$Cache->increment('stats_torrent_count'); $Cache->increment('stats_torrent_count');
$ExtraTorrentID = $DB->inserted_id(); $ExtraTorrentID = $DB->inserted_id();
@ -27,14 +27,18 @@
//******************************************************************************// //******************************************************************************//
//--------------- Write torrent file -------------------------------------------// //--------------- Write torrent file -------------------------------------------//
$DB->query("INSERT INTO torrents_files (TorrentID, File) VALUES ($ExtraTorrentID, '$ExtraTorrent[TorEnc]')"); $DB->query("
INSERT INTO torrents_files
(TorrentID, File)
VALUES
($ExtraTorrentID, '$ExtraTorrent[TorEnc]')");
Misc::write_log("Torrent $ExtraTorrentID ($LogName) (" . number_format($ExtraTorrent['TotalSize'] / (1024 * 1024), 2) . " MB) was uploaded by " . $LoggedUser['Username']); Misc::write_log("Torrent $ExtraTorrentID ($LogName) (" . number_format($ExtraTorrent['TotalSize'] / (1024 * 1024), 2) . ' MB) was uploaded by ' . $LoggedUser['Username']);
Torrents::write_group_log($GroupID, $ExtraTorrentID, $LoggedUser['ID'], "uploaded (" . number_format($ExtraTorrent['TotalSize'] / (1024 * 1024), 2) . " MB)", 0); Torrents::write_group_log($GroupID, $ExtraTorrentID, $LoggedUser['ID'], 'uploaded (' . number_format($ExtraTorrent['TotalSize'] / (1024 * 1024), 2) . ' MB)', 0);
Torrents::update_hash($GroupID); Torrents::update_hash($GroupID);
//IRC // IRC
$Announce = ''; $Announce = '';
$Announce .= Artists::display_artists($ArtistForm, false); $Announce .= Artists::display_artists($ArtistForm, false);
$Announce .= trim($Properties['Title']) . ' '; $Announce .= trim($Properties['Title']) . ' ';

View File

@ -328,7 +328,7 @@
die(); die();
} }
// Strip out amazon's padding // Strip out Amazon's padding
$AmazonReg = '/(http:\/\/ecx.images-amazon.com\/images\/.+)(\._.*_\.jpg)/i'; $AmazonReg = '/(http:\/\/ecx.images-amazon.com\/images\/.+)(\._.*_\.jpg)/i';
$Matches = array(); $Matches = array();
if (preg_match($RegX, $Properties['Image'], $Matches)) { if (preg_match($RegX, $Properties['Image'], $Matches)) {
@ -342,7 +342,7 @@
// Shorten and escape $Properties for database input // Shorten and escape $Properties for database input
$T = array(); $T = array();
foreach ($Properties as $Key => $Value) { foreach ($Properties as $Key => $Value) {
$T[$Key]="'".db_string(trim($Value))."'"; $T[$Key] = "'".db_string(trim($Value))."'";
if (!$T[$Key]) { if (!$T[$Key]) {
$T[$Key] = NULL; $T[$Key] = NULL;
} }
@ -362,13 +362,13 @@
$DB->query(" $DB->query("
SELECT ID SELECT ID
FROM torrents FROM torrents
WHERE info_hash='".db_string($InfoHash)."'"); WHERE info_hash = '".db_string($InfoHash)."'");
if ($DB->record_count() > 0) { if ($DB->record_count() > 0) {
list($ID) = $DB->next_record(); list($ID) = $DB->next_record();
$DB->query(" $DB->query("
SELECT TorrentID SELECT TorrentID
FROM torrents_files FROM torrents_files
WHERE TorrentID = ".$ID); WHERE TorrentID = $ID");
if ($DB->record_count() > 0) { if ($DB->record_count() > 0) {
$Err = '<a href="torrents.php?torrentid='.$ID.'">The exact same torrent file already exists on the site!</a>'; $Err = '<a href="torrents.php?torrentid='.$ID.'">The exact same torrent file already exists on the site!</a>';
} else { } else {
@ -381,7 +381,7 @@
} }
if (isset($Tor->Dec['encrypted_files'])) { if (isset($Tor->Dec['encrypted_files'])) {
$Err = 'This torrent contains an encrypted file list which is not supported here'; $Err = 'This torrent contains an encrypted file list which is not supported here.';
} }
// File list and size // File list and size
@ -436,7 +436,10 @@
$Body = $Properties['GroupDescription']; $Body = $Properties['GroupDescription'];
// Trickery // Trickery
if (!preg_match("/^".IMAGE_REGEX."$/i", $Properties['Image'])) { $Properties['Image'] = ''; $T['Image'] = "''"; } if (!preg_match('/^'.IMAGE_REGEX.'$/i', $Properties['Image'])) {
$Properties['Image'] = '';
$T['Image'] = "''";
}
if ($Type == 'Music') { if ($Type == 'Music') {
// Does it belong in a group? // Does it belong in a group?
@ -480,7 +483,7 @@
tg.WikiBody, tg.WikiBody,
tg.RevisionID tg.RevisionID
FROM torrents_group AS tg FROM torrents_group AS tg
LEFT JOIN torrents_artists AS ta ON ta.GroupID=tg.ID LEFT JOIN torrents_artists AS ta ON ta.GroupID = tg.ID
LEFT JOIN artists_group AS ag ON ta.ArtistID = ag.ArtistID LEFT JOIN artists_group AS ag ON ta.ArtistID = ag.ArtistID
WHERE ag.Name = '".db_string($Artist['name'])."' WHERE ag.Name = '".db_string($Artist['name'])."'
AND tg.Name = ".$T['Title']." AND tg.Name = ".$T['Title']."
@ -660,10 +663,10 @@
Scene, HasLog, HasCue, info_hash, FileCount, FileList, FilePath, Scene, HasLog, HasCue, info_hash, FileCount, FileList, FilePath,
Size, Time, Description, LogScore, FreeTorrent, FreeLeechType) Size, Time, Description, LogScore, FreeTorrent, FreeLeechType)
VALUES VALUES
($GroupID, $LoggedUser[ID], $T[Media], $T[Format], $T[Encoding], " . ($GroupID, $LoggedUser[ID], $T[Media], $T[Format], $T[Encoding],
"$T[Remastered], $T[RemasterYear], $T[RemasterTitle], $T[RemasterRecordLabel], $T[RemasterCatalogueNumber], " . $T[Remastered], $T[RemasterYear], $T[RemasterTitle], $T[RemasterRecordLabel], $T[RemasterCatalogueNumber],
"$T[Scene], '$HasLog', '$HasCue', '".db_string($InfoHash)."', $NumFiles, '$FileString', '$FilePath', " . $T[Scene], '$HasLog', '$HasCue', '".db_string($InfoHash)."', $NumFiles, '$FileString', '$FilePath',
"$TotalSize, '".sqltime()."', $T[TorrentDescription], $LogScore, '$T[FreeLeech]', '$T[FreeLeechType]')"); $TotalSize, '".sqltime()."', $T[TorrentDescription], $LogScore, '$T[FreeLeech]', '$T[FreeLeechType]')");
$Cache->increment('stats_torrent_count'); $Cache->increment('stats_torrent_count');
$TorrentID = $DB->inserted_id(); $TorrentID = $DB->inserted_id();
@ -712,7 +715,7 @@
//--------------- Stupid Recent Uploads ----------------------------------------// //--------------- Stupid Recent Uploads ----------------------------------------//
if (trim($Properties['Image']) != '') { if (trim($Properties['Image']) != '') {
$RecentUploads = $Cache->get_value('recent_uploads_'.$UserID); $RecentUploads = $Cache->get_value("recent_uploads_$UserID");
if (is_array($RecentUploads)) { if (is_array($RecentUploads)) {
do { do {
foreach ($RecentUploads as $Item) { foreach ($RecentUploads as $Item) {