From 88375ff9807785a5843b47e2312d76eef66e0f62 Mon Sep 17 00:00:00 2001 From: thomascube Date: Sun, 5 Feb 2006 16:35:40 +0000 Subject: Added RSS output (experimental) --- index.php | 5 +- program/include/main.inc | 1 + program/steps/mail/rss.inc | 117 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 program/steps/mail/rss.inc diff --git a/index.php b/index.php index d99f24dbd..fd356c8ba 100644 --- a/index.php +++ b/index.php @@ -217,7 +217,7 @@ if ($_action=='keep-alive') 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 ($_task=='mail') 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(); diff --git a/program/include/main.inc b/program/include/main.inc index ac612cd06..aa6a60790 100644 --- a/program/include/main.inc +++ b/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 { diff --git a/program/steps/mail/rss.inc b/program/steps/mail/rss.inc new file mode 100644 index 000000000..062a292b9 --- /dev/null +++ b/program/steps/mail/rss.inc @@ -0,0 +1,117 @@ + | + +-----------------------------------------------------------------------+ + + $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 ' + '; + +// Send channel-specific output +echo ' + + '.date('r').' + '.date('r').' + 5 + http://blogs.law.harvard.edu/tech/rss + INBOX contains '.$messagecount.' messages, of which '.$messagecount_unread.' unread + '.rss_encode($auth_webmail_url, 'xml') .' + webmail for '.rss_encode($_SESSION['username'].' @ '.$_SESSION['imap_host']).' + '.rss_encode($CONFIG['useragent'], 'xml').' (RSS extension by Sjon Hortensius) + + http://www.roundcube.net/ + '.rss_encode($CONFIG['product_name']).' logo + '.rss_encode($webmail_url.'skins/default/images/roundcube_logo.png').' + '; + +// 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" ' 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 ' + + '.rss_encode($item->subject).' + '.rss_encode($item->link).' + body))."\n".']]> + '.rss_encode($item->from).' + + '.rss_encode($item->link).' + '.date('r', $item->timestamp).' + '; + } + } + +echo ' +'; + +exit; +?> \ No newline at end of file -- cgit v1.2.3