-
Notifications
You must be signed in to change notification settings - Fork 7
/
rss.php
144 lines (126 loc) · 5.53 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
<?php
/////////////////////////////////////////////////////////////////////////////////////
// xbtit - Bittorrent tracker/frontend
//
// Copyright (C) 2004 - 2019 Btiteam
//
// This file is part of xbtit.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// 3. The name of the author may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// **Edited by mcangeli on 1/24/2008 to correct torrent detail link
//
////////////////////////////////////////////////////////////////////////////////////
require_once 'include/functions.php';
require_once 'include/config.php';
if ($XBTT_USE) {
$tseeds = 'f.seeds+ifnull(x.seeders,0)';
$tleechs = 'f.leechers+ifnull(x.leechers,0)';
$ttables = "{$TABLE_PREFIX}files f INNER JOIN xbt_files x ON x.info_hash=f.bin_hash";
} else {
$tseeds = 'f.seeds';
$tleechs = 'f.leechers';
$ttables = "{$TABLE_PREFIX}files f";
}
dbconn(true);
if ($CURUSER['view_torrents'] != 'yes' && $CURUSER['view_forum'] != 'yes') {
header(ERR_500);
die;
}
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="'.$GLOBALS['charset'].'"?>';
function safehtml($string)
{
$validcharset = [
'ISO-8859-1',
'ISO-8859-15',
'UTF-8',
'cp866',
'cp1251',
'cp1252',
'KOI8-R',
'BIG5',
'GB2312',
'BIG5-HKSCS',
'Shift_JIS',
'EUC-JP', ];
if (in_array($GLOBALS['charset'], $validcharset)) {
return htmlentities($string, ENT_COMPAT, $GLOBALS['charset']);
} else {
return htmlentities($string);
}
}
?>
<rss version="2.0" >
<channel>
<title><?php echo $SITENAME; ?></title>
<description>rss feed script designed and coded by beeman (modified by Lupin and VisiGod)</description>
<link><?php echo $BASEURL; ?></link>
<lastBuildDate><?php echo date('D, d M Y H:i:s T'); ?></lastBuildDate>
<copyright><?php echo '(c) '.date('Y', time()).' '.$SITENAME; ?></copyright>
<?php
if ($CURUSER['view_torrents'] == 'yes') {
$getItems = "SELECT f.info_hash as id, f.comment as description, f.filename, $tseeds AS seeders, $tleechs as leechers, UNIX_TIMESTAMP( f.data ) as added, c.name as cname, f.size FROM $ttables LEFT JOIN {$TABLE_PREFIX}categories c ON c.id = f.category ORDER BY data DESC LIMIT 20";
$doGet = get_result($getItems, true, $btit_settings['cache_duration']);
foreach ($doGet as $id => $item) {
$id = $item['id'];
$filename = strip_tags($item['filename']);
$added = strip_tags(date('d/m/Y H:i:s', $item['added']));
$descr = format_comment($item['description']."\n");
$seeders = strip_tags($item['seeders']);
$leechers = strip_tags($item['leechers']);
// output to browser?>
<item>
<title><![CDATA[<?php echo htmlspecialchars('['.TORRENT.'] '.$filename); ?>]]></title>
<description><![CDATA[<?php echo($descr).' ('.SEEDERS.' '.safehtml($seeders).' -- '.LEECHERS.' '.safehtml($leechers); ?>)]]></description>
<link><?php echo $BASEURL; ?>/index.php?page=torrent-details&id=<?php echo $id; ?></link>
<pubDate><?php echo $added; ?></pubDate>
</item>
<?php
}
}
// forums
if ($CURUSER['view_forum'] == 'yes') {
$getItems = "select t.id as topicid, p.id as postid, f.name, u.username,t.subject,p.added, p.body from {$TABLE_PREFIX}topics t inner join {$TABLE_PREFIX}posts p on p.topicid=t.id inner join {$TABLE_PREFIX}forums f on t.forumid=f.id inner join {$TABLE_PREFIX}users u on u.id=p.userid ORDER BY added DESC LIMIT 50";
$doGet = get_result($getItems, true, $btit_settings['cache_duration']);
foreach ($doGet as $id => $item) {
$topicid = $item['topicid'];
$postid = $item['postid'];
$forum = (htmlspecialchars($item['name']));
$subject = (htmlspecialchars($item['subject']));
$added = strip_tags(date('d/m/Y H:i:s', $item['added']));
$body = format_comment('[b]Author: '.$item['username']."[/b]\n\n".$item['body']."\n");
// output to browser
$link = htmlspecialchars($BASEURL."/index.php?page=forum&action=viewtopic&topicid=$topicid&page=p$postid#$postid"); ?>
<item>
<title><![CDATA[<?php echo '['.FORUM.'] '.$forum.' - '.$subject; ?>]]></title>
<description><![CDATA[<?php echo $body; ?>]]></description>
<link><?php echo $link; ?></link>
<pubDate><?php echo $added; ?></pubDate>
</item>
<?php
}
}
?>
</channel>
</rss>