forked from kestasjk/webDiplomacy
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathrss.php
More file actions
77 lines (60 loc) · 2.82 KB
/
rss.php
File metadata and controls
77 lines (60 loc) · 2.82 KB
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
<?php
/*
Copyright (C) 2018 Oliver Auth
This file is part of vDiplomacy.
vDiplomacy is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
vDiplomacy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with vDiplomacy. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @package rss
*/
define('IN_CODE', 1);
// No need to load all the vDip overhead if there is no valid user or RSS ID.
if( !isset($_REQUEST['rssID']) ) die('rssID not provided.');
require_once('header.php');
$rssID = $DB->escape($_REQUEST['rssID']);
if ( !($rssID) ) die('rssID not provided.');
header("Content-Type: application/rss+xml; charset=ISO-8859-1");
list($userID, $name)= $DB->sql_row('SELECT id, username FROM wD_Users WHERE rssID="'.$rssID.'"');
$rssLink = "http://".str_replace("rss.php","",$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']);
$rssfeed = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
$rssfeed .= "<rss version=\"2.0\">\n";
$rssfeed .= " <channel>\n";
$rssfeed .= " <title>".$name."'s VDiplomacy RSS feed</title>\n";
$rssfeed .= " <link>http://".$_SERVER['SERVER_NAME']."</link>\n";
$rssfeed .= " <description>This is the personal vDip RSS-feed of ".$name.".</description>\n";
$rssfeed .= " <language>en-us</language>\n";
$rssfeed .= " <copyright>Copyright (C) 2018 vDiplomacy.com</copyright>\n";
$tabl=$DB->sql_tabl('SELECT type, text, linkName, linkID, timeSent FROM wD_Notices
WHERE toUserID = "'.$userID.'" AND substring(linkName,1,3) <> "To:"
ORDER BY timeSent DESC LIMIT 50');
while(list($type, $text, $linkName, $linkID, $timeSent) = $DB->tabl_row($tabl))
{
if ($type == 'Game')
$link = $rssLink."/board.php?gameID=".$linkID;
else
$link = $rssLink."/profile.php?userID=".$linkID."#message";
$text = html_entity_decode ($text, ENT_QUOTES | ENT_XHTML | ENT_HTML5, 'ISO-8859-1');
$text = strip_tags ($text);
$text = str_replace("&","-",$text);
$rssfeed .= " <item>\n";
$rssfeed .= " <title>".$linkName."</title>\n";
$rssfeed .= " <description>".$text."</description>\n";
// remove guid entry as it is not unique (timeSent can be duplicate)
// $rssfeed .= " <guid>".$link."time".$timeSent."</guid>\n";
$rssfeed .= " <link>".$link."</link>\n";
$rssfeed .= " <pubDate>".date("D, d M Y H:i:s O", $timeSent)."</pubDate>\n";
$rssfeed .= " </item>\n";
}
$rssfeed .= " </channel>\n";
$rssfeed .= "</rss>\n";
echo $rssfeed;
?>