mirror of
https://git.code.sf.net/p/quake/website
synced 2024-11-30 16:01:24 +00:00
66 lines
No EOL
1.9 KiB
PHP
66 lines
No EOL
1.9 KiB
PHP
<?
|
|
/*
|
|
rss.php
|
|
|
|
Quick-and-dirty RSS parser/displayer
|
|
|
|
Copyright (C) 2004,2006 Jeff Teunissen <deek@quakeforge.net>
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; either version 2
|
|
of the License, or (at your option) any later version.
|
|
|
|
This program 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 General Public License
|
|
along with this program; if not, write to:
|
|
|
|
Free Software Foundation, Inc.
|
|
59 Temple Place - Suite 330
|
|
Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
have ("rss");
|
|
need ("cache");
|
|
need ("html");
|
|
|
|
function displayRSSFeed ($url, $showChannelInfo)
|
|
{
|
|
$channelRegEx = ':<channel .*?>.*?<title>(.*?)</title>.*?<link>(.*?)</link>.*?<description>(.*?)</description>.*?</channel>:s';
|
|
$itemRegEx = ':<item .*?>.*?<title>(.*?)</title>.*?<link>(.*?)</link>.*?<description>(.*?)</description>.*?</item>:s';
|
|
|
|
// grab the file
|
|
$data = implode ('', cachedURL ($url));
|
|
|
|
if ($showChannelInfo) { // Channel information
|
|
if ($itemCount = preg_match ($channelRegEx, $data, $info)) {
|
|
$channelTitle = $info[1];
|
|
$channelLink = $info[2];
|
|
$channelDesc = $info[3];
|
|
echo "<H3><A href=\"$channelLink\">" . convertFromHTML ($channelTitle) . "</A></H3>";
|
|
}
|
|
}
|
|
|
|
if (!($itemCount = @preg_match_all ($itemRegEx, $data, $info))) {
|
|
echo "No items found.";
|
|
return;
|
|
}
|
|
|
|
for ($i = 0; $i < $itemCount; $i++) {
|
|
$title = $info[1][$i];
|
|
$link = $info[2][$i];
|
|
$desc = $info[3][$i];
|
|
echo "<P><A href=\"$link\">" . convertFromHTML ($title) . "</A></P>\n";
|
|
}
|
|
}
|
|
|
|
function slashdot ()
|
|
{
|
|
displayRSSFeed ('http://rss.slashdot.org/Slashdot/slashdot', false);
|
|
}
|
|
?>
|