Location: PHPKode > projects > InFrame > InFrame-0.46/feed/index.php
<?php
/****************************************************************
 * This file is part of InFrame
 * Copyright (c) 2008 Richard Tong. All Rights Reserved.
 * 
 * Licensed under the terms of the GNU General Public License.
 * See http://opensource.org/licenses/gpl-license.php
 * 
 ****************************************************************/

// RSS Feed generator for InFrame
$configFile = "../Config/InFrame.config.php";
if (file_exists($configFile))
  require_once($configFile);

if (!Database::dbExists(ABSP."/Data/InFrame"))
	noContent();
else
if (Photo::totalPosts() < 1)
	noContent();
else
{
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>
<?xml-stylesheet type=\"text/css\" href=\"".Util::currentURL().URLTOP."feed/rss.css\" ?>
<rss version=\"2.0\">
<channel>
<title>".stripslashes(Config::title())."</title>\n";

if (Config::byline() == "none")
	echo "<description>an InFrame photoblog.</description>\n";
else
	echo "<description>".stripslashes(Config::byline())."</description>\n";

echo "<lastBuildDate>".date("r")."</lastBuildDate>\n";
echo "<link>".Util::currentURL().URLTOP."</link>
<language>en-us</language>\n";

if (file_exists(ABSP."/feed/feed-logo.png"))
{
list($w, $h) = getimagesize(ABSP."/feed/feed-logo.png");
echo" <image>
<title>".Config::title()."</title>
<url>".Util::currentURL().URLTOP."feed/feed-logo.png</url>
<link>".Util::currentURL().URLTOP."</link>
<width>".$w."</width>
<height>".$h."</height>
</image>\n";
}

$db = new FFDB();
$db->open(ABSP."/Data/InFrame");
$records = $db->getall();
$db->close();
unset($db);

foreach ($records as $record)
{
	echo "<item>\n";
	echo "<title>".$record["title"]."</title>\n";
	if ($record["caption"] == "none")
		echo "<description>There is no description for this item.</description>\n";
	else
		echo "<description>".$record["caption"]."</description>\n";
	echo "<link>".Util::currentURL().URLTOP."index.php?id=".$record["id"]."</link>\n";
	echo "<pubDate>".$record["gmtdateadded"]."</pubDate>\n";
	echo "</item>\n";
}

echo "</channel>
</rss>";
}
	
function noContent()
{
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<?xml-stylesheet type=\"text/css\" href=\"".URLTOP."feed/feed.css\" ?>
<rss version=\"2.0\">
<channel>
<title>".stripslashes(Config::title())."</title>
<description>There is currently no content here.</description>
<link>".Util::currentURL()."/".URLTOP."</link>
<language>en-us</language>
</channel>
</rss>";
}

function __autoload($class_name)
{
  require_once '../Class/' . $class_name . '.class.php';
}

?>
Return current item: InFrame