74 changes from Mon Oct 3 16:42:37 2011 +0000 to Thu Oct 27 02:24:49 2011 +0000

%B>
This commit is contained in:
Git 2011-10-27 08:00:15 +00:00
parent 9d65045de0
commit 38f0e6765e
44 changed files with 1689 additions and 171 deletions

View File

@ -414,8 +414,10 @@ function get_permissions_for_user($UserID, $CustomPermissions = false) {
$CustomPerms = array();
}
$MaxCollages = $Permissions['Permissions']['MaxCollages'] + $DonorPerms['Permissions']['MaxCollages'] + $ArtistPerms['Permissions']['MaxCollages'] + $CustomPerms['MaxCollages'];
//Combine the permissions
return array_merge($Permissions['Permissions'], $DonorPerms['Permissions'], $ArtistPerms['Permissions'], $CustomPerms);
return array_merge($Permissions['Permissions'], $DonorPerms['Permissions'], $ArtistPerms['Permissions'], $CustomPerms, array('MaxCollages' => $MaxCollages));
}
// This function is slow. Don't call it unless somebody's logging in.
@ -574,11 +576,11 @@ function enforce_login() {
// Make sure $_GET['auth'] is the same as the user's authorization key
// Should be used for any user action that relies solely on GET.
function authorize() {
function authorize($Ajax = false) {
global $LoggedUser;
if(empty($_REQUEST['auth']) || $_REQUEST['auth'] != $LoggedUser['AuthKey']) {
send_irc("PRIVMSG ".LAB_CHAN." :".$LoggedUser['Username']." just failed authorize on ".$_SERVER['REQUEST_URI']." coming from ".$_SERVER['HTTP_REFERER']);
error('Invalid authorization key. Go back, refresh, and try again.');
error('Invalid authorization key. Go back, refresh, and try again.', $Ajax);
return false;
}
return true;

View File

@ -240,6 +240,23 @@
}
}
// Collage subscriptions
if(check_perms('site_collages_subscribe')) {
$NewCollages = $Cache->get_value('collage_subs_user_new_'.$LoggedUser['ID']);
if($NewCollages === FALSE) {
$DB->query("SELECT COUNT(DISTINCT s.CollageID)
FROM users_collage_subs as s
JOIN collages as c ON s.CollageID = c.ID
JOIN collages_torrents as ct on ct.CollageID = c.ID
WHERE s.UserID = ".$LoggedUser['ID']." AND ct.AddedOn > s.LastVisit AND c.Deleted = '0'");
list($NewCollages) = $DB->next_record();
$Cache->cache_value('collage_subs_user_new_'.$LoggedUser['ID'], $NewCollages, 0);
}
if ($NewCollages > 0) {
$Alerts[] = '<a href="userhistory.php?action=subscribed_collages">'.'You have '.$NewCollages.(($NewCollages > 1) ? ' new collage updates' : ' new collage update').'</a>';
}
}
if (check_perms('users_mod')) {
$ModBar[] = '<a href="tools.php">'.'Toolbox'.'</a>';

View File

@ -138,6 +138,7 @@ CREATE TABLE `collages` (
`TagList` varchar(500) NOT NULL DEFAULT '',
`MaxGroups` int(10) NOT NULL DEFAULT '0',
`MaxGroupsPerUser` int(10) NOT NULL DEFAULT '0',
`Featured` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`),
UNIQUE KEY `Name` (`Name`),
KEY `UserID` (`UserID`),

324
sections/ajax/artist.php Normal file
View File

@ -0,0 +1,324 @@
<?
authorize(true);
//For sorting tags
function compare($X, $Y){
return($Y['count'] - $X['count']);
}
include(SERVER_ROOT.'/sections/bookmarks/functions.php'); // has_bookmarked()
include(SERVER_ROOT.'/sections/requests/functions.php');
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
$Text = new TEXT;
// Similar artist map
include(SERVER_ROOT.'/classes/class_artist.php');
include(SERVER_ROOT.'/classes/class_artists_similar.php');
$ArtistID = $_GET['id'];
if(!is_number($ArtistID)) {
print json_encode(array('status' => 'failure'));
}
if (empty($ArtistID)) {
if (!empty($_GET['artistname'])) {
$Name = db_string(trim($_GET['artistname']));
$DB->query("SELECT ArtistID FROM artists_alias WHERE Name LIKE '$Name'");
if (!(list($ArtistID) = $DB->next_record(MYSQLI_NUM, false))) {
//if (list($ID) = $DB->next_record(MYSQLI_NUM, false)) {
print json_encode(array('status' => 'failure'));
die();
}
// If we get here, we got the ID!
}
}
if(!empty($_GET['revisionid'])) { // if they're viewing an old revision
$RevisionID=$_GET['revisionid'];
if(!is_number($RevisionID)){ error(0); }
$Data = $Cache->get_value("artist_$ArtistID"."_revision_$RevisionID");
} else { // viewing the live version
$Data = $Cache->get_value('artist_'.$ArtistID);
$RevisionID = false;
}
if($Data) {
$Data = unserialize($Data);
list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray, $TorrentList, $Importances)) = each($Data);
} else {
if ($RevisionID) {
$sql = "SELECT
a.Name,
wiki.Image,
wiki.body,
a.VanityHouse
FROM wiki_artists AS wiki
LEFT JOIN artists_group AS a ON wiki.RevisionID=a.RevisionID
WHERE wiki.RevisionID='$RevisionID' ";
} else {
$sql = "SELECT
a.Name,
wiki.Image,
wiki.body,
a.VanityHouse
FROM artists_group AS a
LEFT JOIN wiki_artists AS wiki ON wiki.RevisionID=a.RevisionID
WHERE a.ArtistID='$ArtistID' ";
}
$sql .= " GROUP BY a.ArtistID";
$DB->query($sql);
if($DB->record_count()==0) {
print json_encode(array('status' => 'failure'));
}
list($Name, $Image, $Body, $VanityHouseArtist) = $DB->next_record(MYSQLI_NUM, array(0));
}
ob_start();
// Requests
$Requests = $Cache->get_value('artists_requests_'.$ArtistID);
if(!is_array($Requests)) {
$DB->query("SELECT
r.ID,
r.CategoryID,
r.Title,
r.Year,
r.TimeAdded,
COUNT(rv.UserID) AS Votes,
SUM(rv.Bounty) AS Bounty
FROM requests AS r
LEFT JOIN requests_votes AS rv ON rv.RequestID=r.ID
LEFT JOIN requests_artists AS ra ON r.ID=ra.RequestID
WHERE ra.ArtistID = ".$ArtistID."
AND r.TorrentID = 0
GROUP BY r.ID
ORDER BY Votes DESC");
if($DB->record_count() > 0) {
$Requests = $DB->to_array();
} else {
$Requests = array();
}
$Cache->cache_value('artists_requests_'.$ArtistID, $Requests);
}
$NumRequests = count($Requests);
$LastReleaseType = 0;
if(empty($Importances) || empty($TorrentList)) {
$DB->query("SELECT
DISTINCT ta.GroupID, ta.Importance, tg.VanityHouse
FROM torrents_artists AS ta
JOIN torrents_group AS tg ON tg.ID=ta.GroupID
WHERE ta.ArtistID='$ArtistID'
ORDER BY ta.Importance, tg.ReleaseType ASC, tg.Year DESC, tg.Name DESC");
$GroupIDs = $DB->collect('GroupID');
$Importances = $DB->to_array('GroupID', MYSQLI_BOTH, false);
if(count($GroupIDs)>0) {
$TorrentList = get_groups($GroupIDs, true,true);
$TorrentList = $TorrentList['matches'];
} else {
$TorrentList = array();
}
}
$NumGroups = count($TorrentList);
//Get list of used release types
$UsedReleases = array();
foreach($TorrentList as $GroupID=>$Group) {
if($Importances[$GroupID]['Importance'] == '2') {
$TorrentList[$GroupID]['ReleaseType'] = 1024;
$GuestAlbums = true;
}
if($Importances[$GroupID]['Importance'] == '3') {
$TorrentList[$GroupID]['ReleaseType'] = 1023;
$RemixerAlbums = true;
}
if(!in_array($TorrentList[$GroupID]['ReleaseType'], $UsedReleases)) {
$UsedReleases[] = $TorrentList[$GroupID]['ReleaseType'];
}
}
if(!empty($GuestAlbums)) {
$ReleaseTypes[1024] = "Guest Appearance";
}
if(!empty($RemixerAlbums)) {
$ReleaseTypes[1023] = "Remixed By";
}
reset($TorrentList);
$JsonTorrents = array();
foreach ($TorrentList as $GroupID=>$Group) {
list($GroupID, $GroupName, $GroupYear, $GroupRecordLabel, $GroupCatalogueNumber, $TagList, $ReleaseType, $GroupVanityHouse, $Torrents, $Artists) = array_values($Group);
$GroupVanityHouse = $Importances[$GroupID]['VanityHouse'];
$TagList = explode(' ',str_replace('_','.',$TagList));
// $Tags array is for the sidebar on the right
foreach($TagList as $Tag) {
if(!isset($Tags[$Tag])) {
$Tags[$Tag] = array('name'=>$Tag, 'count'=>1);
} else {
$Tags[$Tag]['count']++;
}
}
$DisplayName ='<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
if(check_perms('users_mod')) {
$DisplayName .= ' [<a href="torrents.php?action=fix_group&amp;groupid='.$GroupID.'&amp;artistid='.$ArtistID.'&amp;auth='.$LoggedUser['AuthKey'].'">Fix</a>]';
}
if (($ReleaseType == 1023) || ($ReleaseType == 1024)) {
$DisplayName = display_artists(array(1 => $Artists), true, true).$DisplayName;
}
if($GroupYear>0) { $DisplayName = $GroupYear. ' - '.$DisplayName; }
if($GroupVanityHouse) { $DisplayName .= ' [<abbr title="This is a vanity house release">VH</abbr>]'; }
?>
<tr class="releases_<?=$ReleaseType?> group discog<?=$HideDiscog?>">
<td class="center">
<div title="View" id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
<a href="#" class="show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event)" title="Collapse this group"></a>
</div>
</td>
<td colspan="5">
<strong><?=$DisplayName?></strong>
<?=$TorrentTags?>
</td>
</tr>
<?
$LastRemasterYear = '-';
$LastRemasterTitle = '';
$LastRemasterRecordLabel = '';
$LastRemasterCatalogueNumber = '';
$LastMedia = '';
$EditionID = 0;
unset($FirstUnknown);
$InnerTorrents = array();
foreach ($Torrents as $TorrentID => $Torrent) {
$NumTorrents++;
if ($Torrent['Remastered'] && !$Torrent['RemasterYear']) {
$FirstUnknown = !isset($FirstUnknown);
}
$Torrent['Seeders'] = (int)$Torrent['Seeders'];
$Torrent['Leechers'] = (int)$Torrent['Leechers'];
$Torrent['Snatched'] = (int)$Torrent['Snatched'];
$NumSeeders+=$Torrent['Seeders'];
$NumLeechers+=$Torrent['Leechers'];
$NumSnatches+=$Torrent['Snatched'];
}
$JsonTorrents[] = array(
'groupId' => $GroupID,
'groupName' => $GroupName,
'groupYear' => $GroupYear,
'groupRecordLabel' => $GroupRecordLabel,
'groupCatalogueNumber' => $GroupCatalogueNumber,
'tags' => $TagList,
'releaseType' => $ReleaseType,
'groupVanityHouse' => $GroupVanityHouse,
'hasBookmarked' => $hasBookmarked = has_bookmarked('torrent', $GroupID),
'torrent' => array_values($Torrents)
);
}
$TorrentDisplayList = ob_get_clean();
$JsonSimilar = array();
if(empty($SimilarArray)) {
$DB->query("
SELECT
s2.ArtistID,
a.Name,
ass.Score,
ass.SimilarID
FROM artists_similar AS s1
JOIN artists_similar AS s2 ON s1.SimilarID=s2.SimilarID AND s1.ArtistID!=s2.ArtistID
JOIN artists_similar_scores AS ass ON ass.SimilarID=s1.SimilarID
JOIN artists_group AS a ON a.ArtistID=s2.ArtistID
WHERE s1.ArtistID='$ArtistID'
ORDER BY ass.Score DESC
LIMIT 30
");
$SimilarArray = $DB->to_array();
foreach ($SimilarArray as $Similar) {
$JsonSimilar[] = array(
'artistId' => $Similar['ArtistID'],
'name' => $Similar['Name'],
'score' => $Similar['Score'],
'similarId' => $Similar['SimilarID']
);
}
$NumSimilar = count($SimilarArray);
}
$JsonRequests = array();
foreach ($Requests as $Request) {
list($RequestID, $CategoryID, $Title, $Year, $TimeAdded, $Votes, $Bounty) = $Request;
$JsonRequests[] = array(
'requestId' => $RequestID,
'categoryId' => $CategoryID,
'title' => $Title,
'year' => $Year,
'timeAdded' => $TimeAdded,
'votes' => $Votes,
'bounty' => $Bounty
);
}
//notifications disabled by default
$notificationsEnabled = False;
if (check_perms('site_torrents_notify')) {
if (($Notify = $Cache->get_value('notify_artists_'.$LoggedUser['ID'])) === false) {
$DB->query("SELECT ID, Artists FROM users_notify_filters WHERE UserID='$LoggedUser[ID]' AND Label='Artist notifications' LIMIT 1");
$Notify = $DB->next_record(MYSQLI_ASSOC, false);
$Cache->cache_value('notify_artists_'.$LoggedUser['ID'], $Notify, 0);
}
if (stripos($Notify['Artists'], '|'.$Name.'|') === false) {
$notificationsEnabled = False;
} else {
$notificationsEnabled = True;
}
}
print
json_encode(
array(
'status' => 'success',
'response' => array(
'id' => $ArtistID,
'name' => $Name,
'notificationsEnabled' => $notificationsEnabled,
'hasBookmarked' => has_bookmarked('artist', $ArtistID),
'image' => $Image,
'body' => $Text->full_format($Body),
'vanityHouse' => $VanityHouseArtist,
'tags' => array_values($Tags),
'similarArtists' => $JsonSimilar,
'statistics' => array(
'numGroups' => $NumGroups,
'numTorrents' => $NumTorrents,
'numSeeders' => $NumSeeders,
'numLeechers' => $NumLeechers,
'numSnatches' => $NumSnatches
),
'torrentgroup' => $JsonTorrents,
'requests' => $JsonRequests
)
)
)
?>

View File

@ -0,0 +1,112 @@
<?
$UserID = $LoggedUser['ID'];
if(empty($_GET['type'])) { $Section = 'inbox'; }
else {
$Section = $_GET['type']; // either 'inbox' or 'sentbox'
}
if(!in_array($Section, array('inbox', 'sentbox'))) {
print
json_encode(
array(
'status' => 'failure'
)
);
die();
}
list($Page,$Limit) = page_limit(MESSAGES_PER_PAGE);
$Sort = empty($_GET['sort']) || $_GET['sort'] != "unread" ? "Date DESC" : "cu.Unread = '1' DESC, DATE DESC";
$sql = "SELECT
SQL_CALC_FOUND_ROWS
c.ID,
c.Subject,
cu.Unread,
cu.Sticky,
cu.ForwardedTo,
um2.Username AS ForwardedName,
cu2.UserID,
um.Username,
ui.Donor,
ui.Warned,
um.Enabled,";
$sql .= ($Section == 'sentbox')? ' cu.SentDate ' : ' cu.ReceivedDate ';
$sql .= "AS Date
FROM pm_conversations AS c
LEFT JOIN pm_conversations_users AS cu ON cu.ConvID=c.ID AND cu.UserID='$UserID'
LEFT JOIN pm_conversations_users AS cu2 ON cu2.ConvID=c.ID AND cu2.UserID!='$UserID' AND cu2.ForwardedTo=0
LEFT JOIN users_main AS um ON um.ID=cu2.UserID
LEFT JOIN users_info AS ui ON ui.UserID=um.ID
LEFT JOIN users_main AS um2 ON um2.ID=cu.ForwardedTo";
if(!empty($_GET['search']) && $_GET['searchtype'] == "message") {
$sql .= " JOIN pm_messages AS m ON c.ID=m.ConvID";
}
$sql .= " WHERE ";
if(!empty($_GET['search'])) {
$Search = db_string($_GET['search']);
if($_GET['searchtype'] == "user") {
$sql .= "um.Username LIKE '".$Search."' AND ";
} elseif($_GET['searchtype'] == "subject") {
$Words = explode(' ', $Search);
$sql .= "c.Subject LIKE '%".implode("%' AND c.Subject LIKE '%", $Words)."%' AND ";
} elseif($_GET['searchtype'] == "message") {
$Words = explode(' ', $Search);
$sql .= "m.Body LIKE '%".implode("%' AND m.Body LIKE '%", $Words)."%' AND ";
}
}
$sql .= ($Section == 'sentbox')? ' cu.InSentbox' : ' cu.InInbox';
$sql .="='1'";
$sql .=" GROUP BY c.ID
ORDER BY cu.Sticky, ".$Sort." LIMIT $Limit";
$Results = $DB->query($sql);
$DB->query('SELECT FOUND_ROWS()');
list($NumResults) = $DB->next_record();
$DB->set_query_id($Results);
$CurURL = get_url(array('sort'));
if(empty($CurURL)) {
$CurURL = "inbox.php?";
} else {
$CurURL = "inbox.php?".$CurURL."&";
}
$Pages=get_pages($Page,$NumResults,MESSAGES_PER_PAGE,9);
$JsonMessages = array();
while(list($ConvID, $Subject, $Unread, $Sticky, $ForwardedID, $ForwardedName, $SenderID, $Username, $Donor, $Warned, $Enabled, $Date) = $DB->next_record()) {
$JsonMessage = array(
'convId' => $ConvID,
'subject' => $Subject,
'unread' => $Unread,
'sticky' => $Sticky,
'forwardedId' => $ForwardedID,
'forwardedName' => $ForwardedName,
'senderId' => $SenderID,
'username' => $Username,
'donor' => $Donor,
'warned' => $Warned,
'enabled' => ($Enabled == 2 ? false : true),
'date' => $Date
);
$JsonMessages[] = $JsonMessage;
}
print
json_encode(
array(
'status' => 'success',
'response' => array(
'currentPage' => $Page,
'pages' => ceil($NumResults/MESSAGES_PER_PAGE),
'messages' => $JsonMessages
)
)
);
?>

View File

@ -0,0 +1,14 @@
<?
authorize(true);
if(empty($_GET['type']) || $_GET['type'] == 'inbox' || $_GET['type'] == 'sentbox') {
require(SERVER_ROOT.'/sections/ajax/inbox/inbox.php');
} else if ($_GET['type'] == 'viewconv') {
require(SERVER_ROOT.'/sections/ajax/inbox/viewconv.php');
} else {
print json_encode(array('status' => 'failure'));
die();
}
?>

View File

@ -0,0 +1,91 @@
<?
include(SERVER_ROOT.'/classes/class_text.php');
$Text = new TEXT;
$ConvID = $_GET['id'];
if(!$ConvID || !is_number($ConvID)) {
print json_encode(array('status' => 'failure'));
die();
}
$UserID = $LoggedUser['ID'];
$DB->query("SELECT InInbox, InSentbox FROM pm_conversations_users WHERE UserID='$UserID' AND ConvID='$ConvID'");
if($DB->record_count() == 0) {
print json_encode(array('status' => 'failure'));
die();
}
list($InInbox, $InSentbox) = $DB->next_record();
if (!$InInbox && !$InSentbox) {
print json_encode(array('status' => 'failure'));
die();
}
// Get information on the conversation
$DB->query("SELECT
c.Subject,
cu.Sticky,
cu.UnRead,
cu.ForwardedTo,
um.Username
FROM pm_conversations AS c
JOIN pm_conversations_users AS cu ON c.ID=cu.ConvID
LEFT JOIN users_main AS um ON um.ID=cu.ForwardedTo
WHERE c.ID='$ConvID' AND UserID='$UserID'");
list($Subject, $Sticky, $UnRead, $ForwardedID, $ForwardedName) = $DB->next_record();
$DB->query("SELECT UserID, Username, PermissionID, Enabled, Donor, Warned
FROM pm_messages AS pm
JOIN users_info AS ui ON ui.UserID=pm.SenderID
JOIN users_main AS um ON um.ID=pm.SenderID
WHERE pm.ConvID='$ConvID'");
while(list($PMUserID, $Username, $PermissionID, $Enabled, $Donor, $Warned) = $DB->next_record()) {
$PMUserID = (int)$PMUserID;
$Users[$PMUserID]['UserStr'] = format_username($PMUserID, $Username, $Donor, $Warned, $Enabled == 2 ? false : true, $PermissionID);
$Users[$PMUserID]['Username'] = $Username;
}
$Users[0]['UserStr'] = 'System'; // in case it's a message from the system
$Users[0]['Username'] = 'System';
if($UnRead=='1') {
$DB->query("UPDATE pm_conversations_users SET UnRead='0' WHERE ConvID='$ConvID' AND UserID='$UserID'");
// Clear the caches of the inbox and sentbox
$Cache->decrement('inbox_new_'.$UserID);
}
// Get messages
$DB->query("SELECT SentDate, SenderID, Body, ID FROM pm_messages AS m WHERE ConvID='$ConvID' ORDER BY ID");
$JsonMessages = array();
while(list($SentDate, $SenderID, $Body, $MessageID) = $DB->next_record()) {
$JsonMessage = array(
'messageId' => $MessageID,
'senderId' => $SenderID,
'senderName' => $Users[(int)$SenderID]['Username'],
'sentDate' => $SentDate,
'body' => $Text->full_format($Body)
);
$JsonMessages[] = $JsonMessage;
}
print
json_encode(
array(
'status' => 'success',
'response' => array(
'convId' => $ConvID,
'subject' => $Subject.($ForwardedID > 0 ? ' (Forwarded to '.$ForwardedName.')':''),
'sticky' => $Sticky,
'messages' => $JsonMessages
)
)
);

View File

@ -10,6 +10,8 @@
enforce_login();
header('Content-Type: application/json; charset=utf-8');
switch ($_GET['action']){
// things that (may be) used on the site
case 'upload_section':
@ -39,6 +41,18 @@
case 'top10':
require(SERVER_ROOT.'/sections/ajax/top10/index.php');
break;
case 'artist':
require(SERVER_ROOT.'/sections/ajax/artist.php');
break;
case 'inbox':
require(SERVER_ROOT.'/sections/ajax/inbox/index.php');
break;
case 'subscriptions':
require(SERVER_ROOT.'/sections/ajax/subscriptions.php');
break;
case 'index':
require(SERVER_ROOT.'/sections/ajax/info.php');
break;
default:
// If they're screwing around with the query string
error(403);

59
sections/ajax/info.php Normal file
View File

@ -0,0 +1,59 @@
<?
//no authorization because this page needs to be accessed to get the authkey
//authorize(true);
$UserID == $LoggedUser['ID'];
global $DB, $Cache;
$HeavyInfo = $Cache->get_value('user_info_heavy_'.$UserID);
$DB->query("SELECT
m.Username,
m.torrent_pass,
i.AuthKey,
Uploaded AS BytesUploaded,
Downloaded AS BytesDownloaded,
RequiredRatio,
p.Level AS Class
FROM users_main AS m
INNER JOIN users_info AS i ON i.UserID=m.ID
LEFT JOIN permissions AS p ON p.ID=m.PermissionID
WHERE m.ID='$UserID'");
list($Username,$torrent_pass,$AuthKey,$Uploaded,$Downloaded,$RequiredRatio,$Class) = $DB->next_record(MYSQLI_NUM, array(9,11));
//calculate ratio --Gwindow
//returns 0 for DNE and -1 for infiinity, because we dont want strings being returned for a numeric value in our java
if($Uploaded == 0 && $Downloaded == 0) {
$Ratio = '0';
} elseif($Downloaded == 0) {
$Ratio = '-1';}
else {
$Ratio = number_format(max($Uploaded/$Downloaded-0.005,0), 2); //Subtract .005 to floor to 2 decimals
}
print json_encode(
array(
'status' => 'success',
'response' => array(
'username' => $Username,
'id' => $UserID,
'authkey'=>$AuthKey,
'passkey'=>$torrent_pass,
'userstats' => array(
'uploaded' => $Uploaded,
'downloaded' => $Downloaded,
'ratio' => $Ratio,
'requiredratio' => $RequiredRatio,
//'class' => $Class
'class' => $ClassLevels[$Class]['Name']
),
)
)
);
?>

View File

@ -0,0 +1,121 @@
<?
authorize(true);
/*
User topic subscription page
*/
if(!empty($LoggedUser['DisableForums'])) {
print
json_encode(
array(
'status' => 'failure'
)
);
}
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
$Text = new TEXT;
if (isset($LoggedUser['PostsPerPage'])) {
$PerPage = $LoggedUser['PostsPerPage'];
} else {
$PerPage = POSTS_PER_PAGE;
}
list($Page,$Limit) = page_limit($PerPage);
if($LoggedUser['CustomForums']) {
unset($LoggedUser['CustomForums']['']);
$RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0));
$PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1));
}
$ShowUnread = (!isset($_GET['showunread']) && !isset($HeavyInfo['SubscriptionsUnread']) || isset($HeavyInfo['SubscriptionsUnread']) && !!$HeavyInfo['SubscriptionsUnread'] || isset($_GET['showunread']) && !!$_GET['showunread']);
$ShowCollapsed = (!isset($_GET['collapse']) && !isset($HeavyInfo['SubscriptionsCollapse']) || isset($HeavyInfo['SubscriptionsCollapse']) && !!$HeavyInfo['SubscriptionsCollapse'] || isset($_GET['collapse']) && !!$_GET['collapse']);
$sql = 'SELECT
SQL_CALC_FOUND_ROWS
MAX(p.ID) AS ID
FROM forums_posts AS p
LEFT JOIN forums_topics AS t ON t.ID = p.TopicID
JOIN users_subscriptions AS s ON s.TopicID = t.ID
LEFT JOIN forums AS f ON f.ID = t.ForumID
LEFT JOIN forums_last_read_topics AS l ON p.TopicID = l.TopicID AND l.UserID = s.UserID
WHERE s.UserID = '.$LoggedUser['ID'].'
AND p.ID <= IFNULL(l.PostID,t.LastPostID)
AND ((f.MinClassRead <= '.$LoggedUser['Class'];
if(!empty($RestrictedForums)) {
$sql.=' AND f.ID NOT IN (\''.$RestrictedForums.'\')';
}
$sql .= ')';
if(!empty($PermittedForums)) {
$sql.=' OR f.ID IN (\''.$PermittedForums.'\')';
}
$sql .= ')';
if($ShowUnread) {
$sql .= '
AND IF(l.PostID IS NULL OR (t.IsLocked = \'1\' && t.IsSticky = \'0\'), t.LastPostID, l.PostID) < t.LastPostID';
}
$sql .= '
GROUP BY t.ID
ORDER BY t.LastPostID DESC
LIMIT '.$Limit;
$PostIDs = $DB->query($sql);
$DB->query('SELECT FOUND_ROWS()');
list($NumResults) = $DB->next_record();
if($NumResults > $PerPage*($Page-1)) {
$DB->set_query_id($PostIDs);
$PostIDs = $DB->collect('ID');
$sql = 'SELECT
f.ID AS ForumID,
f.Name AS ForumName,
p.TopicID,
t.Title,
p.Body,
t.LastPostID,
t.IsLocked,
t.IsSticky,
p.ID,
um.ID,
um.Username,
ui.Avatar,
p.EditedUserID,
p.EditedTime,
ed.Username AS EditedUsername
FROM forums_posts AS p
LEFT JOIN forums_topics AS t ON t.ID = p.TopicID
LEFT JOIN forums AS f ON f.ID = t.ForumID
LEFT JOIN users_main AS um ON um.ID = p.AuthorID
LEFT JOIN users_info AS ui ON ui.UserID = um.ID
LEFT JOIN users_main AS ed ON ed.ID = um.ID
WHERE p.ID IN ('.implode(',',$PostIDs).')
ORDER BY f.Name ASC, t.LastPostID DESC';
$DB->query($sql);
}
$JsonPosts = array();
while(list($ForumID, $ForumName, $TopicID, $ThreadTitle, $Body, $LastPostID, $Locked, $Sticky, $PostID, $AuthorID, $AuthorName, $AuthorAvatar, $EditedUserID, $EditedTime, $EditedUsername) = $DB->next_record()){
$JsonPost = array(
'forumId' => $ForumID,
'forumName' => $ForumName,
'threadId' => $TopicID,
'threadTitle' => $ThreadTitle,
'postId' => $PostID,
'lastPostId' => $LastPostID,
'locked' => $Locked,
'new' => ($PostID<$LastPostID && !$Locked)
);
$JsonPosts[] = $JsonPost;
}
print
json_encode(
array(
'status' => 'success',
'response' => array(
'posts' => $JsonPosts
)
)
);
?>

View File

@ -165,7 +165,10 @@ function generate_torrent_json($Caption, $Tag, $Details, $Limit) {
'torrentId' => $TorrentID,
'groupId' => $GroupID,
'artist' => $TruncArtist,
'groupName' => $GroupName,
'groupCategory' => $GroupCategoryID,
'groupYear' => $GroupYear,
'remasterTitle' => $RemasterTitle,
'format' => $Format,
'encoding' => $Encoding,
'hasLog' => $HasLog,
@ -176,7 +179,8 @@ function generate_torrent_json($Caption, $Tag, $Details, $Limit) {
'tags' => $TagList,
'snatched' => $Snatched,
'seeders' => $Seeders,
'leechers' => $Leechers
'leechers' => $Leechers,
'data' => $Data
);
}

View File

@ -60,6 +60,13 @@ function compare($X, $Y){
list($Name, $Image, $Body, $VanityHouseArtist) = $DB->next_record(MYSQLI_NUM, array(0));
}
$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);
}
//----------------- Build list and get stats
ob_start();
@ -332,7 +339,12 @@ 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>]
</span>
&nbsp;&nbsp;&raquo;&nbsp; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=torrent_info($Torrent)?></a>
</td>

View File

@ -46,6 +46,13 @@ function compare($X, $Y){
}
}
$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);
}
$Title = ($Sneaky)?"$Username's bookmarked torrents":'Your bookmarked torrents';
show_header($Title, 'browse');
@ -185,8 +192,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>]
<span>[
<? 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>]
</span>
&nbsp;&nbsp;&raquo;&nbsp; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=torrent_info($Torrent)?></a>
</td>
@ -206,6 +217,8 @@ function compare($X, $Y){
if(!empty($Torrent['FreeTorrent'])) {
$DisplayName .=' <strong>Freeleech!</strong>';
} elseif(in_array($TorrentID, $TokenTorrents)) {
$DisplayName .= '<strong>Personal Freeleech!</strong>';
}
?>
<tr class="torrent" id="group_<?=$GroupID?>">
@ -216,7 +229,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']?>" title="Download">DL</a>
| <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" title="Report">RP</a>]
</span>
<strong><?=$DisplayName?></strong>

View File

@ -51,15 +51,20 @@
$DB->query("SELECT GroupID FROM collages_torrents WHERE CollageID='$CollageID' AND GroupID='$GroupID'");
if($DB->record_count() == 0) {
$DB->query("INSERT IGNORE INTO collages_torrents
(CollageID, GroupID, UserID, Sort)
(CollageID, GroupID, UserID, Sort, AddedOn)
VALUES
('$CollageID', '$GroupID', '$LoggedUser[ID]', '$Sort')");
('$CollageID', '$GroupID', '$LoggedUser[ID]', '$Sort', NOW())");
$DB->query("UPDATE collages SET NumTorrents=NumTorrents+1 WHERE ID='$CollageID'");
$Cache->delete_value('collage_'.$CollageID);
$Cache->delete_value('torrents_details_'.$GroupID);
$Cache->delete_value('torrent_collages_'.$GroupID);
$DB->query("SELECT UserID FROM users_collage_subs WHERE CollageID=$CollageID");
while (list($CacheUserID) = $DB->next_record()) {
$Cache->delete_value('collage_subs_user_new_'.$CacheUserID);
}
} else {
error('Torrent already in collage!');
}

View File

@ -67,23 +67,25 @@
$BookmarkJoin = '';
}
$SQL = "SELECT SQL_CALC_FOUND_ROWS
c.ID,
c.Name,
$BaseSQL = $SQL = "SELECT SQL_CALC_FOUND_ROWS
c.ID,
c.Name,
c.NumTorrents,
c.TagList,
c.CategoryID,
c.UserID,
um.Username
FROM collages AS c
um.Username
FROM collages AS c
$BookmarkJoin
LEFT JOIN users_main AS um ON um.ID=c.UserID
LEFT JOIN users_main AS um ON um.ID=c.UserID
WHERE Deleted = '0'";
if ($BookmarkView) {
$SQL .= " AND bc.UserID = '" . $LoggedUser['ID'] . "'";
}
if(!empty($Search)) {
$SQL .= " AND $Type LIKE '%";
$SQL .= implode("%' AND $Type LIKE '%", $Words);
@ -126,6 +128,11 @@
$SQL.=" AND CategoryID IN(".db_string(implode(',',$Categories)).")";
}
if ($_GET['action'] == 'mine') {
$SQL = $BaseSQL;
$SQL .= " AND c.UserID='".$LoggedUser['ID']."' AND c.CategoryID=0";
}
$SQL.=" ORDER BY $Order $Way LIMIT $Limit ";
$DB->query($SQL);
$Collages = $DB->to_array();
@ -140,42 +147,6 @@
<? } else { ?>
<h2>Browse collages<?=(!empty($UserLink) ? (isset($CollageIDs) ? ' with contributions by '.$UserLink : ' started by '.$UserLink) : '')?></h2>
<? } ?>
<div class="linkbox">
<? if (!$BookmarkView) {
if (check_perms('site_collages_create')) { ?>
<a href="collages.php?action=new">[New collage]</a>
<? }
if (check_perms('site_collages_personal')) {
$DB->query("SELECT ID FROM collages WHERE UserID='$LoggedUser[ID]' AND CategoryID='0' AND Deleted='0'");
if($DB->record_count() == 0) {
?>
<a href="collages.php?action=create_personal">[New <strong>personal</strong> collage]</a>
<? } else {
list($CollageID) = $DB->next_record();
?>
<a href="collages.php?id=<?=$CollageID?>">[Your personal collage]</a>
<?
}
}
if (check_perms('site_collages_recover')) { ?>
<a href="collages.php?action=recover">[Recover collage]</a>
<?
}
if (check_perms('site_collages_create') || check_perms('site_collages_personal') || check_perms('site_collages_recover')) {
?>
<br /><br />
<?
}
?>
<a href="collages.php?userid=<?=$LoggedUser['ID']?>">[Collages you started]</a>
<a href="collages.php?userid=<?=$LoggedUser['ID']?>&amp;contrib=1">[Collages you've contributed to]</a>
<? } else { ?>
<a href="bookmarks.php?type=torrents">[Torrents]</a>
<a href="bookmarks.php?type=artists">[Artists]</a>
<a href="bookmarks.php?type=collages">[Collages]</a>
<a href="bookmarks.php?type=requests">[Requests]</a>
<? } ?>
</div>
<? if (!$BookmarkView) { ?>
<div>
<form action="" method="get">
@ -228,11 +199,50 @@
<input type="submit" value="Search" />
</td>
</tr>
</table>
</table>
</form>
</div>
<? } // if (!$BookmarkView) ?>
<div class="linkbox">
<? if (!$BookmarkView) {
if (check_perms('site_collages_create')) { ?>
<a href="collages.php?action=new">[New collage]</a>
<? }
if (check_perms('site_collages_personal')) {
$DB->query("SELECT ID FROM collages WHERE UserID='$LoggedUser[ID]' AND CategoryID='0' AND Deleted='0'");
$CollageCount = $DB->record_count();
if ($CollageCount == 1) {
list($CollageID) = $DB->next_record();
?>
<a href="collages.php?id=<?=$CollageID?>">[My personal collage]</a>
<? } elseif ($CollageCount > 1) { ?>
<a href="collages.php?action=mine">[My personal collages]</a>
<? }
}
if (check_perms('site_collages_subscribe')) { ?>
<a href="userhistory.php?action=subscribed_collages">[My Subscribed Collages]</a>
<? }
if (check_perms('site_collages_recover')) { ?>
<a href="collages.php?action=recover">[Recover collage]</a>
<?
}
if (check_perms('site_collages_create') || check_perms('site_collages_personal') || check_perms('site_collages_recover')) {
?>
<br />
<?
}
?>
<a href="collages.php?userid=<?=$LoggedUser['ID']?>">[Collages you started]</a>
<a href="collages.php?userid=<?=$LoggedUser['ID']?>&amp;contrib=1">[Collages you've contributed to]</a>
<? } else { ?>
<a href="bookmarks.php?type=torrents">[Torrents]</a>
<a href="bookmarks.php?type=artists">[Artists]</a>
<a href="bookmarks.php?type=collages">[Collages]</a>
<a href="bookmarks.php?type=requests">[Requests]</a>
<? } ?>
<br /><br />
<?
$Pages=get_pages($Page,$NumResults,COLLAGES_PER_PAGE,9);
echo $Pages;
@ -268,7 +278,7 @@
$Tags[]='<a href="collages.php?action=search&amp;tags='.$Tag.'">'.$Tag.'</a>';
}
$Tags = implode(', ', $Tags);
//Print results
?>
<tr class="row<?=$Row?> <?=($BookmarkView)?'bookmark_'.$ID:''?>">

View File

@ -12,6 +12,13 @@ function compare($X, $Y){
$CollageID = $_GET['id'];
if(!is_number($CollageID)) { error(0); }
$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);
}
$Data = $Cache->get_value('collage_'.$CollageID);
if($Data) {
@ -39,6 +46,22 @@ function compare($X, $Y){
}
}
//Handle subscriptions
if(($CollageSubscriptions = $Cache->get_value('collage_subs_user_'.$LoggedUser['ID'])) === FALSE) {
$DB->query("SELECT CollageID FROM users_collage_subs WHERE UserID = '$LoggedUser[ID]'");
$CollageSubscriptions = $DB->collect(0);
$Cache->cache_value('collage_subs_user_'.$LoggedUser['ID'],$CollageSubscriptions,0);
}
if(empty($CollageSubscriptions)) {
$CollageSubscriptions = array();
}
if(in_array($CollageID, $CollageSubscriptions)) {
$Cache->delete_value('collage_subs_user_new_'.$LoggedUser['ID']);
}
$DB->query("UPDATE users_collage_subs SET LastVisit=NOW() WHERE UserID = ".$LoggedUser['ID']." AND CollageID=$CollageID");
show_header($Name,'browse,collage,bbcode');
// Build the data for the collage and the torrent list
@ -205,7 +228,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>]
</span>
&nbsp;&nbsp;&raquo;&nbsp; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=torrent_info($Torrent)?></a>
</td>
@ -225,6 +253,8 @@ function compare($X, $Y){
if(!empty($Torrent['FreeTorrent'])) {
$DisplayName .=' <strong>Freeleech!</strong>';
} elseif(in_array($TorrentID, $TokenTorrents)) {
$DisplayName .= $AddExtra.'<strong>Personal Freeleech!</strong>';
}
?>
<tr class="torrent" id="group_<?=$GroupID?>">
@ -235,7 +265,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']?>" title="Download">DL</a>
| <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" title="Report">RP</a>]
</span>
<strong><?=$DisplayName?></strong>
@ -289,7 +324,10 @@ function compare($X, $Y){
<a href="collages.php?action=new">[New collage]</a>
<? } ?>
<br /><br />
<? if (check_perms('site_edit_wiki') && !$Locked) { ?>
<? if(check_perms('site_collages_subscribe')) { ?>
<a href="#" onclick="CollageSubscribe(<?=$CollageID?>);return false;" id="subscribelink<?=$CollageID?>">[<?=(in_array($CollageID, $CollageSubscriptions) ? 'Unsubscribe' : 'Subscribe')?>]</a>
<? }
if (check_perms('site_edit_wiki') && !$Locked) { ?>
<a href="collages.php?action=edit&amp;collageid=<?=$CollageID?>">[Edit description]</a>
<? }
if(has_bookmarked('collage', $CollageID)) {

View File

@ -2,8 +2,8 @@
$CollageID = $_GET['collageid'];
if(!is_number($CollageID)) { error(0); }
$DB->query("SELECT Name, Description, TagList, UserID, CategoryID, Locked, MaxGroups, MaxGroupsPerUser FROM collages WHERE ID='$CollageID'");
list($Name, $Description, $TagList, $UserID, $CategoryID, $Locked, $MaxGroups, $MaxGroupsPerUser) = $DB->next_record();
$DB->query("SELECT Name, Description, TagList, UserID, CategoryID, Locked, MaxGroups, MaxGroupsPerUser, Featured FROM collages WHERE ID='$CollageID'");
list($Name, $Description, $TagList, $UserID, $CategoryID, $Locked, $MaxGroups, $MaxGroupsPerUser, $Featured) = $DB->next_record();
$TagList = implode(', ', explode(' ', $TagList));
if($CategoryID == 0 && $UserID!=$LoggedUser['ID'] && !check_perms('site_collages_delete')) { error(403); }
@ -17,7 +17,7 @@
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="collageid" value="<?=$CollageID?>" />
<table id="edit_collage">
<? if (check_perms('site_collages_delete')) { ?>
<? if (check_perms('site_collages_delete') || ($CategoryID == 0 && $UserID == $LoggedUser['ID'] && check_perms('site_collages_renamepersonal'))) { ?>
<tr>
<td class="label">Name</td>
<td><input type="text" name="name" size="60" value="<?=$Name?>" /></td>
@ -47,7 +47,13 @@
<td class="label">Tags</td>
<td><input type="text" name="tags" size="60" value="<?=$TagList?>" /></td>
</tr>
<? if(check_perms('site_collages_delete')) { ?>
<? if($CategoryID == 0) { ?>
<tr>
<td class="label">Featured</td>
<td><input type="checkbox" name="featured" <?=($Featured?'checked':'')?> /></td>
</tr>
<? }
if(check_perms('site_collages_delete')) { ?>
<tr>
<td class="label">Locked</td>
<td><input type="checkbox" name="locked" <?if($Locked) { ?>checked="checked" <? }?>/></td>

View File

@ -26,7 +26,18 @@
$DB->query("UPDATE collages SET Description='".db_string($_POST['description'])."', TagList='$TagList' WHERE ID='$CollageID'");
if (check_perms('site_collages_delete')) {
if (!check_perms('site_collages_delete') && ($CategoryID == 0 && $UserID == $LoggedUser['ID'] && check_perms('site_collages_renamepersonal'))) {
if(!stristr($_POST['name'], $LoggedUser['Username'])) {
error("Your personal collage's title must include your username.");
}
}
if (isset($_POST['featured']) && $CategoryID == 0 && (($LoggedUser['ID'] == $UserID && check_perms('site_collages_personal')) || check_perms('site_collages_delete'))) {
$DB->query("UPDATE collages SET Featured=0 WHERE CategoryID=0 and UserID=$UserID");
$DB->query("UPDATE collages SET Featured=1 WHERE ID=$CollageID");
}
if (check_perms('site_collages_delete') || ($CategoryID == 0 && $UserID == $LoggedUser['ID'] && check_perms('site_collages_renamepersonal'))) {
$DB->query("UPDATE collages SET Name='".db_string($_POST['name'])."' WHERE ID='$CollageID'");
}

View File

@ -65,14 +65,17 @@
if(!check_perms('site_collages_personal')) {
error(403);
}
$DB->query("SELECT ID FROM collages WHERE UserID='$LoggedUser[ID]' AND CategoryID='0' AND Deleted='0'");
if($DB->record_count() > 0) {
$DB->query("SELECT COUNT(ID) FROM collages WHERE UserID='$LoggedUser[ID]' AND CategoryID='0' AND Deleted='0'");
list($CollageCount) = $DB->next_record();
if($CollageCount >= $LoggedUser['Permissions']['MaxCollages']) {
list($CollageID) = $DB->next_record();
header('Location: collage.php?id='.$CollageID);
die();
}
$DB->query("INSERT INTO collages (Name, Description, CategoryID, UserID) VALUES ('$LoggedUser[Username]\'s personal collage', 'Personal collage for $LoggedUser[Username]. The first 5 albums will appear on his or her [url=http:\/\/".NONSSL_SITE_URL."\/user.php?id=$LoggedUser[ID]]profile[\/url].', '0', $LoggedUser[ID])");
$NameStr = ($CollageCount > 0)?" no. " . ($CollageCount + 1):'';
$DB->query("INSERT INTO collages (Name, Description, CategoryID, UserID) VALUES ('$LoggedUser[Username]\'s personal collage$NameStr', 'Personal collage for $LoggedUser[Username]. The first 5 albums will appear on his or her [url=http:\/\/".NONSSL_SITE_URL."\/user.php?id=$LoggedUser[ID]]profile[\/url].', '0', $LoggedUser[ID])");
$CollageID = $DB->inserted_id();
header('Location: collage.php?id='.$CollageID);
die();

View File

@ -1,25 +1,36 @@
<?
show_header('Create a collage');
if (!check_perms('site_collages_renamepersonal')) {
$ChangeJS = 'OnChange="if ( this.options[this.selectedIndex].value == \'0\') { namebox.style.display = \'none\'; personal.style.display = \'inline\'; } else { namebox.style.display = \'inline\'; personal.style.display = \'none\'; }"';
}
?>
<div class="thin">
<form action="collages.php" method="post">
<form action="collages.php" method="post" name="newcollage">
<input type="hidden" name="action" value="new_handle" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<table id="new_collage">
<tr>
<table>
<tr id="collagename">
<td class="label"><strong>Name</strong></td>
<td>
<input type="text" id="name" name="name" size="60" />
<input type="text" name="name" size="60" id="namebox" />
<span id="personal" style="display: none; font-style: oblique"><strong><?=$LoggedUser['Username']?>'s personal collage</strong></span>
</td>
</tr>
<tr>
<td class="label"><strong>Category</strong></td>
<td>
<select name="category">
<select name="category" <?=$ChangeJS?>>
<?
array_shift($CollageCats);
foreach($CollageCats as $CatID=>$CatName) { ?>
<option value="<?=$CatID+1?>"><?=$CatName?></option>
<? }
$DB->query("SELECT COUNT(ID) FROM collages WHERE UserID='$LoggedUser[ID]' AND CategoryID='0' AND Deleted='0'");
list($CollageCount) = $DB->next_record();
if(($CollageCount < $LoggedUser['Permissions']['MaxCollages']) && check_perms('site_collages_personal')) { ?>
<option value="0">Personal</option>
<? } ?>
</select>
<br />
@ -30,7 +41,10 @@
<li><strong>Label</strong> - A collage containing all the releases of a particular record label</li>
<li><strong>Staff picks</strong> - A list of recommendations picked by the staff on special occasions</li>
<li><strong>Charts</strong> - A collage containing all the releases that comprise a certain chart (Billboard Top 100, Pitchfork Top 100, What.cd Top 10 for a certain week)</li>
<?
if(($CollageCount < $LoggedUser['Permissions']['MaxCollages']) && check_perms('site_collages_personal')) { ?>
<li><strong>Personal</strong> - You can put whatever your want here. It's your personal collage.</li>
<? } ?>
</ul>
</td>
</tr>

View File

@ -4,12 +4,36 @@
include(SERVER_ROOT.'/classes/class_validate.php');
$Val = new VALIDATE;
$Val->SetFields('name', '1','string','The name must be between 3 and 100 characters',array('maxlength'=>100, 'minlength'=>3));
$P = array();
$P = db_array($_POST);
if ($P['category'] > 0 || check_perms('site_collages_renamepersonal')) {
$Val->SetFields('name', '1','string','The name must be between 3 and 100 characters',array('maxlength'=>100, 'minlength'=>3));
} else {
// Get a collage name and make sure it's unique
$name = $LoggedUser['Username']."'s personal collage";
$P['name'] = db_string($name);
$DB->query("SELECT ID FROM collages WHERE Name='".$P['name']."'");
$i = 2;
while ($DB->record_count() != 0) {
$P['name'] = db_string($name." no. $i");
$DB->query("SELECT ID FROM collages WHERE Name='".$P['name']."'");
$i++;
}
}
$Val->SetFields('description', '1','string','The description must be at least 10 characters',array('maxlength'=>65535, 'minlength'=>10));
$Err = $Val->ValidateForm($_POST);
$P = array();
$P = db_array($_POST);
if ($P['category'] == '0') {
$DB->query("SELECT COUNT(ID) FROM collages WHERE UserID='$LoggedUser[ID]' AND CategoryID='0' AND Deleted='0'");
list($CollageCount) = $DB->next_record();
if (($CollageCount >= $LoggedUser['Permissions']['MaxCollages']) || !check_perms('site_collages_personal')) {
$Err = 'You may not create a personal collage.';
} elseif (check_perms('site_collages_renamepersonal') && !stristr($P['name'], $LoggedUser['Username'])) {
$Err = 'Your personal collage\'s title must include your username.';
}
}
if(!$Err) {
$DB->query("SELECT ID,Deleted FROM collages WHERE Name='$P[name]'");
@ -24,7 +48,7 @@
}
if(!$Err) {
if(empty($CollageCats[$P['category']]) || $P['category'] == 0) {
if(empty($CollageCats[$P['category']])) {
$Err = 'Please select a category';
}
}

View File

@ -7,8 +7,8 @@
error(404);
}
$DB->query("SELECT Name, UserID FROM collages WHERE ID='$CollageID'");
list($Name, $UserID) = $DB->next_record();
$DB->query("SELECT Name, CategoryID, UserID FROM collages WHERE ID='$CollageID'");
list($Name, $CategoryID, $UserID) = $DB->next_record();
if(!check_perms('site_collages_delete') && $UserID != $LoggedUser['ID']) {
error(403);
@ -24,7 +24,8 @@
$Cache->delete_value('torrents_details_'.$GroupID);
}
if (preg_match("/personal collage$/", $Name) > 0) {
//Personal collages have CategoryID 0
if ($CategoryID == 0) {
$DB->query("DELETE FROM collages WHERE ID='$CollageID'");
$DB->query("DELETE FROM collages_torrents WHERE CollageID='$CollageID'");
$DB->query("DELETE FROM collages_comments WHERE CollageID='$CollageID'");

View File

@ -7,10 +7,11 @@
list($Page,$Limit) = page_limit(POSTS_PER_PAGE);
// Searching for posts by a specific user
// What are we looking for? Let's make sure it isn't dangerous.
if($LoggedUser['CustomForums']) {
unset($LoggedUser['CustomForums']['']);
$RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0));
$PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1));
}
if((isset($_GET['type']) && $_GET['type'] == 'body')) {
$Type = 'body';
@ -48,11 +49,33 @@
}
}
// Searching for posts in a specific thread
if(!empty($_GET['threadid'])) {
$ThreadID = db_string($_GET['threadid']);
$Type='body';
$SQL = "SELECT Title FROM forums_topics AS t
JOIN forums AS f ON f.ID=t.ForumID
WHERE f.MinClassRead <= '$LoggedUser[Class]'
AND t.ID=$ThreadID";
if(!empty($RestrictedForums)) {
$SQL .= " AND f.ID NOT IN ('".$RestrictedForums."')";
}
$DB->query($SQL);
if (list($Title) = $DB->next_record()) {
$Title = " &gt; <a href=\"forums.php?action=viewthread&threadid=$ThreadID\">$Title</a>";
} else {
$Title = '';
$ThreadID = '';
}
} else {
$ThreadID = '';
}
// Let's hope we got some results - start printing out the content.
show_header('Forums'.' > '.'Search');
?>
<div class="thin">
<h2><a href="forums.php">Forums</a> &gt; Search</h2>
<h2><a href="forums.php">Forums</a> &gt; Search<?=$Title?></h2>
<form action="" method="get">
<input type="hidden" name="action" value="search" />
<table cellpadding="6" cellspacing="1" border="0" class="border" width="100%">
@ -62,6 +85,8 @@
<input type="text" name="search" size="70" value="<?=display_str($Search)?>" />
</td>
</tr>
<?
if (empty($ThreadID)) { ?>
<tr>
<td><strong>Search in:</strong></td>
<td>
@ -77,53 +102,56 @@
<table class="cat_list">
<?// List of forums
$Open = false;
$LastCategoryID = -1;
$Columns = 0;
<?// List of forums
$Open = false;
$LastCategoryID = -1;
$Columns = 0;
foreach($Forums as $Forum) {
if (!check_forumperm($Forum['ID'])) {
continue;
}
$Columns++;
if ($Forum['CategoryID'] != $LastCategoryID) {
$LastCategoryID = $Forum['CategoryID'];
if($Open) {
if ($Columns%5) { ?>
foreach($Forums as $Forum) {
if (!check_forumperm($Forum['ID'])) {
continue;
}
$Columns++;
if ($Forum['CategoryID'] != $LastCategoryID) {
$LastCategoryID = $Forum['CategoryID'];
if($Open) {
if ($Columns%5) { ?>
<td colspan="<?=(5-($Columns%5))?>"></td>
<?
}
}
?>
</tr>
<?
}
$Columns = 0;
$Open = true;
}
$Columns = 0;
$Open = true;
?>
<tr>
<td colspan="5"><strong><?=$ForumCats[$Forum['CategoryID']]?></strong></td>
</tr>
<tr>
<? } elseif ($Columns%5 == 0) { ?>
<? } elseif ($Columns%5 == 0) { ?>
</tr>
<tr>
<? } ?>
<? } ?>
<td>
<input type="checkbox" name="forums[]" value="<?=$Forum['ID']?>" id="forum_<?=$Forum['ID']?>"<? if(isset($_GET['forums']) && in_array($Forum['ID'], $_GET['forums'])) { echo ' checked="checked"';} ?> />
<label for="forum_<?=$Forum['ID']?>"><?=$Forum['Name']?></label>
</td>
<? }
if ($Columns%5) { ?>
<? }
if ($Columns%5) { ?>
<td colspan="<?=(5-($Columns%5))?>"></td>
<? } ?>
<? } ?>
</tr>
</table>
</td>
</tr>
<? } else { ?>
<input type="hidden" name="threadid" value="<?=$ThreadID?>" />
<? } ?>
<tr>
<td><strong>Username:</strong></td>
<td>
@ -143,25 +171,15 @@
// Break search string down into individual words
$Words = explode(' ', db_string($Search));
if($LoggedUser['CustomForums']) {
unset($LoggedUser['CustomForums']['']);
$RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0));
$PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1));
}
if($Type == 'body') {
$sql = "SELECT SQL_CALC_FOUND_ROWS
t.ID,
t.Title,
".(!empty($ThreadID) ? "SUBSTRING_INDEX(p.Body, ' ', 40)":"t.Title").",
t.ForumID,
f.Name,
p.AddedTime,
p.ID,
CEIL((SELECT COUNT(ID)
FROM forums_posts
WHERE forums_posts.TopicID = p.TopicID
AND forums_posts.ID <= p.ID))
AS Post
p.ID
FROM forums_posts AS p
JOIN forums_topics AS t ON t.ID=p.TopicID
JOIN forums AS f ON f.ID=t.ForumID
@ -191,6 +209,9 @@
if(isset($AuthorID)) {
$sql.=" AND p.AuthorID='$AuthorID' ";
}
if(!empty($ThreadID)) {
$sql.=" AND t.ID='$ThreadID' ";
}
$sql .= "ORDER BY p.AddedTime DESC LIMIT $Limit";
@ -240,7 +261,7 @@
<table cellpadding="6" cellspacing="1" border="0" class="border" width="100%">
<tr class="colhead">
<td>Forum</td>
<td>Topic</td>
<td><?=(!empty($ThreadID))?'Post Begins':'Topic'?></td>
<td>Time</td>
</tr>
<? if($DB->record_count() == 0) { ?>
@ -248,7 +269,7 @@
<? }
$Row = 'a'; // For the pretty colours
while(list($ID, $Title, $ForumID, $ForumName, $LastTime, $PostID, $Post) = $DB->next_record()) {
while(list($ID, $Title, $ForumID, $ForumName, $LastTime, $PostID) = $DB->next_record()) {
$Row = ($Row == 'a') ? 'b' : 'a';
// Print results
?>
@ -257,9 +278,13 @@
<a href="forums.php?action=viewforum&amp;forumid=<?=$ForumID?>"><?=$ForumName?></a>
</td>
<td>
<a href="forums.php?action=viewthread&amp;threadid=<?=$ID?>"><?=cut_string($Title, 80) ?></a>
<? if($Type == 'body') { ?>
<span style="float: right;" class="last_read" title="Jump to post"><a href="forums.php?action=viewthread&amp;threadid=<?=$ID?><? if(!empty($PostID) && !empty($Post)) { echo '&amp;post='.$Post.'#post'.$PostID; } ?>"></a></span>
<? if(empty($ThreadID)) { ?>
<a href="forums.php?action=viewthread&amp;threadid=<?=$ID?>"><?=cut_string($Title, 80); ?></a>
<? } else { ?>
<?=cut_string($Title, 80); ?>
<? }
if ($Type == 'body') { ?>
<span style="float: right;" class="last_read" title="Jump to post"><a href="forums.php?action=viewthread&amp;threadid=<?=$ID?><? if(!empty($PostID)) { echo '&amp;postid='.$PostID.'#post'.$PostID; } ?>"></a></span>
<? } ?>
</td>
<td>

View File

@ -136,6 +136,26 @@
<div class="center">
<a href="reports.php?action=report&amp;type=thread&amp;id=<?=$ThreadID?>">[Report Thread]</a>
<a href="#" onclick="Subscribe(<?=$ThreadID?>);return false;" id="subscribelink<?=$ThreadID?>">[<?=(in_array($ThreadID, $UserSubscriptions) ? 'Unsubscribe' : 'Subscribe')?>]</a>
<a href="#" onclick="$('#searchthread').toggle(); this.innerHTML = (this.innerHTML == '[Search this Thread]'?'[Hide Search]':'[Search this Thread]'); return false;">[Search this Thread]</a>
</div>
<div id="searchthread" class="hidden center">
<div style="display: inline-block;">
<h3>Search this thread:</h3>
<form action="forums.php" method="get">
<table cellpadding="6" cellspacing="1" border="0" class="border">
<input type="hidden" name="action" value="search" />
<input type="hidden" name="threadid" value="<?=$ThreadID?>" />
<tr>
<td><strong>Search for:</strong></td><td><input type="text" id="searchbox" name="search" size="70" /></td>
</tr>
<tr>
<td><strong>Username:</strong></td><td><input type="text" id="username" name="user" size="70" /></td>
</tr>
<tr><td colspan="2" style="text-align: center"><input type="submit" name="submit" value="Search" /></td></tr>
</table>
</form>
<br />
</div>
</div>
<?
$Pages=get_pages($Page,$ThreadInfo['Posts'],$PerPage,9);

View File

@ -156,7 +156,9 @@
</tr>
<? } ?>
</table>
<input type="submit" value="Delete message(s)" />
<input type="submit" name="read" value="Mark as read" />&nbsp;
<input type="submit" name="unread" value="Mark as unread" />&nbsp;
<input type="submit" name="delete" value="Delete message(s)" />
</form>
<? } ?>
</div>

View File

@ -25,13 +25,20 @@
error(0);
}
$DB->query("UPDATE pm_conversations_users SET
InInbox='0',
InSentbox='0',
Sticky='0',
UnRead='0'
WHERE ConvID IN($ConvIDs) AND UserID=$UserID");
if (isset($_POST['delete'])) {
$DB->query("UPDATE pm_conversations_users SET
InInbox='0',
InSentbox='0',
Sticky='0',
UnRead='0'
WHERE ConvID IN($ConvIDs) AND UserID=$UserID");
} elseif (isset($_POST['unread'])) {
$DB->query("UPDATE pm_conversations_users SET Unread='1'
WHERE ConvID IN($ConvIDs) AND UserID=$UserID");
} elseif (isset($_POST['read'])) {
$DB->query("UPDATE pm_conversations_users SET Unread='0'
WHERE ConvID IN($ConvIDs) AND UserID=$UserID");
}
$Cache->delete_value('inbox_new_'.$UserID);
header('Location: inbox.php');

View File

@ -79,6 +79,23 @@ function next_hour() {
//------------- Delete unpopular tags -----------------------------------//
$DB->query("DELETE FROM torrents_tags WHERE NegativeVotes>PositiveVotes");
//------------- 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");
while (list($UserID) = $DB->next_record()) {
$Cache->delete_value('users_tokens_'.$UserID[0]);
}
$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");
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");
/*************************************************************************\
@ -642,7 +659,7 @@ function next_hour() {
);
foreach ($TorrentIDs as $TorrentID) {
list($ID, $GroupID, $Name, $ArtistName, $LastAction, $Format, $Encoding, $UserID) = $TorrentID;
list($ID, $GroupID, $Name, $ArtistName, $LastAction, $Format, $Encoding, $UserID, $Media) = $TorrentID;
if (array_key_exists($UserID, $InactivityExceptionsMade) && (time() < $InactivityExceptionsMade[$UserID])) {
// don't delete the torrent!
continue;
@ -651,16 +668,26 @@ function next_hour() {
$Name = $ArtistName.' - '.$Name;
}
if($Format && $Encoding) {
$Name.=' ['.$Format.' / '.$Encoding.']';
$Name.=' ['.(empty($Media)?'':"$Media / ").$Format.' / '.$Encoding.']';
}
delete_torrent($ID, $GroupID);
$LogEntries[] = "Torrent ".$ID." (".$Name.") was deleted for inactivity (unseeded)";
send_pm($UserID,0,db_string('One of your torrents has been deleted for inactivity'), db_string("The torrent ".$Name." was deleted for being unseeded. Since it didn't break any rules (we hope), you can feel free to re-upload it."));
if (!array_key_exists($UserID, $DeleteNotes))
$DeleteNotes[$UserID] = array('Count' => 0, 'Msg' => '');
$DeleteNotes[$UserID]['Msg'] .= "\n$Name";
$DeleteNotes[$UserID]['Count']++;
++$i;
}
foreach($DeleteNotes as $UserID => $MessageInfo){
$Singular = ($MessageInfo['Count'] == 1) ? true : false;
send_pm($UserID,0,db_string($MessageInfo['Count'].' of your torrents '.($Singular?'has':'have').' been deleted for inactivity'), db_string(($Singular?'One':'Some').' of you torrents '.($Singular?'was':'were').' deleted for being unseeded. Since '.($Singular?'it':'they').' didn\'t break any rules (we hope), you can feel free to re-upload '.($Singular?'it':'them').'.\n\nThe following torrent'.($Singular?' was':'s were').' deleted:'.$MessageInfo['Msg']));
}
unset($DeleteNotes);
if(count($LogEntries) > 0) {
$Values = "('".implode("', '".$sqltime."'), ('",$LogEntries)."', '".$sqltime."')";
$DB->query('INSERT INTO log (Message, Time) VALUES '.$Values);
@ -846,8 +873,48 @@ function next_hour() {
(".$HistoryID.", ".$i.", ".$TorrentID.", '".db_string($TitleString)."', '".db_string($TagString)."')");
$i++;
}
// Send warnings to uploaders of torrents that will be deleted this week
$DB->query("SELECT
t.ID,
t.GroupID,
tg.Name,
t.Format,
t.Encoding,
t.UserID
FROM torrents AS t
JOIN torrents_group AS tg ON tg.ID = t.GroupID
JOIN users_info AS u ON u.UserID = t.UserID
LEFT JOIN artists_group AS ag ON ag.ArtistID = tg.ArtistID
WHERE t.last_action < NOW() - INTERVAL 20 DAY
AND t.last_action != 0
AND u.UnseededAlerts = '1'
ORDER BY t.last_action ASC");
$TorrentIDs = $DB->to_array();
$TorrentAlerts = array();
foreach ($TorrentIDs as $TorrentID) {
list($ID, $GroupID, $Name, $Format, $Encoding, $UserID) = $TorrentID;
if (array_key_exists($UserID, $InactivityExceptionsMade) && (time() < $InactivityExceptionsMade[$UserID])) {
// don't notify exceptions
continue;
}
if (!array_key_exists($UserID, $TorrentAlerts))
$TorrentAlerts[$UserID] = array('Count' => 0, 'Msg' => '');
$ArtistName = display_artists(get_artist($GroupID), false, false, false);
if($ArtistName) {
$Name = $ArtistName.' - '.$Name;
}
if($Format && $Encoding) {
$Name.=' ['.$Format.' / '.$Encoding.']';
}
$TorrentAlerts[$UserID]['Msg'] .= "\n[url=http://".NONSSL_SITE_URL."/torrents.php?torrentid=$ID]".$Name."[/url]";
$TorrentAlerts[$UserID]['Count']++;
}
foreach($TorrentAlerts as $UserID => $MessageInfo){
send_pm($UserID, 0, db_string('Unseeded torrent notification'), db_string($MessageInfo['Count']." of your upload".($MessageInfo['Count']>1?'s':'')." will be deleted for inactivity soon. Unseeded torrents are deleted after 4 weeks. If you still have the files, you can seed your uploads by ensuring the torrents are in your client and that they aren't stopped. You can view the time that a torrent has been unseeded by clicking on the torrent description line and looking for the \"Last active\" time. For more information, please go [url=/wiki.php?action=article&id=663]here[/url].\n\nThe following torrent".($MessageInfo['Count']>1?'s':'')." will be removed for inactivity:".$MessageInfo['Msg']."\n\nIf you no longer wish to recieve these notifications, please disable them in your profile settings."));
}
}
}
/*************************************************************************\

View File

@ -17,7 +17,7 @@
$_REQUEST['action'] = $argv[1];
} else {
if(empty($_REQUEST['action']) || $_REQUEST['action'] != "public_sandbox") {
if(empty($_REQUEST['action']) || ($_REQUEST['action'] != "public_sandbox" && $_REQUEST['action'] != "ocelot")) {
enforce_login();
}
}

View File

@ -0,0 +1,22 @@
<?
$Key = $_REQUEST['key'];
$Type = $_REQUEST['type'];
if (($Key != TRACKER_SECRET) || ($_SERVER['REMOTE_ADDR'] != TRACKER_HOST && $_SERVER['REMOTE_HOST'] != TRACKER_HOST)) {
error(403);
}
switch ($Type) {
case 'expiretoken':
$TorrentID = $_REQUEST['torrentid'];
$UserID = $_REQUEST['userid'];
if (!is_number($TorrentID) || !is_number($UserID)) {
error(403);
}
$DB->query("UPDATE users_freeleeches SET Expired=TRUE WHERE UserID=$UserID AND TorrentID=$TorrentID");
$Cache->delete_value('users_tokens_'.$UserID);
break;
}
?>

View File

@ -11,19 +11,50 @@
$sql .= " AND can_leech = 1";
}
$DB->query($sql);
$sql = "SELECT ID FROM users_main WHERE Enabled = '1'";
if (!isset($_REQUEST['leechdisabled'])) {
$sql .= " AND can_leech = 1";
}
$DB->query($sql);
while (list($UserID) = $DB->next_record()) {
$Cache->delete_value('user_info_heavy_'.$UserID);
}
$message = "<strong>$Tokens freeleech tokens added to all enabled users" . (!isset($_REQUEST['leechdisabled'])?' with enabled leeching privs':'') . '.</strong><br /><br />';
} elseif (isset($_REQUEST['cleartokens'])) {
authorize();
$Tokens = $_REQUEST['numtokens'];
if (!is_number($Tokens) || ($Tokens < 0)) { error("Please enter a valid number of tokens."); }
if (isset($_REQUEST['onlydrop'])) {
$Where = "WHERE FLTokens > $Tokens";
} elseif (!isset($_REQUEST['leechdisabled'])) {
$Where = "WHERE (Enabled = '1' AND can_leech = 1) OR FLTokens > $Tokens";
} else {
$Where = "WHERE Enabled = '1' OR FLTokens > $Tokens";
}
$DB->query("SELECT ID FROM users_main $Where");
$Users = $DB->to_array();
$DB->query("UPDATE users_main SET FLTokens = $Tokens $Where");
foreach ($Users as $UserID) {
list($UserID) = $UserID;
$Cache->delete_value('user_info_heavy_'.$UserID);
}
$where = "";
} elseif (isset($_REQUEST['expire'])) {
$Tokens = $_REQUEST['tokens'];
foreach ($Tokens as $Token) {
list($UserID, $TorrentID) = explode(',', $Token);
if (empty($UserID) || empty($TorrentID)) { continue; }
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);
if (!isset($_REQUEST['ocelot'])) { update_tracker('remove_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $UserID)); }
update_tracker('remove_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $UserID));
}
}
}
@ -45,6 +76,18 @@
<input type="submit" name="addtokens" value="Add tokens">
</form>
</div>
<br />
<div class="box pad" style="margin-left: auto; margin-right: auto; text-align:center; max-width: 40%">
<?=$message?>
<form action="" method="post">
<input type="hidden" name="action" value="tokens" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
Tokens to set: <input type="text" name="numtokens" size="5" style="text-align: right" value="0"><br /><br />
<span id="droptokens" class=""><label for="onlydrop">Only affect users with at least this many tokens: </label><input type="checkbox" id="onlydrop" name="onlydrop" value="1" onChange="$('#disabled').toggle();return true;"></span><br />
<span id="disabled" class=""><label for="leechdisabled">Also add tokens (as needed) to leech disabled users: </label><input type="checkbox" id="leechdisabled" name="leechdisabled" value="1" onChange="$('#droptokens').toggle();return true;"></span><br /><br />
<input type="submit" name="cleartokens" value="Set token total">
</form>
</div>
<?
} else {
show_header('FL Token Abusers');
@ -85,7 +128,9 @@
<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>
@ -109,7 +154,9 @@
}
?>
<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>
@ -117,12 +164,14 @@
<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>

View File

@ -27,7 +27,7 @@
<tr><td><a href="tools.php?action=recommend">Vanity House additions</a></td></tr>
<? } if (check_perms('users_mod')) { ?>
<tr><td><a href="tools.php?action=email_blacklist">Email Blacklist</a></td></tr>
<!--<tr><td><a href="tools.php?action=tokens">Manage freeleech tokens</a></td></tr>-->
<tr><td><a href="tools.php?action=tokens">Manage freeleech tokens</a></td></tr>
<? } ?>
</table>

View File

@ -35,6 +35,13 @@ function header_link($SortKey,$DefaultWay="desc") {
return "torrents.php?order_way=".$NewWay."&amp;order_by=".$SortKey."&amp;".get_url(array('order_way','order_by'));
}
$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);
}
// Search by infohash
if(!empty($_GET['searchstr']) || !empty($_GET['groupname'])) {
if(!empty($_GET['searchstr'])) {
@ -879,7 +886,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>
[<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['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>]
</span>
&raquo; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=torrent_info($Data)?></a>
@ -903,6 +915,8 @@ function header_link($SortKey,$DefaultWay="desc") {
$DisplayName .= ' <strong>Freeleech!</strong>';
} elseif($Data['FreeTorrent'] == '2') {
$DisplayName .= ' <strong>Neutral Leech!</strong>';
} elseif(in_array($TorrentID, $TokenTorrents)) {
$DisplayName .= $AddExtra.'<strong>Personal Freeleech!</strong>';
}
?>
<tr class="torrent">
@ -912,7 +926,12 @@ function header_link($SortKey,$DefaultWay="desc") {
</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) && ($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="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" title="Report">RP</a>]
</span>
<?=$DisplayName?>

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)) {
if(!is_array($Info) || !array_key_exists('PlainArtists', $Info) || !array_key_exists('info_hash', $Info)) {
$DB->query("SELECT
t.Media,
t.Format,
@ -48,7 +48,7 @@
header('Location: log.php?search='.$TorrentID);
die();
}
$Info = array($DB->next_record(MYSQLI_NUM, array(4,5,6)));
$Info = array($DB->next_record(MYSQLI_NUM, array(4,5,6,10)));
$Artists = get_artist($Info[0][4],false);
$Info['Artists'] = display_artists($Artists, false, true);
$Info['PlainArtists'] = display_artists($Artists, false, true, false);
@ -62,34 +62,51 @@
// If he's trying use a token on this, we need to make sure he has one,
// deduct it, add this to the FLs table, and update his cache key.
if ($_REQUEST['usetoken'] && $FreeTorrent == '0' && $LoggedUser['CanLeech'] == '1') {
if ($_REQUEST['usetoken'] && $FreeTorrent == '0') {
if (isset($LoggedUser)) {
$FLTokens = $LoggedUser['FLTokens'];
if ($LoggedUser['CanLeech'] != '1') {
error('You cannot use tokens while leech disabled.');
}
}
else {
$UInfo = user_heavy_info($UserID);
if ($UInfo['CanLeech'] != '1') {
error('You may not use tokens while leech disabled.');
}
$FLTokens = $UInfo['FLTokens'];
}
// First make sure this isn't already FL, and if it is, do nothing
$Data = $Cache->get_value('users_tokens_'.$UserID);
if (empty($Data)) {
$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');
}
if (!in_array($TorrentID, $Data)) {
if (!($LoggedUser['FLTokens'] > 0)) {
if (!in_array($TorrentID, $TokenTorrents)) {
if ($FLTokens <= 0) {
error("You do not have any freeleech tokens left. Please use the regular DL link.");
}
if ($Size >= 1073741824) {
error("This torrent is too large. Please use the regular DL link.");
}
// Let the tracker know about this
if (!update_tracker('add_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $UserID))) {
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");
$Cache->begin_transaction('user_info_heavy_'.$UserID);
$Cache->update_row(false, array('FLTokens'=>($LoggedUser['FLTokens'] - 1)));
$Cache->update_row(false, array('FLTokens'=>($FLTokens - 1)));
$Cache->commit_transaction(0);
$Data[] = $TorrentID;
$Cache->cache_value('users_tokens_'.$UserID, $Data);
// Let the tracker know about this
update_tracker('add_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $LoggedUser['ID']));
$TokenTorrents[] = $TorrentID;
$Cache->cache_value('users_tokens_'.$UserID, $TokenTorrents);
}
}

View File

@ -189,8 +189,9 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
break;
case 'download':
require(SERVER_ROOT.'/sections/torrents/download.php');
require(SERVER_ROOT.'/sections/torrents/download.php');
break;
case 'reply':
enforce_login();
authorize();

View File

@ -18,12 +18,13 @@
i.StyleID,
i.StyleURL,
i.SiteOptions,
i.UnseededAlerts,
p.Level AS Class
FROM users_main AS m
JOIN users_info AS i ON i.UserID = m.ID
LEFT JOIN permissions AS p ON p.ID=m.PermissionID
WHERE m.ID = '".db_string($UserID)."'");
list($Username,$Email,$IRCKey,$Paranoia,$Info,$Avatar,$Country,$StyleID,$StyleURL,$SiteOptions,$Class)=$DB->next_record(MYSQLI_NUM, array(3,9));
list($Username,$Email,$IRCKey,$Paranoia,$Info,$Avatar,$Country,$StyleID,$StyleURL,$SiteOptions,$UnseededAlerts,$Class)=$DB->next_record(MYSQLI_NUM, array(3,9));
if($UserID != $LoggedUser['ID'] && !check_perms('users_edit_profiles', $Class)) {
@ -219,6 +220,13 @@ function checked($Checked) {
<label for="downloadalt">For users whose ISP block the downloading of torrent files</label>
</td>
</tr>
<tr>
<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>
</td>
</tr>
<tr class="colhead_dark">
<td colspan="2">
<strong>User info</strong>

View File

@ -28,6 +28,9 @@
$Delta[$Perm] = $Setting;
}
}
if (!is_number($_POST['maxcollages']) && !empty($_POST['maxcollages'])) { error("Please enter a valid number of extra personal collages"); }
$Delta['MaxCollages'] = $_POST['maxcollages'];
$Cache->begin_transaction('user_info_heavy_'.$UserID);
$Cache->update_row(false, array('CustomPermissions' => $Delta));
$Cache->commit_transaction(0);
@ -37,6 +40,7 @@
}
$Permissions = array_merge($Defaults,$Delta);
$MaxCollages = $Customs['MaxCollages'] + $Delta['MaxCollages'];
function display_perm($Key,$Title) {
global $Defaults, $Permissions;
@ -67,7 +71,15 @@ function reset() {
<div class="box pad">
Before using permissions, please understand that it allows you to both add and remove access to specific features. If you think that to add access to a feature, you need to uncheck everything else, <strong>YOU ARE WRONG</strong>. The checkmarks on the left, which are grayed out, are the standard permissions granted by their class (and donor/artist status), any changes you make to the right side will overwrite this. It's not complicated, and if you screw up, click the defaults link at the top. It will reset the user to their respective features granted by class, then you can check or uncheck the one or two things you want to change. <strong>DO NOT UNCHECK EVERYTHING.</strong> If you need further clarification, ask A9 before using this tool.
</div>
<br />
<form name="permform" id="permform" method="post" action="">
<table class="permission_head">
<tr>
<td class="label">Extra personal collages</td>
<td><input type="text" name="maxcollages" size="5" value="<?=($MaxCollages?$MaxCollages:'0')?>" /></td>
</tr>
</table>
<input type="hidden" name="action" value="permissions" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="id" value="<?=$_REQUEST['userid']?>" />

View File

@ -209,6 +209,7 @@
unset($Options['ShowCacheList']);
$DownloadAlt = (isset($_POST['downloadalt']))? 1:0;
$UnseededAlerts = (isset($_POST['unseededalerts']))? 1:0;
// Information on how the user likes to download torrents is stored in cache
if($DownloadAlt != $LoggedUser['DownloadAlt']) {
@ -241,6 +242,7 @@
i.SiteOptions='".db_string(serialize($Options))."',
i.Info='".db_string($_POST['info'])."',
i.DownloadAlt='$DownloadAlt',
i.UnseededAlerts='$UnseededAlerts',
m.Email='".db_string($_POST['email'])."',
m.IRCKey='".db_string($_POST['irckey'])."',";

View File

@ -86,6 +86,7 @@
m.Enabled,
m.Paranoia,
m.Invites,
m.FLTokens,
m.Title,
m.torrent_pass,
m.can_leech,
@ -110,7 +111,7 @@
header("Location: log.php?search=User+".$UserID);
}
list($Username, $Email, $LastAccess, $IP, $Class, $Uploaded, $Downloaded, $RequiredRatio, $Enabled, $Paranoia, $Invites, $CustomTitle, $torrent_pass, $DisableLeech, $JoinDate, $Info, $Avatar, $Country, $Donor, $Warned, $ForumPosts, $InviterID, $DisableInvites, $InviterName, $RatioWatchEnds, $RatioWatchDownload) = $DB->next_record(MYSQLI_NUM, array(9,11));
list($Username, $Email, $LastAccess, $IP, $Class, $Uploaded, $Downloaded, $RequiredRatio, $Enabled, $Paranoia, $Invites, $FLTokens, $CustomTitle, $torrent_pass, $DisableLeech, $JoinDate, $Info, $Avatar, $Country, $Donor, $Warned, $ForumPosts, $InviterID, $DisableInvites, $InviterName, $RatioWatchEnds, $RatioWatchDownload) = $DB->next_record(MYSQLI_NUM, array(9,11));
}
// Image proxy CTs
@ -186,7 +187,7 @@ function check_paranoia_here($Setting) {
<? }
if (check_perms('users_mod')) {
?>
<!--[<a href="userhistory.php?action=token_history&userid=<?=$UserID?>">FL Tokens</a>]-->
[<a href="userhistory.php?action=token_history&userid=<?=$UserID?>">FL Tokens</a>]
<? } ?>
</div>
@ -219,6 +220,9 @@ 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>
<? } ?>
</ul>
</div>
@ -664,9 +668,11 @@ function check_paranoia_here($Setting) {
<?
}
$DB->query("SELECT ID, Name FROM collages WHERE UserID='$UserID' AND CategoryID='0' AND Deleted='0'");
list($CollageID, $Name) = $DB->next_record();
if($CollageID) {
$DB->query("SELECT ID, Name FROM collages WHERE UserID='$UserID' AND CategoryID='0' AND Deleted='0' ORDER BY Featured DESC, Name ASC");
$Collages = $DB->to_array();
$FirstCol = true;
foreach ($Collages as $CollageInfo) {
list($CollageID, $CName) = $CollageInfo;
$DB->query("SELECT ct.GroupID,
tg.WikiImage,
tg.CategoryID
@ -675,12 +681,18 @@ function check_paranoia_here($Setting) {
WHERE ct.CollageID='$CollageID'
ORDER BY ct.Sort LIMIT 5");
$Collage = $DB->to_array();
?>
<table class="recent" cellpadding="0" cellspacing="0" border="0">
<tr class="colhead">
<td colspan="5"><?=display_str($Name)?> - <a href="collages.php?id=<?=$CollageID?>">see full</a></td>
<tr>
<td colspan="5">
<span style="float:left;">
<?=display_str($CName)?> - <a href="collages.php?id=<?=$CollageID?>">see full</a>
</span>
<span style="float:right;">
<a href="#" onclick="$('#collage<?=$CollageID?>').toggle(); this.innerHTML=(this.innerHTML=='(Hide)'?'(Show)':'(Hide)'); return false;"><?=$FirstCol?'(Hide)':'(Show)'?></a>
</span>
</td>
<tr id="collage<?=$CollageID?>" <?=$FirstCol?'':'class="hidden"'?>>
<? foreach($Collage as $C) {
$Group = get_groups(array($C['GroupID']));
$Group = array_pop($Group['matches']);
@ -697,6 +709,7 @@ function check_paranoia_here($Setting) {
</tr>
</table>
<?
$FirstCol = false;
}
@ -995,12 +1008,12 @@ function check_paranoia_here($Setting) {
<input type="text" size="40" name="MergeStatsFrom" />
</td>
</tr>
<!--<tr>
<tr>
<td class="label">Freeleech Tokens:</td>
<td>
<input type="text" size="5" name="FLTokens" value="<?=$FLTokens?>" />
</td>
</tr>-->
</tr>
<?
}

View File

@ -0,0 +1,6 @@
<?
authorize();
$DB->query("UPDATE users_collage_subs SET LastVisit = NOW() WHERE UserID = ".$LoggedUser['ID']);
$Cache->delete_value('collage_subs_user_new_'.$LoggedUser['ID']);
header('Location: userhistory.php?action=subscribed_collages');
?>

View File

@ -0,0 +1,23 @@
<?
// perform the back end of subscribing to collages
authorize();
if(!is_number($_GET['collageid'])) {
error(0);
}
if(!$UserSubscriptions = $Cache->get_value('collage_subs_user_'.$LoggedUser['ID'])) {
$DB->query('SELECT CollageID FROM users_collage_subs WHERE UserID = '.db_string($LoggedUser['ID']));
$UserSubscriptions = $DB->collect(0);
$Cache->cache_value('collage_subs_user_'.$LoggedUser['ID'],$UserSubscriptions,0);
}
if(($Key = array_search($_GET['collageid'],$UserSubscriptions)) !== FALSE) {
$DB->query('DELETE FROM users_collage_subs WHERE UserID = '.db_string($LoggedUser['ID']).' AND CollageID = '.db_string($_GET['collageid']));
unset($UserSubscriptions[$Key]);
} else {
$DB->query("INSERT IGNORE INTO users_collage_subs (UserID, CollageID, LastVisit) VALUES ($LoggedUser[ID], ".db_string($_GET['collageid']).", NOW())");
array_push($UserSubscriptions, $_GET['collageid']);
}
$Cache->replace_value('collage_subs_user_'.$LoggedUser['ID'], $UserSubscriptions, 0);
$Cache->delete_value('collage_subs_user_new_'.$LoggedUser['ID']);

View File

@ -52,7 +52,19 @@
case 'catchup':
require('catchup.php');
break;
case 'collage_subscribe':
require('collage_subscribe.php');
break;
case 'subscribed_collages':
require('subscribed_collages.php');
break;
case 'catchup_collages':
require('catchup_collages.php');
break;
case 'token_history':
require('token_history.php');
break;
default:
//You trying to mess with me query string? To the home page with you!
header('Location: index.php');

View File

@ -0,0 +1,299 @@
<?
/*
User collage subscription page
*/
if(!check_perms('site_collages_subscribe')) { error(403); }
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
$Text = new TEXT;
show_header('Subscribed collages','browse,collage');
$ShowAll = !empty($_GET['showall']);
if (!$ShowAll) {
$sql = "SELECT c.ID,
c.Name,
c.NumTorrents,
s.LastVisit
FROM collages AS c
JOIN users_collage_subs AS s ON s.CollageID = c.ID
JOIN collages_torrents AS ct ON ct.CollageID = c.ID
WHERE s.UserID = ".$LoggedUser['ID']." AND c.Deleted='0'
AND ct.AddedOn > s.LastVisit
GROUP BY c.ID";
} else {
$sql = "SELECT c.ID,
c.Name,
c.NumTorrents,
s.LastVisit
FROM collages AS c
JOIN users_collage_subs AS s ON s.CollageID = c.ID
LEFT JOIN collages_torrents AS ct ON ct.CollageID = c.ID
WHERE s.UserID = ".$LoggedUser['ID']." AND c.Deleted='0'
GROUP BY c.ID";
}
$DB->query($sql);
$NumResults = $DB->record_count();
$CollageSubs = $DB->to_array();
?>
<div class="thin">
<h2>Subscribed collages<?=($ShowAll?'':' with new additions')?></h2>
<div class="linkbox">
<?
if($ShowAll) {
?>
<br /><br />
[<a href="userhistory.php?action=subscribed_collages&showall=0">Only display collages with new additions</a>]&nbsp;&nbsp;&nbsp;
<?
} else {
?>
<br /><br />
[<a href="userhistory.php?action=subscribed_collages&showall=1">Show all subscribed collages</a>]&nbsp;&nbsp;&nbsp;
<?
}
?>
[<a href="userhistory.php?action=catchup_collages&auth=<?=$LoggedUser['AuthKey']?>">Catch up</a>]&nbsp;&nbsp;&nbsp;
</div>
<?
if(!$NumResults) {
?>
<div class="center">
No subscribed collages<?=($ShowAll?'':' with new additions')?>
</div>
<?
} else {
$HideGroup='';
$ActionTitle="Hide";
$ActionURL="hide";
$ShowGroups = 0;
foreach ($CollageSubs as $Collage) {
unset($TorrentTable);
list($CollageID, $CollageName, $CollageSize, $LastVisit) = $Collage;
$RS = $DB->query("SELECT ct.GroupID,
tg.WikiImage,
tg.CategoryID
FROM collages_torrents AS ct
JOIN torrents_group AS tg ON ct.GroupID = tg.ID
WHERE ct.CollageID = $CollageID
AND ct.AddedOn > '$LastVisit'
ORDER BY ct.AddedOn");
$NewTorrentCount = $DB->record_count();
//$NewTorrents = $DB->to_array();
//$Artists = get_artists($GroupID);
$GroupIDs = $DB->collect('GroupID');
$CollageDataList=$DB->to_array('GroupID', MYSQLI_ASSOC);
if(count($GroupIDs)>0) {
$TorrentList = get_groups($GroupIDs);
$TorrentList = $TorrentList['matches'];
} else {
$TorrentList = array();
}
$Artists = get_artists($GroupIDs);
$Number = 0;
// foreach ($NewTorrents as $TorrentGroup) {
// list($GroupID, $GroupName, $GroupYear, $ReleaseType, $RecordLabel, $CatalogueNumber, $WikiImage) = $TorrentGroup;
// $DisplayName = display_artists($Artists[$GroupID]);
// $AltName=$GroupName;
foreach ($TorrentList as $GroupID => $Group) {
list($GroupID, $GroupName, $GroupYear, $GroupRecordLabel, $GroupCatalogueNumber, $TagList, $ReleaseType, $GroupVanityHouse, $Torrents, $GroupArtists) = array_values($Group);
list($GroupID2, $Image, $GroupCategoryID) = array_values($CollageDataList[$GroupID]);
unset($DisplayName);
$TagList = explode(' ',str_replace('_','.',$TagList));
$TorrentTags = array();
foreach($TagList as $Tag) {
if(!isset($Tags[$Tag])) {
$Tags[$Tag] = array('name'=>$Tag, 'count'=>1);
} else {
$Tags[$Tag]['count']++;
}
$TorrentTags[]='<a href="torrents.php?taglist='.$Tag.'">'.$Tag.'</a>';
}
$PrimaryTag = $TagList[0];
$TorrentTags = implode(', ', $TorrentTags);
$TorrentTags='<br /><div class="tags">'.$TorrentTags.'</div>';
if(count($GroupArtists)>0) {
$DisplayName .= display_artists(array('1'=>$GroupArtists));
}
$DisplayName .= '<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
if($GroupYear>0) { $DisplayName = $DisplayName. ' ['. $GroupYear .']';}
if($GroupVanityHouse) { $DisplayName .= ' [<abbr title="This is a vanity house release">VH</abbr>]'; }
// Start an output buffer, so we can store this output in $TorrentTable
ob_start();
if(count($Torrents)>1 || $GroupCategoryID==1) {
?>
<tr class="group discog" id="group_<?=$CollageID?><?=$GroupID?>">
<td class="center">
<div title="View" id="showimg_<?=$CollageID?><?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
<a href="#" class="show_torrents_link" onclick="toggle_group(<?=$CollageID?><?=$GroupID?>, this, event)" title="Collapse this group"></a>
</div>
</td>
<? if (!$LoggedUser['HideCollage']) {?>
<td style="width: 60px; padding: 0;">
<? if ($Image) { ?>
<img style="max-width: 60px; max-height: 60px" src="<?=$Image?>" alt="<?=$AltName?>" onclick="lightbox.init(this,60);" />
<? } else { ?>
<img src="<?=STATIC_SERVER?>common/noartwork/<?=$CategoryIcons[$GroupCategoryID-1]?>" alt="<?=$Categories[$GroupCategoryID-1]?>" title="<?=$Categories[$GroupCategoryID-1]?>" width="60" height="60" border="0" />
<? } ?>
</td>
<? } ?>
<td colspan="5" style="vertical-align: middle;">
<strong><?=$DisplayName?></strong>
<?=$TorrentTags?>
</td>
</tr>
<?
$LastRemasterYear = '-';
$LastRemasterTitle = '';
$LastRemasterRecordLabel = '';
$LastRemasterCatalogueNumber = '';
$LastMedia = '';
$EditionID = 0;
unset($FirstUnknown);
foreach ($Torrents as $TorrentID => $Torrent) {
if ($Torrent['Remastered'] && !$Torrent['RemasterYear']) {
$FirstUnknown = !isset($FirstUnknown);
}
if($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear ||
$Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber || $FirstUnknown || $Torrent['Media'] != $LastMedia) {
if($Torrent['Remastered'] && $Torrent['RemasterYear'] != 0) {
$EditionID++;
$RemasterName = $Torrent['RemasterYear'];
$AddExtra = " - ";
if($Torrent['RemasterRecordLabel']) { $RemasterName .= $AddExtra.display_str($Torrent['RemasterRecordLabel']); $AddExtra=' / '; }
if($Torrent['RemasterCatalogueNumber']) { $RemasterName .= $AddExtra.display_str($Torrent['RemasterCatalogueNumber']); $AddExtra=' / '; }
if($Torrent['RemasterTitle']) { $RemasterName .= $AddExtra.display_str($Torrent['RemasterTitle']); $AddExtra=' / '; }
$RemasterName .= $AddExtra.display_str($Torrent['Media']);
?>
<tr class="group_torrent groupid_<?=$CollageID?><?=$GroupID?> edition hidden">
<td colspan="<?=($LoggedUser['HideCollage']?'6':'7')?>" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?=$CollageID?><?=$GroupID?>, <?=$EditionID?>, this, event)" title="Collapse this edition">&minus;</a> <?=$RemasterName?></strong></td>
</tr>
<?
} else {
$AddExtra = " / ";
if (!$Torrent['Remastered']) {
$MasterName = "Original Release";
if($GroupRecordLabel) { $MasterName .= $AddExtra.$GroupRecordLabel; $AddExtra=' / '; }
if($GroupCatalogueNumber) { $MasterName .= $AddExtra.$GroupCatalogueNumber; $AddExtra=' / '; }
} else {
$MasterName = "Unknown Release(s)";
}
$MasterName .= $AddExtra.display_str($Torrent['Media']);
?>
<tr class="group_torrent groupid_<?=$CollageID?><?=$GroupID?> edition hidden">
<td colspan="<?=($LoggedUser['HideCollage']?'6':'7')?>" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?=$CollageID?><?=$GroupID?>, <?=$EditionID?>, this, event)" title="Collapse this edition">&minus;</a> <?=$MasterName?></strong></td>
</tr>
<?
}
}
$LastRemasterTitle = $Torrent['RemasterTitle'];
$LastRemasterYear = $Torrent['RemasterYear'];
$LastRemasterRecordLabel = $Torrent['RemasterRecordLabel'];
$LastRemasterCatalogueNumber = $Torrent['RemasterCatalogueNumber'];
$LastMedia = $Torrent['Media'];
?>
<tr class="group_torrent groupid_<?=$CollageID?><?=$GroupID?> edition_<?=$EditionID?> hidden">
<td colspan="<?=($LoggedUser['HideCollage']?'2':'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>]
</span>
&nbsp;&nbsp;&raquo;&nbsp; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=torrent_info($Torrent)?></a>
</td>
<td class="nobr"><?=get_size($Torrent['Size'])?></td>
<td><?=number_format($Torrent['Snatched'])?></td>
<td<?=($Torrent['Seeders']==0)?' class="r00"':''?>><?=number_format($Torrent['Seeders'])?></td>
<td><?=number_format($Torrent['Leechers'])?></td>
</tr>
<?
}
} else {
// Viewing a type that does not require grouping
list($TorrentID, $Torrent) = each($Torrents);
$DisplayName = '<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
if(!empty($Torrent['FreeTorrent'])) {
$DisplayName .=' <strong>Freeleech!</strong>';
}
?>
<tr class="torrent" id="group_<?=$CollageID?><?=$GroupID?>">
<td></td>
<td class="center">
<div title="<?=ucfirst(str_replace('_',' ',$PrimaryTag))?>" class="cats_<?=strtolower(str_replace(array('-',' '),array('',''),$Categories[$GroupCategoryID-1]))?> tags_<?=str_replace('.','_',$PrimaryTag)?>">
</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="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" title="Report">RP</a>]
</span>
<strong><?=$DisplayName?></strong>
<?=$TorrentTags?>
</td>
<td class="nobr"><?=get_size($Torrent['Size'])?></td>
<td><?=number_format($Torrent['Snatched'])?></td>
<td<?=($Torrent['Seeders']==0)?' class="r00"':''?>><?=number_format($Torrent['Seeders'])?></td>
<td><?=number_format($Torrent['Leechers'])?></td>
</tr>
<?
}
$TorrentTable.=ob_get_clean();
} ?>
<!-- I hate that proton is making me do it like this -->
<!--<div class="head colhead_dark" style="margin-top: 8px">-->
<table style="margin-top: 8px">
<tr class="colhead_dark">
<td>
<span style="float:left;">
<strong><a href="collage.php?id=<?=$CollageID?>"><?=$CollageName?></a></strong> (<?=$NewTorrentCount?> new torrent<?=($NewTorrentCount==1?'':'s')?>)
</span>&nbsp;
<span style="float:right;">
<a href="#" onclick="$('#discog_table_<?=$CollageID?>').toggle(); this.innerHTML=(this.innerHTML=='[Hide]'?'[Show]':'[Hide]'); return false;"><?=$ShowAll?'[Show]':'[Hide]'?></a>&nbsp;&nbsp;&nbsp;<a href="#" onclick="CollageSubscribe(<?=$CollageID?>); return false;" id="subscribelink<?=$CollageID?>">[Unsubscribe]</a>
</span>
</td>
</tr>
</table>
<!--</div>-->
<table class="torrent_table <?=$ShowAll?'hidden':''?>" id="discog_table_<?=$CollageID?>">
<tr class="colhead">
<td><!-- expand/collapse --></td>
<? if(!$LoggedUser['HideCollage']) {?>
<td style="padding: 0"><!-- image --></td>
<? } ?>
<td width="70%"><strong>Torrents</strong></td>
<td>Size</td>
<td class="sign"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/snatched.png" alt="Snatches" title="Snatches" /></td>
<td class="sign"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/seeders.png" alt="Seeders" title="Seeders" /></td>
<td class="sign"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/leechers.png" alt="Leechers" title="Leechers" /></td>
</tr>
<?=$TorrentTable?>
</table>
<? } // foreach() ?>
<?
} // else -- if(empty($NumResults)) ?>
</div>
<?
show_footer();
?>

View File

@ -29,7 +29,7 @@
if (!is_number($UserID) || !is_number($TorrentID)) { error(403); }
$DB->query("SELECT info_hash FROM torrents where ID = $TorrentID");
if (list($InfoHash) = $DB->next_record()) {
if (list($InfoHash) = $DB->next_record(MYSQLI_NUM, FALSE)) {
$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));

View File

@ -18,4 +18,17 @@ function Cancel() {
}
}
document.getElementById("choices").raw().value = "";
}
function CollageSubscribe(collageid) {
ajax.get("userhistory.php?action=collage_subscribe&collageid=" + collageid + "&auth=" + authkey, function() {
var subscribeLink = $("#subscribelink" + collageid).raw();
if(subscribeLink) {
if(subscribeLink.firstChild.nodeValue.substr(1,1) == 'U') {
subscribeLink.firstChild.nodeValue = "[Subscribe]";
} else {
subscribeLink.firstChild.nodeValue = "[Unsubscribe]";
}
}
});
}