Empty commit

This commit is contained in:
Git 2012-06-09 08:00:19 +00:00
parent f28034f335
commit 68c4c3d357
7 changed files with 129 additions and 112 deletions

View File

@ -2122,7 +2122,7 @@ function get_tags($TagNames) {
return($TagIDs); return($TagIDs);
} }
function torrent_info($Data) { function torrent_info($Data, $ShowMedia = false) {
$Info = array(); $Info = array();
if(!empty($Data['Format'])) { $Info[]=$Data['Format']; } if(!empty($Data['Format'])) { $Info[]=$Data['Format']; }
if(!empty($Data['Encoding'])) { $Info[]=$Data['Encoding']; } if(!empty($Data['Encoding'])) { $Info[]=$Data['Encoding']; }
@ -2135,6 +2135,7 @@ function torrent_info($Data) {
} }
if(!empty($Data['HasCue'])) { $Info[]='Cue'; } if(!empty($Data['HasCue'])) { $Info[]='Cue'; }
if(!empty($Data['Scene'])) { $Info[]='Scene'; } if(!empty($Data['Scene'])) { $Info[]='Scene'; }
if(!empty($Data['Media']) && $ShowMedia) { $Info[]=$Data['Media']; }
if($Data['FreeTorrent'] == '1') { $Info[]='<strong>Freeleech!</strong>'; } if($Data['FreeTorrent'] == '1') { $Info[]='<strong>Freeleech!</strong>'; }
if($Data['FreeTorrent'] == '2') { $Info[]='<strong>Neutral Leech!</strong>'; } if($Data['FreeTorrent'] == '2') { $Info[]='<strong>Neutral Leech!</strong>'; }
if($Data['PersonalFL'] == 1) { $Info[]='<strong>Personal Freeleech!</strong>'; } if($Data['PersonalFL'] == 1) { $Info[]='<strong>Personal Freeleech!</strong>'; }

View File

@ -230,6 +230,7 @@ function compare($X, $Y){
'tagList' => $Torrent['TagList'], 'tagList' => $Torrent['TagList'],
'releaseType' => $Torrent['ReleaseType'], 'releaseType' => $Torrent['ReleaseType'],
'vanityHouse' => $Torrent['VanityHouse'] == 1, 'vanityHouse' => $Torrent['VanityHouse'] == 1,
'image' => $CollageDataList[$Torrent['ID']]['WikiImage'],
'torrents' => $JsonTorrents 'torrents' => $JsonTorrents
); );
} }

View File

@ -136,7 +136,8 @@
'lastAuthorId' => $LastAuthorID == null ? 0 : (int) $LastAuthorID, 'lastAuthorId' => $LastAuthorID == null ? 0 : (int) $LastAuthorID,
'lastAuthorName' => $LastAuthorName == null ? "" : $LastAuthorName, 'lastAuthorName' => $LastAuthorName == null ? "" : $LastAuthorName,
'lastReadPage' => $LastRead[$TopicID]['Page'] == null ? 0 : (int) $LastRead[$TopicID]['Page'], 'lastReadPage' => $LastRead[$TopicID]['Page'] == null ? 0 : (int) $LastRead[$TopicID]['Page'],
'lastReadPostId' => $LastRead[$TopicID]['PostID'] == null ? 0 : (int) $LastRead[$TopicID]['PostID'] 'lastReadPostId' => $LastRead[$TopicID]['PostID'] == null ? 0 : (int) $LastRead[$TopicID]['PostID'],
'read' => $Read == "read"
); );
} }

View File

@ -72,7 +72,7 @@
require(SERVER_ROOT.'/sections/ajax/info.php'); require(SERVER_ROOT.'/sections/ajax/info.php');
break; break;
case 'bookmarks': case 'bookmarks':
require(SERVER_ROOT.'/sections/ajax/bookmarks.php'); require(SERVER_ROOT.'/sections/ajax/bookmarks/index.php');
break; break;
case 'announcements': case 'announcements':
require(SERVER_ROOT.'/sections/ajax/announcements.php'); require(SERVER_ROOT.'/sections/ajax/announcements.php');

