Empty commit

This commit is contained in:
Git 2013-02-17 08:00:08 +00:00
parent a49bc32a52
commit 9291b1fd8c
7 changed files with 219 additions and 81 deletions

View File

@ -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) {

View File

@ -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");
//----------------------------------------------- ?>
<table cellpadding="6" cellspacing="1" border="0" width="100%" class="border">
<tr class="colhead">
<td>Revision</td>
<td>Date</td>
<td>User</td>
<td>Summary</td>
</tr>
<? //-----------------------------------------
@ -68,11 +68,15 @@ function revision_history(){
<tr class="row<?=$Row?>">
<td>
<?= "<a href='$BaseURL&amp;revisionid=$RevisionID'>#$RevisionID</a>" ?>
</td>
<td>
<strong>Edited by</strong> <a href="user.php?id=<?=$UserID?>"><?=$Username ?></a>
<strong>Reason:</strong> <?=$Summary?>
<?=$Time?>
</td>
<td>
<?=Users::format_username($UserID, false, false, false)?>
</td>
<td>
<?=($Summary ? $Summary : '(empty)')?>
</td>
</tr>
<? //---------------------------------------------------

View File

@ -56,7 +56,13 @@ if (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 80) {
}
// Site settings
define('CRYPT_HASH_PREFIX', '$2y$07$'); // Crypt salt prefix for hash settings. See http://php.net/crypt for details
if (PHP_VERSION_ID < 50307) {
die("PHP version 5.3.7 or later is highly recommended for gazelle's password hashing methods.".
" Uncomment line ".__LINE__." in file ".__FILE__." if you want to continue to use this version.");
define('CRYPT_HASH_PREFIX', '$2a$07$'); // Crypt salt prefix for hash settings. See http://php.net/crypt for details
} else {
define('CRYPT_HASH_PREFIX', '$2y$07$');
}
define('DEBUG_MODE', false); //Set to false if you dont want everyone to see debug information, can be overriden with 'site_debug'
define('OPEN_REGISTRATION', true); //Set to false to disable open regirstration, true to allow anyone to register
define('USER_LIMIT', 5000); //The maximum number of users the site can have, 0 for no limit
@ -67,11 +73,10 @@ define('DONOR_INVITES', 2);
// User class IDs needed for automatic promotions. Found in the 'permissions' table
// Name of class Class ID (NOT level)
define('ADMIN', '1');
define('USER', '2');
define('MEMBER', '3');
define('POWER', '4');
define('ARTIST', '19');
define('DONOR', '20');
define('ELITE', '5');
define('VIP', '6');
define('TORRENT_MASTER','7');
@ -80,8 +85,12 @@ define('CELEB', '9');
define('MOD', '11');
define('DESIGNER', '13');
define('CODER', '14');
define('ADMIN', '1');
define('SYSOP', '15');
define('ARTIST', '19');
define('DONOR', '20');
define('FLS_TEAM', '21');
define('POWER_TM', '22');
define('ELITE_TM', '23');
//Pagination
define('TORRENT_COMMENTS_PER_PAGE', 10);

View File

@ -24,7 +24,7 @@
JOIN torrents AS t ON t.ID=x.fid
WHERE t.Format='FLAC'
AND ((t.LogScore = '100' AND t.Media = 'CD')
OR t.Media = 'Vinyl')
OR t.Media != 'CD')
AND x.uid='$UserID'");
$SnatchedTorrentIDs = array_fill_keys($DB->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 @@
<? } ?>
</div>
<div class="thin">
<h2>Transcode <?=($SeedingOnly ? 'seeding' : 'snatched')?> torrents</h2>
<h3>Stats</h3>
<div class="box pad">
<p>
Number of perfect FLACs you can transcode: <?=$Counter['total']?><br />
Number of missing transcodes: <?=$Counter['miss_total']?><br />
Number of missing V2 / V0 / 320 transcodes: <?=$Counter['miss_V2 (VBR)']?> / <?=$Counter['miss_V0 (VBR)']?> / <?=$Counter['miss_320']?>
</p>
</div>
<h3>List</h3>
<table width="100%" class="torrent_table">
<tr class="colhead">
<td>Torrent</td>

View File

@ -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'];
}

View File

