-
Notifications
You must be signed in to change notification settings - Fork 0
/
rss.php
160 lines (133 loc) · 5.29 KB
/
rss.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
//
// TorrentTrader v2.x
// $LastChangedDate: 2011-11-11 16:19:27 +0000 (Fri, 11 Nov 2011) $
// $LastChangedBy: dj-howarth1 $
//
// http://www.torrenttrader.org
//
//
//
// Validated at: http://feedvalidator.org
//
require_once("backend/functions.php");
dbconn(false);
if (isset($_GET["custom"])){
stdhead(T_("CUSTOM_RSS_XML_FEED"));
begin_frame(T_("CUSTOM_RSS_XML_FEED"));
$rqt = "SELECT id, name, parent_cat FROM categories ORDER BY parent_cat ASC, sort_index ASC";
$resqn = SQL_Query_exec($rqt);
if ($_POST) {
$params = array();
if ($cats = $_POST["cats"]) {
$catlist = array();
foreach ($cats as $cat) {
if (is_numeric($cat)) {
$catlist[] = $cat;
}
}
if ($catlist)
$params[] = "cat=".implode(",", $catlist);
}
if ($_POST["incldead"])
$params[] = "incldead=1";
if ($_POST["dllink"])
$params[] = "dllink=1";
if (!$_POST["cookies"] && $CURUSER)
$params[] = "passkey=$CURUSER[passkey]";
if ($params)
$param = "?".implode("&", $params);
else
$param = "";
echo "Your RSS link is: <a href=\"$site_config[SITEURL]/rss.php$param\">$site_config[SITEURL]/rss.php$param</a><br/><br/>";
}
?>
What is RSS? Take a look at the <a href="http://wikipedia.org/wiki/RSS_%28file_format%29">Wiki</a> to <a href="http://wikipedia.org/wiki/RSS_%28file_format%29">learn more</a>.<br /><br />
<form action="rss.php?custom" method="post">
<table border="0" cellpadding="5" cellspacing="0" class="table_table">
<tr>
<td class="table_col1" valign="top">Categories:</td>
<td class="table_col2" valign="top">(Leave blank for All)<br /><br />
<?php while ($row = mysql_fetch_array($resqn)) {
echo '<input type="checkbox" name="cats[]" value="'.$row['id'].'" /> '.htmlspecialchars("$row[parent_cat] - $row[name]").'<br />';
}
?>
</td>
</tr>
<tr>
<td class="table_col1"><?php echo T_("FEED_TYPE");?>:</td>
<td class="table_col2">
<input type="radio" name="dllink" value="0" checked="checked" />Details link<br />
<input type="radio" name="dllink" value="1" /> Download link<br />
</td>
</tr>
<tr>
<td class="table_col1"><?php echo T_("LOGIN_TYPE");?>:</td>
<td class="table_col2">
<input type="radio" name="cookies" value="1" checked="checked" /> Standard (cookies)<br/>
<input type="radio" name="cookies" value="0" /> Alternative (no cookies)<br/>
</td>
</tr>
<tr>
<td class="table_col1"><?php echo T_("INCLUDE_DEAD");?>:</td>
<td class="table_col2"><input type="checkbox" name="incldead" value="1" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Get Link" /></td>
</tr>
</table>
</form>
<br /><br />
<div align="left">
Quick information regarding our RSS:
<ul>
<li>Our RSS feeds are properly validated by true RSS 2.0 XML Parsing Standards. Visit FeedValidator.org to validate.</li>
<li>Our feeds display only the latest 50 uploaded Torrents as default.</li>
</ul>
</div>
<?php
end_frame();
stdfoot();
die();
}
$cat = $_GET["cat"];
$dllink = (int)$_GET["dllink"];
$passkey = $_GET["passkey"];
if (!get_row_count("users", "WHERE passkey=".sqlesc($passkey)))
$passkey = "";
$where = "";
$wherea = array();
if (!$incldead) {
$wherea[] = "visible='yes'";
}
if ($cat) {
$cats = implode(", ", array_unique(array_map("intval", explode(",", $cat))));
$wherea[] = "category in ($cats)";
}
if (is_valid_id($_GET["user"])) {
$wherea[] = "owner=$_GET[user]";
}
if ($wherea)
$where = "WHERE ".implode(" AND ", $wherea);
$limit = "LIMIT 50";
// start the RSS feed output
header("Content-Type: application/xhtml+xml; charset=$site_config[CHARSET]");
echo("<?xml version=\"1.0\" encoding=\"$site_config[CHARSET]\"?>");
echo("<rss version=\"2.0\"><channel><generator>" . htmlspecialchars($site_config["SITENAME"]) . " RSS 2.0</generator><language>en</language>" .
"<title>" . $site_config["SITENAME"] . "</title><description>" . htmlspecialchars($site_config["SITENAME"]) . " RSS Feed</description><link>" . $site_config["SITEURL"] . "</link><copyright>Copyright " . htmlspecialchars($site_config["SITENAME"]) . "</copyright><pubDate>".date("r")."</pubDate>");
$res = SQL_Query_exec("SELECT torrents.id, torrents.name, torrents.size, torrents.category, torrents.added, torrents.leechers, torrents.seeders, categories.parent_cat as cat_parent, categories.name AS cat_name FROM torrents LEFT JOIN categories ON category = categories.id $where ORDER BY added DESC $limit");
while ($row = mysql_fetch_array ($res)){
list($id,$name,$size,$category,$added,$leechers,$seeders,$catname) = $row;
if ($dllink) {
if ($passkey)
$link = "$site_config[SITEURL]/download.php?id=$id&passkey=$passkey";
else
$link = "$site_config[SITEURL]/download.php?id=$id";
} else {
$link = "$site_config[SITEURL]/download.php?id=$id";
// $link = $site_config["SITEURL"]."/torrents-details.php?id=$id&hit=1";
}
$pubdate = date("r", sql_timestamp_to_unix_timestamp($added));
echo("<item><title>" . htmlspecialchars($name) . "</title><guid>" . $link . "</guid><link>" . $link . "</link><pubDate>" . $pubdate . "</pubDate> <category> " . $row["cat_parent"] . ": " . $row["cat_name"] . "</category><description>Category: " . $row["cat_parent"] . ": " . $row["cat_name"] . " Size: " . mksize($size) . " Added: " . $added . " Seeders: " . $seeders . " Leechers: " . $leechers . "</description></item>");
}
echo("</channel></rss>");