\n";
}
/* Output the link. */
if ($javascript_on) {
$result .= '\n" .
"$print_text\n";
} else {
$result .= '$print_text\n";
}
if (!$pf_subtle_link) {
/* The link is large, on the bottom of the header panel. */
$result .= '' . "\n";
}
return ($result);
}
function ServerMDNSupport( $read ) {
/* escaping $ doesn't work -> \x36 */
$ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read );
return ( $ret );
}
function SendMDN ( $recipient , $sender) {
global $imapConnection, $mailbox, $username, $attachment_dir, $SERVER_NAME,
$version, $attachments, $identity, $data_dir, $passed_id;
$header = sqimap_get_message_header($imapConnection, $passed_id, $mailbox);
$hashed_attachment_dir = getHashedDir($username, $attachment_dir);
// part 1 (RFC2298)
$senton = getLongDateString( $header->date );
$to_array = $header->to;
$to = '';
foreach ($to_array as $line) {
$to .= " $line ";
}
$subject = $header->subject;
$now = getLongDateString( time() );
set_my_charset();
$body = _("Your message") . "\r\n\r\n" .
"\t" . _("To:") . ' ' . $to . "\r\n" .
"\t" . _("Subject:") . ' ' . $subject . "\r\n" .
"\t" . _("Sent:") . ' ' . $senton . "\r\n" .
"\r\n" .
sprintf( _("Was displayed on %s"), $now );
// part2 (RFC2298)
$original_recipient = $to;
$original_message_id = $header->message_id;
$part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
if ($original_recipient != '') {
$part2 .= "Original-Recipient : $original_recipient\r\n";
}
$final_recipient = $sender;
$part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
"Original-Message-ID : $original_message_id\r\n" .
"Disposition: manual-action/MDN-sent-manually; displayed\r\n";
$localfilename = GenerateRandomString(32, 'FILE', 7);
$full_localfilename = "$hashed_attachment_dir/$localfilename";
$fp = fopen( $full_localfilename, 'w');
fwrite ($fp, $part2);
fclose($fp);
$newAttachment = array();
$newAttachment['localfilename'] = $localfilename;
$newAttachment['type'] = "message/disposition-notification";
$newAttachment['session']=-1;
$attachments[] = $newAttachment;
$MDN_to = trim($recipient);
$reply_id = 0;
return (SendMessage($MDN_to, '', '', _("Read:") . ' ' . $subject,
$body, $reply_id, True, 3, -1) );
}
function ToggleMDNflag ( $set ) {
global $imapConnection, $passed_id, $mailbox, $uid;
sqimap_mailbox_select($imapConnection, $mailbox);
$sg = $set?'+':'-';
$cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
$read = sqimap_run_command ($imapConnection, $cmd, true, $response,
$readmessage, $uid);
}
function ClearAttachments() {
global $username, $attachments, $attachment_dir;
$hashed_attachment_dir = getHashedDir($username, $attachment_dir);
$rem_attachments = array();
foreach ($attachments as $info) {
if ($info['session'] == -1) {
$attached_file = "$hashed_attachment_dir/$info[localfilename]";
if (file_exists($attached_file)) {
unlink($attached_file);
}
} else {
$rem_attachments[] = $info;
}
}
$attachments = $rem_attachments;
}
function formatRecipientString($recipients, $item ) {
global $base_uri, $passed_id, $urlMailbox, $startMessage, $show_more_cc,
$echo_more, $echo_less, $show_more, $show_more_bcc, $sort, $passed_ent_id,
$PHP_SELF;
$i = 0;
$url_string = '';
if ((is_array($recipients)) && (isset($recipients[0]))) {
$string = '';
$ary = $recipients;
$show = false;
if ($item == 'to') {
if ($show_more) {
$show = true;
$url = set_url_var($PHP_SELF, 'show_more',0);
} else {
$url = set_url_var($PHP_SELF, 'show_more',1);
}
} else if ($item == 'cc') {
if ($show_more_cc) {
$url = set_url_var($PHP_SELF, 'show_more_cc',0);
$show = true;
} else {
$url = set_url_var($PHP_SELF, 'show_more_cc',1);
}
} else if ($item == 'bcc') {
if ($show_more_bcc) {
$url = set_url_var($PHP_SELF, 'show_more_bcc',0);
$show = true;
} else {
$url = set_url_var($PHP_SELF, 'show_more_bcc',1);
}
}
$cnt = count($ary);
while ($i < $cnt) {
$addr_o = $ary[$i];
$ary[$i] = $addr_o->getAddress();
$ary[$i] = decodeHeader(htmlspecialchars($ary[$i]));
$url_string .= $ary[$i];
if ($string) {
$string .= '
'.$ary[$i];
} else {
$string = $ary[$i];
if ($cnt>1) {
$string .= ' ('.$echo_less.')';
} else {
$string .= '">'.$echo_more.')';
break;
}
}
}
$i++;
}
}
else {
$string = '';
}
$url_string = urlencode($url_string);
$result = array();
$result['str'] = $string;
$result['url_str'] = $url_string;
return $result;
}
/*
* Main of read_boby.php --------------------------------------------------
*/
/*
Urled vars
----------
$passed_id
*/
global $uid_support, $sqimap_capabilities;
if (isset($mailbox)){
$mailbox = urldecode( $mailbox );
}
$imapConnection = sqimap_login($username, $key, $imapServerAddress,
$imapPort, 0);
$mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
if (!isset($messages)) {
$messages = array();
session_register('messages');
echo "SET messages";
}
/**
* $message contains all information about the message
* including header and body
*/
if (!isset($messages[$passed_id])) {
$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
$messages["$passed_id"] = $message;
$header = $message->header;
echo "NOT SET $passed_id";
} else {
$message = $messages[$passed_id];
$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
if (isset($passed_ent_id)) {
$message = $message->getEntity($passed_ent_id);
$message->id = $passed_id;
$message->mailbox = $mailbox;
}
$header = $message->header;
}
do_hook('html_top');
/*
* The following code sets necesarry stuff for the MDN thing
*/
if($default_use_mdn &&
($mdn_user_support = getPref($data_dir, $username, 'mdn_user_support',
$default_use_mdn))) {
$supportMDN = ServerMDNSupport($mbx_response["PERMANENTFLAGS"]);
$FirstTimeSee = !$message->is_seen;
}
displayPageHeader($color, $mailbox);
/*
* The following code shows the header of the message and then exit
*/
if (isset($view_hdr)) {
$template_vars = array();
parse_viewheader($imapConnection,$passed_id,&$template_vars);
$template_vars['return_address'] = set_url_var($PHP_SELF, 'view_hdr');
view_header($template_vars, '', '