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

 1: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
 2:             "http://www.w3.org/TR/html4/strict.dtd">
 3: <html lang="en"> <head>
 4: <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 5: <meta name="description" content="RSS Feed Aggregator">
 6: <meta name="author" content="Wayne Pollock">
 7: <link rel="contents" href="index.htm">
 8: <link rel="previous" href="index.htm">
 9: <link rel="Shortcut Icon" type="image/x-icon" href="images/PHP.ico">
10: <link rel="stylesheet" href="Styles.css" type="text/css">
11: <script type="text/JavaScript" src="Common.js"> </script>
12: 
13: <title> PHP File Lister </title>
14: 
15: <style type="text/css">
16: <!--
17: @media screen {
18: b  { color: yellow; }
19: }
20:  -->
21: </style>
22: 
23: </head>
24: <body>
25: <div>
26: <h1> <abbr>RSS</abbr> Feed Aggregator for Prof. Wayne Pollock (All Courses) </h1>
27: 
28: <?php
29: // This PHP script will read a list of (local) RSS feeds
30: // and produce a single aggregate output feed.  This allows
31: // me to have one feed per course, a non-course (general) feed,
32: // and automatically generate a site-wide feed.
33: // All local feeds have the name "*RSS.xml", but the number is
34: // small enough to maintain the list by hand in the file
35: // "RSS-feeds.txt" (one filename per line), which speeds up the
36: // script by avoiding a directory search of the whole site for
37: // feed files.
38: //
39: // Written 2008 by Wayne Pollock, Tampa Florida USA
40: // Last updated: 12/2013 (bug fixes, HTML formatting added)
41: 
42: // Using the Magpie RSS parser:
43: define('MAGPIE_DIR', 'PHP/');
44: require_once(MAGPIE_DIR . 'rss_parse.inc');
45: 
46: $rss_feed_list =
47:    file('RSS-feeds.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
48: 
49: foreach ( $rss_feed_list as $rss_file ) {
50: //   var_dump($rss_file);
51:    $rss_string = file_get_contents( trim($rss_file) );
52:    if ( $rss_string === false ) {  // Can't read RSS file
53:       continue;
54:    }
55:    $rss = new MagpieRSS( $rss_string );
56: 
57:    if ( $rss and !$rss->ERROR) {
58:       echo "<hr>";
59:       echo "<h2> " . $rss->channel['title'] . "</h2>";
60:       echo "<ul>";
61:       foreach ($rss->items as $item) {
62:          $href = $rss->channel['link']; // $item['link'];
63:          $title = $item['title'];
64:          if ( isset($item['pubdate']) ) {
65:             $pubdate = " (" . $item['pubdate'] . ")";
66:          }
67:          echo "<li><a href=\"$href\">$title</a> $pubdate</li>";
68:       }
69:       echo "</ul>";
70:       }
71: //      else {  // For debugging
72: //         echo "Error: " . $rss->ERROR;
73: //      }
74:    echo "\n";
75: }
76: ?>
77: </div>
78: 
79: <div>
80: <?php
81: echo '
82: <script type="text/JavaScript">
83: // <![CDATA[
84:    document.title = "' . basename(__FILE__) . '";
85:    addFooter( "Question: ' . basename(__FILE__) . '" );
86: // ]]>
87: </script>
88: <noscript>
89:     <p> This page was last updated by Wayne Pollock. </p>
90: </noscript>
91: '
92: ?>
93: </div></body></html>