From dde2653aa2983138ee0b5b5632fae1bed8945b34 Mon Sep 17 00:00:00 2001 From: Git Date: Mon, 18 Feb 2013 08:00:22 +0000 Subject: [PATCH] Empty commit --- classes/class_cache.php | 8 ++- classes/class_torrent.php | 11 ++- classes/class_torrent_form.php | 8 +-- classes/class_torrents.php | 2 +- gazelle.sql | 4 +- sections/artist/artist.php | 2 +- sections/better/snatch.php | 19 ++--- sections/better/transcode.php | 10 +-- sections/better/upload.php | 20 +++--- sections/collages/collage.php | 64 ++++++++--------- sections/collages/edit.php | 10 +-- sections/forums/main.php | 8 +-- sections/forums/newthread.php | 10 +-- sections/forums/search.php | 9 ++- sections/inbox/inbox.php | 71 +++++++++--------- sections/index/feat_album.php | 2 +- sections/peerupdate/index.php | 2 +- sections/requests/new_edit.php | 104 +++++++++++++-------------- sections/top10/votes.php | 1 + sections/torrents/details.php | 44 ++++++------ sections/user/edit.php | 14 ++-- sections/user/linkedfunctions.php | 2 +- sections/user/user.php | 116 +++++++++++++++--------------- 23 files changed, 287 insertions(+), 254 deletions(-) diff --git a/classes/class_cache.php b/classes/class_cache.php index 203d86b6..33375f4d 100644 --- a/classes/class_cache.php +++ b/classes/class_cache.php @@ -28,7 +28,13 @@ error('Memcache Extension not loaded.'); } -class CACHE extends Memcache { +class CACHE extends Memcache +{ + /** + * Torrent Group cache version + */ + const GROUP_VERSION = 4; + public $CacheHits = array(); public $MemcacheDBArray = array(); public $MemcacheDBKey = ''; diff --git a/classes/class_torrent.php b/classes/class_torrent.php index 537f7f04..e99f65c4 100644 --- a/classes/class_torrent.php +++ b/classes/class_torrent.php @@ -109,7 +109,9 @@ function decode($Type, $Key){ $this->Val[$Key] = new BENCODE_DICT(substr($this->Str, $this->Pos)); $this->Pos += $this->Val[$Key]->Pos; // Sort by key to respect spec - ksort($this->Val[$Key]->Val); + if (!empty($this->Val[$Key]->Val)) { + ksort($this->Val[$Key]->Val); + } } else { die('Invalid torrent file'); @@ -131,7 +133,7 @@ function encode($Val){ class BENCODE_LIST extends BENCODE { function enc(){ - if(empty($this->Val)) { + if (empty($this->Val)) { return 'le'; } $Str = 'l'; @@ -160,7 +162,7 @@ function dec(){ // Decode the bencoded element. // This function changes $this->Pos and $this->Val, so you don't have to. $this->decode($Type, $Key); - ++ $Key; + ++$Key; } return true; } @@ -168,6 +170,9 @@ function dec(){ class BENCODE_DICT extends BENCODE { function enc(){ + if (empty($this->Val)) { + return 'de'; + } $Str = 'd'; reset($this->Val); foreach ($this->Val as $Key => $Value) { diff --git a/classes/class_torrent_form.php b/classes/class_torrent_form.php index 9a87b80d..17fde2fc 100644 --- a/classes/class_torrent_form.php +++ b/classes/class_torrent_form.php @@ -209,7 +209,7 @@ function music_form($GenreTags) { DisabledFlag) { ?> - [+] [-] + + @@ -228,7 +228,7 @@ function music_form($GenreTags) { - [+] [-] + + @@ -462,8 +462,8 @@ function show() { Log files: - Check your log files before uploading here. For multi-disc releases, click the [+] button to add multiple log files.
- [+] [-] + Check your log files before uploading here. For multi-disc releases, click the "+" button to add multiple log files.
+ + get_value($Key.$GroupID, true); - if (!empty($Data) && (@$Data['ver'] >= 4)) { + if (!empty($Data) && (@$Data['ver'] == CACHE::GROUP_VERSION)) { unset($NotFound[$GroupID]); $Found[$GroupID] = $Data['d']; } diff --git a/gazelle.sql b/gazelle.sql index ec22f359..b10c1df7 100644 --- a/gazelle.sql +++ b/gazelle.sql @@ -492,9 +492,9 @@ CREATE TABLE `permissions` ( CREATE TABLE `pm_conversations` ( `ID` int(12) NOT NULL AUTO_INCREMENT, - `Subject` varchar(255) COLLATE utf8_bin DEFAULT NULL, + `Subject` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, PRIMARY KEY (`ID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_swedish_ci; CREATE TABLE `pm_conversations_users` ( `UserID` int(10) NOT NULL DEFAULT '0', diff --git a/sections/artist/artist.php b/sections/artist/artist.php index e4ee6832..22573a2f 100644 --- a/sections/artist/artist.php +++ b/sections/artist/artist.php @@ -705,7 +705,7 @@ function compare($X, $Y){
  • - - + + X diff --git a/sections/better/snatch.php b/sections/better/snatch.php index 3c0e33e2..99152a1b 100644 --- a/sections/better/snatch.php +++ b/sections/better/snatch.php @@ -22,9 +22,11 @@ $DB->query("SELECT t.GroupID, x.fid FROM ".($SeedingOnly ? 'xbt_files_users' : 'xbt_snatched')." AS x JOIN torrents AS t ON t.ID=x.fid + JOIN torrents_group AS tg ON tg.ID = t.GroupID WHERE t.Format='FLAC' AND ((t.LogScore = '100' AND t.Media = 'CD') OR t.Media != 'CD') + AND tg.CategoryID = 1 AND x.uid='$UserID'"); $SnatchedTorrentIDs = array_fill_keys($DB->collect('fid'), true); @@ -45,7 +47,7 @@ CRC32(CONCAT_WS(' ', Media, Remasteryear, Remastertitle, Remasterrecordlabel, Remastercataloguenumber)) AS RemIdent FROM torrents AS t - WHERE t.GroupID IN(".implode(',',$SnatchedGroupIDs).") + WHERE t.GroupID IN(".implode(',',$SnatchedGroupIDs).") AND t.Format IN ('FLAC', 'MP3') GROUP BY t.GroupID, RemIdent"); //$DB->query('SELECT * FROM t'); @@ -97,19 +99,20 @@ 'RemasterCatalogueNumber' => $Torrent['RemasterCatalogueNumber'] ); } - if (isset($EncodingKeys[$Torrent['Encoding']])) { + if ($Torrent['Format'] == 'MP3' && isset($EncodingKeys[$Torrent['Encoding']])) { $TorrentGroups[$Group['ID']][$TorRemIdent]['Formats'][$Torrent['Encoding']] = true; } elseif (isset($SnatchedTorrentIDs[$Torrent['ID']])) { $TorrentGroups[$Group['ID']][$TorRemIdent]['FlacID'] = $Torrent['ID']; } } } -// count how many FLAC torrents we have in this list totally (key 'total') -// how many transcodes there are missing totally (key 'miss_total') -// and for each format (keys , 'miss_V0 (VBR)', 'miss_V2 (VBR)', 'miss_320') -// the latter happens by counting the number of existing transcodes and then subtracting because that's easier -$Counter = array(); -$Counter['total'] = 0; +$Counter = array( + 'total' => 0, //how many FLAC torrents can be transcoded? + 'miss_total' => 0, //how many transcodes are missing? + 'miss_V0 (VBR)' => 0, //how many V0 transcodes are missing? + 'miss_V2 (VBR)' => 0, //how many V2 transcodes are missing? + 'miss_320' => 0, //how many 320 transcodes are missing? +); foreach($TorrentGroups as $Editions) { foreach($Editions as $Edition) { if($Edition['FlacID'] == 0) { continue; } // no FLAC in this edition diff --git a/sections/better/transcode.php b/sections/better/transcode.php index eb0ebdd1..aba003ca 100644 --- a/sections/better/transcode.php +++ b/sections/better/transcode.php @@ -72,7 +72,7 @@ 'IsSnatched' => false ); } - if (isset($EncodingKeys[$Torrent['Encoding']])) { + if ($Torrent['Format'] == 'MP3' && isset($EncodingKeys[$Torrent['Encoding']])) { $TorrentGroups[$Group['ID']][$TorRemIdent]['Formats'][$Torrent['Encoding']] = true; } elseif ($TorrentGroups[$Group['ID']][$TorRemIdent]['FlacID'] == 0 && $Torrent['Format'] == 'FLAC' && ($Torrent['LogScore'] == 100 || $Torrent['Media'] != 'CD')) { $TorrentGroups[$Group['ID']][$TorRemIdent]['FlacID'] = $Torrent['ID']; @@ -133,9 +133,11 @@ } $TorrentTags = implode(', ', $TorrentTags); foreach ($Editions as $RemIdent => $Edition) { - if (!$Edition['FlacID'] - || !empty($Edition['Formats']) && $_GET['type'] == 3 - || $Edition['Formats'][$Encodings[$_GET['type']]] == true) { + if (!$Edition['FlacID'] //no FLAC in this group + || !empty($Edition['Formats']) && $_GET['type'] == 3 //at least one transcode present when we only wanted groups containing no transcodes at all (type 3) + || $Edition['Formats'][$Encodings[$_GET['type']]] == true //the transcode we asked for is already there + || count($Edition['Formats']) == 3) //all 3 transcodes are there already (this can happen due to the caching of Sphinx's better_transcode table) + { $Debug->log_var($Edition, 'Skipping '.$RemIdent); continue; } diff --git a/sections/better/upload.php b/sections/better/upload.php index 944d9583..86bbbdbb 100644 --- a/sections/better/upload.php +++ b/sections/better/upload.php @@ -15,10 +15,12 @@ // Get list of FLAC uploads $DB->query("SELECT t.GroupID, t.ID FROM torrents AS t + JOIN torrents_group AS tg ON tg.ID = t.GroupID WHERE t.Format='FLAC' AND ((t.LogScore = '100' AND t.Media = 'CD') OR t.Media != 'CD') + AND tg.CategoryID = 1 AND t.UserID='$UserID'"); $UploadedTorrentIDs = array_fill_keys($DB->collect('ID'), true); @@ -35,7 +37,7 @@ CRC32(CONCAT_WS(' ', Media, Remasteryear, Remastertitle, Remasterrecordlabel, Remastercataloguenumber)) AS RemIdent FROM torrents AS t - WHERE t.GroupID IN(".implode(',',$UploadedGroupIDs).") + WHERE t.GroupID IN(".implode(',',$UploadedGroupIDs).") AND t.Format IN ('FLAC', 'MP3') GROUP BY t.GroupID, RemIdent"); $DB->query("SELECT GroupID FROM temp_sections_better_upload @@ -85,7 +87,7 @@ 'RemasterCatalogueNumber' => $Torrent['RemasterCatalogueNumber'] ); } - if (isset($EncodingKeys[$Torrent['Encoding']])) { + if ($Torrent['Format'] == 'MP3' && isset($EncodingKeys[$Torrent['Encoding']])) { $TorrentGroups[$Group['ID']][$TorRemIdent]['Formats'][$Torrent['Encoding']] = true; $Counter['existing'][$Torrent['Encoding']] += 1; } elseif (isset($UploadedTorrentIDs[$Torrent['ID']])) { @@ -93,12 +95,13 @@ } } } -// count how many FLAC torrents we have in this list totally (key 'total') -// how many transcodes there are missing totally (key 'miss_total') -// and for each format (keys , 'miss_V0 (VBR)', 'miss_V2 (VBR)', 'miss_320') -// the latter happens by counting the number of existing transcodes and then subtracting because that's easier -$Counter = array(); -$Counter['total'] = 0; +$Counter = array( + 'total' => 0, //how many FLAC torrents can be transcoded? + 'miss_total' => 0, //how many transcodes are missing? + 'miss_V0 (VBR)' => 0, //how many V0 transcodes are missing? + 'miss_V2 (VBR)' => 0, //how many V2 transcodes are missing? + 'miss_320' => 0, //how many 320 transcodes are missing? +); foreach($TorrentGroups as $Editions) { foreach($Editions as $Edition) { if($Edition['FlacID'] == 0) { continue; } // no FLAC in this edition @@ -117,6 +120,7 @@ View::show_header('Transcode Uploads'); ?>
    +

    Transcode uploaded torrents

    Stats

    diff --git a/sections/collages/collage.php b/sections/collages/collage.php index 88d222ca..9fdb9b0e 100644 --- a/sections/collages/collage.php +++ b/sections/collages/collage.php @@ -9,7 +9,7 @@ function compare($X, $Y){ include(SERVER_ROOT.'/sections/bookmarks/functions.php'); // has_bookmarked() include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class -include(SERVER_ROOT.'/classes/class_image_tools.php'); +include(SERVER_ROOT.'/classes/class_image_tools.php'); $Text = new TEXT; @@ -103,20 +103,20 @@ function compare($X, $Y){ foreach ($TorrentList as $GroupID=>$Group) { list($GroupID, $GroupName, $GroupYear, $GroupRecordLabel, $GroupCatalogueNumber, $TagList, $ReleaseType, $GroupVanityHouse, $Torrents, $GroupArtists, $ExtendedArtists, $GroupFlags) = array_values($Group); list($GroupID2, $Image, $GroupCategoryID, $UserID, $Username) = array_values($CollageDataList[$GroupID]); - + // Handle stats and stuff $Number++; $NumGroups++; if($UserID == $LoggedUser['ID']) { $NumGroupsByUser++; } - + if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4]) || !empty($ExtendedArtists[5]) || !empty($ExtendedArtists[6])) { $CountArtists = array_merge((array)$ExtendedArtists[1], (array)$ExtendedArtists[4], (array)$ExtendedArtists[5], (array)$ExtendedArtists[6]); } else{ $CountArtists = $GroupArtists; } - + if($CountArtists) { foreach($CountArtists as $Artist) { if(!isset($Artists[$Artist['id']])) { @@ -126,7 +126,7 @@ function compare($X, $Y){ } } } - + if($Username) { if(!isset($Users[$UserID])) { $Users[$UserID] = array('name'=>$Username, 'count'=>1); @@ -134,7 +134,7 @@ function compare($X, $Y){ $Users[$UserID]['count']++; } } - + $TagList = explode(' ',str_replace('_','.',$TagList)); $TorrentTags = array(); @@ -151,7 +151,7 @@ function compare($X, $Y){ $TorrentTags='

    '.$TorrentTags.'
    '; $DisplayName = $Number.' - '; - + if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4]) || !empty($ExtendedArtists[5])|| !empty($ExtendedArtists[6])) { unset($ExtendedArtists[2]); unset($ExtendedArtists[3]); @@ -159,7 +159,7 @@ function compare($X, $Y){ } elseif(count($GroupArtists)>0) { $DisplayName .= Artists::display_artists(array('1'=>$GroupArtists)); } - + $DisplayName .= ''.$GroupName.''; if($GroupYear>0) { $DisplayName = $DisplayName. ' ['. $GroupYear .']';} if($GroupVanityHouse) { $DisplayName .= ' [VH]'; } @@ -191,17 +191,17 @@ function compare($X, $Y){ $LastRemasterRecordLabel = ''; $LastRemasterCatalogueNumber = ''; $LastMedia = ''; - + $EditionID = 0; unset($FirstUnknown); - + foreach ($Torrents as $TorrentID => $Torrent) { if ($Torrent['Remastered'] && !$Torrent['RemasterYear']) { $FirstUnknown = !isset($FirstUnknown); } $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : ''; - + if($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear || $Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber || $FirstUnknown || $Torrent['Media'] != $LastMedia) { $EditionID++; @@ -212,7 +212,7 @@ function compare($X, $Y){ if($Torrent['RemasterCatalogueNumber']) { $RemasterName .= $AddExtra.display_str($Torrent['RemasterCatalogueNumber']); $AddExtra=' / '; } if($Torrent['RemasterTitle']) { $RemasterName .= $AddExtra.display_str($Torrent['RemasterTitle']); $AddExtra=' / '; } $RemasterName .= $AddExtra.display_str($Torrent['Media']); - + ?> @@ -261,9 +261,9 @@ function compare($X, $Y){ } } else { // Viewing a type that does not require grouping - + list($TorrentID, $Torrent) = each($Torrents); - + $DisplayName = ''.$GroupName.''; if ($Torrent['IsSnatched']) { @@ -289,7 +289,7 @@ function compare($X, $Y){ [ DL | FL - + | RP ] @@ -303,11 +303,11 @@ function compare($X, $Y){
  • - - + -
    Add artist+
    @@ -317,12 +317,12 @@ function compare($X, $Y){
      $Tag) { - + ?>
    • - - + + @@ -449,7 +449,7 @@ function filelist($Str) { } $ReportInfo .= ""; } - + $CanEdit = (check_perms('torrents_edit') || (($UserID == $LoggedUser['ID'] && !$LoggedUser['DisableWiki']) && !($Remastered && !$RemasterYear))); $RegenLink = check_perms('users_mod') ? ' Regenerate' : ''; @@ -510,24 +510,24 @@ function filelist($Str) { if(!empty($LossymasterApproved)) { $ExtraInfo.=$AddExtra. Format::torrent_label('Lossy Master Approved'); $AddExtra=' / '; } if(!empty($LossywebApproved)) { $ExtraInfo.=$AddExtra. Format::torrent_label('Lossy WEB Approved'); $AddExtra = ' / '; } if(!empty($BadFiles)) { $ExtraInfo.=$AddExtra. Format::torrent_label('Bad File Names'); $AddExtra=' / '; } - - if($GroupCategoryID == 1 + + if($GroupCategoryID == 1 && ($RemasterTitle != $LastRemasterTitle || $RemasterYear != $LastRemasterYear - || $RemasterRecordLabel != $LastRemasterRecordLabel + || $RemasterRecordLabel != $LastRemasterRecordLabel || $RemasterCatalogueNumber != $LastRemasterCatalogueNumber || $FirstUnknown || $Media != $LastMedia)) { - + $EditionID++; if($Remastered && $RemasterYear != 0){ - + $RemasterName = $RemasterYear; $AddExtra = " - "; if($RemasterRecordLabel) { $RemasterName .= $AddExtra.display_str($RemasterRecordLabel); $AddExtra=' / '; } if($RemasterCatalogueNumber) { $RemasterName .= $AddExtra.display_str($RemasterCatalogueNumber); $AddExtra=' / '; } - if($RemasterTitle) { $RemasterName .= $AddExtra.display_str($RemasterTitle); $AddExtra=' / '; } + if($RemasterTitle) { $RemasterName .= $AddExtra.display_str($RemasterTitle); $AddExtra=' / '; } $RemasterName .= $AddExtra.display_str($Media); ?> @@ -563,7 +563,7 @@ function filelist($Str) { [ | FL - + | RP | ED @@ -596,7 +596,7 @@ function filelist($Str) { if ($LastActive != '0000-00-00 00:00:00' && time() - strtotime($LastActive) >= 345678 && time()-strtotime($LastReseedRequest)>=864000) { ?>
      Request re-seed - + @@ -607,7 +607,7 @@ function filelist($Str) {