<?php
/*******************************************************************************
*****************                  PREPARATION                ******************
*******************************************************************************/

	// Define global path
	$PS_CFG->path_adminator = (isset($PS_CFG->path_adminator) && $PS_CFG->path_adminator)
	?	$PS_CFG->path_adminator
	:	dirname($_SERVER['DOCUMENT_ROOT']) . '/adminator/';

	// Load required classes and libraries
	require_once($PS_CFG->path_adminator.'engine_config.php');
	$PS_CFG->db_enable	= TRUE;
	require_once($PS_CFG->path_adminator.'engine_global.php');
	require_once($PS_CFG->path_adminator . '/' . $PS_CFG->dir_engine . '/engine_comment.php');
	$PS_BLOG = engine_comment::factory('PS_CFG', 'blog_');
	$PS_BLOG->assign_object('database_slave', $PS_DB['slave']);
	$PS_BLOG->assign_object('database_master', $PS_DB['master']);
	require_once($PS_CFG->path_adminator . '/' . $PS_CFG->dir_engine . '/engine_feed.php');
	$PS_FEED = new engine_feed('PS_CFG', 'blog_');



	// Language definitions
	$i18n_errors					= array();

	// Format input arrays
	$_GET =& incoming_format($_GET);

/*******************************************************************************
******************                  MAIN CODE                 ******************
*******************************************************************************/

	$PS_DB['slave']->query('SET names "utf8"');
	$PS_BLOG_ENTRY_LIST = $PS_BLOG->load_entry_list(0, 15, 0, 0, time());

	if (array_key_exists('IF_MODIFIED_SINCE', $_SERVER))
	{
		if (array_key_exists(0, $PS_BLOG_ENTRY_LIST)
		    && array_key_exists('date_create', $PS_BLOG_ENTRY_LIST[0])
		    && strtotime($_SERVER['IF_MODIFIED_SINCE']) >= $PS_BLOG_ENTRY_LIST[0]['date_create'])
		{
			header('HTTP/1.1 304 Not Modified');
			@ob_end_clean();
			exit;
		}
	}
	if (array_key_exists(0, $PS_BLOG_ENTRY_LIST) && array_key_exists('date_create', $PS_BLOG_ENTRY_LIST[0]))
	{
		header('Last-Modified: ' . date('r', $PS_BLOG_ENTRY_LIST[0]['date_create']));
	}

	$PS_FEED->feed_base		= "http://www.rene-marc.com";
	$PS_FEED->feed_language		= "en";

	$PS_FEED->feed_title		= "René-Marc's Blog";
	$PS_FEED->feed_subtitle		= "Unique French-Canadian Entrepreneur";
	$PS_FEED->feed_link		= "http://www.rene-marc.com/feed.atom.xml";
	$PS_FEED->feed_link_rel		= "self";
	$PS_FEED->feed_updated		= 0;
	$PS_FEED->feed_author		= "René-Marc Simard";
	$PS_FEED->feed_author_email	= "";
	$PS_FEED->feed_author_uri	= "";
	$PS_FEED->feed_id		= "";
	$PS_FEED->feed_generator	= "PS Engine Feed";
	$PS_FEED->feed_generator_uri	= "";
	$PS_FEED->feed_generator_version	= "1.0";

	$PS_FEED->feed_rights		= "Copyright © " . date('Y') . " René-Marc Simard. All Rights Reserved.";
	$PS_FEED->feed_icon		= "http://www.rene-marc.com/favicon.ico";
	$PS_FEED->feed_image		= "/images/rms_88x31.gif";
	$PS_FEED->feed_image_title	= "René-Marc Simard";
	$PS_FEED->feed_image_link	= "http://www.rene-marc.com/";
	$PS_FEED->feed_image_width	= 88;
	$PS_FEED->feed_image_height	= 31;
	$PS_FEED->feed_image_description	= "";

	$PS_FEED->entry_id_prefix	= "tag:rene-marc.com:blog-entry:";
	$PS_FEED->entry_id_type		= 'def';		// date, id, urn

	$PS_FEED->register_author("René-Marc Simard", '', 'http://www.rene-marc.com/');

	for ($i=0, $c=count($PS_BLOG_ENTRY_LIST); $i<$c; $i++)
	{
		$PS_BLOG_ENTRY_LIST[$i]['link']		= 'http://www.rene-marc.com/blog/' . $PS_BLOG_ENTRY_LIST[$i]['entry_id'];
		$PS_BLOG_ENTRY_LIST[$i]['entry']	= trim($PS_BLOG_ENTRY_LIST[$i]['entry']);
		$PS_BLOG_ENTRY_LIST[$i]['entry']	= entry_build($PS_BLOG_ENTRY_LIST[$i]);
		$PS_BLOG_ENTRY_LIST[$i]['entry']	= preg_replace('#(src|href)="/#', '$1="http://www.rene-marc.com/', $PS_BLOG_ENTRY_LIST[$i]['entry']);

		$PS_BLOG_ENTRY_LIST[$i]['summary']	= html2text($PS_BLOG_ENTRY_LIST[$i]['entry']);
		$PS_BLOG_ENTRY_LIST[$i]['summary']	= ellipsis($PS_BLOG_ENTRY_LIST[$i]['summary'], 200, '...');
		$PS_BLOG_ENTRY_LIST[$i]['author']	= '';

		if ($PS_FEED->feed_updated < $PS_BLOG_ENTRY_LIST[$i]['date_create'])
		{
			$PS_FEED->feed_updated = $PS_BLOG_ENTRY_LIST[$i]['date_create'];
		}
	}


	$feed = $PS_FEED->output_feed($PS_BLOG_ENTRY_LIST);

	$feed = htmlentities($feed);
	echo '<pre>';
	var_dump($feed);



/*******************************************************************************
******************                  FUNCTIONS                 ******************
*******************************************************************************/

/*******************************************************************************
** <EOF>                                                     **       POPCORN **
** End of file.                                              **       studios **
*******************************************************************************/
?>
