36 |
kaklik |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*************************************************************
|
|
|
4 |
* TorrentFlux - PHP Torrent Manager
|
|
|
5 |
* www.torrentflux.com
|
|
|
6 |
**************************************************************/
|
|
|
7 |
/*
|
|
|
8 |
This file is part of TorrentFlux.
|
|
|
9 |
|
|
|
10 |
TorrentFlux is free software; you can redistribute it and/or modify
|
|
|
11 |
it under the terms of the GNU General Public License as published by
|
|
|
12 |
the Free Software Foundation; either version 2 of the License, or
|
|
|
13 |
(at your option) any later version.
|
|
|
14 |
|
|
|
15 |
TorrentFlux is distributed in the hope that it will be useful,
|
|
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
18 |
GNU General Public License for more details.
|
|
|
19 |
|
|
|
20 |
You should have received a copy of the GNU General Public License
|
|
|
21 |
along with TorrentFlux; if not, write to the Free Software
|
|
|
22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
include_once("config.php");
|
|
|
26 |
include_once("functions.php");
|
|
|
27 |
include_once("lastRSS.php");
|
|
|
28 |
|
|
|
29 |
// check http://varchars.com/rss/ for feeds
|
|
|
30 |
|
|
|
31 |
// The following is for PHP < 4.3
|
|
|
32 |
if (!function_exists('html_entity_decode'))
|
|
|
33 |
{
|
|
|
34 |
function html_entity_decode($string, $opt = ENT_COMPAT)
|
|
|
35 |
{
|
|
|
36 |
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
|
|
|
37 |
$trans_tbl = array_flip ($trans_tbl);
|
|
|
38 |
|
|
|
39 |
if ($opt & 1)
|
|
|
40 |
{
|
|
|
41 |
// Translating single quotes
|
|
|
42 |
// Add single quote to translation table;
|
|
|
43 |
// doesn't appear to be there by default
|
|
|
44 |
$trans_tbl["'"] = "'";
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
if (!($opt & 2))
|
|
|
48 |
{
|
|
|
49 |
// Not translating double quotes
|
|
|
50 |
// Remove double quote from translation table
|
|
|
51 |
unset($trans_tbl["""]);
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
return strtr ($string, $trans_tbl);
|
|
|
55 |
}
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
// Just to be safe ;o)
|
|
|
59 |
if (!defined("ENT_COMPAT")) define("ENT_COMPAT", 2);
|
|
|
60 |
if (!defined("ENT_NOQUOTES")) define("ENT_NOQUOTES", 0);
|
|
|
61 |
if (!defined("ENT_QUOTES")) define("ENT_QUOTES", 3);
|
|
|
62 |
|
|
|
63 |
DisplayHead("RSS Torrents");
|
|
|
64 |
|
|
|
65 |
// Get RSS feeds from Database
|
|
|
66 |
$arURL = GetRSSLinks();
|
|
|
67 |
|
|
|
68 |
// create lastRSS object
|
|
|
69 |
$rss = new lastRSS();
|
|
|
70 |
|
|
|
71 |
// setup transparent cache
|
|
|
72 |
$rss->cache_dir = $cfg["torrent_file_path"];
|
|
|
73 |
$rss->cache_time = $cfg["rss_cache_min"] * 60; // 1200 = 20 min. 3600 = 1 hour
|
|
|
74 |
$rss->strip_html = false; // don't remove HTML from the description
|
|
|
75 |
|
|
|
76 |
echo "<a name=\"top\"></a><div align=\"center\">";
|
|
|
77 |
echo "<table border=1 cellspacing=0 width=\"760\" cellpadding=5><tr>";
|
|
|
78 |
echo "<td bgcolor=\"".$cfg["table_header_bg"]."\">RSS Feeds (jump list):";
|
|
|
79 |
echo "<ul>";
|
|
|
80 |
|
|
|
81 |
// Loop through each RSS feed
|
|
|
82 |
foreach( $arURL as $rid => $url )
|
|
|
83 |
{
|
|
|
84 |
if( $rs = $rss->get( $url ) )
|
|
|
85 |
{
|
|
|
86 |
if( !empty( $rs["items"] ) )
|
|
|
87 |
{
|
|
|
88 |
// Cache rss feed so we don't have to call it again
|
|
|
89 |
$rssfeed[] = $rs;
|
|
|
90 |
echo "<li><a href=\"#".$rid."\">".$rs["title"]."</a></li>\n";
|
|
|
91 |
}
|
|
|
92 |
else
|
|
|
93 |
{
|
|
|
94 |
$rssfeed[] = "";
|
|
|
95 |
echo "<li>* RSS timed out * (<a href=\"#".$rid."\">".$url."</a>)</li>\n";
|
|
|
96 |
}
|
|
|
97 |
}
|
|
|
98 |
else
|
|
|
99 |
{
|
|
|
100 |
// Unable to grab RSS feed, must of timed out
|
|
|
101 |
$rssfeed[] = "";
|
|
|
102 |
echo "<li>* RSS timed out * (<a href=\"#".$rid."\">".$url."</a>)</li>\n";
|
|
|
103 |
}
|
|
|
104 |
}
|
|
|
105 |
echo "</ul>* Click on Torrent Links below to add them to the Torrent Download List</td>";
|
|
|
106 |
echo "</tr></table>";
|
|
|
107 |
echo "</div>";
|
|
|
108 |
|
|
|
109 |
// Parse through cache RSS feed
|
|
|
110 |
foreach( $rssfeed as $rid => $rs )
|
|
|
111 |
{
|
|
|
112 |
$title = "";
|
|
|
113 |
$content = "";
|
|
|
114 |
$pageUrl = "";
|
|
|
115 |
|
|
|
116 |
if( !empty( $rs["items"] ) )
|
|
|
117 |
{
|
|
|
118 |
// get Site title and Page Link
|
|
|
119 |
$title = $rs["title"];
|
|
|
120 |
$pageUrl = $rs["link"];
|
|
|
121 |
|
|
|
122 |
$content = "";
|
|
|
123 |
|
|
|
124 |
for ($i=0; $i < count($rs["items"]); $i++)
|
|
|
125 |
{
|
|
|
126 |
$link = $rs["items"][$i]["link"];
|
|
|
127 |
$title2 = $rs["items"][$i]["title"];
|
|
|
128 |
$pubDate = (!empty($rs["items"][$i]["pubDate"])) ? $rs["items"][$i]["pubDate"] : "Unknown";
|
|
|
129 |
|
|
|
130 |
// RSS entry needs to have a link, otherwise pointless
|
|
|
131 |
if( empty( $link ) )
|
|
|
132 |
continue;
|
|
|
133 |
|
|
|
134 |
if($link != "" && $title2 !="")
|
|
|
135 |
{
|
|
|
136 |
$content .= "<tr><td><img src=\"images/download_owner.gif\" width=\"16\" height=\"16\" title=\"".$link."\"><a href=\"index.php?url_upload=".$link."\">".$title2."</a></td><td> ".$pubDate."</td></tr>\n";
|
|
|
137 |
}
|
|
|
138 |
else
|
|
|
139 |
{
|
|
|
140 |
$content .= "<tr><td class=\"tiny\"><img src=\"images/download_owner.gif\" width=\"16\" height=\"16\">".ScrubDescription(str_replace("Torrent: <a href=\"", "Torrent: <a href=\"index.php?url_upload=", html_entity_decode($rs["items"][$i]["description"])), $title2)."</td><td valign=\"top\">".$pubDate."</td></tr>";
|
|
|
141 |
}
|
|
|
142 |
}
|
|
|
143 |
}
|
|
|
144 |
else
|
|
|
145 |
{
|
|
|
146 |
// Request timed out, display timeout message
|
|
|
147 |
echo "<br>**** RSS timed out: <a href=\"".$url."\" target=\"_blank\">".$url."</a>";
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
if ($content != "") { // Close the content and add a line break
|
|
|
151 |
$content .= "<br>";
|
|
|
152 |
}
|
|
|
153 |
displayNews($title, $pageUrl, $content, $rid);
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
DisplayFoot();
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
function displayNews($title, $pageUrl, $content, $rid) {
|
|
|
161 |
global $cfg;
|
|
|
162 |
// Draw the Table
|
|
|
163 |
echo "<a name=\"".$rid."\"></a><table width=\"760\" border=1 bordercolor=\"".$cfg["table_admin_border"]."\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"".$cfg["table_data_bg"]."\">";
|
|
|
164 |
echo "<tr><td colspan=2 bgcolor=\"".$cfg["table_header_bg"]."\" background=\"themes/".$cfg["theme"]."/images/bar.gif\">";
|
|
|
165 |
echo "<img src=\"images/properties.png\" width=18 height=13 border=0> <strong><a href=\"".$pageUrl."\" target=\"_blank\"><font class=\"adminlink\">".$title."</font></a> <font class=\"tinywhite\">[<a href=\"#\"><font class=\"tinywhite\">top</font></a>]</font></strong>";
|
|
|
166 |
echo "</td></tr>";
|
|
|
167 |
echo "<tr><td bgcolor=\"".$cfg["table_header_bg"]."\"><div align=center class=\"title\">"._TORRENTFILE."</div></td>";
|
|
|
168 |
echo "<td bgcolor=\"".$cfg["table_header_bg"]."\" width=\"33%\"><div align=center class=\"title\">"._TIMESTAMP."</div></td>";
|
|
|
169 |
|
|
|
170 |
echo $content;
|
|
|
171 |
|
|
|
172 |
echo "</table>";
|
|
|
173 |
}
|
|
|
174 |
|
|
|
175 |
// Scrub the description to take out the ugly long URLs
|
|
|
176 |
function ScrubDescription($desc, $title)
|
|
|
177 |
{
|
|
|
178 |
$rtnValue = "";
|
|
|
179 |
|
|
|
180 |
$parts = explode("</a>", $desc);
|
|
|
181 |
|
|
|
182 |
$replace = ereg_replace('">.*$', '">'.$title."</a>", $parts[0]);
|
|
|
183 |
|
|
|
184 |
if (strpos($parts[1], "Search:") !== false)
|
|
|
185 |
{
|
|
|
186 |
$parts[1] = $parts[1]."</a>\n";
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
for($inx = 2; $inx < count($parts); $inx++)
|
|
|
190 |
{
|
|
|
191 |
if (strpos($parts[$inx], "Info: <a ") !== false)
|
|
|
192 |
{
|
|
|
193 |
// We have an Info: and URL to clean
|
|
|
194 |
$parts[$inx] = ereg_replace('">.*$', '" target="_blank">Read More...</a>', $parts[$inx]);
|
|
|
195 |
}
|
|
|
196 |
}
|
|
|
197 |
|
|
|
198 |
$rtnValue = $replace;
|
|
|
199 |
for ($inx = 1; $inx < count($parts); $inx++)
|
|
|
200 |
{
|
|
|
201 |
$rtnValue .= $parts[$inx];
|
|
|
202 |
}
|
|
|
203 |
|
|
|
204 |
return $rtnValue;
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
?>
|