Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added RSS output (experimental)

  • Loading branch information...
commit 88375ff9807785a5843b47e2312d76eef66e0f62 1 parent bde645f
@thomascube thomascube authored
Showing with 122 additions and 1 deletion.
  1. +4 −1 index.php
  2. +1 −0  program/include/main.inc
  3. +117 −0 program/steps/mail/rss.inc
View
5 index.php
@@ -217,7 +217,7 @@
if ($_task=='mail')
{
include_once('program/steps/mail/func.inc');
-
+
if ($_action=='show' || $_action=='print')
include('program/steps/mail/show.inc');
@@ -257,6 +257,9 @@
if ($_action=='list' && $_GET['_remote'])
include('program/steps/mail/list.inc');
+ if ($_action=='rss')
+ include('program/steps/mail/rss.inc');
+
// kill compose entry from session
if (isset($_SESSION['compose']))
rcmail_compose_cleanup();
View
1  program/include/main.inc
@@ -813,6 +813,7 @@ function rep_specialchars_output($str, $enctype='', $mode='', $newlines=TRUE)
if (!$js_rep_table)
{
$js_rep_table = $rtf_rep_table = $xml_rep_table = array();
+ $xml_rep_table['&'] = '&';
for ($c=160; $c<256; $c++) // can be increased to support more charsets
{
View
117 program/steps/mail/rss.inc
@@ -0,0 +1,117 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/mail/rss.inc |
+ | |
+ | This file is part of the RoundCube Webmail client |
+ | Copyright (C) 2005, RoundCube Dev. - Switzerland |
+ | Licensed under the GNU GPL |
+ | |
+ | PURPOSE: |
+ | Send mailboxcontents as RSS feed |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Sjon Hortensius <sjon@hortensius.net> |
+ +-----------------------------------------------------------------------+
+
+ $Id$
+
+*/
+
+require_once('Mail/mimeDecode.php');
+
+
+function rss_encode($string){
+ $string = rep_specialchars_output($string, 'xml');
+ return $string;
+}
+
+
+
+$REMOTE_REQUEST = TRUE;
+$OUTPUT_TYPE = 'rss';
+
+$webmail_url = 'http';
+if (strstr('HTTPS', $_SERVER['SERVER_PROTOCOL'] )!== FALSE)
+ $webmail_url .= 's';
+$webmail_url .= '://'.$_SERVER['SERVER_NAME'];
+if ($_SERVER['SERVER_PORT'] != '80')
+ $webmail_url .= ':'.$_SERVER['SERVER_PORT'];
+$webmail_url .= '/';
+if (dirname($_SERVER['SCRIPT_NAME']) != '/')
+ $webmail_url .= dirname($_SERVER['SCRIPT_NAME']).'/';
+
+$auth_webmail_url = $webmail_url.'?_auth='.$GLOBALS['sess_auth'];
+
+$messagecount_unread = $IMAP->messagecount('INBOX', 'UNSEEN', TRUE);
+$messagecount = $IMAP->messagecount();
+
+$sort_col = 'date';
+$sort_order = 'DESC';
+
+// Send global XML output
+header('Content-type: text/xml');
+echo '<?xml version="1.0" encoding="UTF-8"?>
+ <rss version="2.0"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
+ xmlns:admin="http://webns.net/mvcb/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:content="http://purl.org/rss/1.0/modules/content/">';
+
+// Send channel-specific output
+echo '
+ <channel>
+ <pubDate>'.date('r').'</pubDate>
+ <lastBuildDate>'.date('r').'</lastBuildDate>
+ <ttl>5</ttl>
+ <docs>http://blogs.law.harvard.edu/tech/rss</docs>
+ <description>INBOX contains '.$messagecount.' messages, of which '.$messagecount_unread.' unread</description>
+ <link>'.rss_encode($auth_webmail_url, 'xml') .'</link>
+ <title>webmail for '.rss_encode($_SESSION['username'].' @ '.$_SESSION['imap_host']).'</title>
+ <generator>'.rss_encode($CONFIG['useragent'], 'xml').' (RSS extension by Sjon Hortensius)</generator>
+ <image>
+ <link>http://www.roundcube.net/</link>
+ <title>'.rss_encode($CONFIG['product_name']).' logo</title>
+ <url>'.rss_encode($webmail_url.'skins/default/images/roundcube_logo.png').'</url>
+ </image>';
+
+// Check if the user wants to override the default sortingmethode
+if (isset($_GET['_sort']))
+ list($sort_col, $sort_order) = explode('_', $_GET['_sort']);
+
+// Add message to output
+if ($messagecount > 0)
+ {
+ $items = $IMAP->list_headers('INBOX', null, $sort_col, $sort_order);
+ foreach ($items as $item)
+ {
+
+ // Convert '"name" <email>' to 'email (name)'
+ if (strstr($item->from, '<'))
+ $item->from = preg_replace('~"?([^"]*)"? <([^>]*)>~', '\2 (\1)', $item->from);
+
+ $item->link = $auth_webmail_url.'&_task=mail&_action=show&_uid='.$item->uid.'&_mbox=INBOX';
+
+ $item->body = $IMAP->get_body($item->uid);
+
+ // Print the actual messages
+ echo '
+ <item>
+ <title>'.rss_encode($item->subject).'</title>
+ <link>'.rss_encode($item->link).'</link>
+ <description><![CDATA['."\n".nl2br(rss_encode($item->body))."\n".']]></description>
+ <author>'.rss_encode($item->from).'</author>
+ <category></category>
+ <guid>'.rss_encode($item->link).'</guid>
+ <pubDate>'.date('r', $item->timestamp).'</pubDate>
+ </item>';
+ }
+ }
+
+echo '</channel>
+</rss>';
+
+exit;
+?>
Please sign in to comment.
Something went wrong with that request. Please try again.