4 +-----------------------------------------------------------------------+
5 | program/steps/mail/rss.inc |
7 | This file is part of the RoundCube Webmail client |
8 | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Send mailboxcontents as RSS feed |
14 +-----------------------------------------------------------------------+
15 | Author: Sjon Hortensius <sjon@hortensius.net> |
16 +-----------------------------------------------------------------------+
18 $Id: rss.inc 850 2007-10-03 00:13:32Z ihug $
22 require_once('Mail/mimeDecode.php');
25 function rss_encode($string){
26 $string = rep_specialchars_output($string, 'xml');
32 $REMOTE_REQUEST = TRUE;
35 $webmail_url = 'http';
36 if (strstr('HTTPS', $_SERVER['SERVER_PROTOCOL'] )!== FALSE)
38 $webmail_url .= '://'.$_SERVER['SERVER_NAME'];
39 if ($_SERVER['SERVER_PORT'] != '80')
40 $webmail_url .= ':'.$_SERVER['SERVER_PORT'];
42 if (dirname($_SERVER['SCRIPT_NAME']) != '/')
43 $webmail_url .= dirname($_SERVER['SCRIPT_NAME']).'/';
45 $webmail_url .= '?_task=mail';
47 $messagecount_unread = $IMAP->messagecount('INBOX', 'UNSEEN', TRUE);
48 $messagecount = $IMAP->messagecount();
53 // Send global XML output
54 header('Content-type: text/xml');
55 echo '<?xml version="1.0" encoding="UTF-8"?>
57 xmlns:dc="http://purl.org/dc/elements/1.1/"
58 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
59 xmlns:admin="http://webns.net/mvcb/"
60 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
61 xmlns:content="http://purl.org/rss/1.0/modules/content/">';
63 // Send channel-specific output
66 <pubDate>'.date('r').'</pubDate>
67 <lastBuildDate>'.date('r').'</lastBuildDate>
69 <docs>http://blogs.law.harvard.edu/tech/rss</docs>
70 <description>INBOX contains '.$messagecount.' messages, of which '.$messagecount_unread.' unread</description>
71 <link>'.rss_encode($webmail_url, 'xml') .'</link>
72 <title>webmail for '.rss_encode($_SESSION['username'].' @ '.$_SESSION['imap_host']).'</title>
73 <generator>'.rss_encode($CONFIG['useragent'], 'xml').' (RSS extension by Sjon Hortensius)</generator>
75 <link>http://www.roundcube.net/</link>
76 <title>'.rss_encode($CONFIG['product_name']).' logo</title>
77 <url>'.rss_encode($webmail_url.'skins/default/images/roundcube_logo.png').'</url>
80 // Check if the user wants to override the default sortingmethode
81 if (isset($_GET['_sort']))
82 list($sort_col, $sort_order) = explode('_', $_GET['_sort']);
84 // Add message to output
85 if ($messagecount > 0)
87 $items = $IMAP->list_headers('INBOX', null, $sort_col, $sort_order);
88 foreach ($items as $item)
91 // Convert '"name" <email>' to 'email (name)'
92 if (strstr($item->from, '<'))
93 $item->from = preg_replace('~"?([^"]*)"? <([^>]*)>~', '\2 (\1)', $item->from);
95 $item->link = $webmail_url.'&_task=mail&_action=show&_uid='.$item->uid.'&_mbox=INBOX';
97 $item->body = $IMAP->get_body($item->uid);
99 // Print the actual messages
102 <title>'.rss_encode($item->subject).'</title>
103 <link>'.rss_encode($item->link).'</link>
104 <description><![CDATA['."\n".nl2br(rss_encode($item->body))."\n".']]></description>
105 <author>'.rss_encode($item->from).'</author>
106 <category></category>
107 <guid>'.rss_encode($item->link).'</guid>
108 <pubDate>'.date('r', $item->timestamp).'</pubDate>