category as $category) { // loops through all the tags and returns true if any of them contain the filter string if( (!$useregex and strpos($category, $filter) !== false) or // Don't use regex and filter string is found ($useregex and preg_match($filter, $category)) // DO use regex and filter expression is found ) { return true; } } if( (!$useregex and (strpos($item->description, $filter) !== false or strpos($item->title, $filter) !== false)) or // Don't use regex and filter string is found ($useregex and (preg_match($filter, $item->description) or preg_match($filter, $item->title))) // DO use regex and filter expression is found ) { return true; } return false; } function atom_testforfilter($entry) { global $useregex; global $filter; foreach($entry->category as $category) { // loops through all the tags and returns true if any of them contain the filter string if( (!$useregex and strpos($category['term'], $filter) !== false) or // Don't use regex and filter string is found ($useregex and preg_match($filter, $category['term'])) // DO use regex and filter expression is found ) { return true; } } if( (!$useregex and (strpos($entry->description, $filter) !== false or strpos($entry->title, $filter) !== false)) or // Don't use regex and filter string is found ($useregex and (preg_match($filter, $entry->description) or preg_match($filter, $entry->title))) // DO use regex and filter expression is found ) { return true; } return false; } if($feed // A basic check to make sure the URL is formed properly. It doesn't actually check for a valid URL or valid regex. and $filter // If this check fails, the HTML document below this gets served. and ($filtertype === "white" or $filtertype === "black") ){ header('Content-Type: text/xml'); // Not sure if I actually need to do this, but it seems like good practice and it makes Chromium display the XML tree all nice. $content = simplexml_load_string(file_get_contents($feed)); // I've encountered a problem where something between the server this command pulls from and this script seems to // be caching the result. I'm guessing it's some kind of Nginx configuration error, but I'm not sure. Maybe I // should be using a different function to do this? rss-bridge uses the cURL library, which I know because I had // to install it myself. if($content->getName() == 'rss') { // Here I just assume everything not explicitly an RSS feed is an Atom feed. I am 100% certain there is an edge case I'm missing here. echo ''; // This is the most embarrassing part of this code by far. I wanted to do this by looping over all the entries echo $content->channel->title->asXML(); // in the XML object and specifically removing the ones that didn't pass the filter *from* the object, but echo $content->channel->link->asXML(); // I couldn't for the life of me get that to work, so I settled for the next best thing: just echoing all the echo $content->channel->description->asXML(); // fields that are part of the spec out to a brand new XML document and then adding all the entries that did echo $content->channel->language->asXML(); // pass. I mean, if it works it works, but sorry to anyone that was using some nonstandard feature here. echo $content->channel->pubDate->asXML(); echo $content->channel->lastBuildDate->asXML(); echo $content->channel->docs->asXML(); echo "will's RSS filter script"; echo $content->channel->managingEditor->asXML(); echo $content->channel->webMaster->asXML(); foreach($content->channel->item as $item) { $found = rss_testforfilter($item, $filter); if(($found and $filtertype == 'white') or (!$found and $filtertype == 'black')) { echo $item->asXML(); } } echo ''; die(); } else { echo ''; echo $content->title->asXML(); echo $content->link->asXML(); echo $content->updated->asXML(); echo $content->author->asXML(); echo $content->id->asXML(); foreach($content->category as $category) { echo $category->asXML(); } foreach($content->contributor as $contributor) { echo $contributor->asXML(); } echo "will's Atom filter script"; echo $content->icon->asXML(); echo $content->logo->asXML(); echo $content->rights->asXML(); echo $content->subtitle->asXML(); foreach($content->entry as $entry) { $found = atom_testforfilter($entry, $filter); if(($found and $filtertype == 'white') or (!$found and $filtertype == 'black')) { echo $entry->asXML(); } } echo ''; die(); } } ?> RSS Filter

RSS Filter


You need to have Javascript enabled for this generator to work, sorry.
Feed URL
Filter String
Filter Type

Made by an isopod
Download source code