/home/wpollock1/public_html/PHP/AggragateRSS.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en"> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="RSS Feed Aggregator">
<meta name="author" content="Wayne Pollock">
<link rel="contents" href="index.htm">
<link rel="previous" href="index.htm">
<link rel="Shortcut Icon" type="image/x-icon" href="images/PHP.ico">
<link rel="stylesheet" href="Styles.css" type="text/css">
<script type="text/JavaScript" src="Common.js"> </script>

<title> PHP File Lister </title>

<style type="text/css">
<!--
@media screen {
b  { color: yellow; }
}
 -->
</style>

</head>
<body>
<div>
<h1> <abbr>RSS</abbr> Feed Aggregator for Prof. Wayne Pollock (All Courses) </h1>

<?php
// This PHP script will read a list of (local) RSS feeds
// and produce a single aggregate output feed.  This allows
// me to have one feed per course, a non-course (general) feed,
// and automatically generate a site-wide feed.
// All local feeds have the name "*RSS.xml", but the number is
// small enough to maintain the list by hand in the file
// "RSS-feeds.txt" (one filename per line), which speeds up the
// script by avoiding a directory search of the whole site for
// feed files.
//
// Written 2008 by Wayne Pollock, Tampa Florida USA
// Last updated: 12/2013 (bug fixes, HTML formatting added)

// Using the Magpie RSS parser:
define('MAGPIE_DIR', 'PHP/');
require_once(MAGPIE_DIR . 'rss_parse.inc');

$rss_feed_list =
   file('RSS-feeds.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

foreach ( $rss_feed_list as $rss_file ) {
//   var_dump($rss_file);
   $rss_string = file_get_contents( trim($rss_file) );
   if ( $rss_string === false ) {  // Can't read RSS file
      continue;
   }
   $rss = new MagpieRSS( $rss_string );

   if ( $rss and !$rss->ERROR) {
      echo "<hr>";
      echo "<h2> " . $rss->channel['title'] . "</h2>";
      echo "<ul>";
      foreach ($rss->items as $item) {
         $href = $rss->channel['link']; // $item['link'];
         $title = $item['title'];
         if ( isset($item['pubdate']) ) {
            $pubdate = " (" . $item['pubdate'] . ")";
         }
         echo "<li><a href=\"$href\">$title</a> $pubdate</li>";
      }
      echo "</ul>";
      }
//      else {  // For debugging
//         echo "Error: " . $rss->ERROR;
//      }
   echo "\n";
}
?>
</div>

<div>
<?php
echo '
<script type="text/JavaScript">
// <![CDATA[
   document.title = "' . basename(__FILE__) . '";
   addFooter( "Question: ' . basename(__FILE__) . '" );
// ]]>
</script>
<noscript>
    <p> This page was last updated by Wayne Pollock. </p>
</noscript>
'
?>
</div></body></html>