Version: 1.0 Release date: 08 July 2003

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');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    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($_POST['account_id']);
    if ($mail->open($account['host'], $account['type'], $account['port'], $account['username'], $GO_CRYPTO->decrypt($account['password']), $_POST['mailbox'], 0, $account['use_ssl'], $account['novalidate_cert'])) {
        $file = $mail->view_part($_POST['uid'], $_POST['part'], $_POST['transfer'], $_POST['mime']);
        $mail->close();
        if ($file != '') {
            $tmp_file = $GO_CONFIG->tmpdir . md5(uniqid(time()));
            if (!($fp = fopen($tmp_file, 'w+'))) {
                exit("Failed to open temporarily file");
            } elseif (!fwrite($fp, $file)) {
                exit("Failed to write to temporarily file");
            } elseif ($_POST['download'] == 'true') {
                fclose($fp);
                $browser = detect_browser();
                header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
                if ($browser['name'] == 'MSIE') {
                    header('Content-Type: application/download');
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('email');
require $GO_CONFIG->class_path . "imap.class.inc";
require $GO_MODULES->class_path . "email.class.inc";
require $GO_CONFIG->class_path . 'filetypes.class.inc';
$filetypes = new filetypes();
$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'])) {
    $file = $mail->view_part($_REQUEST['uid'], $_REQUEST['part'], $_REQUEST['transfer'], $_REQUEST['mime']);
    $mail->close();
    $filename = smartstrip($_REQUEST['filename']);
    $extension = get_extension($filename);
    $type = $filetypes->get_type($extension);
    $browser = detect_browser();
    //header('Content-Length: '.strlen($file));
    header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    if ($browser['name'] == 'MSIE') {
        header('Content-Type: application/download');
        header('Content-Disposition: attachment; filename="' . $filename . '"');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
    } else {
$texts = '';
$images = '';
$account_id = isset($_REQUEST['account_id']) ? $_REQUEST['account_id'] : 0;
$task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';
$mailbox = isset($_REQUEST['mailbox']) ? $_REQUEST['mailbox'] : "INBOX";
$uid = isset($_REQUEST['uid']) ? $_REQUEST['uid'] : 0;
$max_rows = isset($_REQUEST['max_rows']) ? $_REQUEST['max_rows'] : $_SESSION['GO_SESSION']['max_rows_list'];
$first_row = isset($_REQUEST['first_row']) ? $_REQUEST['first_row'] : 0;
$table_tabindex = isset($_REQUEST['table_tabindex']) ? $_REQUEST['table_tabindex'] : null;
$return_to = isset($_REQUEST['return_to']) && $_REQUEST['return_to'] != '' ? $_REQUEST['return_to'] : null;
$link_back = isset($_REQUEST['link_back']) && $_REQUEST['link_back'] != '' ? $_REQUEST['link_back'] : $_SERVER['REQUEST_URI'];
$task = isset($_REQUEST['task']) && $_REQUEST['task'] != '' ? $_REQUEST['task'] : '';
$print = isset($_REQUEST['print']) ? true : false;
$part = isset($_REQUEST['part']) ? $_REQUEST['part'] : '';
$query = isset($_REQUEST['query']) ? $_REQUEST['query'] : '';
$account = $email->get_account($account_id);
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']);
    }
$GO_MODULES->authenticate('email');
require $GO_CONFIG->class_path . "imap.class.inc";
require $GO_MODULES->class_path . "email.class.inc";
require $GO_LANGUAGE->get_language_file('email');
$mail = new imap();
$email = new email();
$em_settings = $email->get_settings($GO_SECURITY->user_id);
$account_id = isset($_REQUEST['account_id']) ? $_REQUEST['account_id'] : 0;
$task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';
$uid = isset($_REQUEST['uid']) ? $_REQUEST['uid'] : 0;
$max_rows = isset($_REQUEST['max_rows']) ? $_REQUEST['max_rows'] : $_SESSION['GO_SESSION']['max_rows_list'];
$first_row = isset($_REQUEST['first_row']) ? $_REQUEST['first_row'] : 0;
$table_tabindex = isset($_REQUEST['table_tabindex']) ? $_REQUEST['table_tabindex'] : null;
$mailbox = isset($_REQUEST['mailbox']) ? smartstrip($_REQUEST['mailbox']) : 'INBOX';
$link_back = $GO_MODULES->url . 'index.php?account_id=' . $account_id . '&mailbox=' . $mailbox . '&first_row=' . $first_row;
if (!($account = $email->get_account($account_id))) {
    $account = $email->get_account(0);
}
if ($account && $account["user_id"] != $GO_SECURITY->user_id) {
    header('Location: ' . $GO_CONFIG->host . 'error_docs/403.php');
    exit;
}
$disable_accounts = $GO_CONFIG->get_setting('em_disable_accounts') == 'true' ? true : false;
$page_title = $lang_modules['email'];
$GO_HEADER['head'] = '<script type="text/javascript" src="' . $GO_MODULES->url . 'email.js"></script>';
require $GO_THEME->theme_path . "header.inc";
?>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="5"></td>
<td><h1>
            chmod($new_path, $GO_CONFIG->create_mode);
            umask($old_umask);
            unset($_SESSION['tmp_account_id']);
            unset($_SESSION['email_tmp_file']);
            echo "<script type=\"text/javascript\" language=\"javascript\">\n";
            echo "window.close()\n";
            echo "</script>\n";
        } else {
            $feedback = '<p class="Error">' . $strSaveError . '</p>';
        }
    }
}
if (isset($_REQUEST['account_id'])) {
    $_SESSION['tmp_account_id'] = $_REQUEST['account_id'];
}
$account = $email->get_account($_SESSION['tmp_account_id']);
if (!file_exists($_SESSION['email_tmp_file']) && !is_dir($_SESSION['email_tmp_file'])) {
    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'])) {
        $data = $mail->view_part($_REQUEST['uid'], $_REQUEST['part'], $_REQUEST['transfer'], $_REQUEST['mime']);
        $mail->close();
        $fp = fopen($_SESSION['email_tmp_file'], "w+");
        fputs($fp, $data, strlen($data));
        fclose($fp);
    } else {
        die('Could not connect to mail server!');
    }
}
require_once '../../Group-Office.php';
$module = $GO_MODULES->get_module('email');
$GO_HANDLER = $_SERVER['PHP_SELF'];
$GO_CONFIG->window_mode = 'popup';
             copy($_FILES['mail_att']['tmp_name'], $tmp_file);
             $email->register_attachment($tmp_file, basename($_FILES['mail_att']['name']), $_FILES['mail_att']['size'], $_FILES['mail_att']['type']);
         } else {
             $feedback = '<script type="text/javascript">alert("' . $ml_file_too_big . format_size($GO_CONFIG->max_attachment_size) . ' (' . number_format($GO_CONFIG->max_attachment_size, 0, $_SESSION['GO_SESSION']['decimal_seperator'], $_SESSION['GO_SESSION']['thousands_seperator']) . ' bytes)");</script>';
         }
     } else {
         $feedback = '<script type="text/javascript">alert("' . $ml_file_too_big . format_size($GO_CONFIG->max_attachment_size) . ' (' . number_format($GO_CONFIG->max_attachment_size, 0, $_SESSION['GO_SESSION']['decimal_seperator'], $_SESSION['GO_SESSION']['thousands_seperator']) . ' bytes)");</script>';
     }
     break;
 case 'send':
     if (!isset($_POST['mail_from'])) {
         $profile = $GO_USERS->get_user($GO_SECURITY->user_id);
         $middle_name = $profile['middle_name'] == '' ? '' : $profile['middle_name'] . ' ';
         $name = $profile['last_name'] . ' ' . $middle_name . $profile['first_name'];
     } else {
         $profile = $email->get_account($_POST['mail_from']);
         $name = $profile["name"];
     }
     $mail = new PHPMailer();
     $mail->PluginDir = $GO_CONFIG->class_path . 'phpmailer/';
     $mail->SetLanguage($php_mailer_lang, $GO_CONFIG->class_path . 'phpmailer/language/');
     switch ($GO_CONFIG->mailer) {
         case 'smtp':
             $mail->Host = $GO_CONFIG->smtp_server;
             $mail->Port = $GO_CONFIG->smtp_port;
             $mail->IsSMTP();
             break;
         case 'qmail':
             $mail->IsQmail();
             break;
         case 'sendmail':
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('email');
require $GO_CONFIG->class_path . "imap.class.inc";
require $GO_MODULES->class_path . "email.class.inc";
require $GO_LANGUAGE->get_language_file('email');
$mail = new imap();
$email = new email();
$task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';
$return_to = isset($_REQUEST['return_to']) && $_REQUEST['return_to'] != '' ? $_REQUEST['return_to'] : $_SERVER['HTTP_REFERER'];
$link_back = isset($_REQUEST['link_back']) && $_REQUEST['link_back'] != '' ? $_REQUEST['link_back'] : $_SERVER['REQUEST_URI'];
$account_id = isset($_REQUEST['account_id']) ? $_REQUEST['account_id'] : 0;
$account = $email->get_account($account_id);
if ($account && $mail->open($account['host'], $account['type'], $account['port'], $account['username'], $GO_CRYPTO->decrypt($account['password']), 'INBOX', 0, $account['use_ssl'], $account['novalidate_cert'])) {
    if ($task == 'create_folder') {
        $name = smartstrip(trim($_POST['name']));
        if ($name == '') {
            $feedback = '<p class="Error">' . $error_missing_field . '</p>';
        } else {
            $parent_folder_name = isset($_POST['parent_folder_name']) ? smartstrip($_POST['parent_folder_name']) : '';
            if ($parent_folder_name != '' && substr($parent_folder_name, -1) != $_POST['delimiter']) {
                $parent_folder_name .= $_POST['delimiter'];
            }
            $mail->create_folder($parent_folder_name . $name);
        }
    }
    if (isset($_REQUEST['delete_folder'])) {
        $delete_folder = smartstrip($_REQUEST['delete_folder']);