Viewing file: rss.php (15.12 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/*
############################################################################
# DWmail
# - version 4.0
# - Copyright (c) 2003-2006 Dominion Web Design
# - http://www.dominion-web.com/products/dwmail/
############################################################################
#
# The contents of this file are subject to the DWmail License version
# 2.2 ('License'). You may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.dominion-web.com/products/dwmail/license.php
# Software distributed under the License is distributed on an "AS IS" basis,
# without warranty of any kind, either express or implied.
#
# This code is Copyright (c) 2003-2006 Dominion Web Design.
# All rights reserved.
#
# This software may not be redistributed outside the terms of the
# license agreement.
#
############################################################################
*/
require ("./includes/init.inc.php");
require ("./includes/global.inc.php");
require ("./includes/imap.inc.php");
require ("./includes/functions.inc.php");
require ("./includes/config.inc.php");
$MainSettings = new GlobalInit();
$TransIDEnabled = $MainSettings->INIGet('session.use_trans_sid');
session_cache_limiter($DefaultSessionCache);
session_start();
if (!$_SESSION['DefaultLang']) {
$_SESSION['DefaultLang'] = $DefaultLang;
}
require ("./lang/" . strip_tags(str_replace("..", "", trim($_SESSION['DefaultLang']))) . "/global.inc.php");
require ("./lang/" . strip_tags(str_replace("..", "", trim($_SESSION['DefaultLang']))) . "/mailbox.inc.php");
@setlocale(LC_TIME, $AvailLangs[$_SESSION['DefaultLang']]['locale']);
$folder = "INBOX";
$folderencode = urlencode($folder);
$_SESSION['sort'] = "SORTDATE";
$_SESSION['order'] = 1;
$hash = strip_tags(stripslashes($_GET['key']));
$userid = strip_tags(stripslashes($_GET['userid']));
if ($UseDatabase == 1) {
switch ($DatabaseType) {
case 'mysqli':
$DBLib = 'mysqli';
break;
case 'postgresql':
$DBLib = 'postgresql';
break;
default:
$DBLib = 'mysql';
break;
}
require_once ("./includes/db_" . $DBLib . ".inc.php");
$MySQLConnection = new DB_Connection($MySQLServer, $MySQLUsername, $MySQLPassword, $MySQLDBName);
$MySQLMakeConnection = $MySQLConnection->DB_MakeConnection();
}
$MySQLConnection->_DBUserID = $userid;
$rsshash = $MySQLConnection->DB_GetHash($hash, $MySQLConnection->_DBUserID);
if ($rsshash == FALSE) {
exit;
}
$GetRSS = trim($MySQLConnection->DB_GetPrefs('rss'));
$GetRSS = $MainSettings->CheckSlashes($GetRSS);
$UserDetails = unserialize($GetRSS);
if ($UserDetails['enabled'] <> 1) {
// RSS feed is disabled, exit script
exit;
}
if ($_SERVER['HTTPS'] == "on") {
$currenturl = 'https://';
}
else {
$currenturl = 'http://';
}
$currenturl .= $_SERVER["HTTP_HOST"];
$directory = str_replace("rss.php", "", $_SERVER["PHP_SELF"]);
$currenturl .= $directory;
header ("Content-type: text/xml; charset=" . $AvailLangs[$DefaultLang]['charset']);
echo ("<?xml version=\"1.0\" encoding=\"" . $AvailLangs[$DefaultLang]['charset'] . "\" ?>
<?xml-stylesheet title=\"XSL_formatting\" type=\"text/xsl\" href=\"scripts/rss.xsl\"?>
<rss version=\"2.0\">
<channel>
<title>Webmail Inbox for " . $UserDetails['currentemailaddress'] . "</title>
<link>" . $currenturl . "</link>
<description>Powered by DWmail version " . $version . "</description>
<language>" . $_SESSION['DefaultLang'] . "</language>
<lastBuildDate>" . date("r") . "</lastBuildDate>
<copyright>Copyright (c) 2003-2006 Dominion Web: http://www.dominion-web.com/products/dwmail/</copyright>
<generator>DWmail version " . $version . "</generator>
<docs>http://www.dominion-web.com/products/dwmail/adminmanual/</docs>
<ttl>15</ttl>
");
$_SESSION['sess_u'] = $UserDetails['sess_u'];
$_SESSION['sess_p'] = $UserDetails['sess_p'];
$_SESSION['mailserver'] = $UserDetails['mailserver'];
$_SESSION['sess_domain'] = $UserDetails['sess_domain'];
$_SESSION['servertype'] = $UserDetails['servertype'];
$_SESSION['portnumber'] = $UserDetails['portnumber'];
$_SESSION['ssl'] = $UserDetails['ssl'];
$_SESSION['sess_e'] = $UserDetails['sess_e'];
$_SESSION['currentemailaddress'] = $UserDetails['currentemailaddress'];
$_SESSION['folder'] = "INBOX";
$_SESSION['compatibilitymode'] = $CompatibilityMode;
$IMAPConnection = new WM_IMAPConnection($_SESSION);
$mailbox = $IMAPConnection->WM_IMAPConnect();
$imapstatus = $IMAPConnection->WM_IMAPStatus($_SESSION['folder']);
$totalmessages = $imapstatus->messages;
$numberofnewmessages = $imapstatus->unseen;
$mailboxinfo = $IMAPConnection->WM_IMAPMailboxInfo();
$numberofpages = ceil($totalmessages / $messagesperpage);
$counter = 1;
$startmessage = ((1 * $messagesperpage) - $messagesperpage) + 1;
$lastmessage = 1 * $messagesperpage;
$IMAPConnection->_nosort = 0;
$sortmessages = $IMAPConnection->WM_IMAPList($startmessage, $lastmessage, 1, 0);
if ($sortmessages <> "") {
while(list($key, $value) = each($sortmessages)) {
if (!is_null($value['message_number'])) {
$messagenew = 0;
// We need to update the current message number of the UID incase a filter has moved or deleted a message
// as the sequence number would have changed
$sortmessages[$key]['message_number'] = $IMAPConnection->GetSeqNum($sortmessages[$key]['message_uid']);
$IMAPConnection->WM_IMAPGetHeader($sortmessages[$key]['message_uid']);
$headerdetails = $IMAPConnection->WM_IMAPFullHeaders();
if (($IMAPConnection->_msgheader->Recent == "N" || $IMAPConnection->_msgheader->Unseen == "U") && ($_SESSION['servertype'] == "imap" || $_SESSION['servertype'] == "imapssl")) {
$messagenew = 1;
}
if ($messagenew == 1) {
// We must reset the new header. For some reason reading the headers
// sets the message to read
$IMAPConnection->WM_IMAPClearFlag($sortmessages[$key]['message_uid']);
// Now reset any other flags back to their original values excluding read and unseen
if ($IMAPConnection->_msgheader->Answered == "A") {
$SetFlag = $IMAPConnection->WM_IMAPSetFlag("\\Answered", $sortmessages[$key]['message_uid']);
}
if ($IMAPConnection->_msgheader->Deleted == "D") {
$SetFlag = $IMAPConnection->WM_IMAPSetFlag("\\Deleted", $sortmessages[$key]['message_uid']);
}
if ($IMAPConnection->_msgheader->Draft == "X") {
$SetFlag = $IMAPConnection->WM_IMAPSetFlag("\\Draft", $sortmessages[$key]['message_uid']);
}
if ($IMAPConnection->_msgheader->Flagged == "F") {
$SetFlag = $IMAPConnection->WM_IMAPSetFlag("\\Flagged", $sortmessages[$key]['message_uid']);
}
}
unset ($content);
unset ($message["html"]);
unset ($message["text"]);
$actioncomplete = 0;
if ($actioncomplete == 1) {
$displaymessage = 0;
}
else {
$displaymessage = 1;
if ($displaymessage == 1) {
if (!isset($structure)) {
$structure = $IMAPConnection->WM_IMAPGetStructure($sortmessages[$key]['message_uid']);
}
if (!isset($sections)) {
$sections = parseBody($structure);
}
if ($UserDetails['bodydisplay'] && $UserDetails['bodydisplay'] == 1) {
require("./includes/html.inc.php");
if (is_array($sections)) {
for($x=0; $x<sizeof($sections); $x++) {
if ($sections[$x]["type"] == "text/html" && $sections[$x]["disposition"] != "attachment") {
$message["html"] = $IMAPConnection->WM_IMAPGetBody($sortmessages[$key]['message_uid'], $sections[$x]["pid"], $sections[$x]["subpart"]);
$message["html"] = stripslashes(parseEncoding($message["html"], $sections[$x]["encoding"]));
$charsetarry["html"] = $sections[$x]["charset"];
}
elseif ($sections[$x]["type"] == "text/plain" && $sections[$x]["disposition"] != "attachment") {
$message["text"] = $IMAPConnection->WM_IMAPGetBody($sortmessages[$key]['message_uid'], $sections[$x]["pid"], $sections[$x]["subpart"]);
$message["text"] = parseEncoding($message["text"], $sections[$x]["encoding"]);
$message["text"] = nl2br(htmlspecialchars(stripslashes(trim($message["text"]))));
$charsetarry["text"] = $sections[$x]["charset"];
}
}
if ($message["html"] <> '') {
$content = $message["html"];
}
else {
$content = $message["text"];
}
$CleanUpHTML = new HTMLCleanup($content);
$CleanUpHTML->ChangeTarget();
$CleanUpHTML->RemoveScripting();
$CleanUpHTML->RemoveMalicious();
$content = $CleanUpHTML->_body;
}
else {
if ($currpart->ifparameters == 1) {
if ($currpart->parameters) {
foreach ($currpart->parameters as $p2) {
if (strtolower($p2->attribute) == 'charset') {
$charset = $p2->value;
}
}
}
}
if (($structure->subtype == "HTML" || $structure->subtype == "ALTERNATIVE")) {
$content = $IMAPConnection->WM_IMAPGetBody($sortmessages[$key]['message_uid'], -1, -1);
$content = stripslashes(parseEncoding($content, $encoding[$structure->encoding]));
$CleanUpHTML = new HTMLCleanup($content);
$CleanUpHTML->ChangeTarget();
$CleanUpHTML->RemoveScripting();
$CleanUpHTML->RemoveMalicious();
$content = $CleanUpHTML->_body;
}
elseif ($structure->type >= 3) {
$content = '';
}
else {
$content = $IMAPConnection->WM_IMAPGetBody($sortmessages[$key]['message_uid'], -1, -1);
$content = parseEncoding($content, $encoding[$structure->encoding]);
$content = htmlspecialchars(stripslashes(trim($content)));
$content = str_replace("\t", " ", $content);
$content = SeperateSignature($SeperateSignature, $content);
$content = nl2br($content);
$content = parseLinks($content, 1);
}
}
if ($UserDetails['bodylength'] <> '' && $UserDetails['bodylength'] >= 1) {
$content = substr($content, 0, $UserDetails['bodylength']);
$content .= "...";
}
$content = "<br />" . $content;
}
$attachments = get_attachments($sections);
$embeddedattachments = get_embeddedattachments($sections);
if (is_array($attachments) || is_array($embeddedattachments)) {
$message_attachment = $lang['SMbox']['Attachment'];
}
else {
$message_attachment = "";
}
// Find an importance header
$header_full = $IMAPConnection->WM_IMAPRFCHeader($sortmessages[$key]['message_uid']);
if (strstr($header_full, 'Importance:')) {
$header_arry = explode ("\n", $header_full);
$line_number = 0;
$have_importance = 0;
while ($line = $header_arry[$line_number]) {
$line = trim($line);
if (strstr($line, "Importance:")) {
$importancelevel = str_replace ("Importance:", "", $line);
$importancelevel = trim($importancelevel);
$have_importance = 1;
}
$line_number++;
}
}
if ($structure) {
$contenttype = strtolower($type[$structure->type] . '/' . $structure->subtype);
}
else {
unset ($contenttype);
}
if (($_SESSION['servertype'] == "imap" || $_SESSION['servertype'] == "imapssl") && $contenttype <> "text/calendar") {
if (isset($checkreadreceipt) && $checkreadreceipt == TRUE) {
$message_envelope = $lang['SMbox']['Message'] . ". ";
}
elseif (($IMAPConnection->_msgheader->Recent == "N") || ($IMAPConnection->_msgheader->Unseen == "U")) {
$message_envelope = $lang['SMbox']['New'] . ". ";
}
else {
$message_envelope = $lang['SMbox']['Read'] . ". ";
}
if ($IMAPConnection->_msgheader->Answered == "A") {
$messageanswered = 1;
$message_envelope = $lang['SMbox']['Replied'] . ". ";
}
else {
$messageanswered = 0;
}
}
elseif ($contenttype == "text/calendar") {
$message_envelope = $lang['SMbox']['Appointment'] . ". ";
}
else {
if (isset($checkreadreceipt) && $checkreadreceipt == TRUE) {
$message_envelope = $lang['SMbox']['Message'] . ". ";
}
else {
$message_envelope = $lang['SMbox']['Message'] . ". ";
}
}
$messageflag = 'flag_off';
$flagmode = 'f';
if ($IMAPConnection->_msgheader->Flagged == "F") {
$messageflag = 'flag_on';
$flagmode = 'cf';
}
if (strtolower($importancelevel) == "high") {
$importancegraphic = $lang['SMbox']['ImportanceHigh'] . ". ";
}
elseif (strtolower($importancelevel) == "low") {
$importancegraphic = $lang['SMbox']['ImportanceLow'] . ". ";
}
else {
$importancegraphic = '';
}
unset ($importancelevel);
$message_size = ceil(($IMAPConnection->_msgheader->Size/1024)) . " Kb";
if ($sortmessages[$key]['message_title'] == "") {
$sortmessages[$key]['message_title'] = $lang['SMbox']['NoSubject'];
}
$localtime_hours = DateToLocal($tz, $sortmessages[$key]['message_date'], "%R");
$localtime_date = DateToLocal($tz, $sortmessages[$key]['message_date'], "%a " . $DateFormattingb);
// Convert to a UNIX timestamp
$datetimestamp = strtotime ($sortmessages[$key]['message_date']);
// Now we have a GMT timestamp we can apply local timezone settings
$localtimestamp = $datetimestamp + ($tz * 60);
if (gmstrftime ($DateFormattingb, $localtimestamp) == date ($DateFormatting)) {
$display_date = $lang['SMbox']['Today'] . " " . $localtime_hours;
}
else {
$display_date = $localtime_date;
}
if (!isset($display_date)) {
// Fall over option here to display the date/time from the message if for some reason we can't analyse it (some spam mail purposely corrupts the date header)
$display_date = $sortmessages[$key]['message_date'];
}
$rsstime = strtotime($sortmessages[$key]['message_date']);
$rssfttime = date("r", $rsstime);
echo ("<item>
<title>" . htmlspecialchars($sortmessages[$key]['message_title']) . "</title>
<description><![CDATA[" . $message_size . ": " . $message_envelope . " " . $importancegraphic . " " . $message_attachment . " " . $content . "]]></description>
<link>" . $currenturl);
if ($UserDetails['bypasslogin'] == 1) {
echo ("dologin");
}
else {
echo ("index");
}
echo (".php?redir=" . urlencode("view.php?id=" . $sortmessages[$key]['message_uid'] . "&f=INBOX&w=standard"));
if ($UserDetails['bypasslogin'] == 1) {
echo ("&key=$hash&userid=$userid");
}
echo ("</link>
<guid isPermaLink=\"false\">" . $currenturl . "view.php?id=" . $sortmessages[$key]['message_uid'] . "&f=INBOX&w=standard</guid>
<pubDate>" . $rssfttime . "</pubDate>
<author><![CDATA[" . $sortmessages[$key]['message_from'] ."]]></author>
</item>
");
}
$counter++;
if (isset($structure)) { unset($structure); }
if (isset($sections)) { unset($sections); }
if (isset($attachments)) { unset($attachments); }
if (isset($embeddedattachments)) { unset($embeddedattachments); }
}
}
}
}
if ($UseDatabase == 1) {
$MySQLCloseConnection = $MySQLConnection->DB_CloseConnection();
}
$IMAPConnection->WM_IMAPClose();
session_unset();
session_destroy();
echo ("</channel>
</rss>");
?>
|