<?php
	echo '<?xml version="1.0" encoding="ISO-8859-1" ?>'."\n";
	echo '<?xml-stylesheet title="XSL_formatting" type="text/xsl" href="nolsol.xsl"?>';
	// we must echo out above lines manually -- as they confuse PHP
	
	include './scripts/connstring.php';
	include './Aries/scripts/IMG_Utils.php';
	include './Aries/scripts/IMG_AriesUtils.php';
	include './Aries/scripts/IMG_User.php';
	include './Aries/scripts/IMG_ApplicationCache.php';
	$connect = getConnection();	
	session_start();


	$blogID = IMG_AriesUtils::pageLookup("Editors Blog");
	$row = IMG_AriesUtils::page_getAllDetails( $blogID);
	//debugvardump($row);

	if ($row["ImageName"] == "") {
		$imageName = DEFAULT_PAGE_ICON;
	} else {
		$imageName = "/uthumbs/".$row["ImageName"];
	}
	$imageName = "http://".$_SERVER["SERVER_NAME"].$imageName;
	


	$SQL  = "SELECT * FROM messageboard WHERE MBoardID=".$blogID." ";
	$SQL .= "ORDER by PostedTime DESC";
	$rs   = odbc_exec($connect, $SQL);
	$row  = odbc_fetch_array($rs);
	if ($row != null) {
		$workAroundODBCProblem = strtotime($row["PostedTime"]);
		$lastBuildDate = date ("r", $workAroundODBCProblem);
	}
?>	
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel>

<title>Digital Photographer : Editor's Blog</title>
<link>http://ariesdev.internet-media-group.com/blog.php</link>
<description><?=$row["LongDescription"]?></description>
<language>en-gb</language>
<lastBuildDate><?=$lastBuildDate?></lastBuildDate>
<copyright>Imagine Publishing Ltd</copyright>
<docs>http://ariesdev.internet-media-group.com/InfoOnRss.htm</docs>
<ttl>15</ttl>


<image>
	<title>Imagine Publishing</title>
	<url><?=$imageName?></url>
	<link>http://ariesdev.internet-media-group.com/blog.php</link>
</image>



<?php
	$SQL  = "SELECT * FROM messageboard WHERE MBoardID=".$blogID." ";
	$SQL .= "ORDER by PostedTime DESC";
	$rs   = odbc_exec($connect, $SQL);

	// we may have multiple messages posted on one day -- so display 'em all
	$oldLink = "";
	$offset = 0;
	while ($row = odbc_fetch_array($rs))
	{
		$postedDate = odbc_result($rs, PostedTime);
		$title      = odbc_result($rs, Title);
		$message    = odbc_result($rs, Message);			
		$postedBy   = odbc_result($rs, PostedBy);	

		$workAroundODBCProblem = strtotime($postedDate);
		$postedDate = date ("r", $workAroundODBCProblem);

		$message = ereg_replace("<[^>]*>", "", $message);		// remove HTML tags
		$message = ereg_replace("&nbsp;",  "", $message);		// remove HTML tags
		$title   = ereg_replace("<[^>]*>", "", $title);			// remove HTML tags		
		$title   = ereg_replace("&nbsp;",  "", $title);			// remove HTML tags		

		$link    = "http://ariesdev.internet-media-group.com/blog.php?blogdate=".date("Y-m-d", $workAroundODBCProblem);
		if ($oldLink == $link)
		{
			// we cannot have duplicate GUID
			$offset++;
			//$link .= "\&offset".$offset;		// although, of course, XML does not like '&'
		} else {
			$offset = 0;
			$oldLink = $link;
		}

		echo "<item>\n";
		echo "<title>".$title."</title>\n";
		echo "<description>".$message."</description>\n";
		echo "<link>".$link."</link>\n";
		echo '<guid isPermaLink="false">'.$link.'</guid>'."\n";
		echo "<pubDate>".$postedDate."</pubDate>\n";
		echo "<category>Editor's Blog</category>\n";
		echo "</item>\n\n\n";

	}	
?>

</channel>
</rss>