View File

@ -14,20 +14,56 @@
$Ratio = number_format(max($LoggedUser['BytesUploaded']/$LoggedUser['BytesDownloaded']-0.005,0), 2); //Subtract .005 to floor to 2 decimals $Ratio = number_format(max($LoggedUser['BytesUploaded']/$LoggedUser['BytesDownloaded']-0.005,0), 2); //Subtract .005 to floor to 2 decimals
} }
$MyNews = $LoggedUser['LastReadNews'];
$CurrentNews = $Cache->get_value('news_latest_id');
if ($CurrentNews === false) {
$DB->query("SELECT ID FROM news ORDER BY Time DESC LIMIT 1");
if ($DB->record_count() == 1) {
list($CurrentNews) = $DB->next_record();
} else {
$CurrentNews = -1;
}
$Cache->cache_value('news_latest_id', $CurrentNews, 0);
}
$NewMessages = $Cache->get_value('inbox_new_'.$LoggedUser['ID']);
if ($NewMessages === false) {
$DB->query("SELECT COUNT(UnRead) FROM pm_conversations_users WHERE UserID='".$LoggedUser['ID']."' AND UnRead = '1' AND InInbox = '1'");
list($NewMessages) = $DB->next_record();
$Cache->cache_value('inbox_new_'.$LoggedUser['ID'], $NewMessages, 0);
}
if (check_perms('site_torrents_notify')) {
$NewNotifications = $Cache->get_value('notifications_new_'.$LoggedUser['ID']);
if ($NewNotifications === false) {
$DB->query("SELECT COUNT(UserID) FROM users_notify_torrents WHERE UserID='$LoggedUser[ID]' AND UnRead='1'");
list($NewNotifications) = $DB->next_record();
/* if($NewNotifications && !check_perms('site_torrents_notify')) {
$DB->query("DELETE FROM users_notify_torrents WHERE UserID='$LoggedUser[ID]'");
$DB->query("DELETE FROM users_notify_filters WHERE UserID='$LoggedUser[ID]'");
} */
$Cache->cache_value('notifications_new_'.$LoggedUser['ID'], $NewNotifications, 0);
}
}
print json_encode( print json_encode(
array( array(
'status' => 'success', 'status' => 'success',
'response' => array( 'response' => array(
'username' => $LoggedUser['Username'], 'username' => $LoggedUser['Username'],
'id' => $LoggedUser['ID'], 'id' => (int) $LoggedUser['ID'],
'authkey'=> $LoggedUser['AuthKey'], 'authkey'=> $LoggedUser['AuthKey'],
'passkey'=> $LoggedUser['torrent_pass'], 'passkey'=> $LoggedUser['torrent_pass'],
'notifications' => array(
'messages'=> (int) $NewMessages,
'notifications' => (int) $NewNotifications
),
'userstats' => array( 'userstats' => array(
'uploaded' => (int) $LoggedUser['BytesUploaded'], 'uploaded' => (int) $LoggedUser['BytesUploaded'],
'downloaded' => (int) $LoggedUser['BytesDownloaded'], 'downloaded' => (int) $LoggedUser['BytesDownloaded'],
'ratio' => (float) $Ratio, 'ratio' => (float) $Ratio,
'requiredratio' => (float) $LoggedUser['RequiredRatio'], 'requiredratio' => (float) $LoggedUser['RequiredRatio'],
//'class' => $Class
'class' => $ClassLevels[$LoggedUser['Class']]['Name'] 'class' => $ClassLevels[$LoggedUser['Class']]['Name']
), ),
) )

View File

@ -52,7 +52,7 @@
} }
} else if($Recipient == 'Reporter') { } else if($Recipient == 'Reporter') {
$ToID = $_POST['reporterid']; $ToID = $_POST['reporterid'];
$Message = "You reported the above torrent for the reason ".$ReportType['title'].":\n\"".$_POST['report_reason']."\"\n\n".$Message; $Message = "You reported [url=http://".NONSSL_SITE_URL."/torrents.php?torrentid=".$TorrentID."]the above torrent[/url] for the reason ".$ReportType['title'].":\n\"".$_POST['report_reason']."\"\n\n".$Message;
} else { } else {
$Err = "Something went horribly wrong"; $Err = "Something went horribly wrong";
} }

