This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
*/
require "../../Group-Office.php";
$GO_SECURITY->authenticate();
$GO_MODULES->authenticate('squirrelmail');
require $GO_LANGUAGE->get_language_file('squirrelmail');
require $GO_CONFIG->class_path . "imap.class.inc";
require $GO_MODULES->class_path . "email.class.inc";
$mail = new imap();
$email = new email();
$account = $email->get_account($_REQUEST['account_id']);
if ($mail->open($account['host'], $account['type'], $account['port'], $account['username'], $GO_CRYPTO->decrypt($account['password']), $_REQUEST['mailbox'], 0, $account['use_ssl'], $account['novalidate_cert'])) {
    $content = $mail->get_message($_REQUEST['uid']);
}
$page_title = $fbProperties;
require $GO_THEME->theme_path . "header.inc";
?>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
	<td height="50">
	<h1><?php 
echo $fbProperties;
?>
</h1>
	</td>
</tr>
<tr>
	<td>
if ($account && $mail->open($account['host'], $account['type'], $account['port'], $account['username'], $GO_CRYPTO->decrypt($account['password']), $mailbox, 0, $account['use_ssl'], $account['novalidate_cert'])) {
    if ($task == 'move_mail') {
        $messages = array($uid);
        $move_to_mailbox = smartstrip($_REQUEST['move_to_mailbox']);
        if ($mail->move($move_to_mailbox, $messages) && $mail->reopen($move_to_mailbox)) {
            header('Location: ' . $GO_MODULES->url . 'index.php?account_id=' . $account_id . '&mailbox=' . $mailbox);
            exit;
        }
    }
    //sort messages for determination of previous and next message
    if ($query != '') {
        $mail->search($em_settings['sort_field'], $em_settings['sort_order'], base64_decode($query));
    } else {
        $mail->sort($em_settings['sort_field'], $em_settings['sort_order']);
    }
    $content = $mail->get_message($uid, 'html', $part);
    $subject = !empty($content["subject"]) ? $content["subject"] : $ml_no_subject;
} else {
    require $GO_THEME->theme_path . 'header.inc';
    echo '<table border="0" cellpadding="10" width="100%"><tr><td>';
    echo '<p class="Error">' . $ml_connect_failed . ' \'' . $account['host'] . '\' ' . $ml_at_port . ': ' . $account['port'] . '</p>';
    echo '<p class="Error">' . imap_last_error() . '</p>';
    require $GO_THEME->theme_path . 'footer.inc';
    exit;
}
//update notified mail state
if ($content["new"] == '1') {
    $_SESSION['notified_new_mail'] -= 1;
    $_SESSION['unseen_in_mailbox'] -= 1;
}
require $GO_THEME->theme_path . "header.inc";