From 68c4c3d357e57bac222baca64c1a83d1fb31252a Mon Sep 17 00:00:00 2001 From: Git Date: Sat, 9 Jun 2012 08:00:19 +0000 Subject: [PATCH] Empty commit --- classes/script_start.php | 3 +- sections/ajax/bookmarks/torrents.php | 1 + sections/ajax/forum/forum.php | 3 +- sections/ajax/index.php | 2 +- sections/ajax/info.php | 40 +++++- sections/reportsv2/ajax_take_pm.php | 2 +- sections/torrents/notify.php | 190 ++++++++++++--------------- 7 files changed, 129 insertions(+), 112 deletions(-) diff --git a/classes/script_start.php b/classes/script_start.php index b9cb84ac..e5d7c98c 100644 --- a/classes/script_start.php +++ b/classes/script_start.php @@ -2122,7 +2122,7 @@ function get_tags($TagNames) { return($TagIDs); } -function torrent_info($Data) { +function torrent_info($Data, $ShowMedia = false) { $Info = array(); if(!empty($Data['Format'])) { $Info[]=$Data['Format']; } if(!empty($Data['Encoding'])) { $Info[]=$Data['Encoding']; } @@ -2135,6 +2135,7 @@ function torrent_info($Data) { } if(!empty($Data['HasCue'])) { $Info[]='Cue'; } if(!empty($Data['Scene'])) { $Info[]='Scene'; } + if(!empty($Data['Media']) && $ShowMedia) { $Info[]=$Data['Media']; } if($Data['FreeTorrent'] == '1') { $Info[]='Freeleech!'; } if($Data['FreeTorrent'] == '2') { $Info[]='Neutral Leech!'; } if($Data['PersonalFL'] == 1) { $Info[]='Personal Freeleech!'; } diff --git a/sections/ajax/bookmarks/torrents.php b/sections/ajax/bookmarks/torrents.php index d9f1321d..c1947c23 100644 --- a/sections/ajax/bookmarks/torrents.php +++ b/sections/ajax/bookmarks/torrents.php @@ -230,6 +230,7 @@ function compare($X, $Y){ 'tagList' => $Torrent['TagList'], 'releaseType' => $Torrent['ReleaseType'], 'vanityHouse' => $Torrent['VanityHouse'] == 1, + 'image' => $CollageDataList[$Torrent['ID']]['WikiImage'], 'torrents' => $JsonTorrents ); } diff --git a/sections/ajax/forum/forum.php b/sections/ajax/forum/forum.php index 49f94fcc..01cadd81 100644 --- a/sections/ajax/forum/forum.php +++ b/sections/ajax/forum/forum.php @@ -136,7 +136,8 @@ 'lastAuthorId' => $LastAuthorID == null ? 0 : (int) $LastAuthorID, 'lastAuthorName' => $LastAuthorName == null ? "" : $LastAuthorName, '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" ); } diff --git a/sections/ajax/index.php b/sections/ajax/index.php index 73831e23..f7d9f790 100644 --- a/sections/ajax/index.php +++ b/sections/ajax/index.php @@ -72,7 +72,7 @@ require(SERVER_ROOT.'/sections/ajax/info.php'); break; case 'bookmarks': - require(SERVER_ROOT.'/sections/ajax/bookmarks.php'); + require(SERVER_ROOT.'/sections/ajax/bookmarks/index.php'); break; case 'announcements': require(SERVER_ROOT.'/sections/ajax/announcements.php'); diff --git a/sections/ajax/info.php b/sections/ajax/info.php index 93cc9678..5c2a6e77 100644 --- a/sections/ajax/info.php +++ b/sections/ajax/info.php @@ -14,20 +14,56 @@ $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( array( 'status' => 'success', 'response' => array( 'username' => $LoggedUser['Username'], - 'id' => $LoggedUser['ID'], + 'id' => (int) $LoggedUser['ID'], 'authkey'=> $LoggedUser['AuthKey'], 'passkey'=> $LoggedUser['torrent_pass'], + 'notifications' => array( + 'messages'=> (int) $NewMessages, + 'notifications' => (int) $NewNotifications + ), 'userstats' => array( 'uploaded' => (int) $LoggedUser['BytesUploaded'], 'downloaded' => (int) $LoggedUser['BytesDownloaded'], 'ratio' => (float) $Ratio, 'requiredratio' => (float) $LoggedUser['RequiredRatio'], - //'class' => $Class 'class' => $ClassLevels[$LoggedUser['Class']]['Name'] ), ) diff --git a/sections/reportsv2/ajax_take_pm.php b/sections/reportsv2/ajax_take_pm.php index 8ea3c70f..5ef52061 100644 --- a/sections/reportsv2/ajax_take_pm.php +++ b/sections/reportsv2/ajax_take_pm.php @@ -52,7 +52,7 @@ } } else if($Recipient == 'Reporter') { $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 { $Err = "Something went horribly wrong"; } diff --git a/sections/torrents/notify.php b/sections/torrents/notify.php index 127aae01..9a649658 100644 --- a/sections/torrents/notify.php +++ b/sections/torrents/notify.php @@ -4,70 +4,53 @@ define('NOTIFICATIONS_PER_PAGE', 50); 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)) { - $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'); - $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, - g.ID, - g.Name, - 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 + +$UserID = $LoggedUser['ID']; + +$Results = $DB->query("SELECT SQL_CALC_FOUND_ROWS unt.TorrentID, unt.UnRead, unt.FilterID, unf.Label, t.GroupID FROM users_notify_torrents AS unt - 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 torrents_logs_new AS tln ON tln.TorrentID=t.ID - WHERE unt.UserID='$LoggedUser[ID]' - GROUP BY t.ID - ORDER BY t.ID DESC LIMIT $Limit"); + JOIN torrents AS t ON t.ID = unt.TorrentID + LEFT JOIN users_notify_filters AS unf ON unf.ID = unt.FilterID + WHERE unt.UserID=$UserID". + ((!empty($_GET['filterid']) && is_number($_GET['filterid'])) + ? " AND unf.ID='$_GET[filterid]'" + : "")." + ORDER BY TorrentID DESC LIMIT $Limit"); +$GroupIDs = array_unique($DB->collect('GroupID')); + $DB->query('SELECT FOUND_ROWS()'); 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 -$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'); +if(count($GroupIDs)) { + $TorrentGroups = get_groups($GroupIDs); + $TorrentGroups = $TorrentGroups['matches']; + // 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); - -$Pages=get_pages($Page,$TorrentCount,NOTIFICATIONS_PER_PAGE,9); - - - ?>