View File

@ -4,70 +4,53 @@
define('NOTIFICATIONS_PER_PAGE', 50); define('NOTIFICATIONS_PER_PAGE', 50);
list($Page,$Limit) = page_limit(NOTIFICATIONS_PER_PAGE); list($Page,$Limit) = page_limit(NOTIFICATIONS_PER_PAGE);
$TokenTorrents = $Cache->get_value('users_tokens_'.$UserID); $TokenTorrents = $Cache->get_value('users_tokens_'.$LoggedUser['ID']);
if (empty($TokenTorrents)) { if (empty($TokenTorrents)) {
$DB->query("SELECT TorrentID FROM users_freeleeches WHERE UserID=$UserID AND Expired=FALSE"); $DB->query("SELECT TorrentID FROM users_freeleeches WHERE UserID=$LoggedUser[ID] AND Expired=FALSE");
$TokenTorrents = $DB->collect('TorrentID'); $TokenTorrents = $DB->collect('TorrentID');
$Cache->cache_value('users_tokens_'.$UserID, $TokenTorrents); $Cache->cache_value('users_tokens_'.$LoggedUser['ID'], $TokenTorrents);
} }
$Results = $DB->query("SELECT SQL_CALC_FOUND_ROWS
t.ID, $UserID = $LoggedUser['ID'];
g.ID,
g.Name, $Results = $DB->query("SELECT SQL_CALC_FOUND_ROWS unt.TorrentID, unt.UnRead, unt.FilterID, unf.Label, t.GroupID
g.CategoryID,
g.TagList,
t.Size,
t.FileCount,
t.Format,
t.Encoding,
t.Media,
t.Scene,
t.RemasterYear,
g.Year,
t.RemasterYear,
t.RemasterTitle,
t.Snatched,
t.Seeders,
t.Leechers,
t.Time,
t.HasLog,
t.HasCue,
t.LogScore,
t.FreeTorrent,
tln.TorrentID AS LogInDB,
unt.UnRead,
unt.FilterID,
unf.Label,
g.ReleaseType
FROM users_notify_torrents AS unt FROM users_notify_torrents AS unt
JOIN torrents AS t ON t.ID=unt.TorrentID JOIN torrents AS t ON t.ID = unt.TorrentID
JOIN torrents_group AS g ON g.ID = t.GroupID LEFT JOIN users_notify_filters AS unf ON unf.ID = unt.FilterID
LEFT JOIN users_notify_filters AS unf ON unf.ID=unt.FilterID WHERE unt.UserID=$UserID".
LEFT JOIN torrents_logs_new AS tln ON tln.TorrentID=t.ID ((!empty($_GET['filterid']) && is_number($_GET['filterid']))
WHERE unt.UserID='$LoggedUser[ID]' ? " AND unf.ID='$_GET[filterid]'"
GROUP BY t.ID : "")."
ORDER BY t.ID DESC LIMIT $Limit"); ORDER BY TorrentID DESC LIMIT $Limit");
$GroupIDs = array_unique($DB->collect('GroupID'));
$DB->query('SELECT FOUND_ROWS()'); $DB->query('SELECT FOUND_ROWS()');
list($TorrentCount) = $DB->next_record(); list($TorrentCount) = $DB->next_record();
$Debug->log_var($TorrentCount, 'Torrent count');
$Pages = get_pages($Page, $TorrentCount, NOTIFICATIONS_PER_PAGE, 9);
//Clear before header but after query so as to not have the alert bar on this page load if(count($GroupIDs)) {
$DB->query("UPDATE users_notify_torrents SET UnRead='0' WHERE UserID=".$LoggedUser['ID']); $TorrentGroups = get_groups($GroupIDs);
$Cache->delete_value('notifications_new_'.$LoggedUser['ID']); $TorrentGroups = $TorrentGroups['matches'];
show_header('My notifications','notifications');
// Need some extra info that get_groups() doesn't return
$DB->query("SELECT ID, CategoryID FROM torrents_group WHERE ID IN (".implode(',', $GroupIDs).")");
$GroupCategoryIDs = $DB->to_array('ID', MYSQLI_ASSOC, false);
//Clear before header but after query so as to not have the alert bar on this page load
$DB->query("UPDATE users_notify_torrents SET UnRead='0' WHERE UserID=".$LoggedUser['ID']);
$Cache->delete_value('notifications_new_'.$LoggedUser['ID']);
}
show_header('My notifications', 'notifications');
$DB->set_query_id($Results); $DB->set_query_id($Results);
$Pages=get_pages($Page,$TorrentCount,NOTIFICATIONS_PER_PAGE,9);
?> ?>
<h2>Latest notifications <a href="torrents.php?action=notify_clear&amp;auth=<?=$LoggedUser['AuthKey']?>">(clear all)</a> <a href="javascript:SuperGroupClear()">(clear selected)</a> <a href="user.php?action=notify">(edit filters)</a></h2> <h2>Latest notifications <a href="torrents.php?action=notify_clear&amp;auth=<?=$LoggedUser['AuthKey']?>">(clear all)</a> <a href="javascript:SuperGroupClear()">(clear selected)</a> <a href="user.php?action=notify">(edit filters)</a></h2>
<div class="linkbox"> <div class="linkbox">
<?=$Pages?> <?=$Pages?>
</div> </div>
<? if($DB->record_count()==0) { ?> <? if(!$DB->record_count()) { ?>
<table class="border"> <table class="border">
<tr class="rowb"> <tr class="rowb">
<td colspan="8" class="center"> <td colspan="8" class="center">
@ -77,21 +60,28 @@
</table> </table>
<? } else { <? } else {
$FilterGroups = array(); $FilterGroups = array();
while($Result = $DB->next_record()) { while($Result = $DB->next_record(MYSQLI_ASSOC)) {
if(!$Result['FilterID']) { if(!$Result['FilterID']) {
$Result['FilterID'] = 0; $Result['FilterID'] = 0;
} }
if(!isset($FilterGroups[$Result['FilterID']])) { if(!isset($FilterGroups[$Result['FilterID']])) {
$FilterGroups[$Result['FilterID']] = array(); $FilterGroups[$Result['FilterID']] = array();
$FilterGroups[$Result['FilterID']]['FilterLabel'] = ($Result['FilterID'] && !empty($Result['Label']) ? $Result['Label'] : 'unknown filter'.($Result['FilterID']?' ['.$Result['FilterID'].']':'')); $FilterGroups[$Result['FilterID']]['FilterLabel'] = $Result['Label'] ? $Result['Label'] : false;
} }
array_push($FilterGroups[$Result['FilterID']], $Result); array_push($FilterGroups[$Result['FilterID']], $Result);
} }
unset($Result); unset($Result);
foreach($FilterGroups as $ID => $FilterResults) { $Debug->log_var($FilterGroups, 'Filter groups');
foreach($FilterGroups as $FilterID => $FilterResults) {
?> ?>
<h3>Matches for <?=$FilterResults['FilterLabel']?> <a href="torrents.php?action=notify_cleargroup&amp;filterid=<?=$ID?>&amp;auth=<?=$LoggedUser['AuthKey']?>">(clear)</a> <a href="javascript:GroupClear($('#notificationform_<?=$ID?>').raw())">(clear selected)</a></h3> <h3>
<form id="notificationform_<?=$ID?>"> Matches for <?=$FilterResults['FilterLabel'] !== false
? '<a href="torrents.php?action=notify&amp;filterid='.$FilterID.'">'.$FilterResults['FilterLabel'].'</a>'
: 'unknown filter['.$FilterID.']'?>
<a href="torrents.php?action=notify_cleargroup&amp;filterid=<?=$FilterID?>&amp;auth=<?=$LoggedUser['AuthKey']?>">(clear)</a>
<a href="javascript:GroupClear($('#notificationform_<?=$FilterID?>').raw())">(clear selected)</a>
</h3>
<form id="notificationform_<?=$FilterID?>">
<table class="border"> <table class="border">
<tr class="colhead"> <tr class="colhead">
<td style="text-align: center"><input type="checkbox" name="toggle" onClick="ToggleBoxes(this.form, this.checked)" /></td> <td style="text-align: center"><input type="checkbox" name="toggle" onClick="ToggleBoxes(this.form, this.checked)" /></td>
@ -107,57 +97,45 @@
<? <?
unset($FilterResults['FilterLabel']); unset($FilterResults['FilterLabel']);
foreach($FilterResults as $Result) { foreach($FilterResults as $Result) {
list($TorrentID, $GroupID, $GroupName, $GroupCategoryID, $TorrentTags, $Size, $FileCount, $Format, $Encoding, $TorrentID = $Result['TorrentID'];
$Media, $Scene, $RemasterYear, $GroupYear, $RemasterYear, $RemasterTitle, $Snatched, $Seeders, $GroupID = $Result['GroupID'];
$Leechers, $NotificationTime, $HasLog, $HasCue, $LogScore, $FreeTorrent, $LogInDB, $UnRead, $FilterLabel, $FilterLabel, $ReleaseType) = $Result; $GroupCategoryID = $GroupCategoryIDs[$GroupID]['CategoryID'];
$GroupInfo = $TorrentGroups[$Result['GroupID']];
if(!$TorrentInfo = $GroupInfo['Torrents'][$TorrentID]) {
continue;
}
// generate torrent's title // generate torrent's title
$DisplayName=''; $DisplayName = '';
if(!empty($GroupInfo['ExtendedArtists'])) {
$Artists = get_artist($GroupID); $DisplayName = display_artists($GroupInfo['ExtendedArtists'], true, true);
if(!empty($Artists)) {
$DisplayName = display_artists($Artists, true, true);
} }
$DisplayName .= "<a href='torrents.php?id=$GroupID&amp;torrentid=$TorrentID#torrent$TorrentID' title='View Torrent'>".$GroupInfo['Name']."</a>";
if (in_array($TorrentID, $TokenTorrents) && empty($Torrent['FreeTorrent'])) {
$Data['PersonalFL'] = 1; if($GroupCategoryID == 1) {
if($GroupInfo['Year'] > 0) {
$DisplayName .= " [$GroupInfo[Year]]";
}
if($GroupInfo['ReleaseType'] > 0) {
$DisplayName.= " [".$ReleaseTypes[$GroupInfo['ReleaseType']]."]";
}
} }
$DisplayName.= "<a href='torrents.php?id=$GroupID&amp;torrentid=$TorrentID#torrent$TorrentID' title='View Torrent'>".$GroupName."</a>";
if($GroupCategoryID==1 && $GroupYear>0) {
$DisplayName.= " [$GroupYear]";
}
if($GroupCategoryID==1 && $ReleaseType>0) {
$DisplayName.= " [".$ReleaseTypes[$ReleaseType]."]";
}
// append extra info to torrent title // append extra info to torrent title
$ExtraInfo=''; $ExtraInfo = torrent_info($TorrentInfo, true);
$AddExtra=''; $Debug->log_var($ExtraInfo, "Extra torrent info ($TorrentID)");
if($Format) { $ExtraInfo.=$Format; $AddExtra=' / '; }
if($Encoding) { $ExtraInfo.=$AddExtra.$Encoding; $AddExtra=' / '; } $TagLinks = array();
if($HasLog) { $ExtraInfo.=$AddExtra.'Log'; $AddExtra=' / '; } if($GroupInfo['TagList'] != '') {
if($HasLog && $LogInDB) { $ExtraInfo.=' ('.(int) $LogScore.'%)'; } $TorrentTags = explode(' ', $GroupInfo['TagList']);
if($HasCue) { $ExtraInfo.=$AddExtra.'Cue'; $AddExtra=' / '; }
if($Media) { $ExtraInfo.=$AddExtra.$Media; $AddExtra=' / '; }
if($Scene) { $ExtraInfo.=$AddExtra.'Scene'; $AddExtra=' / '; }
if($RemasterYear) { $ExtraInfo.=$AddExtra.$RemasterYear; $AddExtra=' '; }
if($RemasterTitle) { $ExtraInfo.=$AddExtra.$RemasterTitle; }
if($ExtraInfo!='') {
$ExtraInfo = "- [$ExtraInfo]";
}
$TagLinks=array();
if($TorrentTags!='') {
$TorrentTags=explode(' ',$TorrentTags);
$MainTag = $TorrentTags[0]; $MainTag = $TorrentTags[0];
foreach ($TorrentTags as $TagKey => $TagName) { foreach ($TorrentTags as $TagKey => $TagName) {
$TagName = str_replace('_','.',$TagName); $TagName = str_replace('_', '.', $TagName);
$TagLinks[]='<a href="torrents.php?taglist='.$TagName.'">'.$TagName.'</a>'; $TagLinks[] = '<a href="torrents.php?taglist='.$TagName.'">'.$TagName.'</a>';
} }
$TagLinks = implode(', ', $TagLinks); $TagLinks = implode(', ', $TagLinks);
$TorrentTags='<br /><div class="tags">'.$TagLinks.'</div>'; $TorrentTags = '<br /><div class="tags">'.$TagLinks.'</div>';
} else { } else {
$MainTag = $Categories[$GroupCategoryID-1]; $MainTag = $Categories[$GroupCategoryID-1];
} }
@ -171,21 +149,21 @@
<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> [<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) <? if (($LoggedUser['FLTokens'] > 0) && ($Size < 1073741824)
&& !in_array($TorrentID, $TokenTorrents) && empty($FreeTorrent) && ($LoggedUser['CanLeech'] == '1')) { ?> && !in_array($TorrentID, $TokenTorrents) && empty($TorrentInfo['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?>
| <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1" title="Use a FL Token" onClick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a> | <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1" title="Use a FL Token" onClick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
<? } ?> <? } ?>
| <a href="#" onclick="Clear(<?=$TorrentID?>);return false;" title="Remove from notifications list">CL</a>] | <a href="#" onclick="Clear(<?=$TorrentID?>);return false;" title="Remove from notifications list">CL</a>]
</span> </span>
<strong><?=$DisplayName?></strong> <?=$ExtraInfo ?> <strong><?=$DisplayName?></strong> <?=$ExtraInfo?>
<? if($UnRead) { echo '<strong>New!</strong>'; } ?> <? if($Result['UnRead']) { echo '<strong>New!</strong>'; } ?>
<?=$TorrentTags?> <?=$TorrentTags?>
</td> </td>
<td><?=$FileCount ?></td> <td><?=$TorrentInfo['FileCount']?></td>
<td style="text-align:right" class="nobr"><?=time_diff($NotificationTime)?></td> <td style="text-align:right" class="nobr"><?=time_diff($TorrentInfo['Time'])?></td>
<td class="nobr" style="text-align:right"><?=get_size($Size)?></td> <td class="nobr" style="text-align:right"><?=get_size($TorrentInfo['Size'])?></td>
<td style="text-align:right"><?=number_format($Snatched)?></td> <td style="text-align:right"><?=number_format($TorrentInfo['Snatched'])?></td>
<td style="text-align:right"><?=number_format($Seeders)?></td> <td style="text-align:right"><?=number_format($TorrentInfo['Seeders'])?></td>
<td style="text-align:right"><?=number_format($Leechers)?></td> <td style="text-align:right"><?=number_format($TorrentInfo['Leechers'])?></td>
</tr> </tr>
<? <?
} }