<?php
/*
Plugin Name: Control Outbound RSS
Plugin URI: http://software.mywebspace.co.il/2009/09/18/control-outbound-rss-plugin-for-wordpress
Description: Send a smaller RSS feed, containing only the items which were not fetched at the previous feed read.
Author: Mark Kaplun
Version: 0.1

Author URI: 

Copyright 2009 by Mark Kaplun 

Use it as you wish, but if you use it for comercial porpuses don't be to shy to donate.

*/

  function mk_sr_filter_where($where = '') {
    $since=$_SERVER['HTTP_IF_MODIFIED_SINCE'];
    $s = strtotime($since);
    if ($s > 0)
        $where .= " AND post_date_gmt > '" . date('Y-m-d H:i:s', $s) . "'";
    return $where;
  }
  
  function mk_sr_comment_filter_where($where = '') {
    $since=$_SERVER['HTTP_IF_MODIFIED_SINCE'];
    $s = strtotime($since);
    if ($s > 0)
        $where .= " AND comment_date_gmt > '" . date('Y-m-d H:i:s', $s) . "'";
    return $where;
  }
  
function mk_sr_set_query_params() {
    global $query_string;
    
  if (is_feed()) {
    add_filter('posts_where', 'mk_sr_filter_where');
    add_filter('comment_feed_where', 'mk_sr_comment_filter_where');
    query_posts($query_string);
  }
}

add_action('template_redirect','mk_sr_set_query_params');
?>