Latest notifications (clear all) (clear selected) (edit filters)

-record_count()==0) { ?> +record_count()) { ?>
@@ -77,21 +60,28 @@
next_record()) { + while($Result = $DB->next_record(MYSQLI_ASSOC)) { if(!$Result['FilterID']) { $Result['FilterID'] = 0; } if(!isset($FilterGroups[$Result['FilterID']])) { $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); } unset($Result); - foreach($FilterGroups as $ID => $FilterResults) { + $Debug->log_var($FilterGroups, 'Filter groups'); + foreach($FilterGroups as $FilterID => $FilterResults) { ?> -

Matches for (clear) (clear selected)

-
+

+ Matches for '.$FilterResults['FilterLabel'].'' + : 'unknown filter['.$FilterID.']'?> + (clear) + (clear selected) +

+ @@ -107,57 +97,45 @@ ".$GroupInfo['Name'].""; + + if($GroupCategoryID == 1) { + if($GroupInfo['Year'] > 0) { + $DisplayName .= " [$GroupInfo[Year]]"; + } + if($GroupInfo['ReleaseType'] > 0) { + $DisplayName.= " [".$ReleaseTypes[$GroupInfo['ReleaseType']]."]"; + } } - - $DisplayName.= "".$GroupName.""; - - if($GroupCategoryID==1 && $GroupYear>0) { - $DisplayName.= " [$GroupYear]"; - } - if($GroupCategoryID==1 && $ReleaseType>0) { - $DisplayName.= " [".$ReleaseTypes[$ReleaseType]."]"; - } - + // append extra info to torrent title - $ExtraInfo=''; - $AddExtra=''; - if($Format) { $ExtraInfo.=$Format; $AddExtra=' / '; } - if($Encoding) { $ExtraInfo.=$AddExtra.$Encoding; $AddExtra=' / '; } - if($HasLog) { $ExtraInfo.=$AddExtra.'Log'; $AddExtra=' / '; } - if($HasLog && $LogInDB) { $ExtraInfo.=' ('.(int) $LogScore.'%)'; } - 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); + $ExtraInfo = torrent_info($TorrentInfo, true); + $Debug->log_var($ExtraInfo, "Extra torrent info ($TorrentID)"); + + $TagLinks = array(); + if($GroupInfo['TagList'] != '') { + $TorrentTags = explode(' ', $GroupInfo['TagList']); $MainTag = $TorrentTags[0]; foreach ($TorrentTags as $TagKey => $TagName) { - $TagName = str_replace('_','.',$TagName); - $TagLinks[]=''.$TagName.''; + $TagName = str_replace('_', '.', $TagName); + $TagLinks[] = ''.$TagName.''; } $TagLinks = implode(', ', $TagLinks); - $TorrentTags='
'.$TagLinks.'
'; + $TorrentTags = '
'.$TagLinks.'
'; } else { $MainTag = $Categories[$GroupCategoryID-1]; } @@ -171,21 +149,21 @@ [DL 0) && ($Size < 1073741824) - && !in_array($TorrentID, $TokenTorrents) && empty($FreeTorrent) && ($LoggedUser['CanLeech'] == '1')) { ?> + && !in_array($TorrentID, $TokenTorrents) && empty($TorrentInfo['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?> | FL | CL] - - New!'; } ?> + + New!'; } ?> - - - - - - + + + + + +