From d34618314d20c9f5277b7471e0b3dbef130b2cfc Mon Sep 17 00:00:00 2001 From: Git Date: Thu, 2 Feb 2012 08:00:26 +0000 Subject: [PATCH] Empty commit --- classes/class_text.php | 22 +++++++++++++++++++++- classes/script_start.php | 28 ++++++++++++++++++---------- sections/ajax/requests.php | 1 - sections/torrents/add_tag.php | 3 ++- sections/torrents/delete_tag.php | 8 ++++++++ 5 files changed, 49 insertions(+), 13 deletions(-) diff --git a/classes/class_text.php b/classes/class_text.php index 6eaeeae4..8dc9dc59 100644 --- a/classes/class_text.php +++ b/classes/class_text.php @@ -1,7 +1,7 @@ max number of attributes - private $ValidTags = array('b'=>0, 'u'=>0, 'i'=>0, 's'=>0, '*'=>0, '#'=>0, 'artist'=>0, 'user'=>0, 'n'=>0, 'inlineurl'=>0, 'inlinesize'=>1, 'align'=>1, 'color'=>1, 'colour'=>1, 'size'=>1, 'url'=>1, 'img'=>1, 'quote'=>1, 'pre'=>1, 'code'=>1, 'tex'=>0, 'hide'=>1, 'plain'=>0, 'important'=>0 + private $ValidTags = array('b'=>0, 'u'=>0, 'i'=>0, 's'=>0, '*'=>0, '#'=>0, 'artist'=>0, 'user'=>0, 'n'=>0, 'inlineurl'=>0, 'inlinesize'=>1, 'align'=>1, 'color'=>1, 'colour'=>1, 'size'=>1, 'url'=>1, 'img'=>1, 'quote'=>1, 'pre'=>1, 'code'=>1, 'tex'=>0, 'hide'=>1, 'plain'=>0, 'important'=>0, 'torrent'=>0 ); private $Smileys = array( ':angry:' => 'angry.gif', @@ -370,6 +370,9 @@ function parse($Str) { case 'artist': $Array[$ArrayPos] = array('Type'=>'artist', 'Val'=>$Block); break; + case 'torrent': + $Array[$ArrayPos] = array('Type'=>'torrent', 'Val'=>$Block); + break; case 'tex': $Array[$ArrayPos] = array('Type'=>'tex', 'Val'=>$Block); break; @@ -450,6 +453,23 @@ function to_html($Array) { case 'artist': $Str.=''.$Block['Val'].''; break; + case 'torrent': + $Pattern = '/('.NONSSL_SITE_URL.'\/torrents\.php?.*id=)?(\d+)($|&|#)/'; + $Matches = array(); + if (preg_match($Pattern, $Block['Val'], $Matches)) { + if (isset($Matches[2])) { + $Groups = get_groups(array($Matches[2]), true, true, false); + if (!empty($Groups['matches'][$Matches[2]])) { + $Group = $Groups['matches'][$Matches[2]]; + $Str .= display_artists($Group['ExtendedArtists']).''.$Group['Name'].''; + } else { + $Str .= '[torrent]'.str_replace('[inlineurl]','',$Block['Val']).'[/torrent]'; + } + } + } else { + $Str .= '[torrent]'.$Block['Val'].'[/torrent]'; + } + break; case 'wiki': $Str.=''.$Block['Val'].''; break; diff --git a/classes/script_start.php b/classes/script_start.php index 10a1269f..6bc30a90 100644 --- a/classes/script_start.php +++ b/classes/script_start.php @@ -1748,14 +1748,15 @@ function display_artist($Artist, $MakeLink = true, $Escape = true) { // Function to get data and torrents for an array of GroupIDs. // In places where the output from this is merged with sphinx filters, it will be in a different order. -function get_groups($GroupIDs, $Return = true, $GetArtists = true) { +function get_groups($GroupIDs, $Return = true, $GetArtists = true, $Torrents = true) { global $DB, $Cache; $Found = array_flip($GroupIDs); $NotFound = array_flip($GroupIDs); + $Key = $Torrents ? 'torrent_group_' : 'torrent_group_light_'; foreach($GroupIDs as $GroupID) { - $Data = $Cache->get_value('torrent_group_'.$GroupID); + $Data = $Cache->get_value($Key.$GroupID); if(!empty($Data) && (@$Data['ver'] >= 4)) { unset($NotFound[$GroupID]); $Found[$GroupID] = $Data['d']; @@ -1780,14 +1781,21 @@ function get_groups($GroupIDs, $Return = true, $GetArtists = true) { $Found[$Group['ID']]['Torrents'] = array(); $Found[$Group['ID']]['Artists'] = array(); } - - $DB->query("SELECT - ID, GroupID, Media, Format, Encoding, RemasterYear, Remastered, RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber, Scene, HasLog, HasCue, LogScore, FileCount, FreeTorrent, Size, Leechers, Seeders, Snatched, Time, ID AS HasFile - FROM torrents AS t WHERE GroupID IN($IDs) ORDER BY GroupID, Remastered, (RemasterYear <> 0) DESC, RemasterYear, RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber, Media, Format, Encoding, ID"); - while($Torrent = $DB->next_record(MYSQLI_ASSOC, true)) { - $Found[$Torrent['GroupID']]['Torrents'][$Torrent['ID']] = $Torrent; - - $Cache->cache_value('torrent_group_'.$Torrent['GroupID'], array('ver'=>4, 'd'=>$Found[$Torrent['GroupID']]), 0); + + if ($Torrents) { + $DB->query("SELECT + ID, GroupID, Media, Format, Encoding, RemasterYear, Remastered, RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber, Scene, HasLog, HasCue, LogScore, FileCount, FreeTorrent, Size, Leechers, Seeders, Snatched, Time, ID AS HasFile + FROM torrents AS t WHERE GroupID IN($IDs) ORDER BY GroupID, Remastered, (RemasterYear <> 0) DESC, RemasterYear, RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber, Media, Format, Encoding, ID"); + while($Torrent = $DB->next_record(MYSQLI_ASSOC, true)) { + $Found[$Torrent['GroupID']]['Torrents'][$Torrent['ID']] = $Torrent; + + $Cache->cache_value('torrent_group_'.$Torrent['GroupID'], array('ver'=>4, 'd'=>$Found[$Torrent['GroupID']]), 0); + $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); + } } } if($GetArtists) { diff --git a/sections/ajax/requests.php b/sections/ajax/requests.php index 6328561e..f59010f8 100644 --- a/sections/ajax/requests.php +++ b/sections/ajax/requests.php @@ -1,7 +1,6 @@ query("INSERT INTO torrents_tags_votes (GroupID, TagID, UserID, Way) VALUES ('$GroupID', '$TagID', '$UserID', 'up')"); - + $DB->query("INSERT INTO group_log (GroupID, UserID, Time, Info) + VALUES ('$GroupID',".$LoggedUser['ID'].",'".sqltime()."','".db_string('Tag "'.$TagName.'" added to group')."')"); } } diff --git a/sections/torrents/delete_tag.php b/sections/torrents/delete_tag.php index 292db426..f4a13855 100644 --- a/sections/torrents/delete_tag.php +++ b/sections/torrents/delete_tag.php @@ -9,9 +9,17 @@ error(403); } +$DB->query("SELECT Name FROM tags WHERE ID='$TagID'"); +if (list($TagName) = $DB->next_record()) { + $DB->query("INSERT INTO group_log (GroupID, UserID, Time, Info) + VALUES ('$GroupID',".$LoggedUser['ID'].",'".sqltime()."','".db_string('Tag "'.$TagName.'" removed from group')."')"); +} + $DB->query("DELETE FROM torrents_tags_votes WHERE GroupID='$GroupID' AND TagID='$TagID'"); $DB->query("DELETE FROM torrents_tags WHERE GroupID='$GroupID' AND TagID='$TagID'"); + + $Cache->delete_value('torrents_details_'.$GroupID); // Delete torrent group cache update_hash($GroupID);