5 $r = $i[date_timestamp];
7 $r = strtotime($i[dc][date]);
9 $r = strtotime($i[published]);
13 function get_datestr($i)
16 return date('D, d M Y H:i:s +0000', $d);
19 function buildrss($feeds, $chtitle, $chlink, $chlang, $num)
21 define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
22 require('magpierss/rss_fetch.inc');
26 $w->startDocument('1.0');
29 $w->startElement('rss');
30 $w->writeAttribute('version', '2.0');
32 $w->startElement('channel');
36 // loop thru all feeds and merge the items together into the $items array
37 error_reporting(E_ERROR);
38 foreach ($feeds as $f) {
41 $rss = fetch_rss($url);
43 foreach ($rss->items as &$item) {
44 $item['name'] = $name;
45 $item['source_url'] = $url;
46 $item['source_title'] = $rss->channel['title'];
47 if (isset($item['content']['encoded']))
48 print $item['content']['encoded']."\n\n";
50 $items = array_merge($items, $rss->items);
52 error_reporting(USER_WARNINGS);
54 // sorts feed array based on published date (used with usort)
55 // -------------------------------------------------------------
56 function date_cmp($a, $b)
58 $atime = get_date($a);
59 $btime = get_date($b);
64 return ($atime > $btime) ? -1 : 1;
66 // sort all items in array by date
67 usort($items, 'date_cmp');
70 $w->writeElement('title', $chtitle);
71 $w->writeElement('link', $chlink);
72 $w->writeElement('language', $chlang);
75 foreach ($items as $item) {
76 if ($i >= $num) break;
79 $w->startElement('item');
80 $w->writeElement('title', htmlspecialchars_decode($item['title']));
81 $w->writeElement('pubDate', get_datestr($item));
82 $w->writeElement('link', htmlspecialchars_decode($item['link']));
83 if (isset($item['content']['encoded'])) {
84 $w->writeElement('content:encoded',
85 htmlspecialchars_decode($item['content']['encoded']));
86 $w->writeElement('content:encoded2',
87 $item['content']['encoded']);
89 $w->writeElement('description', htmlspecialchars_decode($item['description']));
91 $w->startElement('source');
92 $w->writeAttribute('url', htmlspecialchars_decode($item['source_url']));
93 $w->text(htmlspecialchars_decode($item['source_title']));
99 $w->endElement(); // channel
100 $w->endElement(); // rss
103 return $w->outputMemory();