Empty commit

This commit is contained in:
Git 2011-10-29 08:00:15 +00:00
parent 38f0e6765e
commit d052d1df50
19 changed files with 282 additions and 233 deletions

View File

@ -9,27 +9,28 @@
class DEBUG {
public $Errors = array();
public $Flags = array();
private $LoggedVars = array();
public function profile($Automatic='') {
global $ScriptStartTime;
$Reason = array();
if (!empty($Automatic)) {
$Reason[] = $Automatic;
}
$Micro = (microtime(true)-$ScriptStartTime)*1000;
if ($Micro > MAX_TIME && !defined('TIME_EXCEPTION')) {
if ($Micro > MAX_TIME && !defined('TIME_EXCEPTION')) {
$Reason[] = number_format($Micro, 3).' ms';
}
$Errors = count($this->get_errors());
if ($Errors > MAX_ERRORS && !defined('ERROR_EXCEPTION')) {
if ($Errors > MAX_ERRORS && !defined('ERROR_EXCEPTION')) {
$Reason[] = $Errors.' PHP Errors';
}
/*
$Queries = count($this->get_queries());
if ($Queries > MAX_QUERIES && !defined('QUERY_EXCEPTION')) {
if ($Queries > MAX_QUERIES && !defined('QUERY_EXCEPTION')) {
$Reason[] = $Queries.' Queries';
}
*/
@ -37,20 +38,20 @@ public function profile($Automatic='') {
if ($Ram > MAX_MEMORY && !defined('MEMORY_EXCEPTION')) {
$Reason[] = get_size($Ram).' Ram Used';
}
if (isset($_REQUEST['profile'])) {
global $LoggedUser;
$Reason[] = 'Requested by '.$LoggedUser['Username'];
}
if (isset($Reason[0])) {
$this->analysis(implode(', ', $Reason));
return true;
}
return false;
}
public function analysis($Message, $Report='', $Time=43200) {
global $Cache, $Document;
if (empty($Report)) {
@ -58,7 +59,7 @@ public function analysis($Message, $Report='', $Time=43200) {
}
$Identifier = make_secret(5);
$Cache->cache_value(
'analysis_'.$Identifier,
'analysis_'.$Identifier,
array(
'url' => $_SERVER['REQUEST_URI'],
'message' => $Report,
@ -66,25 +67,36 @@ public function analysis($Message, $Report='', $Time=43200) {
'queries' => $this->get_queries(),
'flags' => $this->get_flags(),
'includes' => $this->get_includes(),
'cache' => $this->get_cache_keys()
'cache' => $this->get_cache_keys(),
'vars' => $this->get_logged_vars()
),
$Time
);
send_irc('PRIVMSG '.LAB_CHAN.' :'.$Message.' '.$Document.' '.' http://'.NONSSL_SITE_URL.'/tools.php?action=analysis&case='.$Identifier.' http://'.NONSSL_SITE_URL.$_SERVER['REQUEST_URI']);
}
public function log_var($Var, $VarName = FALSE) {
$BackTrace = debug_backtrace();
$ID = uniqid();
if(!$VarName) {
$VarName = $ID;
}
$File = array('path' => substr($BackTrace[0]['file'], strlen(SERVER_ROOT)), 'line' => $BackTrace[0]['line']);
$this->LoggedVars[$ID] = array($VarName => array('bt' => $File, 'data' => $Var));
}
public function set_flag($Event) {
global $ScriptStartTime;
$this->Flags[] = array($Event,(microtime(true)-$ScriptStartTime)*1000,memory_get_usage(true));
}
//This isn't in the constructor because $this is not available, and the function cannot be made static
public function handle_errors() {
//error_reporting(E_ALL ^ E_STRICT | E_WARNING | E_DEPRECATED | E_ERROR | E_PARSE); //E_STRICT disabled
error_reporting(E_WARNING | E_ERROR | E_PARSE);
set_error_handler(array($this, 'php_error_handler'));
}
protected function format_args($Array) {
$LastKey = -1;
$Return = array();
@ -110,30 +122,30 @@ protected function format_args($Array) {
}
return implode(', ', $Return);
}
public function php_error_handler($Level, $Error, $File, $Line) {
//Who added this, it's still something to pay attention to...
if (stripos('Undefined index', $Error) !== false) {
//return true;
}
$Steps = 1; //Steps to go up in backtrace, default one
$Call = '';
$Args = '';
$Tracer = debug_backtrace();
//This is in case something in this function goes wrong and we get stuck with an infinite loop
if (isset($Tracer[$Steps]['function'], $Tracer[$Steps]['class']) && $Tracer[$Steps]['function'] == 'php_error_handler' && $Tracer[$Steps]['class'] == 'DEBUG') {
return true;
}
//If this error was thrown, we return the function which threw it
if (isset($Tracer[$Steps]['function']) && $Tracer[$Steps]['function'] == 'trigger_error') {
$Steps++;
$File = $Tracer[$Steps]['file'];
$Line = $Tracer[$Steps]['line'];
}
//At this time ONLY Array strict typing is fully supported.
//Allow us to abuse strict typing (IE: function test(Array))
if (preg_match('/^Argument (\d+) passed to \S+ must be an (array), (array|string|integer|double|object) given, called in (\S+) on line (\d+) and defined$/', $Error, $Matches)) {
@ -141,17 +153,17 @@ public function php_error_handler($Level, $Error, $File, $Line) {
$File = $Matches[4];
$Line = $Matches[5];
}
//Lets not be repetative
if (($Tracer[$Steps]['function'] == 'include' || $Tracer[$Steps]['function'] == 'require' ) && isset($Tracer[$Steps]['args'][0]) && $Tracer[$Steps]['args'][0] == $File) {
unset($Tracer[$Steps]['args']);
}
//Class
if (isset($Tracer[$Steps]['class'])) {
$Call .= $Tracer[$Steps]['class'].'::';
}
//Function & args
if (isset($Tracer[$Steps]['function'])) {
$Call .= $Tracer[$Steps]['function'];
@ -159,7 +171,7 @@ public function php_error_handler($Level, $Error, $File, $Line) {
$Args = $this->format_args($Tracer[$Steps]['args']);
}
}
//Shorten the path & we're done
$File = str_replace(SERVER_ROOT, '', $File);
$Error = str_replace(SERVER_ROOT, '', $Error);
@ -172,13 +184,13 @@ public function php_error_handler($Level, $Error, $File, $Line) {
*/
return true;
}
/* Data wrappers */
public function get_flags() {
return $this->Flags;
}
public function get_errors($Light=false) {
//Because the cache can't take some of these variables
if ($Light) {
@ -192,7 +204,7 @@ public function get_errors($Light=false) {
public function get_constants() {
return get_defined_constants(true);
}
public function get_classes() {
foreach (get_declared_classes() as $Class) {
$Classes[$Class]['Vars'] = get_class_vars($Class);
@ -200,18 +212,18 @@ public function get_classes() {
}
return $Classes;
}
public function get_extensions() {
foreach (get_loaded_extensions() as $Extension) {
$Extensions[$Extension]['Functions'] = get_extension_funcs($Extension);
}
return $Extensions;
}
public function get_includes() {
return get_included_files();
}
public function get_cache_time() {
global $Cache;
return $Cache->Time;
@ -221,27 +233,31 @@ public function get_cache_keys() {
global $Cache;
return array_keys($Cache->CacheHits);
}
public function get_sphinx_queries() {
global $SS;
return $SS->Queries;
}
public function get_sphinx_time() {
global $SS;
return $SS->Time;
}
public function get_queries() {
global $DB;
return $DB->Queries;
}
public function get_query_time() {
global $DB;
return $DB->Time;
}
public function get_logged_vars() {
return $this->LoggedVars;
}
/* Output Formatting */
public function include_table($Includes=false) {
@ -254,7 +270,7 @@ public function include_table($Includes=false) {
<td align="left"><strong><a href="#" onclick="$('#debug_include').toggle();return false;">(View)</a> <?=number_format(count($Includes))?> Includes:</strong></td>
</tr>
</table>
<table id="debug_include" class="hidden" width="100%">
<table id="debug_include" class="debug_table hidden" width="100%">
<?
foreach ($Includes as $File) {
?>
@ -265,7 +281,7 @@ public function include_table($Includes=false) {
}
?>
</table>
<?
<?
}
public function class_table($Classes=false) {
@ -278,7 +294,7 @@ public function class_table($Classes=false) {
<td align="left"><strong><a href="#" onclick="$('#debug_classes').toggle();return false;">(View)</a> Classes:</strong></td>
</tr>
</table>
<table id="debug_classes" class="hidden" width="100%">
<table id="debug_classes" class="debug_table hidden" width="100%">
<tr>
<td align="left">
<pre><? print_r($Classes) ?></pre>
@ -295,7 +311,7 @@ public function extension_table() {
<td align="left"><strong><a href="#" onclick="$('#debug_extensions').toggle();return false;">(View)</a> Extensions:</strong></td>
</tr>
</table>
<table id="debug_extensions" class="hidden" width="100%">
<table id="debug_extensions" class="debug_table hidden" width="100%">
<tr>
<td align="left">
<pre><? print_r($this->get_extensions()) ?></pre>
@ -318,7 +334,7 @@ public function flag_table($Flags=false) {
<td align="left"><strong><a href="#" onclick="$('#debug_flags').toggle();return false;">(View)</a> Flags:</strong></td>
</tr>
</table>
<table id="debug_flags" class="hidden" width="100%">
<table id="debug_flags" class="debug_table hidden" width="100%">
<?
foreach ($Flags as $Flag) {
list($Event,$MicroTime,$Memory) = $Flag;
@ -345,9 +361,9 @@ public function constant_table($Constants=false) {
<td align="left"><strong><a href="#" onclick="$('#debug_constants').toggle();return false;">(View)</a> Constants:</strong></td>
</tr>
</table>
<table id="debug_constants" class="hidden" width="100%">
<table id="debug_constants" class="debug_table hidden" width="100%">
<tr>
<td align="left">
<td align="left" class="debug_data debug_constants_data">
<pre><?=display_str(print_r($Constants, true))?></pre>
</td>
</tr>
@ -373,13 +389,13 @@ public function cache_table($CacheKeys=false) {
<td align="left"><strong><a href="#" onclick="$('#debug_cache').toggle();return false;">(View)</a><?=$Header?></strong></td>
</tr>
</table>
<table id="debug_cache" class="hidden" width="100%">
<table id="debug_cache" class="debug_table hidden" width="100%">
<? foreach($CacheKeys as $Key) { ?>
<tr>
<td align="left">
<a href="#" onclick="$('#debug_cache_<?=$Key?>').toggle(); return false;"><?=display_str($Key)?></a>
</td>
<td align="left">
<td align="left" class="debug_data debug_cache_data">
<pre id="debug_cache_<?=$Key?>" class="hidden"><?=display_str(print_r($Cache->get_value($Key, true), true))?></pre>
</td>
</tr>
@ -401,21 +417,21 @@ public function error_table($Errors=false) {
<td align="left"><strong><a href="#" onclick="$('#debug_error').toggle();return false;">(View)</a> <?=number_format(count($Errors))?> Errors:</strong></td>
</tr>
</table>
<table id="debug_error" class="hidden" width="100%">
<table id="debug_error" class="debug_table hidden" width="100%">
<?
foreach ($Errors as $Error) {
list($Error,$Location,$Call,$Args) = $Error;
?>
<tr valign="top">
<td align="left"><?=display_str($Call)?>(<?=display_str($Args)?>)</td>
<td align="left"><?=display_str($Error)?></td>
<td class="debug_data debug_error_data" align="left"><?=display_str($Error)?></td>
<td align="left"><?=display_str($Location)?></td>
</tr>
<?
}
?>
</table>
<?
<?
}
public function query_table($Queries=false) {
@ -434,20 +450,20 @@ public function query_table($Queries=false) {
<td align="left"><strong><a href="#" onclick="$('#debug_database').toggle();return false;">(View)</a><?=$Header?></strong></td>
</tr>
</table>
<table id="debug_database" class="hidden" width="100%">
<table id="debug_database" class="debug_table hidden" width="100%">
<?
foreach ($Queries as $Query) {
list($SQL,$Time) = $Query;
?>
<tr valign="top">
<td class="query"><div><?=str_replace("\t", '&nbsp;&nbsp;', nl2br(display_str($SQL)))?></div></td>
<td class="debug_data debug_query_data"><div><?=str_replace("\t", '&nbsp;&nbsp;', nl2br(display_str($SQL)))?></div></td>
<td class="rowa" style="width:130px;" align="left"><?=number_format($Time, 5)?> ms</td>
</tr>
<?
}
?>
</table>
<?
<?
}
public function sphinx_table($Queries=false) {
@ -466,19 +482,55 @@ public function sphinx_table($Queries=false) {
<td align="left"><strong><a href="#" onclick="$('#debug_sphinx').toggle();return false;">(View)</a><?=$Header?></strong></td>
</tr>
</table>
<table id="debug_sphinx" class="hidden" width="100%">
<table id="debug_sphinx" class="debug_table hidden" width="100%">
<?
foreach ($Queries as $Query) {
list($Params,$Time) = $Query;
?>
<tr valign="top">
<td><pre><?=str_replace("\t", ' ', display_str($Params))?></pre></td>
<td class="debug_data debug_sphinx_data"><pre><?=str_replace("\t", ' ', display_str($Params))?></pre></td>
<td class="rowa" style="width:130px;" align="left"><?=number_format($Time, 5)?> ms</td>
</tr>
<?
}
?>
</table>
<?
<?
}
public function vars_table($Vars=false) {
$Header = 'Logged Variables';
if (empty($Vars)) {
if(empty($this->LoggedVars)) {
return;
}
$Vars = $this->LoggedVars;
}
$Header = ' '.number_format(count($Vars)).' '.$Header.':';
?>
<table width="100%">
<tr>
<td align="left"><strong><a href="#" onclick="$('#debug_loggedvars').toggle();return false;">(View)</a><?=$Header?></strong></td>
</tr>
</table>
<table id="debug_loggedvars" class="debug_table hidden" width="100%">
<?
foreach($Vars as $ID => $Var) {
list($Key, $Data) = each($Var);
$Size = count($Data['data']);
?>
<tr>
<td align="left">
<a href="#" onclick="$('#debug_loggedvars_<?=$ID?>').toggle(); return false;"><?=display_str($Key)?></a> (<?=$Size . ($Size == 1 ? ' element' : ' elements')?>)
<div><?=$Data['bt']['path'].':'.$Data['bt']['line'];?></div>
</td>
<td class="debug_data debug_loggedvars_data" align="left">
<pre id="debug_loggedvars_<?=$ID?>" class="hidden"><?=display_str(print_r($Data['data'], true));?></pre>
</td>
</tr>
<? } ?>
</table>
<?
}
}

View File

@ -344,16 +344,29 @@ function user_heavy_info($UserID) {
}
if (!empty($HeavyInfo['RestrictedForums'])) {
$HeavyInfo['CustomForums'] = array_fill_keys(explode(',', $HeavyInfo['RestrictedForums']), 0);
$RestrictedForums = explode(',', $HeavyInfo['RestrictedForums']);
} else {
$HeavyInfo['CustomForums'] = null;
$RestrictedForums = array();
}
unset($HeavyInfo['RestrictedForums']);
if (!empty($HeavyInfo['PermittedForums'])) {
$HeavyInfo['CustomForums'] = array_fill_keys(explode(',', $HeavyInfo['PermittedForums']), 1);
$PermittedForums = explode(',', $HeavyInfo['PermittedForums']);
} else {
$PermittedForums = array();
}
unset($HeavyInfo['PermittedForums']);
if (!empty($PermittedForums) || !empty($RestrictedForums)) {
$HeavyInfo['CustomForums'] = array();
foreach ($RestrictedForums as $ForumID) {
$HeavyInfo['CustomForums'][$ForumID] = 0;
}
foreach ($PermittedForums as $ForumID) {
$HeavyInfo['CustomForums'][$ForumID] = 1;
}
} else {
$HeavyInfo['CustomForums'] = null;
}
if(!empty($HeavyInfo['SiteOptions'])) {
$HeavyInfo['SiteOptions'] = unserialize($HeavyInfo['SiteOptions']);
$HeavyInfo = array_merge($HeavyInfo, $HeavyInfo['SiteOptions']);
@ -365,6 +378,40 @@ function user_heavy_info($UserID) {
return $HeavyInfo;
}
function update_site_options($UserID, $NewOptions) {
if(!is_number($UserID)) {
error(0);
}
if(empty($NewOptions)) {
return false;
}
global $DB, $Cache, $LoggedUser;
// Get SiteOptions
$DB->query("SELECT SiteOptions FROM users_info WHERE UserID = $UserID");
list($SiteOptions) = $DB->next_record(MYSQLI_NUM,false);
$SiteOptions = unserialize($SiteOptions);
// Get HeavyInfo
$HeavyInfo = user_heavy_info($UserID);
// Insert new/replace old options
$SiteOptions = array_merge($SiteOptions, $NewOptions);
$HeavyInfo = array_merge($HeavyInfo, $NewOptions);
// Update DB
$DB->query("UPDATE users_info SET SiteOptions = '".db_string(serialize($SiteOptions))."' WHERE UserID = $UserID");
// Update cache
$Cache->cache_value('user_info_heavy_'.$UserID, $HeavyInfo, 0);
// Update $LoggedUser if the options are changed for the current
if($LoggedUser['ID'] == $UserID) {
$LoggedUser = array_merge($LoggedUser, $NewOptions);
$LoggedUser['ID'] = $UserID; // We don't want to allow userid switching
}
}
function get_permissions($PermissionID) {
global $DB, $Cache;
$Permission = $Cache->get_value('perm_'.$PermissionID);
@ -1519,6 +1566,9 @@ function get_artists($GroupIDs, $Escape = array()) {
$Results = array();
$DBs = array();
foreach($GroupIDs as $GroupID) {
if(!is_number($GroupID)) {
continue;
}
$Artists = $Cache->get_value('groups_artists_'.$GroupID, true);
if(is_array($Artists)) {
$Results[$GroupID] = $Artists;
@ -1808,6 +1858,7 @@ function torrent_info($Data) {
if(!empty($Data['Scene'])) { $Info[]='Scene'; }
if($Data['FreeTorrent'] == '1') { $Info[]='<strong>Freeleech!</strong>'; }
if($Data['FreeTorrent'] == '2') { $Info[]='<strong>Neutral Leech!</strong>'; }
if($Data['PersonalFL'] == 1) { $Info[]='<strong>Personal Freeleech!</strong>'; }
return implode(' / ', $Info);
}
@ -1907,14 +1958,17 @@ function disable_users($UserIDs, $AdminComment, $BanReason = 1) {
* @param $Action The action to send
* @param $Updates An associative array of key->value pairs to send to the tracker
*/
function update_tracker($Action, $Updates) {
function update_tracker($Action, $Updates, $ToIRC = false) {
global $Cache;
//Build request
$Get = '/update?action='.$Action;
foreach($Updates as $Key => $Value) {
$Get .= '&'.$Key.'='.$Value;
}
send_irc('PRIVMSG #tracker :'.$Get);
if($ToIRC != false) {
send_irc('PRIVMSG #tracker :'.$Get);
}
$Path = TRACKER_SECRET.$Get;
$Return = "";
@ -1956,7 +2010,10 @@ function update_tracker($Action, $Updates) {
if($Return != "success") {
send_irc("PRIVMSG #tracker :{$Attempts} {$Err} {$Get}");
send_irc("PRIVMSG ".ADMIN_CHAN." :Failed to update ocelot: ".$Err." : ".$Get);
if($Cache->get_value('ocelot_error_reported') === false) {
send_irc("PRIVMSG ".ADMIN_CHAN." :Failed to update ocelot: ".$Err." : ".$Get);
$Cache->cache_value('ocelot_error_reported', true);
}
}
return ($Return == "success");
}
@ -2008,7 +2065,7 @@ function in_array_partial($Needle, $Haystack) {
* @param int $FreeLeechType 0 = Unknown, 1 = Staff picks, 2 = Perma-FL (Toolbox, etc.), 3 = Vanity House
*/
function freeleech_torrents($TorrentIDs, $FreeNeutral = 1, $FreeLeechType = 0) {
global $DB;
global $DB, $Cache;
if(!is_array($TorrentIDs)) {
$TorrentIDs = array($TorrentIDs);
@ -2022,6 +2079,7 @@ function freeleech_torrents($TorrentIDs, $FreeNeutral = 1, $FreeLeechType = 0) {
foreach($Torrents as $Torrent) {
list($TorrentID, $GroupID, $InfoHash) = $Torrent;
update_tracker('update_torrent', array('info_hash' => rawurlencode($InfoHash), 'freetorrent' => $FreeNeutral));
$Cache->delete_value('torrent_download_'.$TorrentID);
}
foreach($GroupIDs as $GroupID) {

View File

@ -39,6 +39,7 @@
$Debug->sphinx_table();
$Debug->query_table();
$Debug->cache_table();
$Debug->vars_table();
?>
</div>
<!-- End Debugging -->

View File

@ -1441,13 +1441,12 @@ CREATE TABLE `xbt_files_users` (
`timespent` bigint(20) NOT NULL,
`useragent` varchar(51) NOT NULL,
`connectable` tinyint(4) NOT NULL DEFAULT '1',
`peer_id` binary(20) DEFAULT NULL,
`peer_id` binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
`fid` int(11) NOT NULL,
`ipa` int(12) unsigned NOT NULL,
`mtime` int(11) NOT NULL,
`ip` varchar(15) NOT NULL DEFAULT '',
UNIQUE KEY `uid_2` (`uid`,`fid`,`ipa`),
KEY `uid` (`uid`),
PRIMARY KEY (`uid`,`fid`,`peer_id`),
KEY `remaining_idx` (`remaining`),
KEY `fid_idx` (`fid`),
KEY `mtime_idx` (`mtime`)

View File

@ -286,6 +286,11 @@ function compare($X, $Y){
$FirstUnknown = !isset($FirstUnknown);
}
if (in_array($TorrentID, $TokenTorrents) && empty($Torrent['FreeTorrent'])) {
$Torrent['PersonalFL'] = 1;
}
$Torrent['Seeders'] = (int)$Torrent['Seeders'];
$Torrent['Leechers'] = (int)$Torrent['Leechers'];
$Torrent['Snatched'] = (int)$Torrent['Snatched'];
@ -339,12 +344,11 @@ function compare($X, $Y){
<tr class="releases_<?=$ReleaseType?> groupid_<?=$GroupID?> edition_<?=$EditionID?> group_torrent discog<?=$HideDiscog.$HideTorrents?>">
<td colspan="2">
<span>
[
[ <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download"><?=$Torrent['HasFile'] ? 'DL' : 'Missing'?></a>
<? if (($LoggedUser['FLTokens'] > 0) && ($Torrent['Size'] < 1073741824)
&& !in_array($TorrentID, $TokenTorrents) && empty($Torrent['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?>
<a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token">FL</a> |
<? } ?>
<a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download"><?=$Torrent['HasFile'] ? 'DL' : 'Missing'?></a>]
| <a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token">FL</a>
<? } ?> ]
</span>
&nbsp;&nbsp;&raquo;&nbsp; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=torrent_info($Torrent)?></a>
</td>

View File

@ -149,6 +149,10 @@ function compare($X, $Y){
$FirstUnknown = !isset($FirstUnknown);
}
if (in_array($TorrentID, $TokenTorrents) && empty($Torrent['FreeTorrent'])) {
$Torrent['PersonalFL'] = 1;
}
if($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear ||
$Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber || $FirstUnknown || $Torrent['Media'] != $LastMedia) {
@ -192,12 +196,12 @@ function compare($X, $Y){
?>
<tr class="group_torrent groupid_<?=$GroupID?> edition_<?=$EditionID?><? if(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping']==1) { echo ' hidden'; } ?>">
<td colspan="3">
<span>[
<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 (($LoggedUser['FLTokens'] > 0) && ($Torrent['Size'] < 1073741824)
&& !in_array($TorrentID, $TokenTorrents) && empty($Torrent['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?>
<a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token">FL</a> |
| <a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token">FL</a>
<? } ?>
<a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>]
| <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" title="Report">RP</a> ]
</span>
&nbsp;&nbsp;&raquo;&nbsp; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=torrent_info($Torrent)?></a>
</td>
@ -229,13 +233,12 @@ function compare($X, $Y){
</td>
<td>
<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 (($LoggedUser['FLTokens'] > 0) && ($Torrent['Size'] < 1073741824)
&& !in_array($TorrentID, $TokenTorrents) && empty($Torrent['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?>
<a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token">FL</a> |
| <a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token">FL</a>
<? } ?>
<a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
| <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" title="Report">RP</a>]
| <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" title="Report">RP</a> ]
</span>
<strong><?=$DisplayName?></strong>
<?=$TorrentTags?>

View File

@ -186,6 +186,10 @@ function compare($X, $Y){
$FirstUnknown = !isset($FirstUnknown);
}
if (in_array($TorrentID, $TokenTorrents) && empty($Torrent['FreeTorrent'])) {
$Torrent['PersonalFL'] = 1;
}
if($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear ||
$Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber || $FirstUnknown || $Torrent['Media'] != $LastMedia) {
$EditionID++;
@ -228,12 +232,12 @@ function compare($X, $Y){
<tr class="group_torrent groupid_<?=$GroupID?> edition_<?=$EditionID?><? if(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping']==1) { echo ' 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 (($LoggedUser['FLTokens'] > 0) && ($Torrent['Size'] < 1073741824)
&& !in_array($TorrentID, $TokenTorrents) && empty($Torrent['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?>
<a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token">FL</a> |
<? } ?>
<a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>]
| <a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token">FL</a>
<? } ?>
| <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" title="Report">RP</a> ]
</span>
&nbsp;&nbsp;&raquo;&nbsp; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=torrent_info($Torrent)?></a>
</td>
@ -265,12 +269,11 @@ function compare($X, $Y){
</td>
<td>
<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 (($LoggedUser['FLTokens'] > 0) && ($Torrent['Size'] < 1073741824)
&& !in_array($TorrentID, $TokenTorrents) && empty($Torrent['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?>
<a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token">FL</a> |
<? } ?>
<a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
| <a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token">FL</a>
<? } ?>
| <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" title="Report">RP</a>]
</span>
<strong><?=$DisplayName?></strong>

View File

@ -81,7 +81,7 @@ function next_hour() {
//------------- Expire old FL Tokens and clear cache where needed ------//
$sqltime = sqltime();
$DB->query("SELECT DISTINCT UserID from users_freeleeches WHERE Expired = FALSE AND Time < '$sqltime' - INTERVAL 2 DAY");
$DB->query("SELECT DISTINCT UserID from users_freeleeches WHERE Expired = FALSE AND Time < '$sqltime' - INTERVAL 4 DAY");
while (list($UserID) = $DB->next_record()) {
$Cache->delete_value('users_tokens_'.$UserID[0]);
}
@ -89,11 +89,11 @@ function next_hour() {
$DB->query("SELECT uf.UserID, t.info_hash
FROM users_freeleeches AS uf
JOIN torrents AS t ON uf.TorrentID = t.ID
WHERE uf.Expired = FALSE AND uf.Time < '$sqltime' - INTERVAL 2 DAY");
WHERE uf.Expired = FALSE AND uf.Time < '$sqltime' - INTERVAL 4 DAY");
while (list($UserID,$InfoHash) = $DB->next_record()) {
update_tracker('remove_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $UserID));
}
$DB->query("UPDATE users_freeleeches SET Expired = True WHERE Time < '$sqltime' - INTERVAL 2 DAY");
$DB->query("UPDATE users_freeleeches SET Expired = True WHERE Time < '$sqltime' - INTERVAL 4 DAY");

View File

@ -43,23 +43,9 @@
}
$where = "";
} elseif (isset($_REQUEST['expire'])) {
$Tokens = $_REQUEST['tokens'];
foreach ($Tokens as $Token) {
list($UserID, $TorrentID) = explode(',', $Token);
if (empty($UserID) || empty($TorrentID) || !is_number($UserID)) { continue; }
$DB->query("SELECT info_hash FROM torrents where ID = $TorrentID");
if (list($InfoHash) = $DB->next_record()) {
$DB->query("UPDATE users_freeleeches SET Expired=TRUE WHERE UserID=$UserID AND TorrentID=$TorrentID");
$Cache->delete_value('users_tokens_'.$UserID);
update_tracker('remove_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $UserID));
}
}
}
if (empty($_GET['showabusers'])) {
show_header('Add tokens sitewide');
?>
@ -89,100 +75,6 @@
</form>
</div>
<?
} else {
show_header('FL Token Abusers');
$Expired = $_GET['expired'] ? 1 : 0;
$Ratio = $_REQUEST['ratio'] ? db_string($_REQUEST['ratio']) : '1.25';
if (!preg_match('/^\d+\.?\d*$/',$Ratio)) { $Ratio = '1.25'; }
list($Page,$Limit) = page_limit(50);
$SQL = "SELECT SQL_CALC_FOUND_ROWS
m.ID, m.Username, i.Donor, i.Warned, m.Enabled,
t.ID, t.GroupID, t.Size, g.Name,
fl.Downloaded, fl.Expired
FROM users_freeleeches AS fl
JOIN users_main AS m ON m.ID = fl.UserID
JOIN torrents AS t ON t.ID = fl.TorrentID
JOIN users_info AS i ON m.ID = i.UserID
JOIN torrents_group AS g ON g.ID = t.GroupID
WHERE fl.Downloaded/t.Size >= $Ratio ";
if (!$Expired) {
$SQL .= "AND fl.Expired = 0 ";
}
$SQL .= "ORDER BY fl.Downloaded/t.Size
LIMIT $Limit";
$DB->query($SQL);
$Pages = get_pages($Page, $DB->record_count(), 50);
$Abuses = $DB->to_array();
?>
<h2>Freeleech token abusers</h2>
<div class="linkbox">
<a href="tools.php?action=tokens&showabusers=1&ratio=<?=$Ratio?>&expired=<?=($Expired ? '0' : '1')?>">[<?=($Expired ? 'Hide' : 'Show')?> Expired Tokens]</a>&nbsp;&nbsp;&nbsp;
<a href="tools.php?action=tokens&showabusers=0">[Add Tokens]</a>
</div>
<div class="linkbox pager"><?=$Pages?></div>
<form action="tools.php?action=tokens&showabusers=1&expired=<?=$Expired?>&page=<?=$Page?>" method="post">
<input type="hidden" name="ratio" value="<?=$Ratio?>" />
<table>
<tr class="colhead_dark">
<? if ($Expired != '1') { ?>
<td><!--Checkbox--></td>
<? } ?>
<td>User</td>
<td>Torrent</td>
<td>Size</td>
<td>Transferred</td>
<td>Ratio</td>
<? if ($Expired) { ?>
<td>Expired</td>
<? } ?>
</tr>
<?
$i = true;
foreach ($Abuses as $TokenInfo) {
$i = !$i;
list($UserID, $Username, $Donor, $Warned, $Enabled, $TorrentID, $GroupID, $Size, $Name, $Downloaded, $IsExpired) = $TokenInfo;
$ArtistName = display_artists(get_artist($GroupID));
if($ArtistName) {
$Name = $ArtistName."<a href=\"torrents.php?torrentid=$TorrentID\">$Name</a>";
}
if($Format && $Encoding) {
$Name.=' ['.$Format.' / '.$Encoding.']';
}
?>
<tr class="<?=($i?'rowa':'rowb')?>">
<? if ($Expired != '1') { ?>
<td><input type="checkbox" name="tokens[]" value="<?=$UserID?>,<?=$TorrentID?>" /></td>
<? } ?>
<td><?=format_username($UserID, $Username, $Donor, $Warned, $Enabled)?></td>
<td><?=$Name?></td>
<td><?=get_size($Size)?></td>
<td><?=get_size($Downloaded)?></td>
<td><?=number_format($Downloaded/$Size, 2)?></td>
<? if ($Expired) { ?>
<td><?=($IsExpired ? 'Yes' : 'No')?></td>
<? } ?>
</tr>
<? } ?>
<? if ($Expired != '1') { ?>
<tr>
<td colspan="<?=($Expired?'7':'6')?>"><input type="submit" name="expire" value="Expire Selected"></td>
</tr>
<? } ?>
</table>
</form>
<div class="linkbox pager"><?=$Pages?></div>
<div class="box pad">
<form action="tools.php" method="get">
<input type="hidden" name="action" value="tokens" />
<input type="hidden" name="showabusers" value="1" />
<input type="hidden" name="expired" value="<?=$Expired?>" />
<label for="ratiobox">Abuse ratio: </label><input type="text" size="5" name="ratio" id="ratiobox" value="<?=$Ratio?>" />
</form>
</div>
<? }
show_footer()
?>

View File

@ -16,4 +16,6 @@
$Debug->class_table();
$Debug->extension_table();
$Debug->constant_table();
show_footer(); ?>
$Debug->vars_table($Analysis['vars']);
show_footer();
?>

View File

@ -841,6 +841,10 @@ function header_link($SortKey,$DefaultWay="desc") {
if ($Data['Remastered'] && !$Data['RemasterYear']) {
$FirstUnknown = !isset($FirstUnknown);
}
if (in_array($TorrentID, $TokenTorrents) && empty($Torrent['FreeTorrent'])) {
$Data['PersonalFL'] = 1;
}
if($CategoryID == 1 && ($Data['RemasterTitle'] != $LastRemasterTitle || $Data['RemasterYear'] != $LastRemasterYear ||
$Data['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Data['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber) || $FirstUnknown || $Data['Media'] != $LastMedia) {
@ -886,13 +890,12 @@ function header_link($SortKey,$DefaultWay="desc") {
<tr class="group_torrent groupid_<?=$GroupID?> edition_<?=$EditionID?><? if (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping']==1) { echo ' hidden'; }?>">
<td colspan="3">
<span>
[
<? if (($LoggedUser['FLTokens'] > 0) && ($Data['Size'] < 1073741824)
[ <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download"><?=$Data['HasFile'] ? 'DL' : 'Missing'?></a>
<? if (($LoggedUser['FLTokens'] > 0) && $Data['HasFile'] && ($Data['Size'] < 1073741824)
&& !in_array($TorrentID, $TokenTorrents) && empty($Data['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?>
<a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token">FL</a> |
<? } ?>
<a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download"><?=$Data['HasFile'] ? 'DL' : 'Missing'?></a>
| <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" title="Report">RP</a>]
| <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token">FL</a>
<? } ?>
| <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" title="Report">RP</a> ]
</span>
&raquo; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=torrent_info($Data)?></a>
</td>
@ -926,12 +929,11 @@ function header_link($SortKey,$DefaultWay="desc") {
</td>
<td>
<span>
[
<? if (($LoggedUser['FLTokens'] > 0) && ($Data['Size'] < 1073741824)
[ <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
<? if (($LoggedUser['FLTokens'] > 0) && $Data['HasFile'] && ($Data['Size'] < 1073741824)
&& !in_array($TorrentID, $TokenTorrents) && empty($Data['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?>
<a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token">FL</a> |
<? } ?>
<a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
| <a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token">FL</a>
<? } ?>
| <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" title="Report">RP</a>]
</span>
<?=$DisplayName?>

View File

@ -426,12 +426,11 @@ function filelist($Str) {
<tr class="releases_<?=$ReleaseType?> groupid_<?=$GroupID?> edition_<?=$EditionID?> group_torrent" style="font-weight: normal;" id="torrent<?=$TorrentID?>">
<td>
<span>[
<span>[ <a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download"><?=$HasFile ? 'DL' : 'Missing'?></a>
<? if (($LoggedUser['FLTokens'] > 0) && $HasFile && ($Size < 1073741824)
&& !in_array($TorrentID, $TokenTorrents) && ($FreeTorrent == '0') && ($LoggedUser['CanLeech'] == '1')) { ?>
<a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token">FL</a> |
<? } ?>
<a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download"><?=$HasFile ? 'DL' : 'Missing'?></a>
| <a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token">FL</a>
<? } ?>
| <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" title="Report">RP</a>
<? if($CanEdit) { ?>
| <a href="torrents.php?action=edit&amp;id=<?=$TorrentID ?>" title="Edit">ED</a>

View File

@ -28,7 +28,7 @@
if (!is_number($TorrentID)){ error(0); }
$Info = $Cache->get_value('torrent_download_'.$TorrentID);
if(!is_array($Info) || !array_key_exists('PlainArtists', $Info) || !array_key_exists('info_hash', $Info)) {
if(!is_array($Info) || !array_key_exists('PlainArtists', $Info) || empty($Info[10])) {
$DB->query("SELECT
t.Media,
t.Format,
@ -97,16 +97,26 @@
error("An error has occured. Please try again.");
}
$DB->query("INSERT INTO users_freeleeches (UserID, TorrentID, Time) VALUES ($UserID, $TorrentID, NOW())
ON DUPLICATE KEY UPDATE Time=VALUES(Time), Expired=FALSE");
$DB->query("UPDATE users_main SET FLTokens = FLTokens - 1 WHERE ID=$UserID");
// We need to fetch and check this again here because of people
// double-clicking the FL link while waiting for a tracker response.
$TokenTorrents = $Cache->get_value('users_tokens_'.$UserID);
if (empty($TokenTorrents)) {
$DB->query("SELECT TorrentID FROM users_freeleeches WHERE UserID=$UserID AND Expired=FALSE");
$TokenTorrents = $DB->collect('TorrentID');
}
$Cache->begin_transaction('user_info_heavy_'.$UserID);
$Cache->update_row(false, array('FLTokens'=>($FLTokens - 1)));
$Cache->commit_transaction(0);
$TokenTorrents[] = $TorrentID;
$Cache->cache_value('users_tokens_'.$UserID, $TokenTorrents);
if (!in_array($TorrentID, $TokenTorrents)) {
$DB->query("INSERT INTO users_freeleeches (UserID, TorrentID, Time) VALUES ($UserID, $TorrentID, NOW())
ON DUPLICATE KEY UPDATE Time=VALUES(Time), Expired=FALSE");
$DB->query("UPDATE users_main SET FLTokens = FLTokens - 1 WHERE ID=$UserID");
$Cache->begin_transaction('user_info_heavy_'.$UserID);
$Cache->update_row(false, array('FLTokens'=>($FLTokens - 1)));
$Cache->commit_transaction(0);
$TokenTorrents[] = $TorrentID;
$Cache->cache_value('users_tokens_'.$UserID, $TokenTorrents);
}
}
}

View File

@ -4,6 +4,13 @@
define('NOTIFICATIONS_PER_PAGE', 50);
list($Page,$Limit) = page_limit(NOTIFICATIONS_PER_PAGE);
$TokenTorrents = $Cache->get_value('users_tokens_'.$UserID);
if (empty($TokenTorrents)) {
$DB->query("SELECT TorrentID FROM users_freeleeches WHERE UserID=$UserID AND Expired=FALSE");
$TokenTorrents = $DB->collect('TorrentID');
$Cache->cache_value('users_tokens_'.$UserID, $TokenTorrents);
}
$Results = $DB->query("SELECT SQL_CALC_FOUND_ROWS
t.ID,
g.ID,
@ -27,6 +34,7 @@
t.HasLog,
t.HasCue,
t.LogScore,
t.FreeTorrent,
tln.TorrentID AS LogInDB,
unt.UnRead,
unt.FilterID,
@ -98,7 +106,7 @@
foreach($FilterResults as $Result) {
list($TorrentID, $GroupID, $GroupName, $GroupCategoryID, $TorrentTags, $Size, $FileCount, $Format, $Encoding,
$Media, $Scene, $RemasterYear, $GroupYear, $RemasterYear, $RemasterTitle, $Snatched, $Seeders,
$Leechers, $NotificationTime, $HasLog, $HasCue, $LogScore, $LogInDB, $UnRead) = $Result;
$Leechers, $NotificationTime, $HasLog, $HasCue, $LogScore, $FreeTorrent, $LogInDB, $UnRead) = $Result;
// generate torrent's title
$DisplayName='';
@ -108,6 +116,10 @@
$DisplayName = display_artists($Artists, true, true);
}
if (in_array($TorrentID, $TokenTorrents) && empty($Torrent['FreeTorrent'])) {
$Data['PersonalFL'] = 1;
}
$DisplayName.= "<a href='torrents.php?id=$GroupID&amp;torrentid=$TorrentID#torrentID$TorrentID' title='View Torrent'>".$GroupName."</a>";
if($GroupCategoryID==1 && $GroupYear>0) {
@ -150,8 +162,12 @@
<td class="center cats_cols"><div title="<?=ucfirst(str_replace('_',' ',$MainTag))?>" class="cats_<?=strtolower(str_replace(array('-',' '),array('',''),$Categories[$GroupCategoryID-1])).' tags_'.str_replace('.','_',$MainTag)?>"></div></td>
<td>
<span>
[<a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a> |
<a href="#" onclick="Clear(<?=$TorrentID?>);return false;" title="Remove from notifications list">CL</a>]
[<a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
<? if (($LoggedUser['FLTokens'] > 0) && ($Size < 1073741824)
&& !in_array($TorrentID, $TokenTorrents) && empty($FreeTorrent) && ($LoggedUser['CanLeech'] == '1')) { ?>
| <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token">FL</a>
<? } ?>
| <a href="#" onclick="Clear(<?=$TorrentID?>);return false;" title="Remove from notifications list">CL</a>]
</span>
<strong><?=$DisplayName?></strong> <?=$ExtraInfo ?>
<? if($UnRead) { echo '<strong>New!</strong>'; } ?>

View File

@ -83,7 +83,7 @@
?>
<div class="<?=(check_perms('torrents_hide_dnu')?'box pad':'')?>" style="margin:0px auto;width:700px">
<h3 id="dnu_header">Do not upload</h3>
<p>The following releases are currently forbidden from being uploaded from the site. Do not upload them unless your torrent meets a condition specified in the comment.
<p>The following releases are currently forbidden from being uploaded to the site. Do not upload them unless your torrent meets a condition specified in the comment.
<? if (check_perms('torrents_hide_dnu')) { ?>
<span id="showdnu"><a href="#" <a href="#" onclick="$('#dnulist').toggle(); this.innerHTML=(this.innerHTML=='(Hide)'?'(Show)':'(Hide)'); return false;">(Show)</a></span>
<? } ?>

View File

@ -224,7 +224,7 @@ function checked($Checked) {
<td class="label"><strong>Unseeded torrent alerts</strong></td>
<td>
<input type="checkbox" name="unseededalerts" id="unseededalerts" <?=checked($UnseededAlerts)?> />
<label for="unseededalerts">Recieve a PM alert before your uploads are deleted for being unseeded</label>
<label for="unseededalerts">Receive a PM alert before your uploads are deleted for being unseeded</label>
</td>
</tr>
<tr class="colhead_dark">

View File

@ -221,8 +221,8 @@ function check_paranoia_here($Setting) {
<? if (check_paranoia_here('requiredratio') && isset($RequiredRatio)) { ?>
<li>Required ratio: <?=number_format((double)$RequiredRatio, 2)?></li>
<? } ?>
<? if (($FLTokens > 0) && ($OwnProfile || check_perms('users_mod'))) { ?>
<li>Tokens: <?=$FLTokens?></li>
<? if ($OwnProfile || check_perms('users_mod')) { ?>
<li><a href="userhistory.php?action=token_history&userid=<?=$UserID?>">Tokens</a>: <?=number_format($FLTokens)?></li>
<? } ?>
</ul>
</div>

View File

@ -56,8 +56,12 @@
WHERE f.UserID = $UserID
ORDER BY f.Time DESC
LIMIT $Limit");
$Tokens = $DB->to_array();
$Pages=get_pages($Page, $DB->record_count(), 25, 9);
$Tokens = $DB->to_array();
$DB->query("SELECT FOUND_ROWS()");
list($NumResults) = $DB->next_record();
$Pages=get_pages($Page, $NumResults, 25);
?>
<h2>Freeleech token history for <?=format_username($UserID, $UserInfo['Username'], $UserInfo['Donor'], $UserInfo['Warned'], $UserInfo['Enabled'])?></h2>

View File

@ -1123,13 +1123,17 @@ div.pad ul,div.body ul,table.torrent_table blockquote>ul,div.pad ol,div.body ol
white-space: pre-wrap;
}
#debug_database td.query {
table.debug_table td.debug_data {
padding: 0;
}
#debug_database td.query>div {
table.debug_table td.debug_data>div, table.debug_table td.debug_data>pre {
overflow: auto;
padding: 8px;
max-height: 400px;
}
table.debug_table td.debug_query_data>div {
width: 796px;
}