Browse Source

Get list of torrents from DB when cache is empty

ElectraHeart 7 years ago
parent
commit
5777c22cfb
1 changed files with 20 additions and 1 deletions
  1. 20
    1
      classes/feed.class.php

+ 20
- 1
classes/feed.class.php View File

@@ -47,7 +47,26 @@ class FEED {
47 47
     global $Cache;
48 48
     $Entries = $Cache->get_value($CacheKey);
49 49
     if (!$Entries) {
50
-      $Entries = [];
50
+ 		require(SERVER_ROOT.'/classes/mysql.class.php');
51
+		$DB = NEW DB_MYSQL; //Load the database wrapper
52
+		
53
+		$DB->query("
54
+			SELECT t.*,
55
+				(SELECT Name from artists_group ag WHERE ag.ArtistID=ta.ArtistID) AS ArtistName,
56
+			    tg.Name AS GroupName,
57
+				tg.WikiBody AS WikiBody
58
+			FROM `torrents` t
59
+			LEFT JOIN torrents_artists ta ON t.GroupID=ta.GroupID
60
+			LEFT JOIN torrents_group tg ON tg.ID=ta.GroupID
61
+			ORDER BY ID DESC
62
+			LIMIT 50");
63
+		while ($torrent = $DB->next_record()) {
64
+			$Title = $torrent['ArtistName'].' - '.$torrent['GroupName'].' - '.$torrent['Recorded'].' | '.$torrent['Codec'].' / '.$torrent['Media'].' / '.$torrent['Container'].' / '.$torrent['Resolution'].' / '.$torrent['AudioFormat'];
65
+			
66
+			$Item = self::item($Title, Text::strip_bbcode($torrent['WikiBody']), 'torrents.php?action=download&authkey=[[AUTHKEY]]&torrent_pass=[[PASSKEY]]&id='.$torrent['ID'], $torrent['UserID'], 'torrents.php?id='.$torrent['GroupID']);
67
+			self::populate('torrents_all', $Item);
68
+			echo str_replace(array('[[PASSKEY]]', '[[AUTHKEY]]'), array(display_str($PassKey), display_str($AuthKey)), $Item);
69
+		}
51 70
     } else {
52 71
       foreach ($Entries as $Item) {
53 72
         echo str_replace(array('[[PASSKEY]]', '[[AUTHKEY]]'), array(display_str($PassKey), display_str($AuthKey)), $Item);

Loading…
Cancel
Save