From 2ab1207afa28a2e337fa1dd2c980eb4f71c6a69c Mon Sep 17 00:00:00 2001 From: Git Date: Sun, 28 Oct 2012 08:00:19 +0000 Subject: [PATCH] Empty commit --- classes/class_cache.php | 7 +- classes/class_text.php | 5 +- classes/class_torrents.php | 94 ++++++++++++---- classes/class_users.php | 21 ---- gazelle.sql | 2 + sections/ajax/takevote.php | 15 ++- sections/artist/artist.php | 80 +++++++------- sections/bookmarks/torrents.php | 30 ++---- sections/collages/collage.php | 78 ++++++-------- sections/comments/torrentcomments.php | 2 +- sections/forums/thread.php | 13 ++- sections/top10/index.php | 4 +- sections/top10/tags.php | 5 +- sections/top10/torrents.php | 16 ++- sections/top10/users.php | 3 +- sections/top10/votes.php | 107 ++++++++++--------- sections/torrents/browse2.php | 9 +- sections/torrents/details.php | 19 +--- sections/torrents/download.php | 24 ----- sections/torrents/notify.php | 2 +- sections/torrents/voter_picks.php | 2 +- sections/user/edit.php | 15 +-- sections/user/takeedit.php | 1 - sections/user/takemoderate.php | 28 ++--- sections/userhistory/quote_notifications.php | 2 +- static/functions/comments.js | 19 +++- static/functions/torrent.js | 16 +++ static/styles/global.css | 7 +- 28 files changed, 323 insertions(+), 303 deletions(-) diff --git a/classes/class_cache.php b/classes/class_cache.php index cd5e8ed1..3334f30d 100644 --- a/classes/class_cache.php +++ b/classes/class_cache.php @@ -40,7 +40,8 @@ class CACHE extends Memcache { 'top10tor_*', 'query_lock_*', 'top10votes_*', - 'similar_albums_*' + 'similar_albums_*', + 'users_snatched_*' ); public $CanClear = false; @@ -129,8 +130,8 @@ public function get_value($Key, $NoCache=false) { } $Return = $this->get($Key); - if ($Return !== false && !$NoCache) { - $this->CacheHits[$Key] = $Return; + if ($Return !== false) { + $this->CacheHits[$Key] = $NoCache ? null : $Return; } $this->Time+=(microtime(true)-$StartTime)*1000; return $Return; diff --git a/classes/class_text.php b/classes/class_text.php index 8bab5048..384c497b 100644 --- a/classes/class_text.php +++ b/classes/class_text.php @@ -658,11 +658,12 @@ private function to_html ($Array) { break; case 'headline': $text = $this->to_html($Block['Val']); + $raw = $this->raw_text($Block['Val']); if(!in_array($Block['Attr'], $this->HeadlineLevels)) { $Str .= sprintf('%1$s%2$s%1$s', str_repeat('=', $Block['Attr'] + 1), $text); } else { - $id = '_' . crc32($text . $this->HeadlineID); - if ($this->InQuotes === 0) $this->Headlines[] = array($Block['Attr'], $text, $id); + $id = '_' . crc32($raw . $this->HeadlineID); + if ($this->InQuotes === 0) $this->Headlines[] = array($Block['Attr'], $raw, $id); $Str .= sprintf('%2$s', ($Block['Attr']+2), $text, $id); $this->HeadlineID++; diff --git a/classes/class_torrents.php b/classes/class_torrents.php index 7d2ddd32..2b522f14 100644 --- a/classes/class_torrents.php +++ b/classes/class_torrents.php @@ -24,7 +24,7 @@ class Torrents { * GroupID, Media, Format, Encoding, RemasterYear, Remastered, * RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber, Scene, * HasLog, HasCue, LogScore, FileCount, FreeTorrent, Size, Leechers, - * Seeders, Snatched, Time, HasFile, PersonalFL + * Seeders, Snatched, Time, HasFile, PersonalFL, IsSnatched * } * } * ExtendedArtists => { @@ -34,14 +34,14 @@ class Torrents { * } */ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true, $Torrents = true) { - global $DB, $Cache; - + global $DB, $Cache, $Debug; + // Make sure there's something in $GroupIDs, otherwise the SQL // will break if (count($GroupIDs) == 0) { return array('matches'=>array(),'notfound'=>array()); } - + $Found = array_flip($GroupIDs); $NotFound = array_flip($GroupIDs); $Key = $Torrents ? 'torrent_group_' : 'torrent_group_light_'; @@ -99,6 +99,7 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true, $Cache->cache_value('torrent_group_light_'.$Torrent['GroupID'], array('ver'=>4, 'd'=>$Found[$Torrent['GroupID']]), 0); } + } else { foreach ($Found as $Group) { $Cache->cache_value('torrent_group_light_'.$Group['ID'], array('ver'=>4, 'd'=>$Found[$Group['ID']]), 0); @@ -129,6 +130,7 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true, array_walk($Group['Torrents'], 'self::torrent_properties'); } } + $Matches = array('matches'=>$Found, 'notfound'=>array_flip($NotFound)); return $Matches; @@ -144,6 +146,7 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true, */ public static function torrent_properties(&$Torrent, $TorrentID) { $Torrent['PersonalFL'] = empty($Torrent['FreeTorrent']) && self::has_token($TorrentID); + $Torrent['IsSnatched'] = self::has_snatched($TorrentID); } @@ -441,7 +444,7 @@ public static function torrent_info($Data, $ShowMedia = false, $ShowEdition = fa if (!empty($Data['RemasterTitle'])) { $EditionInfo[]=$Data['RemasterTitle']; } if (count($EditionInfo)) { $Info[]=implode(' ',$EditionInfo); } } - if ($Data['SnatchedTorrent'] == '1') { $Info[]='Snatched!'; } + if ($Data['IsSnatched']) { $Info[]='Snatched!'; } if ($Data['FreeTorrent'] == '1') { $Info[]='Freeleech!'; } if ($Data['FreeTorrent'] == '2') { $Info[]='Neutral Leech!'; } if ($Data['PersonalFL']) { $Info[]='Personal Freeleech!'; } @@ -505,6 +508,7 @@ public static function freeleech_groups($GroupIDs, $FreeNeutral = 1, $FreeLeechT } } + /** * Check if the logged in user has an active freeleech token * @@ -513,7 +517,7 @@ public static function freeleech_groups($GroupIDs, $FreeNeutral = 1, $FreeLeechT */ public static function has_token($TorrentID) { global $DB, $Cache, $LoggedUser; - if (empty($LoggedUser) || empty($LoggedUser['ID'])) { + if (empty($LoggedUser)) { return false; } @@ -539,7 +543,7 @@ public static function has_token($TorrentID) { */ public static function can_use_token($Torrent) { global $LoggedUser; - if (empty($LoggedUser) || empty($LoggedUser['ID'])) { + if (empty($LoggedUser)) { return false; } return ($LoggedUser['FLTokens'] > 0 @@ -548,23 +552,73 @@ public static function can_use_token($Torrent) { && empty($Torrent['FreeTorrent']) && $LoggedUser['CanLeech'] == '1'); } + - public static function get_snatched_torrents($UserID = false) { + public static function has_snatched($TorrentID) { global $DB, $Cache, $LoggedUser; - if($LoggedUser['ShowSnatched']) { - $UserID = $LoggedUser['ID']; - $SnatchedTorrents = $Cache->get_value('users_snatched_'.$UserID); - if (empty($SnatchedTorrents)) { - $DB->query("SELECT DISTINCT fid as TorrentID FROM xbt_snatched WHERE uid='$UserID'"); - $SnatchedTorrents = array_flip($DB->collect('TorrentID')); - $Cache->cache_value('users_snatched_'.$UserID, $SnatchedTorrents, 86400); + if (empty($LoggedUser) || !$LoggedUser['ShowSnatched']) { + return false; + } + + $UserID = $LoggedUser['ID']; + $Buckets = 64; + $LastBucket = $Buckets - 1; + $BucketID = $TorrentID & $LastBucket; + static $SnatchedTorrents = array(), $LastUpdate = 0; + + if (empty($SnatchedTorrents)) { + $SnatchedTorrents = array_fill(0, $Buckets, false); + $LastUpdate = $Cache->get_value('users_snatched_'.$UserID.'_lastupdate') ?: 0; + } else if (isset($SnatchedTorrents[$BucketID][$TorrentID])) { + return true; + } + + // Torrent was not found in the previously inspected snatch lists + $CurSnatchedTorrents =& $SnatchedTorrents[$BucketID]; + if (empty($CurSnatchedTorrents)) { + $CurTime = time(); + // This bucket hasn't been checked before + $CurSnatchedTorrents = $Cache->get_value('users_snatched_'.$UserID.'_'.$BucketID, true); + if ($CurSnatchedTorrents === false || $CurTime - $LastUpdate > 1800) { + if ($CurSnatchedTorrents === false) { + // Not found in cache. Since we don't have a suitable index, it's faster to update everything + $DB->query("SELECT fid, tstamp AS TorrentID FROM xbt_snatched WHERE uid='$UserID'"); + } elseif (isset($CurSnatchedTorrents[$TorrentID])) { + // Old cache, but torrent is snatched, so no need to update + return true; + } else { + // Old cache, check if torrent has been snatched recently + $DB->query("SELECT fid AS TorrentID FROM xbt_snatched WHERE uid='$UserID' AND tstamp>=".$LastUpdate); + } + $Updated = array(); + while (list($ID) = $DB->next_record(MYSQLI_NUM, false)) { + $CurBucketID = $ID & $LastBucket; + if ($SnatchedTorrents[$CurBucketID] === false) { + $SnatchedTorrents[$CurBucketID] = $Cache->get_value('users_snatched_'.$UserID.'_'.$CurBucketID, true); + if ($SnatchedTorrents[$CurBucketID] === false) { + $SnatchedTorrents[$CurBucketID] = array(); + } + } + $SnatchedTorrents[$CurBucketID][(int)$ID] = true; + $Updated[$CurBucketID] = true; + } + for ($i = 0; $i < $Buckets; $i++) { + if (empty($SnatchedTorrents[$i])) { + $SnatchedTorrents[$i] = $Cache->get_value('users_snatched_'.$UserID.'_'.$i, true); + if ($SnatchedTorrents[$i] === false) { + // No snatched torrents with this bucket number + $SnatchedTorrents[$i] = array(); + $Updated[$i] = true; + } + } + if ($Updated[$i]) { + $Cache->cache_value('users_snatched_'.$UserID.'_'.$i, $SnatchedTorrents[$i], 0); + } + } + $Cache->cache_value('users_snatched_'.$UserID.'_lastupdate', $CurTime, 21600); } } - else { - $SnatchedTorrents = array(); - } - return $SnatchedTorrents; + return isset($CurSnatchedTorrents[$TorrentID]); } - } ?> diff --git a/classes/class_users.php b/classes/class_users.php index d225c195..8ccc6252 100644 --- a/classes/class_users.php +++ b/classes/class_users.php @@ -487,25 +487,4 @@ function bookmark_data ($UserID) return array($K, $GroupIDs, $CollageDataList, $TorrentList); } - - /** - * Returns a list of torrents that a user has spent tokens on - * @global CACHE $Cache - * @global DB_MYSQL $DB - * @param type $UserID - * @return type - */ - function token_torrents ($UserID) - { - global $Cache, $DB; - - $UserID = (int) $UserID; - $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); - } - return $TokenTorrents; - } } diff --git a/gazelle.sql b/gazelle.sql index fe7feed5..ac7d8189 100644 --- a/gazelle.sql +++ b/gazelle.sql @@ -1614,6 +1614,8 @@ CREATE TABLE `xbt_snatched` ( KEY `tstamp` (`tstamp`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +; + SET FOREIGN_KEY_CHECKS = 1; INSERT INTO permissions (ID, Level, Name, `Values`, DisplayStaff) VALUES (15, 1000, 'Sysop', 'a:99:{s:10:\"site_leech\";i:1;s:11:\"site_upload\";i:1;s:9:\"site_vote\";i:1;s:20:\"site_submit_requests\";i:1;s:21:\"site_see_old_requests\";i:1;s:20:\"site_advanced_search\";i:1;s:10:\"site_top10\";i:1;s:19:\"site_advanced_top10\";i:1;s:16:\"site_album_votes\";i:1;s:20:\"site_torrents_notify\";i:1;s:20:\"site_collages_create\";i:1;s:20:\"site_collages_manage\";i:1;s:20:\"site_collages_delete\";i:1;s:23:\"site_collages_subscribe\";i:1;s:22:\"site_collages_personal\";i:1;s:28:\"site_collages_renamepersonal\";i:1;s:19:\"site_make_bookmarks\";i:1;s:14:\"site_edit_wiki\";i:1;s:22:\"site_can_invite_always\";i:1;s:27:\"site_send_unlimited_invites\";i:1;s:22:\"site_moderate_requests\";i:1;s:18:\"site_delete_artist\";i:1;s:20:\"site_moderate_forums\";i:1;s:17:\"site_admin_forums\";i:1;s:23:\"site_forums_double_post\";i:1;s:14:\"site_view_flow\";i:1;s:18:\"site_view_full_log\";i:1;s:28:\"site_view_torrent_snatchlist\";i:1;s:18:\"site_recommend_own\";i:1;s:27:\"site_manage_recommendations\";i:1;s:15:\"site_delete_tag\";i:1;s:23:\"site_disable_ip_history\";i:1;s:14:\"zip_downloader\";i:1;s:10:\"site_debug\";i:1;s:17:\"site_proxy_images\";i:1;s:16:\"site_search_many\";i:1;s:20:\"users_edit_usernames\";i:1;s:16:\"users_edit_ratio\";i:1;s:20:\"users_edit_own_ratio\";i:1;s:17:\"users_edit_titles\";i:1;s:18:\"users_edit_avatars\";i:1;s:18:\"users_edit_invites\";i:1;s:22:\"users_edit_watch_hours\";i:1;s:21:\"users_edit_reset_keys\";i:1;s:19:\"users_edit_profiles\";i:1;s:18:\"users_view_friends\";i:1;s:20:\"users_reset_own_keys\";i:1;s:19:\"users_edit_password\";i:1;s:19:\"users_promote_below\";i:1;s:16:\"users_promote_to\";i:1;s:16:\"users_give_donor\";i:1;s:10:\"users_warn\";i:1;s:19:\"users_disable_users\";i:1;s:19:\"users_disable_posts\";i:1;s:17:\"users_disable_any\";i:1;s:18:\"users_delete_users\";i:1;s:18:\"users_view_invites\";i:1;s:20:\"users_view_seedleech\";i:1;s:19:\"users_view_uploaded\";i:1;s:15:\"users_view_keys\";i:1;s:14:\"users_view_ips\";i:1;s:16:\"users_view_email\";i:1;s:23:\"users_override_paranoia\";i:1;s:12:\"users_logout\";i:1;s:20:\"users_make_invisible\";i:1;s:9:\"users_mod\";i:1;s:13:\"torrents_edit\";i:1;s:15:\"torrents_delete\";i:1;s:20:\"torrents_delete_fast\";i:1;s:18:\"torrents_freeleech\";i:1;s:20:\"torrents_search_fast\";i:1;s:17:\"torrents_hide_dnu\";i:1;s:19:\"torrents_fix_ghosts\";i:1;s:17:\"admin_manage_news\";i:1;s:17:\"admin_manage_blog\";i:1;s:18:\"admin_manage_polls\";i:1;s:19:\"admin_manage_forums\";i:1;s:16:\"admin_manage_fls\";i:1;s:13:\"admin_reports\";i:1;s:26:\"admin_advanced_user_search\";i:1;s:18:\"admin_create_users\";i:1;s:15:\"admin_donor_log\";i:1;s:19:\"admin_manage_ipbans\";i:1;s:9:\"admin_dnu\";i:1;s:17:\"admin_clear_cache\";i:1;s:15:\"admin_whitelist\";i:1;s:24:\"admin_manage_permissions\";i:1;s:14:\"admin_schedule\";i:1;s:17:\"admin_login_watch\";i:1;s:17:\"admin_manage_wiki\";i:1;s:18:\"admin_update_geoip\";i:1;s:21:\"site_collages_recover\";i:1;s:19:\"torrents_add_artist\";i:1;s:13:\"edit_unknowns\";i:1;s:19:\"forums_polls_create\";i:1;s:21:\"forums_polls_moderate\";i:1;s:12:\"project_team\";i:1;s:25:\"torrents_edit_vanityhouse\";i:1;s:23:\"artist_edit_vanityhouse\";i:1;}', '1'), (2, 100, 'User', 'a:7:{s:10:\"site_leech\";i:1;s:11:\"site_upload\";i:1;s:9:\"site_vote\";i:1;s:20:\"site_advanced_search\";i:1;s:10:\"site_top10\";i:1;s:14:\"site_edit_wiki\";i:1;s:19:\"torrents_add_artist\";i:1;}', '0'), (3, 150, 'Member', 'a:10:{s:10:\"site_leech\";i:1;s:11:\"site_upload\";i:1;s:9:\"site_vote\";i:1;s:20:\"site_submit_requests\";i:1;s:20:\"site_advanced_search\";i:1;s:10:\"site_top10\";i:1;s:20:\"site_collages_manage\";i:1;s:19:\"site_make_bookmarks\";i:1;s:14:\"site_edit_wiki\";i:1;s:19:\"torrents_add_artist\";i:1;}', '0'), (4, 200, 'Power User', 'a:14:{s:10:\"site_leech\";i:1;s:11:\"site_upload\";i:1;s:9:\"site_vote\";i:1;s:20:\"site_submit_requests\";i:1;s:20:\"site_advanced_search\";i:1;s:10:\"site_top10\";i:1;s:20:\"site_torrents_notify\";i:1;s:20:\"site_collages_create\";i:1;s:20:\"site_collages_manage\";i:1;s:19:\"site_make_bookmarks\";i:1;s:14:\"site_edit_wiki\";i:1;s:14:\"zip_downloader\";i:1;s:19:\"forums_polls_create\";i:1;s:19:\"torrents_add_artist\";i:1;} ', '0'), (5, 250, 'Elite', 'a:18:{s:10:\"site_leech\";i:1;s:11:\"site_upload\";i:1;s:9:\"site_vote\";i:1;s:20:\"site_submit_requests\";i:1;s:20:\"site_advanced_search\";i:1;s:10:\"site_top10\";i:1;s:20:\"site_torrents_notify\";i:1;s:20:\"site_collages_create\";i:1;s:20:\"site_collages_manage\";i:1;s:19:\"site_advanced_top10\";i:1;s:19:\"site_make_bookmarks\";i:1;s:14:\"site_edit_wiki\";i:1;s:15:\"site_delete_tag\";i:1;s:14:\"zip_downloader\";i:1;s:19:\"forums_polls_create\";i:1;s:13:\"torrents_edit\";i:1;s:19:\"torrents_add_artist\";i:1;s:17:\"admin_clear_cache\";i:1;}', '0'), (20, 202, 'Donor', 'a:9:{s:9:\"site_vote\";i:1;s:20:\"site_submit_requests\";i:1;s:20:\"site_advanced_search\";i:1;s:10:\"site_top10\";i:1;s:20:\"site_torrents_notify\";i:1;s:20:\"site_collages_create\";i:1;s:20:\"site_collages_manage\";i:1;s:14:\"zip_downloader\";i:1;s:19:\"forums_polls_create\";i:1;}', '0'), (19, 201, 'Artist', 'a:9:{s:10:\"site_leech\";s:1:\"1\";s:11:\"site_upload\";s:1:\"1\";s:9:\"site_vote\";s:1:\"1\";s:20:\"site_submit_requests\";s:1:\"1\";s:20:\"site_advanced_search\";s:1:\"1\";s:10:\"site_top10\";s:1:\"1\";s:19:\"site_make_bookmarks\";s:1:\"1\";s:14:\"site_edit_wiki\";s:1:\"1\";s:18:\"site_recommend_own\";s:1:\"1\";}', '0'); diff --git a/sections/ajax/takevote.php b/sections/ajax/takevote.php index 3ceff73d..60401909 100644 --- a/sections/ajax/takevote.php +++ b/sections/ajax/takevote.php @@ -39,22 +39,27 @@ } $Type = ($_REQUEST['vote'] == 'up')?"Up":"Down"; + // Update the two votes tables if needed + $DB->query("INSERT IGNORE INTO users_votes (UserID, GroupID, Type) VALUES ($UserID, $GroupID, '$Type')"); + if ($DB->affected_rows() == 0) { + echo 'noaction'; + die(); + } + // Update the group's cache key $GroupVotes['Total'] += 1; if ($Type == "Up") { $GroupVotes['Ups'] += 1; } $Cache->cache_value('votes_'.$GroupID, $GroupVotes); - - // Update the two votes tables - $DB->query("INSERT INTO users_votes (UserID, GroupID, Type) VALUES ($UserID, $GroupID, '$Type') ON DUPLICATE KEY UPDATE Type = '$Type'"); + // If the group has no votes yet, we need an insert, otherwise an update // so we can cut corners and use the magic of INSERT...ON DUPLICATE KEY UPDATE... // to accomplish both in one query $DB->query("INSERT INTO torrents_votes (GroupID, Total, Ups, Score) VALUES ($GroupID, 1, ".($Type=='Up'?1:0).", 0) ON DUPLICATE KEY UPDATE Total = Total + 1, - Score = binomial_ci(".$GroupVotes['Ups'].",". $GroupVotes['Total'].")". + Score = IFNULL(binomial_ci(".$GroupVotes['Ups'].",". $GroupVotes['Total']."),0)". ($Type=='Up'?', Ups = Ups+1':'')); $UserVotes[$GroupID] = array('GroupID' => $GroupID, 'Type' => $Type); @@ -137,7 +142,7 @@ $Cache->cache_value('votes_'.$GroupID, $GroupVotes); $DB->query("UPDATE torrents_votes SET Total = GREATEST(0, Total - 1), - Score = binomial_ci(".$GroupVotes['Ups'].",".$GroupVotes['Total'].")". + Score = IFNULL(binomial_ci(".$GroupVotes['Ups'].",".$GroupVotes['Total']."),0)". ($Type=='Up'?', Ups = GREATEST(0, Ups - 1)':'')." WHERE GroupID=$GroupID"); // Update paired cache keys diff --git a/sections/artist/artist.php b/sections/artist/artist.php index 236e61b0..333cfa37 100644 --- a/sections/artist/artist.php +++ b/sections/artist/artist.php @@ -23,16 +23,20 @@ function compare($X, $Y){ 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"); + if(!is_number($RevisionID)) { + error(0); + } + $Data = $Cache->get_value("artist_$ArtistID"."_revision_$RevisionID", true); } else { // viewing the live version - $Data = $Cache->get_value('artist_'.$ArtistID); + $Data = $Cache->get_value('artist_'.$ArtistID, true); $RevisionID = false; } -if($Data) { - $Data = unserialize($Data); - list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray, $TorrentList, $Importances, $VanityHouseArtist)) = each($Data); +if($Data) { + if (!is_array($Data)) { + $Data = unserialize($Data); + } + list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray, ,,,, $VanityHouseArtist)) = each($Data); } else { if ($RevisionID) { $sql = "SELECT @@ -61,14 +65,6 @@ 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); -} - -$SnatchedTorrents = Torrents::get_snatched_torrents(); //----------------- Build list and get stats @@ -102,23 +98,22 @@ function compare($X, $Y){ } $NumRequests = count($Requests); + $LastReleaseType = 0; -if(empty($Importances) || empty($TorrentList)) { - $DB->query("SELECT - DISTINCTROW ta.GroupID, ta.Importance, tg.VanityHouse, tg.ReleaseType - FROM torrents_artists AS ta - JOIN torrents_group AS tg ON tg.ID=ta.GroupID - WHERE ta.ArtistID='$ArtistID' - ORDER BY IF(ta.Importance IN ('2', '3', '4', '7'),1000 + ta.Importance, tg.ReleaseType) ASC, - tg.Year DESC, tg.Name DESC"); - $GroupIDs = $DB->collect('GroupID'); - $Importances = $DB->to_array(false, MYSQLI_BOTH, false); - if(count($GroupIDs)>0) { - $TorrentList = Torrents::get_groups($GroupIDs, true,true); - $TorrentList = $TorrentList['matches']; - } else { - $TorrentList = array(); - } +$DB->query("SELECT + DISTINCTROW ta.GroupID, ta.Importance, tg.VanityHouse, tg.Year + FROM torrents_artists AS ta + JOIN torrents_group AS tg ON tg.ID=ta.GroupID + WHERE ta.ArtistID='$ArtistID' + ORDER BY IF(ta.Importance IN ('2', '3', '4', '7'),1000 + ta.Importance, tg.ReleaseType) ASC, + tg.Year DESC, tg.Name DESC"); +$GroupIDs = $DB->collect('GroupID'); +$Importances = $DB->to_array(false, MYSQLI_BOTH, false); +if(count($GroupIDs)>0) { + $TorrentList = Torrents::get_groups($GroupIDs, true,true); + $TorrentList = $TorrentList['matches']; +} else { + $TorrentList = array(); } $NumGroups = count($TorrentList); @@ -182,10 +177,16 @@ function compare($X, $Y){ $SortOrder = array_keys($LoggedUser['SortHide']); uasort($Importances, function ($a, $b) { global $SortOrder; +// global $Debug; +// $Debug->log_var($a); $c = array_search($a['ReleaseType'], $SortOrder); $d = array_search($b['ReleaseType'], $SortOrder); if ($c == $d) { - return 0; + if ($a['Year'] == $b['Year']) { + return 0; + } else { + return ($a['Year'] > $b['Year']) ? -1 : 1; + } } return $c < $d ? -1 : 1; }); @@ -449,16 +450,11 @@ function compare($X, $Y){ [ - 0) && ($Torrent['Size'] < 1073741824) - && !$Torrent['PersonalFL'] && empty($Torrent['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?> + | FL ] - - -   »  + +   »  @@ -967,7 +963,7 @@ function require(file, callback) { //---------- Begin printing foreach($Thread as $Key => $Post){ - list($PostID, $AuthorID, $AddedTime, $Body, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post); + list($PostID, $AuthorID, $AddedTime, $CommentBody, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post); list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID)); ?> @@ -1014,7 +1010,7 @@ function require(file, callback) { ?> @@ -203,9 +189,14 @@ function compare($X, $Y){ $DisplayName = ''.$GroupName.''; - if(!empty($Torrent['FreeTorrent'])) { - $DisplayName .=' Freeleech!'; - } elseif($Torrent['PersonalFL']) { + if ($Torrent['IsSnatched']) { + $DisplayName .= ' Snatched!'; + } + if ($Torrent['FreeTorrent'] == '1') { + $DisplayName .= ' Freeleech!'; + } elseif ($Torrent['FreeTorrent'] == '2') { + $DisplayName .= ' Neutral Leech!'; + } elseif ($Torrent['PersonalFL']) { $DisplayName .= 'Personal Freeleech!'; } ?> @@ -218,8 +209,7 @@ function compare($X, $Y){ @@ -272,9 +260,14 @@ function compare($X, $Y){ $DisplayName = ''.$GroupName.''; - if(!empty($Torrent['FreeTorrent'])) { - $DisplayName .=' Freeleech!'; - } elseif($Torrent['PersonalFL']) { + if ($Torrent['IsSnatched']) { + $DisplayName .= ' Snatched!'; + } + if ($Torrent['FreeTorrent'] == '1') { + $DisplayName .= ' Freeleech!'; + } elseif ($Torrent['FreeTorrent'] == '2') { + $DisplayName .= ' Neutral Leech!'; + } elseif ($Torrent['PersonalFL']) { $DisplayName .= $AddExtra.'Personal Freeleech!'; } ?> @@ -287,8 +280,7 @@ function compare($X, $Y){
-full_format($Body)?> +full_format($CommentBody)?>

@@ -1088,7 +1084,7 @@ function require(file, callback) { $Key = 'artist_'.$ArtistID; } -$Data = serialize(array(array($Name, $Image, $Body, $NumSimilar, $SimilarArray, $TorrentList, $Importances, $VanityHouseArtist))); +$Data = array(array($Name, $Image, $Body, $NumSimilar, $SimilarArray, array(), array(), $VanityHouseArtist)); $Cache->cache_value($Key, $Data, 3600); ?> diff --git a/sections/bookmarks/torrents.php b/sections/bookmarks/torrents.php index c4592ee2..e7a28fb8 100644 --- a/sections/bookmarks/torrents.php +++ b/sections/bookmarks/torrents.php @@ -25,15 +25,6 @@ function compare($X, $Y){ list($K, $GroupIDs, $CollageDataList, $TorrentList) = Users::bookmark_data($UserID); -$TokenTorrents = Users::token_torrents($UserID); - -$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); -} -$SnatchedTorrents = Torrents::get_snatched_torrents(); $Title = ($Sneaky)?"$Username's bookmarked torrents":'Your bookmarked torrents'; // Loop through the result set, building up $Collage and $TorrentTable @@ -177,16 +168,11 @@ function compare($X, $Y){
[ DL - 0) && ($Torrent['Size'] < 1073741824) - && !$Torrent['PersonalFL'] && empty($Torrent['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?> + | FL | RP ] -   »  [ DL - 0) && ($Torrent['Size'] < 1073741824) - && !$Torrent['PersonalFL'] && empty($Torrent['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?> + | FL | RP ] diff --git a/sections/collages/collage.php b/sections/collages/collage.php index 85457ab2..7560301b 100644 --- a/sections/collages/collage.php +++ b/sections/collages/collage.php @@ -16,19 +16,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); -} -$SnatchedTorrents = Torrents::get_snatched_torrents(); - $Data = $Cache->get_value('collage_'.$CollageID); if($Data) { - $Data = unserialize($Data); - list($K, list($Name, $Description, $CollageDataList, $TorrentList, $CommentList, $Deleted, $CollageCategoryID, $CreatorID)) = each($Data); + if (!is_array($Data)) { + $Data = unserialize($Data); + } + list($K, list($Name, $Description, ,,,, $CommentList, $Deleted, $CollageCategoryID, $CreatorID)) = each($Data); } else { $DB->query("SELECT Name, Description, UserID, Deleted, CategoryID, Locked, MaxGroups, MaxGroupsPerUser FROM collages WHERE ID='$CollageID'"); if($DB->record_count() > 0) { @@ -69,28 +63,27 @@ function compare($X, $Y){ // Build the data for the collage and the torrent list -if(!is_array($TorrentList)) { - $DB->query("SELECT ct.GroupID, - tg.WikiImage, - tg.CategoryID, - um.ID, - um.Username - FROM collages_torrents AS ct - JOIN torrents_group AS tg ON tg.ID=ct.GroupID - LEFT JOIN users_main AS um ON um.ID=ct.UserID - WHERE ct.CollageID='$CollageID' - ORDER BY ct.Sort"); - - $GroupIDs = $DB->collect('GroupID'); - $CollageDataList=$DB->to_array('GroupID', MYSQLI_ASSOC); - if(count($GroupIDs)>0) { - $TorrentList = Torrents::get_groups($GroupIDs); - $TorrentList = $TorrentList['matches']; - } else { - $TorrentList = array(); - } +$DB->query("SELECT ct.GroupID, + tg.WikiImage, + tg.CategoryID, + um.ID, + um.Username + FROM collages_torrents AS ct + JOIN torrents_group AS tg ON tg.ID=ct.GroupID + LEFT JOIN users_main AS um ON um.ID=ct.UserID + WHERE ct.CollageID='$CollageID' + ORDER BY ct.Sort"); + +$GroupIDs = $DB->collect('GroupID'); +$CollageDataList = $DB->to_array('GroupID', MYSQLI_ASSOC); +if(count($GroupIDs)>0) { + $TorrentList = Torrents::get_groups($GroupIDs); + $TorrentList = $TorrentList['matches']; +} else { + $TorrentList = array(); } + // Loop through the result set, building up $Collage and $TorrentTable // Then we print them. $Collage = array(); @@ -246,16 +239,11 @@ function compare($X, $Y){ [ DL - 0) && ($Torrent['Size'] < 1073741824) - && !$Torrent['PersonalFL'] && empty($Torrent['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?> + | FL | RP ] -   »  [ DL - 0) && ($Torrent['Size'] < 1073741824) - && !$Torrent['PersonalFL'] && empty($Torrent['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?> + | FL | RP ] @@ -570,7 +562,7 @@ function compare($X, $Y){ LEFT JOIN users_main AS um ON um.ID=cc.UserID WHERE CollageID='$CollageID' ORDER BY ID DESC LIMIT 15"); - $CommentList = $DB->to_array(); + $CommentList = $DB->to_array(false, MYSQLI_NUM); } foreach ($CommentList as $Comment) { list($CommentID, $Body, $UserID, $Username, $CommentTime) = $Comment; @@ -651,5 +643,5 @@ function compare($X, $Y){ cache_value('collage_'.$CollageID, serialize(array(array($Name, $Description, $CollageDataList, $TorrentList, $CommentList, $Deleted, $CollageCategoryID, $CreatorID, $Locked, $MaxGroups, $MaxGroupsPerUser))), 3600); +$Cache->cache_value('collage_'.$CollageID, array(array($Name, $Description, array(), array(), $CommentList, $Deleted, $CollageCategoryID, $CreatorID, $Locked, $MaxGroups, $MaxGroupsPerUser)), 3600); ?> diff --git a/sections/comments/torrentcomments.php b/sections/comments/torrentcomments.php index fd44292c..51008903 100644 --- a/sections/comments/torrentcomments.php +++ b/sections/comments/torrentcomments.php @@ -80,7 +80,7 @@ while(list($UserID, $TorrentID, $GroupID, $Title, $PostID, $Body, $AddedTime, $EditedTime, $EditorID) = $DB->next_record()) { $permalink = "torrents.php?id=$GroupID&postid=$PostID#post$PostID"; - $postheader = " on " . Artists::display_artists($Artists[$GroupID]) . " \">$Title"; + $postheader = " on " . Artists::display_artists($Artists[$GroupID]) . " $Title"; comment_body($UserID, $PostID, $postheader, $permalink, $Body, $EditorID, $AddedTime, $EditedTime); diff --git a/sections/forums/thread.php b/sections/forums/thread.php index 019c8626..317ef7b4 100644 --- a/sections/forums/thread.php +++ b/sections/forums/thread.php @@ -385,7 +385,16 @@ list($PostID, $AuthorID, $AddedTime, $Body, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post); list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID)); ?> - id="post"> +
+ + + + + -
# @@ -528,7 +537,7 @@ - + diff --git a/sections/top10/index.php b/sections/top10/index.php index a2133d8b..f23a6c5f 100644 --- a/sections/top10/index.php +++ b/sections/top10/index.php @@ -26,9 +26,9 @@ case 'history' : include(SERVER_ROOT.'/sections/top10/history.php'); break; - /*case 'votes' : + case 'votes' : include(SERVER_ROOT.'/sections/top10/votes.php'); - break;*/ + break; default : error(404); break; diff --git a/sections/top10/tags.php b/sections/top10/tags.php index d32672bb..3bfed737 100644 --- a/sections/top10/tags.php +++ b/sections/top10/tags.php @@ -19,9 +19,8 @@ [Torrents] [Users] [Tags] - -
+ [Favorites] +
@@ -50,8 +49,7 @@ [Torrents] [Users] [Tags] - + [Favorites]
>  >
Format @@ -344,7 +343,7 @@ // generate a table based on data from most recent query to $DB function generate_torrent_table($Caption, $Tag, $Details, $Limit) { - global $LoggedUser,$Categories,$ReleaseTypes, $SnatchedTorrents; + global $LoggedUser,$Categories,$ReleaseTypes; ?>

Top @@ -436,6 +435,7 @@ function generate_torrent_table($Caption, $Tag, $Details, $Limit) { if($GroupCategoryID==1 && $ReleaseType > 0) { $DisplayName.= ' ['.$ReleaseTypes[$ReleaseType].']'; } + // append extra info to torrent title $ExtraInfo=''; $AddExtra=''; @@ -448,15 +448,13 @@ function generate_torrent_table($Caption, $Tag, $Details, $Limit) { if($Scene) { $ExtraInfo.=$AddExtra.'Scene'; $AddExtra=' / '; } if($Year>0) { $ExtraInfo.=$AddExtra.$Year; $AddExtra=' '; } if($RemasterTitle) { $ExtraInfo.=$AddExtra.$RemasterTitle; } - if(array_key_exists($TorrentID, $SnatchedTorrents)) { $ExtraInfo.=' / Snatched!'; } + if(Torrents::has_snatched($TorrentID)) { $ExtraInfo.=' / Snatched!'; } if($ExtraInfo!='') { $ExtraInfo = "- [$ExtraInfo]"; } - - - + $TagList=array(); - + $PrimaryTag = ''; if($TorrentTags!='') { $TorrentTags=explode(' ',$TorrentTags); diff --git a/sections/top10/users.php b/sections/top10/users.php index 9f655302..80a0bbb2 100644 --- a/sections/top10/users.php +++ b/sections/top10/users.php @@ -19,8 +19,7 @@ [Torrents] [Users] [Tags] - + [Favorites] 0 && $Year1 <= 0) { $Where[] = "g.Year <= $Year2"; - } + } } else { $Details = 'all'; // defaults to 10 (duh) @@ -33,14 +33,17 @@ } $Filtered = !empty($Where); - -$Where = implode(' AND ', $Where); +if ($_GET['anyall'] == 'any') { + $Where = '('.implode(' OR ', $Where).')'; +} else { + $Where = implode(' AND ', $Where); +} $WhereSum = (empty($Where)) ? '' : md5($Where); // Unlike the other top 10s, this query just gets some raw stats // We'll need to do some fancy-pants stuff to translate it into // BPCI scores before getting the torrent data -$Query = "SELECT v.GroupID +$Query = "SELECT v.GroupID, v.Ups, v.Total, v.Score FROM torrents_votes AS v"; if (!empty($Where)) { $Query .= " JOIN torrents_group AS g ON g.ID = v.GroupID @@ -52,13 +55,15 @@ $TopVotes = $Cache->get_value('top10votes_'.$Limit.$WhereSum); if ($TopVotes === false) { - if (true || $Cache->get_query_lock('top10votes')) { + if ($Cache->get_query_lock('top10votes')) { $DB->query($Query); $Results = $DB->collect('GroupID'); + $Data = $DB->to_array('GroupID'); + $Groups = Torrents::get_groups($Results); if (count($Results) > 0) { - $DB->query('SELECT ID, CategoryID FROM torrents_group + $DB->query('SELECT ID, CategoryID FROM torrents_group WHERE ID IN ('.implode(',', $Results).')'); $Cats = $DB->to_array('ID'); } @@ -67,15 +72,18 @@ foreach ($Results as $GroupID) { $TopVotes[$GroupID] = $Groups['matches'][$GroupID]; $TopVotes[$GroupID]['CategoryID'] = $Cats[$GroupID]['CategoryID']; + $TopVotes[$GroupID]['Ups'] = $Data[$GroupID]['Ups']; + $TopVotes[$GroupID]['Total'] = $Data[$GroupID]['Total']; + $TopVotes[$GroupID]['Score'] = $Data[$GroupID]['Score']; } - + $Cache->cache_value('top10votes_'.$Limit.$WhereSum,$TopVotes,60*30); $Cache->clear_query_lock('top10votes'); } else { $TopVotes = false; } } -$SnatchedTorrents = Torrents::get_snatched_torrents(); + View::show_header('Top '.$Limit.' Voted Groups','browse'); ?>
@@ -101,6 +109,13 @@

+ >  + > +
Year: @@ -114,7 +129,7 @@
+

Top - + - - [Top 10] @@ -144,18 +159,18 @@ +} ?>

$Group) { - list($GroupID, $GroupName, $GroupYear, $GroupRecordLabel, - $GroupCatalogueNumber, $TagList, $ReleaseType, $GroupVanityHouse, - $Torrents, $GroupArtists, $ExtendedArtists, $GroupCategoryID) = array_values($Group); - + list($GroupID, $GroupName, $GroupYear, $GroupRecordLabel, + $GroupCatalogueNumber, $TagList, $ReleaseType, $GroupVanityHouse, + $Torrents, $GroupArtists, $ExtendedArtists, $GroupCategoryID,$Ups,$Total,$Score) = array_values($Group); + // Handle stats and stuff $Number++; $NumGroups++; @@ -170,7 +185,7 @@ $TorrentTags='
'.$TorrentTags.'
'; $DisplayName = $Number.' - '; - + if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4]) || !empty($ExtendedArtists[5])|| !empty($ExtendedArtists[6])) { unset($ExtendedArtists[2]); unset($ExtendedArtists[3]); @@ -178,7 +193,7 @@ } elseif(count($GroupArtists)>0) { $DisplayName .= Artists::display_artists(array('1'=>$GroupArtists)); } - + $DisplayName .= ''.$GroupName.''; if($GroupYear>0) { $DisplayName = $DisplayName. ' ['. $GroupYear .']';} if($GroupVanityHouse) { $DisplayName .= ' [VH]'; } @@ -200,16 +215,13 @@ - [ Unbookmark ] + [ Unbookmark ] - [ Bookmark ] + [ Bookmark ] - - - - + upvotes out of total (Score: ). $Torrent) { if ($Torrent['Remastered'] && !$Torrent['RemasterYear']) { $FirstUnknown = !isset($FirstUnknown); } - - if (in_array($TorrentID, $TokenTorrents) && empty($Torrent['FreeTorrent'])) { - $Torrent['PersonalFL'] = 1; - } - + if($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear || $Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber || $FirstUnknown || $Torrent['Media'] != $LastMedia) { $EditionID++; @@ -241,7 +249,7 @@ 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']); - + ?> @@ -274,8 +282,7 @@ [ DL - 0) && ($Torrent['Size'] < 1073741824) - && !in_array($TorrentID, $TokenTorrents) && empty($Torrent['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?> + | FL | RP ] @@ -291,18 +298,21 @@ } } else { // Viewing a type that does not require grouping - + list($TorrentID, $Torrent) = each($Torrents); - + $DisplayName = $Number .' - '.$GroupName.''; - - if(array_key_exists($TorrentID, $SnatchedTorrents)) { $DisplayName.=' Snatched!'; } - - if(!empty($Torrent['FreeTorrent'])) { - $DisplayName .=' Freeleech!'; - } elseif(in_array($TorrentID, $TokenTorrents)) { + if($Torrent['IsSnatched']) { + $DisplayName .= ' Snatched!'; + } + if ($Torrent['FreeTorrent'] == '1') { + $DisplayName .= ' Freeleech!'; + } elseif ($Torrent['FreeTorrent'] == '2') { + $DisplayName .= ' Neutral Leech!'; + } elseif(Torrents::has_token($TorrentID)) { $DisplayName .= $AddExtra.'Personal Freeleech!'; } + ?> @@ -313,10 +323,9 @@ [ DL - 0) && ($Torrent['Size'] < 1073741824) - && !in_array($TorrentID, $TokenTorrents) && empty($Torrent['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?> + | FL - + | RP | Unbookmark @@ -354,7 +363,7 @@ Server is busy processing another top list request. Please try again in a minute. +} elseif (count($TopVotes) == 0) { ?> No torrents were found that meet your criteria. diff --git a/sections/torrents/browse2.php b/sections/torrents/browse2.php index fad3bfea..3227210f 100644 --- a/sections/torrents/browse2.php +++ b/sections/torrents/browse2.php @@ -956,8 +956,7 @@ function header_link($SortKey,$DefaultWay="desc") { [ - 0) && $Data['HasFile'] && ($Data['Size'] < 1073741824) - && !$Data['PersonalFL'] && empty($Data['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?> + | FL | RP ] @@ -980,6 +979,9 @@ function header_link($SortKey,$DefaultWay="desc") { $DisplayName = ''.$GroupName.''; + if ($Data['IsSnatched']) { + $DisplayName .= ' Snatched!'; + } if ($Data['FreeTorrent'] == '1') { $DisplayName .= ' Freeleech!'; } elseif ($Data['FreeTorrent'] == '2') { @@ -996,8 +998,7 @@ function header_link($SortKey,$DefaultWay="desc") { [ DL - 0) && $Data['HasFile'] && ($Data['Size'] < 1073741824) - && !$Data['PersonalFL'] && empty($Data['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1')) { ?> + | FL | RP ] diff --git a/sections/torrents/details.php b/sections/torrents/details.php index 5aeb0804..3545f543 100644 --- a/sections/torrents/details.php +++ b/sections/torrents/details.php @@ -80,13 +80,6 @@ function compare($X, $Y){ die(); }*/ -$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); -} -$SnatchedTorrents = Torrents::get_snatched_torrents(); // Start output View::show_header($Title,'browse,comments,torrent,bbcode'); ?> @@ -365,8 +358,7 @@ function compare($X, $Y){ - +
@@ -404,7 +396,7 @@ function filelist($Str) { $Snatched, $FreeTorrent, $TorrentTime, $Description, $FileList, $FilePath, $UserID, $LastActive, $BadTags, $BadFolders, $BadFiles, $CassetteApproved, $LossymasterApproved, $LossywebApproved, $LastReseedRequest, - $LogInDB, $HasFile, $PersonalFL) = array_values($Torrent); + $LogInDB, $HasFile, $PersonalFL, $IsSnatched) = array_values($Torrent); if($Remastered && !$RemasterYear) { $FirstUnknown = !isset($FirstUnknown); @@ -473,7 +465,7 @@ function filelist($Str) { if(!$ExtraInfo) { $ExtraInfo = $GroupName ; $AddExtra=' / '; } - if(array_key_exists($TorrentID, $SnatchedTorrents)) {$ExtraInfo.=$AddExtra.'Snatched!'; $AddExtra=' / '; } + if($IsSnatched) { $ExtraInfo.=$AddExtra.'Snatched!'; $AddExtra=' / '; } if($FreeTorrent == '1') { $ExtraInfo.=$AddExtra.'Freeleech!'; $AddExtra=' / '; } if($FreeTorrent == '2') { $ExtraInfo.=$AddExtra.'Neutral Leech!'; $AddExtra=' / '; } if($PersonalFL) { $ExtraInfo.=$AddExtra.'Personal Freeleech!'; $AddExtra=' / '; } @@ -535,8 +527,7 @@ function filelist($Str) { - @@ -303,7 +299,6 @@ function checked($Checked) { - - */ ?> diff --git a/sections/user/takeedit.php b/sections/user/takeedit.php index c1eb30d0..6758ec8c 100644 --- a/sections/user/takeedit.php +++ b/sections/user/takeedit.php @@ -196,7 +196,6 @@ $Options['ShowSnatched'] = (!empty($_POST['showsnatched']) ? 1 : 0); - if(isset($LoggedUser['DisableFreeTorrentTop10'])) { $Options['DisableFreeTorrentTop10'] = $LoggedUser['DisableFreeTorrentTop10']; } diff --git a/sections/user/takemoderate.php b/sections/user/takemoderate.php index 03d0f691..8ee09b37 100644 --- a/sections/user/takemoderate.php +++ b/sections/user/takemoderate.php @@ -365,7 +365,7 @@ } if ($Warned == 1 && $Cur['Warned']=='0000-00-00 00:00:00' && check_perms('users_warn')) { - Misc::send_pm($UserID,0,db_string('You have received a warning'),db_string("You have been [url=http://".NONSSL_SITE_URL."/wiki.php?action=article&id=218]warned for $WarnLength week(s)[/url] by [user]".$LoggedUser['Username']."[/user]. The reason given was: $WarnReason")); + Misc::send_pm($UserID,0,db_string('You have received a warning'),db_string("You have been [url=https://".NONSSL_SITE_URL."/wiki.php?action=article&id=218]warned for $WarnLength week(s)[/url] by [user]".$LoggedUser['Username']."[/user]. The reason given was: $WarnReason")); $UpdateSet[]="Warned='".sqltime()."' + INTERVAL $WarnLength WEEK"; $Msg = "warned for $WarnLength week(s)"; if ($WarnReason) { $Msg.=" for $WarnReason"; } @@ -444,7 +444,7 @@ $EditSummary[]="avatar status changed"; $HeavyUpdates['DisableAvatar']=$DisableAvatar; if (!empty($UserReason)) { - Misc::send_pm($UserID, 0, db_string('Your avatar privileges have been disabled'),db_string("Your avatar privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=http://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); + Misc::send_pm($UserID, 0, db_string('Your avatar privileges have been disabled'),db_string("Your avatar privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=https://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); } } @@ -454,7 +454,7 @@ $HeavyUpdates['DisableLeech']=$DisableLeech; $HeavyUpdates['CanLeech']=$DisableLeech; if (!empty($UserReason)) { - Misc::send_pm($UserID, 0, db_string('Your leeching privileges have been disabled'),db_string("Your leeching privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=http://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); + Misc::send_pm($UserID, 0, db_string('Your leeching privileges have been disabled'),db_string("Your leeching privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=https://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); } Tracker::update_tracker('update_user', array('passkey' => $Cur['torrent_pass'], 'can_leech' => $DisableLeech)); } @@ -464,7 +464,7 @@ if ($DisableInvites == 1) { //$UpdateSet[]="Invites='0'"; if (!empty($UserReason)) { - Misc::send_pm($UserID, 0, db_string('Your invite privileges have been disabled'),db_string("Your invite privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=http://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); + Misc::send_pm($UserID, 0, db_string('Your invite privileges have been disabled'),db_string("Your invite privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=https://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); } } $EditSummary[]="invites status changed"; @@ -476,7 +476,7 @@ $EditSummary[]="posting status changed"; $HeavyUpdates['DisablePosting']=$DisablePosting; if (!empty($UserReason)) { - Misc::send_pm($UserID, 0, db_string('Your forum posting privileges have been disabled'),db_string("Your forum posting privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=http://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); + Misc::send_pm($UserID, 0, db_string('Your forum posting privileges have been disabled'),db_string("Your forum posting privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=https://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); } } @@ -485,7 +485,7 @@ $EditSummary[]="forums status changed"; $HeavyUpdates['DisableForums']=$DisableForums; if (!empty($UserReason)) { - Misc::send_pm($UserID, 0, db_string('Your forum privileges have been disabled'),db_string("Your forum privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=http://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); + Misc::send_pm($UserID, 0, db_string('Your forum privileges have been disabled'),db_string("Your forum privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=https://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); } } @@ -494,7 +494,7 @@ $EditSummary[]="tagging status changed"; $HeavyUpdates['DisableTagging']=$DisableTagging; if (!empty($UserReason)) { - Misc::send_pm($UserID, 0, db_string('Your tagging privileges have been disabled'),db_string("Your tagging privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=http://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); + Misc::send_pm($UserID, 0, db_string('Your tagging privileges have been disabled'),db_string("Your tagging privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=https://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); } } @@ -503,7 +503,7 @@ $EditSummary[]="upload status changed"; $HeavyUpdates['DisableUpload']=$DisableUpload; if ($DisableUpload == 1) { - Misc::send_pm($UserID, 0, db_string('Your upload privileges have been disabled'),db_string("Your upload privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=http://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); + Misc::send_pm($UserID, 0, db_string('Your upload privileges have been disabled'),db_string("Your upload privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=https://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); } } @@ -513,7 +513,7 @@ $HeavyUpdates['DisableWiki']=$DisableWiki; $HeavyUpdates['site_edit_wiki']=0; if (!empty($UserReason)) { - Misc::send_pm($UserID, 0, db_string('Your site editing privileges have been disabled'),db_string("Your site editing privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=http://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); + Misc::send_pm($UserID, 0, db_string('Your site editing privileges have been disabled'),db_string("Your site editing privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=https://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); } } @@ -523,7 +523,7 @@ $EditSummary[]="PM status changed"; $HeavyUpdates['DisablePM']=$DisablePM; if (!empty($UserReason)) { - Misc::send_pm($UserID, 0, db_string('Your PM privileges have been disabled'),db_string("Your PM privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=http://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); + Misc::send_pm($UserID, 0, db_string('Your PM privileges have been disabled'),db_string("Your PM privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=https://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url].")); } } @@ -532,7 +532,7 @@ $EditSummary[]="IRC status changed"; $HeavyUpdates['DisableIRC']=$DisableIRC; if (!empty($UserReason)) { - Misc::send_pm($UserID, 0, db_string('Your IRC privileges have been disabled'),db_string("Your IRC privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=http://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url]. This loss of privileges does not affect the ability to join and talk to staff in #what.cd-disabled.")); + Misc::send_pm($UserID, 0, db_string('Your IRC privileges have been disabled'),db_string("Your IRC privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=https://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url]. This loss of privileges does not affect the ability to join and talk to staff in #what.cd-disabled.")); } } @@ -541,7 +541,7 @@ $EditSummary[]="request status changed"; $HeavyUpdates['DisableRequests']=$DisableRequests; if (!empty($UserReason)) { - Misc::send_pm($UserID, 0, db_string('Your request privileges have been disabled'),db_string("Your request privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=http://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url]. This loss of privileges does not affect the ability to join and talk to staff in #what.cd-disabled.")); + Misc::send_pm($UserID, 0, db_string('Your request privileges have been disabled'),db_string("Your request privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=https://".NONSSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url]. This loss of privileges does not affect the ability to join and talk to staff in #what.cd-disabled.")); } } @@ -614,10 +614,10 @@ $DB->query("SELECT ID, Uploaded, Downloaded FROM users_main WHERE Username LIKE '".$MergeStatsFrom."'"); if($DB->record_count() > 0) { list($MergeID, $MergeUploaded, $MergeDownloaded) = $DB->next_record(); - $DB->query("UPDATE users_main AS um JOIN users_info AS ui ON um.ID=ui.UserID SET um.Uploaded = 0, um.Downloaded = 0, ui.AdminComment = CONCAT('".sqltime()." - Stats merged into http://".NONSSL_SITE_URL."/user.php?id=".$UserID." (".$Cur['Username'].") by ".$LoggedUser['Username']."\n\n', ui.AdminComment) WHERE ID = ".$MergeID); + $DB->query("UPDATE users_main AS um JOIN users_info AS ui ON um.ID=ui.UserID SET um.Uploaded = 0, um.Downloaded = 0, ui.AdminComment = CONCAT('".sqltime()." - Stats merged into https://".NONSSL_SITE_URL."/user.php?id=".$UserID." (".$Cur['Username'].") by ".$LoggedUser['Username']."\n\n', ui.AdminComment) WHERE ID = ".$MergeID); $UpdateSet[]="Uploaded = Uploaded + '$MergeUploaded'"; $UpdateSet[]="Downloaded = Downloaded + '$MergeDownloaded'"; - $EditSummary[]="stats merged from http://".NONSSL_SITE_URL."/user.php?id=".$MergeID." (".$MergeStatsFrom.")"; + $EditSummary[]="stats merged from https://".NONSSL_SITE_URL."/user.php?id=".$MergeID." (".$MergeStatsFrom.")"; $Cache->delete_value('users_stats_'.$UserID); $Cache->delete_value('users_stats_'.$MergeID); } diff --git a/sections/userhistory/quote_notifications.php b/sections/userhistory/quote_notifications.php index c241e9b4..d34c6ce0 100644 --- a/sections/userhistory/quote_notifications.php +++ b/sections/userhistory/quote_notifications.php @@ -40,7 +40,7 @@

Quote notifications -

[ - 0) && $HasFile && ($Size < 1073741824) - && !$PersonalFL && ($FreeTorrent == '0') && ($LoggedUser['CanLeech'] == '1')) { ?> + | FL | RP @@ -740,7 +731,7 @@ function filelist($Str) {
diff --git a/sections/torrents/download.php b/sections/torrents/download.php index 31e22b10..edb3b73d 100644 --- a/sections/torrents/download.php +++ b/sections/torrents/download.php @@ -144,30 +144,6 @@ $DB->query("INSERT IGNORE INTO users_downloads (UserID, TorrentID, Time) VALUES ('$UserID', '$TorrentID', '".sqltime()."')"); -$SnatchedTorrents = $Cache->get_value('users_snatched_'.$UserID); -if (empty($SnatchedTorrents)) { - $DB->query("SELECT DISTINCT fid as TorrentID FROM xbt_snatched WHERE uid='$UserID' ORDER BY TorrentID ASC"); - $SnatchedTorrents = array_flip($DB->collect('TorrentID')); - $Cache->cache_value('users_snatched_'.$UserID, $SnatchedTorrents, 86400); -} -if(!array_key_exists($TorrentID, $SnatchedTorrents)) { - $SnatchedTorrents[$TorrentID] = 1; - $Cache->cache_value('users_snatched_'.$UserID, $SnatchedTorrents, 86400); -} - - -$SnatchedTorrents = $Cache->get_value('users_snatched_'.$UserID); -if (empty($SnatchedTorrents)) { - $DB->query("SELECT DISTINCT fid as TorrentID FROM xbt_snatched WHERE uid='$UserID' ORDER BY TorrentID ASC"); - $SnatchedTorrents = array_flip($DB->collect('TorrentID')); - $Cache->cache_value('users_snatched_'.$UserID, $SnatchedTorrents, 86400); -} -if(!array_key_exists($TorrentID, $SnatchedTorrents)) { - $SnatchedTorrents[$TorrentID] = 1; - $Cache->cache_value('users_snatched_'.$UserID, $SnatchedTorrents, 86400); -} - - $DB->query("SELECT File FROM torrents_files WHERE TorrentID='$TorrentID'"); diff --git a/sections/torrents/notify.php b/sections/torrents/notify.php index 86530f12..2cfb4e4d 100644 --- a/sections/torrents/notify.php +++ b/sections/torrents/notify.php @@ -65,7 +65,7 @@ function header_link($SortKey, $DefaultWay = "desc") { $DB->query("CREATE TEMPORARY TABLE temp_notify_torrents (TorrentID int, GroupID int, UnRead tinyint, FilterID int, Year smallint, PRIMARY KEY(GroupID, TorrentID), KEY(Year)) ENGINE=MyISAM"); - $DB->query("INSERT INTO temp_notify_torrents (TorrentID, GroupID, UnRead, FilterID) + $DB->query("INSERT IGNORE INTO temp_notify_torrents (TorrentID, GroupID, UnRead, FilterID) SELECT t.ID, t.GroupID, unt.UnRead, unt.FilterID FROM users_notify_torrents AS unt JOIN torrents AS t ON t.ID=unt.TorrentID WHERE unt.UserID=$UserID". diff --git a/sections/torrents/voter_picks.php b/sections/torrents/voter_picks.php index 3fe4c572..2dd0b4c3 100644 --- a/sections/torrents/voter_picks.php +++ b/sections/torrents/voter_picks.php @@ -28,7 +28,7 @@ arsort($GroupScores); $Top10 = array_slice($GroupScores, 0, 10, true); - $Cache->cache_value('similar_albums_'.$GroupID, $Top10, 12*3600); + $Cache->cache_value('similar_albums_'.$GroupID, $Top10, 2*3600); } if (count($Top10) > 0) { ?> diff --git a/sections/user/edit.php b/sections/user/edit.php index 239bd913..2722d575 100644 --- a/sections/user/edit.php +++ b/sections/user/edit.php @@ -52,9 +52,6 @@ function checked($Checked) { return $Checked ? 'checked="checked"' : ''; } -$DB->query("SELECT COUNT(x.uid) FROM xbt_snatched AS x INNER JOIN torrents AS t ON t.ID=x.fid WHERE x.uid='$UserID'"); -list($Snatched) = $DB->next_record(); - if ($SiteOptions) { $SiteOptions = unserialize($SiteOptions); } else { @@ -142,7 +139,6 @@ function checked($Checked) { checked="checked" />
Posts per page (Forum)
Push Notifications @@ -327,15 +322,13 @@ function checked($Checked) {
checked="checked" />Announcements
checked="checked" />Private Messages
- checked="checked" />Rippys
- ?> + checked="checked" />Rippys
*/ ?> + [Test Push] - [Wiki Guide] + [Wiki Guide]
Rippy! @@ -407,7 +400,7 @@ function checked($Checked) {  

Note: Paranoia has nothing to do with your security on this site; the only thing affected by this setting is other users' ability to see your site activity and taste in music.

-

Select the elements you want to show on your profile. For example, if you tick "Show count" for "Snatched", users will be able to see that you have snatched torrents. If you tick "Show list", they will be able to see the full list of torrents you've snatched.

+

Select the elements you want to show on your profile. For example, if you tick "Show count" for "Snatched", users will be able to see how many torrents you have snatched. If you tick "Show list", they will be able to see the full list of torrents you've snatched.

Some information will still be available in the site log.