<?php
/* Comment feed */
$last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT';
make_cacheable($last_modified, 60*60*3);/* make cacheable in browsers for 3 hours & send 'Not modified' (304) header if not modified. */
header('Content-Type: text/xml;charset=' . get_option('blog_charset'), true);
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
	<channel>
		<title><?php echo 'Comments : ', get_wp_title_rss(''), ' - ', get_bloginfo( 'name' );?></title>
		<atom:link href="http://<?php echo $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']; ?>" rel="self" type="application/rss+xml" />
		<link><?php the_permalink_rss(); ?></link>
		<description><?php the_excerpt_rss(); ?></description>
		<pubDate><?php echo gmdate('r'); ?></pubDate>
	
		<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
		<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
		<image>
			<url>http://media.example.com/logo.png</url>
			<title><?php echo 'Comments : ', get_wp_title_rss(''), ' - ', get_bloginfo( 'name' );?></title>
			<link><?php the_permalink_rss(); ?></link>
			<width>50</width>
			<height>50</height>
			<description><?php the_excerpt_rss(); ?></description>
		</image>	
		<?php do_action('commentsrss2_head');
		$q = "SELECT comment_ID, comment_author, comment_date_gmt, comment_content FROM $wpdb->comments WHERE comment_post_ID = $post->ID AND comment_approved = 1 ORDER BY comment_date DESC LIMIT 10";
		$comments = $wpdb->get_results($q);
		foreach($comments as $comment) 
		{ $comment->comment_ID; $date = mysql2date('D, d M Y H:i:s +0000', $comment->comment_date_gmt); ?>

		<item>
			<title><?php echo $comment->comment_author; ?></title>
			<link><?php trailingslashit(the_permalink_rss()); ?>#comments</link>
			<pubDate><?php echo $date; ?></pubDate>
			<dc:creator><?php echo $comment->comment_author; ?></dc:creator>
			<guid isPermaLink="false"><?php trailingslashit(the_permalink_rss()); ?>#comment-<?php echo $comment->comment_ID; ?></guid>
			<description><![CDATA[<?php echo strip_tags(substr($comment->comment_content, 0, 40)); ?>]]></description>
			<content:encoded><![CDATA[<?php echo $comment->comment_content; ?>]]></content:encoded>
		</item>
<?php	} ?>

	</channel>
</rss>

