diff --git a/classes/class_torrent.php b/classes/class_torrent.php index 72377c52..537f7f04 100644 --- a/classes/class_torrent.php +++ b/classes/class_torrent.php @@ -131,6 +131,9 @@ function encode($Val){ class BENCODE_LIST extends BENCODE { function enc(){ + if(empty($this->Val)) { + return 'le'; + } $Str = 'l'; reset($this->Val); foreach ($this->Val as $Value) { diff --git a/classes/class_wiki.php b/classes/class_wiki.php index 301670dc..e732491b 100644 --- a/classes/class_wiki.php +++ b/classes/class_wiki.php @@ -48,16 +48,16 @@ function revision_history(){ RevisionID, Summary, Time, - UserID, - users.Username + UserID FROM ".$this->Table." AS wiki - JOIN users_main AS users ON users.ID = wiki.UserID WHERE wiki.PageID = ".$this->PageID." ORDER BY RevisionID DESC"); //----------------------------------------------- ?> + + "> + + collect('fid'), true); @@ -35,7 +35,7 @@ } if (count($SnatchedGroupIDs) == 0) { - error(($SeedingOnly ? "You aren't seeding any 100% FLACs!" : "You haven't snatched any 100% FLACs!")); + error(($SeedingOnly ? "You aren't seeding any perfect FLACs!" : "You haven't snatched any perfect FLACs!")); } // Create hash table @@ -104,6 +104,26 @@ } } } +// 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; +foreach($TorrentGroups as $Editions) { + foreach($Editions as $Edition) { + if($Edition['FlacID'] == 0) { continue; } // no FLAC in this edition + $edition_miss = 0; //number of transcodes missing in this edition + foreach($Encodings as $Encoding) { + if(!isset($Edition['Formats'][$Encoding])) { + ++$edition_miss; + ++$Counter['miss_'.$Encoding]; + } + } + $Counter['miss_total'] += $edition_miss; + $Counter['total'] += (bool)$edition_miss; + } +} View::show_header('Transcode Snatches'); ?> @@ -115,6 +135,16 @@
+

Transcode torrents

+

Stats

+
+

+ Number of perfect FLACs you can transcode:
+ Number of missing transcodes:
+ Number of missing V2 / V0 / 320 transcodes: / / +

+
+

List

RevisionDateUser Summary
#$RevisionID" ?> - - Edited by - Reason: + + + + +
diff --git a/sections/better/transcode.php b/sections/better/transcode.php index 78086e4f..eb0ebdd1 100644 --- a/sections/better/transcode.php +++ b/sections/better/transcode.php @@ -74,7 +74,7 @@ } if (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) { + } elseif ($TorrentGroups[$Group['ID']][$TorRemIdent]['FlacID'] == 0 && $Torrent['Format'] == 'FLAC' && ($Torrent['LogScore'] == 100 || $Torrent['Media'] != 'CD')) { $TorrentGroups[$Group['ID']][$TorRemIdent]['FlacID'] = $Torrent['ID']; $TorrentGroups[$Group['ID']][$TorRemIdent]['IsSnatched'] = $Torrent['IsSnatched']; } diff --git a/sections/better/upload.php b/sections/better/upload.php index 8b78382e..944d9583 100644 --- a/sections/better/upload.php +++ b/sections/better/upload.php @@ -1,7 +1,5 @@ query("SELECT t.GroupID, t.ID FROM torrents AS t WHERE t.Format='FLAC' AND ((t.LogScore = '100' AND t.Media = 'CD') - OR t.Media = 'Vinyl') + OR t.Media != 'CD') AND t.UserID='$UserID'"); +$UploadedTorrentIDs = array_fill_keys($DB->collect('ID'), true); $UploadedGroupIDs = $DB->collect('GroupID'); -$Uploads = $DB->to_array('GroupID'); -if(count($UploadedGroupIDs) == 0) { error('You haven\'t uploaded any 100% flacs!'); } +if (count($UploadedGroupIDs) == 0) { + error("You haven't uploaded any perfect FLACs!"); +} + // Create hash table - $DB->query("CREATE TEMPORARY TABLE temp_sections_better_upload SELECT t.GroupID, - GROUP_CONCAT(t.Encoding SEPARATOR ' ') AS EncodingList + GROUP_CONCAT(t.Encoding SEPARATOR ' ') AS EncodingList, + CRC32(CONCAT_WS(' ', Media, Remasteryear, Remastertitle, + Remasterrecordlabel, Remastercataloguenumber)) AS RemIdent FROM torrents AS t WHERE t.GroupID IN(".implode(',',$UploadedGroupIDs).") - GROUP BY t.GroupID"); - -//$DB->query('SELECT * FROM t'); + GROUP BY t.GroupID, RemIdent"); $DB->query("SELECT GroupID FROM temp_sections_better_upload WHERE EncodingList NOT LIKE '%V0 (VBR)%' OR EncodingList NOT LIKE '%V2 (VBR)%' OR EncodingList NOT LIKE '%320%'"); -$GroupIDs = $DB->collect('GroupID'); +$GroupIDs = array_fill_keys($DB->collect('GroupID'), true); -if(count($GroupIDs) == 0) { error('No results found'); } +if (count($GroupIDs) == 0) { + error('No results found.'); +} -$Results = Torrents::get_groups($GroupIDs); +$Groups = Torrents::get_groups(array_keys($GroupIDs)); +$Groups = $Groups['matches']; + +$TorrentGroups = array(); +foreach ($Groups as $GroupID => $Group) { + if (empty($Group['Torrents'])) { + unset($Groups[$GroupID]); + continue; + } + foreach ($Group['Torrents'] as $Torrent) { + $TorRemIdent = "$Torrent[Media] $Torrent[RemasterYear] $Torrent[RemasterTitle] $Torrent[RemasterRecordLabel] $Torrent[RemasterCatalogueNumber]"; + if (!isset($TorrentGroups[$Group['ID']])) { + $TorrentGroups[$Group['ID']] = array( + $TorRemIdent => array( + 'FlacID' => 0, + 'Formats' => array(), + 'IsSnatched' => $Torrent['IsSnatched'], + 'Medium' => $Torrent['Media'], + 'RemasterTitle' => $Torrent['RemasterTitle'], + 'RemasterYear' => $Torrent['RemasterYear'], + 'RemasterRecordLabel' => $Torrent['RemasterRecordLabel'], + 'RemasterCatalogueNumber' => $Torrent['RemasterCatalogueNumber'] + ) + ); + } elseif (!isset($TorrentGroups[$Group['ID']][$TorRemIdent])) { + $TorrentGroups[$Group['ID']][$TorRemIdent] = array( + 'FlacID' => 0, + 'Formats' => array(), + 'IsSnatched' => $Torrent['IsSnatched'], + 'Medium' => $Torrent['Media'], + 'RemasterTitle' => $Torrent['RemasterTitle'], + 'RemasterYear' => $Torrent['RemasterYear'], + 'RemasterRecordLabel' => $Torrent['RemasterRecordLabel'], + 'RemasterCatalogueNumber' => $Torrent['RemasterCatalogueNumber'] + ); + } + if (isset($EncodingKeys[$Torrent['Encoding']])) { + $TorrentGroups[$Group['ID']][$TorRemIdent]['Formats'][$Torrent['Encoding']] = true; + $Counter['existing'][$Torrent['Encoding']] += 1; + } elseif (isset($UploadedTorrentIDs[$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; +foreach($TorrentGroups as $Editions) { + foreach($Editions as $Edition) { + if($Edition['FlacID'] == 0) { continue; } // no FLAC in this edition + $edition_miss = 0; //number of transcodes missing in this edition + foreach($Encodings as $Encoding) { + if(!isset($Edition['Formats'][$Encoding])) { + ++$edition_miss; + ++$Counter['miss_'.$Encoding]; + } + } + $Counter['miss_total'] += $edition_miss; + $Counter['total'] += (bool)$edition_miss; + } +} View::show_header('Transcode Uploads'); ?>
+

Stats

+
+

+ Number of perfect FLACs you can transcode:
+ Number of missing transcodes:
+ Number of missing V2 / V0 / 320 transcodes: / / +

+
+

List

Torrent
@@ -56,64 +134,80 @@ $Group) { - list($GroupID, $GroupName, $GroupYear, $GroupRecordLabel, $GroupCatalogueNumber, $TorrentTags, $ReleaseType, $GroupVanityHouse, $Torrents, $Artists, $ExtendedArtists, $GroupFlags) = array_values($Group); +foreach ($TorrentGroups as $GroupID => $Editions) { + $GroupInfo = $Groups[$GroupID]; + $GroupYear = $GroupInfo['Year']; + $ExtendedArtists = $GroupInfo['ExtendedArtists']; + $GroupCatalogueNumber = $GroupInfo['CatalogueNumber']; + $GroupName = $GroupInfo['Name']; + $GroupRecordLabel = $GroupInfo['RecordLabel']; + $ReleaseType = $GroupInfo['ReleaseType']; + if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4]) || !empty($ExtendedArtists[5]) || !empty($ExtendedArtists[6])) { unset($ExtendedArtists[2]); unset($ExtendedArtists[3]); - $DisplayName = Artists::display_artists($ExtendedArtists); + $ArtistNames = Artists::display_artists($ExtendedArtists); } else { - $DisplayName = ''; - } - $FlacID = $Uploads[$GroupID]['ID']; - - $DisplayName = ''; - if(count($Artists)>0) { - $DisplayName = Artists::display_artists(array('1'=>$Artists)); - } - $DisplayName.=''.$GroupName.''; - if($GroupYear>0) { $DisplayName.=" [".$GroupYear."]"; } - if($ReleaseType>0) { $DisplayName.=" [".$ReleaseTypes[$ReleaseType]."]"; } - - $ExtraInfo = Torrents::torrent_info($Torrents[$FlacID]); - if($ExtraInfo) { - $DisplayName.=' - '.$ExtraInfo; + $ArtistNames = ''; } - $MissingEncodings = array('V0 (VBR)'=>1, 'V2 (VBR)'=>1, '320'=>1); - - foreach($Torrents as $Torrent) { - if(!empty($MissingEncodings[$Torrent['Encoding']])) { - $MissingEncodings[$Torrent['Encoding']] = 0; + $TagList = array(); + $TagList = explode(' ', str_replace('_', '.', $GroupInfo['TagList'])); + $TorrentTags = array(); + foreach ($TagList as $Tag) { + $TorrentTags[] = ''.$Tag.''; + } + $TorrentTags = implode(', ', $TorrentTags); + foreach ($Editions as $RemIdent => $Edition) { + if (!$Edition['FlacID'] || count($Edition['Formats']) == 3) { + continue; } - } - - $TagList=array(); - if($TorrentTags!='') { - $TorrentTags=explode(' ',$TorrentTags); - foreach ($TorrentTags as $TagKey => $TagName) { - $TagName = str_replace('_','.',$TagName); - $TagList[]=''.$TagName.''; + $DisplayName = $ArtistNames . ''.$GroupName.''; + if($GroupYear > 0) { + $DisplayName .= " [".$GroupYear."]"; } - $PrimaryTag = $TorrentTags[0]; - $TagList = implode(', ', $TagList); - $TorrentTags='
'.$TagList.'
'; - } + if ($ReleaseType > 0) { + $DisplayName .= " [".$ReleaseTypes[$ReleaseType]."]"; + } + $DisplayName .= ' ['.$Edition['Medium'].']'; + + $EditionInfo = array(); + if (!empty($Edition['RemasterYear'])) { + $ExtraInfo = $Edition['RemasterYear']; + } else { + $ExtraInfo = ''; + } + if (!empty($Edition['RemasterRecordLabel'])) { + $EditionInfo[] = $Edition['RemasterRecordLabel']; + } + if (!empty($Edition['RemasterTitle'])) { + $EditionInfo[] = $Edition['RemasterTitle']; + } + if (!empty($Edition['RemasterCatalogueNumber'])) { + $EditionInfo[] = $Edition['RemasterCatalogueNumber']; + } + if (!empty($Edition['RemasterYear'])) { + $ExtraInfo .= ' - '; + } + $ExtraInfo .= implode(' / ', $EditionInfo); ?> - > + - - - + + + - +
Torrent320
- DL + DL - +
+
YES' : 'NO'?>YES' : 'NO'?>YES' : 'NO'?>YES':'NO'?>YES':'NO'?>YES':'NO'?>
'.$Name;} - /* $Err = 'The torrent contained one or more files with too long a name ('.$Name.')'; */ + foreach($TooLongPaths as $Name) { + $Names .= '
'.$Name; + } $Err = 'The torrent contained one or more files with too long a name:'.$Names; } @@ -411,10 +412,9 @@ // The string that will make up the final torrent file $TorrentText = $Tor->enc(); - +$Debug->set_flag('upload: torrent decoded'); // Infohash - $InfoHash = pack("H*", sha1($Tor->Val['info']->enc())); $DB->query("SELECT ID FROM torrents WHERE info_hash='".db_string($InfoHash)."'"); if($DB->record_count()>0) { @@ -650,10 +650,8 @@ $Cache->increment('stats_torrent_count'); $TorrentID = $DB->inserted_id(); - Tracker::update_tracker('add_torrent', array('id' => $TorrentID, 'info_hash' => rawurlencode($InfoHash), 'freetorrent' => $T['FreeLeech'])); - - +$Debug->set_flag('upload: ocelot updated'); //******************************************************************************// //--------------- Write torrent file -------------------------------------------// @@ -743,7 +741,7 @@ send_irc('PRIVMSG #'.NONSSL_SITE_URL.'-announce :'.html_entity_decode($Announce)); send_irc('PRIVMSG #'.NONSSL_SITE_URL.'-announce-ssl :'.$AnnounceSSL); //send_irc('PRIVMSG #'.NONSSL_SITE_URL.'-announce :'.html_entity_decode($Announce)); - +$Debug->set_flag('upload: announced on irc'); // Manage notifications $UsedFormatBitrates = array(); @@ -890,7 +888,7 @@ $SQL.=" AND UserID != '".$LoggedUser['ID']."' "; $DB->query($SQL); - +$Debug->set_flag('upload: notification query finished'); if($DB->record_count()>0){ $UserArray = $DB->to_array('UserID'); @@ -906,7 +904,7 @@ } $InsertSQL.=implode(',', $Rows); $DB->query($InsertSQL); - + $Debug->set_flag('upload: notification inserts finished'); foreach ($FilterArray as $Filter) { list($FilterID, $UserID, $Passkey) = $Filter; @@ -924,7 +922,7 @@ } $Feed->populate('torrents_all',$Item); - +$Debug->set_flag('upload: notifications handled'); if($Type == 'Music'){ $Feed->populate('torrents_music',$Item); if($Properties['Media'] == 'Vinyl') { $Feed->populate('torrents_vinyl',$Item); }