source: github/program/steps/mail/rss.inc @ 161c28d

HEADcourier-fixdev-browser-capabilitiespdorelease-0.6release-0.7release-0.8
Last change on this file since 161c28d was 161c28d, checked in by alecpl <alec@…>, 4 years ago
  • Fix wrong headers for IE on servers without $_SERVERHTTPS? (#1485926)
  • Force IE style headers for attachments in non-HTTPS session, 'use_https' option (#1485655)
  • Property mode set to 100644
File size: 3.9 KB
Line 
1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | program/steps/mail/rss.inc                                            |
6 |                                                                       |
7 | This file is part of the RoundCube Webmail client                     |
8 | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
9 | Licensed under the GNU GPL                                            |
10 |                                                                       |
11 | PURPOSE:                                                              |
12 |   Send mailboxcontents as RSS feed                                    |
13 |                                                                       |
14 +-----------------------------------------------------------------------+
15 | Author: Sjon Hortensius <sjon@hortensius.net>                         |
16 +-----------------------------------------------------------------------+
17
18 $Id$
19
20*/
21
22
23function rss_encode($string){
24        $string = rep_specialchars_output($string, 'xml');
25        return $string;
26}
27
28
29$REMOTE_REQUEST = TRUE;
30$OUTPUT_TYPE = 'rss';
31
32$webmail_url = 'http';
33if (strstr('HTTPS', $_SERVER['SERVER_PROTOCOL'] )!== FALSE || $RCMAIL->config->get('use_https'))
34  $webmail_url .= 's';
35$webmail_url .= '://'.$_SERVER['SERVER_NAME'];
36if ($_SERVER['SERVER_PORT'] != '80')
37        $webmail_url .= ':'.$_SERVER['SERVER_PORT'];
38$webmail_url .= '/';
39if (dirname($_SERVER['SCRIPT_NAME']) != '/')
40        $webmail_url .= dirname($_SERVER['SCRIPT_NAME']).'/';
41
42$webmail_url .= '?_task=mail';
43
44$messagecount_unread = $IMAP->messagecount('INBOX', 'UNSEEN', TRUE);
45$messagecount = $IMAP->messagecount();
46
47$sort_col = 'date';
48$sort_order = 'DESC';
49
50// Send global XML output
51header('Content-type: text/xml');
52echo '<?xml version="1.0" encoding="'.RCMAIL_CHARSET.'"?>
53        <rss version="2.0"
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/">';
59
60// Send channel-specific output
61echo '
62        <channel>
63                <pubDate>'.date('r').'</pubDate>
64                <lastBuildDate>'.date('r').'</lastBuildDate>
65                <ttl>5</ttl>
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>
71                <image>
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>
75                </image>';
76
77// Check if the user wants to override the default sortingmethode
78if (isset($_GET['_sort']))
79  list($sort_col, $sort_order) = explode('_', get_input_value('_sort', RCUBE_INPUT_GET));
80
81// Add message to output
82if ($messagecount > 0)
83  {
84  $items = $IMAP->list_headers('INBOX', null, $sort_col, $sort_order);
85  foreach ($items as $item)
86    {
87
88    // Convert '"name" <email>' to 'email (name)'
89    if (strstr($item->from, '<'))
90      $item->from = preg_replace('~"?([^"]*)"? <([^>]*)>~', '\2 (\1)', $item->from);
91
92    $item->link = $webmail_url.'&_task=mail&_action=show&_uid='.$item->uid.'&_mbox=INBOX';
93
94    $item->body = $IMAP->get_body($item->uid);
95
96    // Print the actual messages
97    echo '
98                        <item>
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>
106                        </item>';
107    }
108  }
109
110echo '</channel>
111</rss>';
112
113exit;
114?>
Note: See TracBrowser for help on using the repository browser.