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 2927 2009-09-05 12:31:19Z alec $
23 function rss_encode($string){
24 $string = rep_specialchars_output($string, 'xml');
29 $REMOTE_REQUEST = TRUE;
32 $webmail_url = 'http';
33 if (strstr('HTTPS', $_SERVER['SERVER_PROTOCOL'] )!== FALSE || $RCMAIL->config->get('use_https'))
35 $webmail_url .= '://'.$_SERVER['SERVER_NAME'];
36 if ($_SERVER['SERVER_PORT'] != '80')
37 $webmail_url .= ':'.$_SERVER['SERVER_PORT'];
39 if (dirname($_SERVER['SCRIPT_NAME']) != '/')
40 $webmail_url .= dirname($_SERVER['SCRIPT_NAME']).'/';
42 $webmail_url .= '?_task=mail';
44 $messagecount_unread = $IMAP->messagecount('INBOX', 'UNSEEN', TRUE);
45 $messagecount = $IMAP->messagecount();
50 // Send global XML output
51 header('Content-type: text/xml');
52 echo '<?xml version="1.0" encoding="'.RCMAIL_CHARSET.'"?>
54 xmlns:dc="http://purl.org/dc/elements/1.1/"
55 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
56 xmlns:admin="http://webns.net/mvcb/"
57 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
58 xmlns:content="http://purl.org/rss/1.0/modules/content/">';
60 // Send channel-specific output
63 <pubDate>'.date('r').'</pubDate>
64 <lastBuildDate>'.date('r').'</lastBuildDate>
66 <docs>http://blogs.law.harvard.edu/tech/rss</docs>
67 <description>INBOX contains '.$messagecount.' messages, of which '.$messagecount_unread.' unread</description>
68 <link>'.rss_encode($webmail_url, 'xml') .'</link>
69 <title>webmail for '.rss_encode($_SESSION['username'].' @ '.$_SESSION['imap_host']).'</title>
70 <generator>'.rss_encode($CONFIG['useragent'], 'xml').' (RSS extension by Sjon Hortensius)</generator>
72 <link>http://www.roundcube.net/</link>
73 <title>'.rss_encode($CONFIG['product_name']).' logo</title>
74 <url>'.rss_encode($webmail_url.'skins/default/images/roundcube_logo.png').'</url>
77 // Check if the user wants to override the default sortingmethode
78 if (isset($_GET['_sort']))
79 list($sort_col, $sort_order) = explode('_', get_input_value('_sort', RCUBE_INPUT_GET));
81 // Add message to output
82 if ($messagecount > 0)
84 $items = $IMAP->list_headers('INBOX', null, $sort_col, $sort_order);
85 foreach ($items as $item)
88 // Convert '"name" <email>' to 'email (name)'
89 if (strstr($item->from, '<'))
90 $item->from = preg_replace('~"?([^"]*)"? <([^>]*)>~', '\2 (\1)', $item->from);
92 $item->link = $webmail_url.'&_task=mail&_action=show&_uid='.$item->uid.'&_mbox=INBOX';
94 $item->body = $IMAP->get_body($item->uid);
96 // Print the actual messages
99 <title>'.rss_encode($item->subject).'</title>
100 <link>'.rss_encode($item->link).'</link>
101 <description><![CDATA['."\n".nl2br(rss_encode($item->body))."\n".']]></description>
102 <author>'.rss_encode($item->from).'</author>
103 <category></category>
104 <guid>'.rss_encode($item->link).'</guid>
105 <pubDate>'.date('r', $item->timestamp).'</pubDate>