@ -1,6 +1,4 @@
<?
// Get list of FLAC uploads
if (!empty($_GET['userid']) && is_number($_GET['userid'])) {
if (check_perms('users_override_paranoia')) {
$UserID = $_GET['userid'];
@ -11,43 +9,123 @@
$UserID = $LoggedUser['ID'];
}
$Encodings = array('V0 (VBR)', 'V2 (VBR)', '320');
$EncodingKeys = array_fill_keys($Encodings, true);
// Get list of FLAC uploads
$DB->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');
?>
<div class="thin">
<h3>Stats</h3>
<div class="box pad">
<p>
Number of perfect FLACs you can transcode: <?=$Counter['total']?><br />
Number of missing transcodes: <?=$Counter['miss_total']?><br />
Number of missing V2 / V0 / 320 transcodes: <?=$Counter['miss_V2 (VBR)']?> / <?=$Counter['miss_V0 (VBR)']?> / <?=$Counter['miss_320']?>
</p>
</div>
<h3>List</h3>
<table width="100%" class="torrent_table">
<tr class="colhead">
<td>Torrent</td>
@ -56,64 +134,80 @@
<td>320</td>
</tr>
<?
$Results = $Results['matches'];
foreach ($Results as $GroupID=>$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.='<a href="torrents.php?id='.$GroupID.'&amp;torrentid='.$FlacID.'#torrent'.$FlacID.'" title="View Torrent">'.$GroupName.'</a>';
if($GroupYear>0) { $DisplayName.=" [".$GroupYear."]"; }
if($ReleaseType>0) { $DisplayName.=" [".$ReleaseTypes[$ReleaseType]."]"; }
$ExtraInfo = Torrents::torrent_info($Torrents[$FlacID]);
if($ExtraInfo) {
$DisplayName.=' - '.$ExtraInfo;
}
$MissingEncodings = array('V0 (VBR)'=>1, 'V2 (VBR)'=>1, '320'=>1);
foreach($Torrents as $Torrent) {
if(!empty($MissingEncodings[$Torrent['Encoding']])) {
$MissingEncodings[$Torrent['Encoding']] = 0;
}
$ArtistNames = '';
}
$TagList = array();
if($TorrentTags!='') {
$TorrentTags=explode(' ',$TorrentTags);
foreach ($TorrentTags as $TagKey => $TagName) {
$TagName = str_replace('_','.',$TagName);
$TagList[]='<a href="torrents.php?taglist='.$TagName.'">'.$TagName.'</a>';
$TagList = explode(' ', str_replace('_', '.', $GroupInfo['TagList']));
$TorrentTags = array();
foreach ($TagList as $Tag) {
$TorrentTags[] = '<a href="torrents.php?taglist='.$Tag.'">'.$Tag.'</a>';
}
$PrimaryTag = $TorrentTags[0];
$TagList = implode(', ', $TagList);
$TorrentTags='<br /><div class="tags">'.$TagList.'</div>';
$TorrentTags = implode(', ', $TorrentTags);
foreach ($Editions as $RemIdent => $Edition) {
if (!$Edition['FlacID'] || count($Edition['Formats']) == 3) {
continue;
}
$DisplayName = $ArtistNames . '<a href="torrents.php?id='.$GroupID.'&amp;torrentid='.$Edition['FlacID'].'#torrent'.$Edition['FlacID'].'" title="View Torrent">'.$GroupName.'</a>';
if($GroupYear > 0) {
$DisplayName .= " [".$GroupYear."]";
}
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);
?>
<tr<?=$Torrents[$FlacID]['IsSnatched'] ? ' class="snatched_torrent"' : ''?>>
<tr class="torrent torrent_row<?=$Edition['IsSnatched'] ? ' snatched_torrent' : ''?>">
<td>
<span class="torrent_links_block">
<a href="torrents.php?action=download&amp;id=<?=$FlacID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" class="brackets">DL</a>
<a href="torrents.php?action=download&amp;id=<?=$Edition['FlacID']?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download" class="brackets">DL</a>
</span>
<?=$DisplayName?>
<?=$TorrentTags?>
<div class="torrent_info"><?=$ExtraInfo?></div>
<div class="tags"><?=$TorrentTags?></div>
</td>
<td><?=($MissingEncodings['V2 (VBR)'] == 0) ? '<strong class="important_text_alt">YES</strong>' : '<strong class="important_text">NO</strong>'?></td>
<td><?=($MissingEncodings['V0 (VBR)'] == 0) ? '<strong class="important_text_alt">YES</strong>' : '<strong class="important_text">NO</strong>'?></td>
<td><?=($MissingEncodings['320'] == 0) ? '<strong class="important_text_alt">YES</strong>' : '<strong class="important_text">NO</strong>'?></td>
<td><?=isset($Edition['Formats']['V2 (VBR)'])?'<strong class="important_text_alt">YES</strong>':'<strong class="important_text">NO</strong>'?></td>
<td><?=isset($Edition['Formats']['V0 (VBR)'])?'<strong class="important_text_alt">YES</strong>':'<strong class="important_text">NO</strong>'?></td>
<td><?=isset($Edition['Formats']['320'])?'<strong class="important_text_alt">YES</strong>':'<strong class="important_text">NO</strong>'?></td>
</tr>
<? } ?>
<?
}
}
?>
</table>
</div>
<?

View File

@ -396,8 +396,9 @@
if(count($TooLongPaths)!=0) {
$Names = '';
foreach($TooLongPaths as $Name) {$Names .= '<br>'.$Name;}
/* $Err = 'The torrent contained one or more files with too long a name ('.$Name.')'; */
foreach($TooLongPaths as $Name) {
$Names .= '<br>'.$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); }