summaryrefslogtreecommitdiffstats
path: root/website/new/rss-aggregator.php
blob: 9cbb837b25f5ae5a7d81a3bd8a15c9633f305f96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<h1>Simple RSS agregator</h1>
<a href="http://www.webdot.cz/lastrss/">
<img src="lastrss_button.gif" alt="" width="88" height="31" border="0">
</a><hr>
<!-- / Heading -->

<?php
/* 
 ======================================================================
 lastRSS usage DEMO 3 - Simple RSS agregator
 ----------------------------------------------------------------------
 This example shows, how to create simple RSS agregator
     - create lastRSS object
    - set transparent cache
    - show a few RSS files at once
 ======================================================================
*/

function ShowOneRSS($url) {
    global $rss;
    if ($rs = $rss->get($url)) {
        echo "<big><b><a href=\"$rs[link]\">$rs[title]</a></b></big><br />\n";
        echo "$rs[description]<br />\n";

            echo "<ul>\n";
            foreach ($rs['items'] as $item) {
                echo "\t<li><a href=\"$item[link]\" title=\"$item[description]\">$item[title]</a></li>\n";
            }
            if ($rs['items_count'] <= 0) { echo "<li>Sorry, no items found in the RSS file :-(</li>"; }
            echo "</ul>\n";
    }
    else {
        echo "Sorry: It's not possible to reach RSS file $url\n<br />";
        // you will probably hide this message in a live version
    }
}

// ===============================================================================

// include lastRSS
include "./rss-parser.php";

// List of RSS URLs
$rss_left = array(
    'http://freshmeat.net/backend/fm.rdf',
    'http://slashdot.org/slashdot.rdf'
);
$rss_right = array(
    'http://www.freshfolder.com/rss.php',
    'http://phpbuilder.com/rss_feed.php'
);

// Create lastRSS object
$rss = new lastRSS;

// Set cache dir and cache time limit (5 seconds)
// (don't forget to chmod cahce dir to 777 to allow writing)
$rss->cache_dir = './temp';
$rss->cache_time = 1200;


// Show all rss files
echo "<table cellpadding=\"10\" border=\"0\"><tr><td width=\"50%\" valign=\"top\">";
foreach ($rss_left as $url) {
    ShowOneRSS($url);
}
echo "</td><td width=\"50%\" valign=\"top\">";
foreach ($rss_right as $url) {
    ShowOneRSS($url);
}
echo "</td></tr></table>";
?>