Location: PHPKode > projects > Fretsweb > fretsweb-1.2/fretsweb/feed.php
<?php

/*
Fretsweb - A Frets on Fire chart server
Copyright (C) 2009  Daan Sprenkels

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 3 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, see <http://www.gnu.org/licenses/>.
*/


//Include the common file
require_once 'admin/common.php';


// Send xml/rss header
header('Content-type: application/rss+xml');


// Write header
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";


// Write rss
echo "<rss version=\"2.0\">\n";


// Get the site url
if($_SERVER['HTTPS'] == 'on')
	$protocol = 'https';
else
	$protocol = 'http';
if(dirname($_SERVER['PHP_SELF']) == '/')
	$dir = '';
else
	$dir = dirname($_SERVER['PHP_SELF']);
$rootlink = $protocol.'://' . $_SERVER['HTTP_HOST'] . $dir; 


// Channel headers
echo " <channel>\n";
echo "  <title>Fretsweb RSS Feed</title>\n";
echo "  <link>$rootlink</link>\n";
echo "  <description>All Fretsweb's updates on one page.</description>\n";


// Get feed priority
if($feed == 0)
	$feedp = 4;
else
	$feedp = $feed;


// Fetch feed items
$sql = "SELECT `title`, `text`, `code`, `time` FROM `contest_news` WHERE `priority` >= '$feedp ORDER BY `time` DESC LIMIT 256'";
$query = mysql_query($sql);


// Write the items
while($item = mysql_fetch_assoc($query))
{
	echo '  <item>';
	echo "   <title>{$item['title']}</title>\n";
	list($datearr, $timearr) = explode(' ', $item['time']);
	$date = explode('-', $datearr);
	$time = explode(':', $timearr);
	$pubTime = mktime($time[0], $time[1], $time[2], $date[1], $date[2], $date[0]);
	echo "   <pubDate>" . date('r', $pubTime) . "</pubDate>\n";
	if($item['code'] == 'songchange')
	{
		echo "   <link>$rootlink/songs.php</link>\n";
	}
	if($item['code'] == 'chartupdate')
	{
		echo "   <link>$rootlink/scores.php</link>\n";
	}
	if($item['code'] == 'playerchange')
	{
		echo "   <link>$rootlink/players.php</link>\n";
	}
	if($item['code'] == 'forumchange')
	{
		echo "   <link>$rootlink/forum.php</link>\n";
	}
	else
	{
		echo "   <link>$rootlink</link>\n";
	}
	echo "   <description>{$item['text']}</description>\n";
	echo '  </item>';
}


// End channel
echo " </channel>\n";


// End rss
echo "</rss>\n";


// Close the database link
mysql_close( $db_link );

?>
Return current item: Fretsweb