!C99Shell v. 1.0 pre-release build #16!

Software: Apache/2.0.54 (Fedora). PHP/5.0.4 

uname -a: Linux mina-info.me 2.6.17-1.2142_FC4smp #1 SMP Tue Jul 11 22:57:02 EDT 2006 i686 

uid=48(apache) gid=48(apache) groups=48(apache)
context=system_u:system_r:httpd_sys_script_t
 

Safe-mode: OFF (not secure)

/home/mnnews/public_html/dwmail/   drwxr-xr-x
Free 4.04 GB of 27.03 GB (14.94%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     compose.php (54.05 KB)      -rwxr-xr-x
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/*
############################################################################
# DWmail
#      - version 4.0.4
#      - 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/html.inc.php");
require (
"./includes/config.inc.php");
require (
"./includes/browser.inc.php");
require_once(
"./includes/mime.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']))) . "/compose.inc.php");
require (
"./lang/" . strip_tags(str_replace("..", "", trim($_SESSION['DefaultLang']))) . "/wysiwyg.inc.php");
@
setlocale(LC_TIME, $AvailLangs[$_SESSION['DefaultLang']]['locale']);

// It has been reported and replicated in a very few circumstances that
// $_SESSION['ca'] simply disappears from being set at the bottom
// of this page to being missing when reloaded right at this location.
// $_SESSION['ca'] is the array used for sending attachments
// If anyone can replicate this issue or find out why please let us know!

require ("./includes/options.inc.php");

$_SESSION['tpl'] = strip_tags(trim($_SESSION['tpl']));

if (isset(
$_GET['w']) && $_GET['w'] == 'popup') {
    
$prependheader = "popup_";
}
else {
    
$prependheader = "";
}

$getFile = new fileProperties($_SESSION['tpl']);
$PageHeader = $getFile->fileRead('header');
$PageFooter = $getFile->fileRead('footer');
$PageCopyright = $getFile->fileRead('copyright');
$PageCompose = $getFile->fileRead('composemessage');
$PageAttachments = $getFile->fileRead('composeattachments');
$PageAttachment = $getFile->fileRead('composeattachment2');
$PageShowAttachments = $getFile->fileRead('composeshowattachments2');
$PageCompose = str_replace("[displayattachments]", $PageShowAttachments, $PageCompose);

$id = $_GET['id'];
if (
$id == "") {
    
$id = $_POST['id'];
}

if (
$id == "") {
    
$PageComposeMenu = "";
}
else {
    
$PageComposeMenu = $getFile->fileRead('composemenu');
}

$isdraft = 0;

$draftmode = $_GET['w'];
if (
$draftmode == 'draft') {
    
$isdraft = 1;
}

$postmode = $_POST['edit'];

$mode = $_GET['mode'];
if (
$mode == "") {
    
$mode = $_POST['mode'];
}

// Compose Mode has been changed
if ($_POST['text']) {
    
$edit = "text";
}
if (
$_POST['html']) {
    
$edit = "html";
}
if (
$_POST['wysiwyg']) {
    
$edit = "wysiwyg";
}

if ((
$DefaultComposeMode) && ($edit == "")) {
    
$edit = $DefaultComposeMode;
}

$enablespellcheck = 0;
// Check that the pspell library is installed and that the $AvailLanguages array tells us that
// aspell support for the current language is enabled
if (function_exists('pspell_new') && $AvailLangs[trim($_SESSION['DefaultLang'])]['spell']['enable'] == 1) {
    
$enablespellcheck = 1;
}

$MIMEChecker = new MIME();

$myoptions['DefaultComposeMode'] = $edit;

// Clear out old attachments from the session if we have a NEW email
if (!$_POST['submit'] && !$_POST['sendbutton'] && !$_POST['spellcheck'] && !$_POST['savedraft'] && !$_POST['attachfile'] && !$_POST['text'] && !$_POST['html'] && !$_POST['wysiwyg'] && !$_POST['updateattachments']) {
    unset(
$_SESSION['ca']);
    unset(
$_SESSION['cafwd']);
}
if (
$UseDatabase == 1) {
    
$MySQLUpdate = $MySQLConnection->DB_UpdatePrefs(serialize($myoptions), 'standard');
}
else {
    if (
$AllowCookies == 1) {
        
$expiretime = 3600 * 8760;
        
setcookie ("dwmailoptions", serialize($myoptions), time()+$expiretime);
    }
}

// Display text for the current Compose Mode
if ($edit == "text") {
    
$currentmode = $lang['SCompose']['ComposePlain'];
}
elseif (
$edit == "html") {
    
$currentmode = $lang['SCompose']['ComposeHTML'];
}
else {
    
$currentmode = $lang['SCompose']['ComposeWYSIWYG'];
}

$PageMenu = $getFile->fileRead('menu');

$PageMenu = str_replace("[session]", $MainSettings->SessAppend_noecho($TransIDEnabled, 1), $PageMenu);
$PageMenu = str_replace("[session_append]", $MainSettings->SessAppend_noecho($TransIDEnabled, 0), $PageMenu);

$PageMenu = str_replace("[emailaddress]", $_SESSION['currentemailaddress'], $PageMenu);

if (
$_GET['id'] && $_GET['mode'] == 'fwd' && $isdraft <> 1) {
    
$pagetitle = " - " . $lang['SCompose']['Forward'];
}
elseif (
$_GET['id'] && $_GET['mode'] <> 'fwd' && $isdraft <> 1) {
    
$pagetitle = " - " . $lang['SCompose']['Reply'];
}
else {
    
$pagetitle = " - " . $lang['SCompose']['Title'];
}

$CodeSearch = array (
    
"[view_id]",
    
"[view_folder]",
    
"[session_append]",
    
"[session]",
);

$CodeReplace = array (
    
$id,
    
urlencode($_SESSION['folder']),
    
$MainSettings->SessAppend_noecho($TransIDEnabled, 0),
    
$MainSettings->SessAppend_noecho($TransIDEnabled, 1)
);

$PageComposeMenu = str_replace ($CodeSearch, $CodeReplace, $PageComposeMenu);

$PageHeader = str_replace("[mainmenu]", $PageMenu, $PageHeader);
$PageHeader = str_replace("[header_refresh]", "", $PageHeader);
$PageHeader = str_replace("[charset]", $_SESSION['DefaultCharSet'], $PageHeader);
$PageHeader = str_replace("[lang]", $_SESSION['DefaultLang'], $PageHeader);
$PageHeader = str_replace("[langdir]", $AvailLangs[$_SESSION['DefaultLang']]['dir'], $PageHeader);
$PageHeader = str_replace("[pagetitle]", $pagetitle, $PageHeader);
$PageFooter = str_replace("[mainmenu]", $PageMenu, $PageFooter);
$PageFooter = str_replace("[copyright]", $PageCopyright, $PageFooter);

if (
$AllowExternal == 1 && $UseDatabase == 1) {
    
$PageHeader = str_replace("[ifexternal]", "", $PageHeader);
    
$PageHeader = str_replace("[/ifexternal]", "", $PageHeader);
    
$PageFooter = str_replace("[ifexternal]", "", $PageFooter);
    
$PageFooter = str_replace("[/ifexternal]", "", $PageFooter);
}
else {
    
$PageHeader = preg_replace("/(\[)(ifexternal)(])(\r\n)*(.*)(\[\/ifexternal\])/siU", "", $PageHeader);
    
$PageFooter = preg_replace("/(\[)(ifexternal)(])(\r\n)*(.*)(\[\/ifexternal\])/siU", "", $PageFooter);
}

$genericerror = $getFile->fileRead('generic_message');
$genericerror = str_replace ('[pagetitle]', $lang['SErrors']['Title'], $genericerror);

$error_session = str_replace ('[pagemessage]', $lang['SErrors']['Session'], $genericerror);
CheckValidSession($_SESSION, $PageFooter, $error_session, $PageHeader, $lang);

$IMAPConnection = new WM_IMAPConnection($_SESSION);

$securitycheck = $IMAPConnection->WM_IMAPCheckSecurity();
$error_ipfailuresession = str_replace ('[pagemessage]', $lang['SErrors']['IP'], $genericerror);
CheckSessionSecurity($securitycheck, $PageFooter, $error_ipfailure, $PageHeader, $lang);

$crlf = $MainSettings->GetCRLF();
$IMAPConnection->_crlf = $crlf;
$IMAPConnection->_charset = $_SESSION['DefaultCharSet'];

$mailbox = $IMAPConnection->WM_IMAPConnect();

checkmailbox_active($mailbox, $IMAPConnection, $PageHeader, $_SESSION['tpl'], $PageFooter, $getFile, $lang, $genericerror);

// Deal with submitted forms
require ('./includes/compose.inc.php');

// Now we have handled any outgoing email we can display either the compose form, error or success pages
include ("./includes/folderpane.inc.php");
$PageHeader = str_replace ("[folders]", $PageFolderPane, $PageHeader);
$PageHeader = LangReplace('Generic', $PageHeader, $lang);
$PageHeader = LangReplace('SFolderPane', $PageHeader, $lang);
$PageFooter = LangReplace('Generic', $PageFooter, $lang);
$PageFooter = LangReplace('SFolderPane', $PageFooter, $lang);

if (
$returnmessage) {
    
header ("Content-Type: text/html; charset=" . $_SESSION['DefaultCharSet']);
    echo
$PageHeader;
    
$PageGenericMessage = str_replace("[pagemessage]", $returnmessage, $PageGenericMessage);
    echo
$PageGenericMessage;
}
else {

    
// Get a user defined signature
    
if ($UseDatabase == 1) {
        if (
$edit <> 'text') {
            
$GetSignature = trim($MySQLConnection->DB_GetPrefs('signaturehtml'));
            if (
$GetSignature == FALSE) {
                
$GetSignature = "";
            }
            else {
                
$GetSignature = stripslashes($GetSignature);
                
$GetSignature = strip_tags($GetSignature, '<p><b><em><strong><a><i><br><div><span><img><sup><sup><ul><li><ol><hr><u>');
                
$GetSignature = nl2br($GetSignature);
                
$GetSignature .= $nlhtml . $crlf . $nlhtml . $crlf;
            }
        }
        else {
            
$GetSignature = trim($MySQLConnection->DB_GetPrefs('signature'));
            if (
$GetSignature == FALSE) {
                
$GetSignature = "";
            }
            else {
                
$GetSignature = stripslashes($GetSignature);
                
$GetSignature = strip_tags($GetSignature);
                
$GetSignature = $crlf . $GetSignature;
                
$GetSignature .= $nlhtml . $crlf . $nlhtml . $crlf;
            }
        }
    }
    else {
        
$GetSignature = "";
    }

    
// Have we got a message id.  Means we have a reply or forward so get message details.
    
if ($id <> '') {

        if (
$_GET['f']) {
            
$_SESSION['folder'] = strip_tags(trim($_GET['f']));
        }
        
$IMAPConnection->WM_IMAPGetHeader($id);
        
$headerdetails = $IMAPConnection->WM_IMAPFullHeaders();
        
$subj = $IMAPConnection->WM_IMAPGetSubject();

        if (
$subj == "") {
            
$subj2 = "(no subject)";
        }
        if (
$isdraft == 1) {
            
$subj2 = $MainSettings->CheckSlashes($subj);
        }
        elseif ((
$mode == "" || $mode == "all") && (substr(strtoupper($subj), 0, 3) <> "RE:")) {
            
$subj2 = "RE: " . $MainSettings->CheckSlashes($subj);
        }
        elseif ((
$mode == "fwd") && (substr(strtoupper($subj), 0, 3) <> "FW:")) {
            
$subj2 = "FW: " . $MainSettings->CheckSlashes($subj);
        }
        else {
            
$subj2 = $MainSettings->CheckSlashes($subj);
        }
        
$subj2 = preg_replace("/(\[)(autosave)*(.*)(])/siU", "", $subj2);
        
$structure = $IMAPConnection->WM_IMAPGetStructure($id);

        if (
sizeof($structure->parts) > 1) {
            
$sections = parseBody($structure);
            
$attachments = get_attachments($sections);
            
$embeddedattachments = get_embeddedattachments($sections);

            if (
is_array($attachments) && is_array($embeddedattachments)) {
                
$allattachments = array_merge($attachments, $embeddedattachments);
            }
            elseif (
is_array($embeddedattachments)) {
                
$allattachments = $embeddedattachments;
            }
            else {
                
$allattachments = $attachments;
            }
            if (!
is_array($_SESSION['cafwd'])) {
                
$_SESSION['cafwd'] = $allattachments;
            }
        }


        if (
is_array($sections)) {
            for(
$x=0; $x<sizeof($sections); $x++) {
                if (
$sections[$x]["type"] == "multipart/alternative" && $sections[$x]["disposition"] != "attachment") {
                    
$message["alternative"] = $IMAPConnection->WM_IMAPGetBody($id, $sections[$x]["pid"], $sections[$x]["subpart"]);
                }
                elseif (
$sections[$x]["type"] == "text/html"  && $sections[$x]["disposition"] != "attachment") {
                    
$message["html"] = $IMAPConnection->WM_IMAPGetBody($id, $sections[$x]["pid"], $sections[$x]["subpart"]);
                    
$message["html"] = parseEncoding($message["html"], $sections[$x]["encoding"]);
                    
$origformat = "html";
                }
                elseif (
$sections[$x]["type"] == "text/plain"  && $sections[$x]["disposition"] != "attachment") {
                    
$message["text"] = $IMAPConnection->WM_IMAPGetBody($id, $sections[$x]["pid"], $sections[$x]["subpart"]);
                    
$message["text"] = parseEncoding($message["text"], $sections[$x]["encoding"]);
                    
$message["text"] = htmlspecialchars(stripslashes(trim($message["text"])));
                    
$origformat = "text";
                }
            }
            if (isset(
$message["html"]) && ($HTMLemail == 1 || ($HTMLemail == 2 && !isset($message["text"])))) {
                
$content = stripslashes(trim($message["html"]));
                
$origformat = "html";
                
$CleanUpHTML = new HTMLCleanup($content);
                
$CleanUpHTML->ChangeTarget();
                
$CleanUpHTML->RemoveScripting();
                
$CleanUpHTML->RemoveMalicious();
                
$content = $CleanUpHTML->_body;
            }
            else {
                
$content = $message["text"];
                
$origformat = "text";
            }
        }
        else {
            
$content = $IMAPConnection->WM_IMAPGetBody($id, -1, -1);
            
$content = parseEncoding($content, $encoding[$structure->encoding]);
            
$origformat = "text";
        }
        unset (
$message);

        if (
$isdraft <> 1) {
            if (
$edit <> "text") {
                
$nlhtml .= "<br />";
                if (!isset(
$ve['c_fontface'])) {
                    
$ve['c_fontface'] = "Arial, Helvetica, sans-serif";
                }
                if (!isset(
$ve['c_fontsize'])) {
                    
$ve['c_fontsize'] = "2";
                }
                if (!isset(
$ve['c_fontcolour'])) {
                    
$ve['c_fontcolour'] = "#000000";
                }
                
$fonthtml = "<font face=\"" . stripslashes($ve['c_fontface']) . "\"  size=\"" . stripslashes($ve['c_fontsize']) . "\" color=\"" . stripslashes($ve['c_fontcolour']) . "\">";
            }
            else {
                
$nlhtml .= "";
                
$fonthtml = "";
            }

            
$message = $fonthtml . $crlf . $GetSignature . $nlhtml . $crlf . $crlf;
            if ((
$IncOrig == "1") || (!isset($IncOrig))) {
                
$localtime_date = DateToLocal($tz, $headerdetails['date'], $DateFormattingFull);

                
$message .= "-----" . $lang['SCompose']['ComposeOriginal'] . "-----" .  $nlhtml . $crlf;
                if (
$edit == "html" || $edit == "wysiwyg") {
                    
$message .= "<strong>" . $lang['SCompose']['From'] . ":</strong> " . $headerdetails['fromaddress'] . $nlhtml . $crlf;
                    
$message .= "<strong>" . $lang['SCompose']['Sent'] . ":</strong> " . $localtime_date . $nlhtml . $crlf;
                    
$message .= "<strong>" . $lang['SCompose']['To'] . ":</strong> " . $headerdetails['toaddress'] . $nlhtml . $crlf;
                    if (
$headerdetails['ccaddress'] <> "") {
                        
$message .= "<strong>" . $lang['SCompose']['Cc'] . ":</strong> " . $headerdetails['ccaddress'] . $crlf;
                    }
                    
$message .= "<strong>" . $lang['SCompose']['Subject'] . ":</strong> " . $subj . $nlhtml . $nlhtml . $crlf . $crlf;
                }
                else {
                    
$message .= $lang['SCompose']['From'] . ": " . $headerdetails['fromaddress'] . $nlhtml . $crlf;
                    
$message .= $lang['SCompose']['Sent'] . ": " . $localtime_date . $nlhtml . $crlf;
                    
$message .= $lang['SCompose']['To'] . ": " . $headerdetails['toaddress'] . $nlhtml . $crlf;

                    if (
$headerdetails['ccaddress'] <> "") {
                        
$message .= $lang['SCompose']['Cc'] . ": " . $headerdetails['ccaddress'] . $crlf;
                    }
                    
$message .= $lang['SCompose']['Subject'] . ": " . $subj . $nlhtml . $nlhtml . $crlf . $crlf;
                }

                if (
$edit <> "text") {
                    if (
$origformat == "text") {
                        
$content = nl2br($content);
                    }
                    
$message .= $content;
                    
$message .= "</font>";
                }
                else {
                    if (
$origformat == "html") {
                        
$content = str_replace ("\n", "", $content);
                        
$content = str_replace ("\r", "", $content);
                        
$content = str_replace ("<BR>", "\n", $content);
                        
$content = str_replace ("<BR />", "\n", $content);
                        
$content = str_replace ("<br>", "\n", $content);
                        
$content = str_replace ("<br />", "\n", $content);
                        
$content = str_replace ("</p>", "\n\n", $content);
                        
$content = str_replace ("</P>", "\n\n", $content);
                    }
                    
$message = $message . strip_tags($content);
                }
            }
        }
        else {
            
// This is draft content
            
$message = $content;
            if (
$origformat == 'html' && $allowbrowser == 0) {
                
$edit == 'html';
            }
            elseif (
$origformat == 'html' && $allowbrowser == 1) {
                
$edit == 'wysiwyg';
            }
            else {
                
$edit == 'text';
            }
        }

        if (
$mode == "" && $id <> "" && $isdraft == 0) {
            if (
htmlspecialchars($headerdetails['reply_toaddress'] == "")) {
                
$sendto = $headerdetails['fromaddress'];
            }
            else {
                
$sendto = $headerdetails['reply_toaddress'];
            }
        }
        elseif (
$mode == "all" && $isdraft == 0) {
            if (
htmlspecialchars($headerdetails['reply_toaddress'] == "")) {
                
$sendto = $headerdetails['fromaddress'];
            }
            else {
                
$sendto = $headerdetails['reply_toaddress'];
            }
            
$sendto .= ", " . $headerdetails['toaddress'];
            
$sendcc = $headerdetails['ccaddress'];
        }
        elseif (
$isdraft == 1) {
            
$sendto = str_replace('"', '&quot;', $headerdetails['toaddress']);
            
$sendcc = str_replace('"', '&quot;', $headerdetails['ccaddress']);
            
$sendbcc = str_replace('"', '&quot;', $headerdetails['bccaddress']);
        }
    }

    
// Set value of 'to' field if parsed from view.php
    
if ($_GET['newto']) {
        
$sendto = htmlspecialchars($_GET['newto']);
    }
    if (
$_GET['newcc']) {
        
$sendcc = htmlspecialchars($_GET['newcc']);
    }
    if (
$_GET['newbcc']) {
        
$sendbcc = htmlspecialchars($_GET['newbcc']);
    }
    if (
$_GET['newsubject']) {
        
$subj2 = htmlspecialchars($_GET['newsubject']);
    }
    if (
$_GET['newbody']) {
        
$message = preg_replace('/javascript/i', 'java script', $_GET['newbody']);
    }

    
// Set values if a mode change has occurred.
    
if ($_POST['replyto']) {
        
$ReplyTo = $_POST['replyto'];
    }
    else {
        if (!isset(
$ReplyTo) || $ReplyTo == "") {
            
$ReplyTo = stripslashes($_SESSION['currentemailaddress']);
        }        
    }
    if (
$_POST['to']) {
        
$sendto = $_POST['to'];
    }
    if (
$_POST['cc']) {
        
$sendcc = $_POST['cc'];
    }
    if (
$_POST['bcc']) {
        
$sendbcc = $_POST['bcc'];
    }
    if (
$_POST['subject']) {
        
$subj2 = $_POST['subject'];
    }
    if (
$_POST['body']) {
        
$message = $_POST['body'];
    }

    if (
$_POST['correctspelling']) {
        
// Now we have a submission to correct spelling.
        // Look in enter own first, if blank then use suggestions
        
if (is_array($_POST['spell'])) {
            for (
$i=0; $i<sizeof($_POST['spell']); $i++) {
                if (
trim($_POST['othersuggest'][$i]) <> '') {
                    
$message = str_replace($_POST['spell'][$i], $_POST['othersuggest'][$i], $message);
                }
                else {
                    
$message = str_replace($_POST['spell'][$i], $_POST['suggest'][$i], $message);
                }
            }
        }
    }

    
$session_formdetails = $MainSettings->SessAppend_form($TransIDEnabled);

    if (
$AllowAttachments == 1) {
        
// This is the compose form with attachments enabled (note that the <form> must have an enctype)
        
if ($edit == "text" || $edit == "html") {
            
$message = $MainSettings->CheckSlashes($message);
            if (((
$postmode == "html") || ($postmode == "wysiwyg")) && ($edit == "text")) {
                
$message = str_replace ("<BR>", "\n", $message);
                
$message = str_replace ("<BR />", "\n", $message);
                
$message = str_replace ("<br>", "\n", $message);
                
$message = str_replace ("<br />", "\n", $message);
                
$message = str_replace ("</p>", "\n\n", $message);
                
$message = str_replace ("</P>", "\n\n", $message);
                
$message = strip_tags ($message);
            }
            elseif ((
$postmode == "text") && (($edit == "html") || ($edit == "wysiwyg"))) {
                
$message = nl2br ($message);
            }
            if (
$message == "" && $GetSignature <> "") {
                
$message = $crlf . $GetSignature;
            }
            
$compose_form = "<form action=\"compose.php\" method=\"post\" enctype=\"multipart/form-data\" name=\"composeform\">$session_formdetails";
            
// Find any embedded images and replace their ID in the body of the message so we can view them
            
if (is_array($embeddedattachments)) {
                for(
$x=0; $x<sizeof($embeddedattachments); $x++) {
                    
// Note this calls the same file as attachment download but we must set submit=inline to allow display rather than download
                    
$message = str_replace("cid:" . $embeddedattachments[$x]["id"], "attachment.php?submit=inline&amp;id=$id&amp;pid=" . $embeddedattachments[$x]["pid"]  . "&amp;f=" . $_GET['f'] . "&amp;" . strip_tags(SID), $message);
                }
            }
            
$messagebox = "<textarea name=\"body\" cols=\"65\" rows=\"15\" id=\"body\" class=\"compose\">" . $message . "</textarea>";
            
$PageCompose = str_replace("[iftextactive]", "", $PageCompose);
            
$PageCompose = str_replace("[/iftextactive]", "", $PageCompose);
            
$PageCompose = preg_replace("/(\[)(ifie)(])(\r\n)*(.*)(\[\/ifie\])/siU", "", $PageCompose);
            
$PageCompose = preg_replace("/(\[)(ifmozilla)(])(\r\n)*(.*)(\[\/ifmozilla\])/siU", "", $PageCompose);
            
$PageCompose = preg_replace("/(\[)(ifwysiwygactive)(])(\r\n)*(.*)(\[\/ifwysiwygactive\])/siU", "", $PageCompose);
        }
        else {
            
$message = $MainSettings->CheckSlashes($message);
            if ((
$postmode == "text") && (($edit == "html") || ($edit == "wysiwyg"))) {
                
$message = nl2br ($message);
            }

            if (
$allowbrowser == 1 && ($bd['browser'] == "Mozilla" || $bd['browser'] == "Opera")) {
                
$compose_form = "<form action=\"compose.php\" method=\"post\" enctype=\"multipart/form-data\" name=\"composeform\" onsubmit=\"ReFormat(this);\">$session_formdetails";
                
$PageHeader = str_replace("<body", "<body onload=\"InitializeEditor();\"", $PageHeader);
                
$PageHeader = str_replace("<BODY", "<body onload=\"InitializeEditor();\"", $PageHeader);
            }
            else {
                
$compose_form = "<form action=\"compose.php\" method=\"post\" enctype=\"multipart/form-data\" name=\"composeform\" onsubmit=\"ReFormat(this);\">$session_formdetails";
                
$PageHeader = str_replace("<body", "<body onload=\"InitializeEditor();\"", $PageHeader);
                
$PageHeader = str_replace("<BODY", "<body onload=\"InitializeEditor();\"", $PageHeader);
            }

            if (
$allowbrowser == 1 && ($bd['browser'] == "Mozilla" || $bd['browser'] == "Opera")) {
                
$messagebox = $getFile->fileRead('wysiwyg_mozilla');
                
$messagebox = LangReplace('SWYSIWYG', $messagebox, $lang);
                
$messagebox = str_replace("[parseelements]", "?" . strip_tags(SID), $messagebox);
                
$_SESSION['tmpmsg'] = $message;
                
$PageCompose = str_replace("[ifmozilla]", "", $PageCompose);
                
$PageCompose = str_replace("[/ifmozilla]", "", $PageCompose);
                
$PageCompose = str_replace("[ifwysiwygactive]", "", $PageCompose);
                
$PageCompose = str_replace("[/ifwysiwygactive]", "", $PageCompose);
                
$PageCompose = preg_replace("/(\[)(ifie)(])(\r\n)*(.*)(\[\/ifie\])/siU", "", $PageCompose);
                
$PageCompose = preg_replace("/(\[)(iftextactive)(])(\r\n)*(.*)(\[\/iftextactive\])/siU", "", $PageCompose);
            }
            elseif (
$allowbrowser == 1 && ($bd['browser'] <> "Mozilla" && $bd['browser'] <> "Opera")) {
                
$messagebox = $getFile->fileRead('wysiwyg_ie');
                
$messagebox = LangReplace('SWYSIWYG', $messagebox, $lang);
                
$messagebox = str_replace("[session_force]", strip_tags(SID), $messagebox);
                
$PageCompose = str_replace("[ifie]", "", $PageCompose);
                
$PageCompose = str_replace("[/ifie]", "", $PageCompose);
                
$PageCompose = str_replace("[ifwysiwygactive]", "", $PageCompose);
                
$PageCompose = str_replace("[/ifwysiwygactive]", "", $PageCompose);
                
$PageCompose = preg_replace("/(\[)(ifmozilla)(])(\r\n)*(.*)(\[\/ifmozilla\])/siU", "", $PageCompose);
                
$PageCompose = preg_replace("/(\[)(iftextactive)(])(\r\n)*(.*)(\[\/iftextactive\])/siU", "", $PageCompose);
            }
            else {
                
$messagebox = $lang['SErrors']['WYSIWYGError'];
            }

            if ((
$message == "")  && ($id == "") && ($mode == "")) {
                if (
$GetSignature <> "") {
                    
$GetSignature = "<br />" . $GetSignature;
                }
                if (!isset(
$ve['c_fontface'])) {
                    
$ve['c_fontface'] = "Arial, Helvetica, sans-serif";
                    
$fontface = "Arial, Helvetica, sans-serif";
                }
                else {
                    
$fontface = $ve['c_fontface'];
                }
                if (!isset(
$ve['c_fontsize'])) {
                    
$ve['c_fontsize'] = "2";
                    
$fontsize = "2";
                }
                else {
                    
$fontsize = $ve['c_fontsize'];
                }
                if (!isset(
$ve['c_fontcolour'])) {
                    
$ve['c_fontcolour'] = "#000000";
                    
$forecolour = "#000000";
                }
                else {
                    
$forecolour = $ve['c_fontcolour'];
                }
                
$message = "<font face=\"" . stripslashes($ve['c_fontface']) . "\" size=\"" . stripslashes($ve['c_fontsize']) . "\" color=\"" . stripslashes($ve['c_fontcolour']) . "\"><p>$GetSignature</p></font>";
            }
            elseif ((
$message <> "")  && ($id <> "")) {
                if (!isset(
$ve['r_fontface'])) {
                    
$ve['r_fontface'] = "Arial, Helvetica, sans-serif";
                    
$fontface = "Arial, Helvetica, sans-serif";
                }
                else {
                    
$fontface = $ve['r_fontface'];
                }
                if (!isset(
$ve['r_fontsize'])) {
                    
$ve['r_fontsize'] = "2";
                    
$fontsize = "2";
                }
                else {
                    
$fontsize = $ve['r_fontsize'];
                }
                if (!isset(
$ve['r_fontcolour'])) {
                    
$ve['r_fontcolour'] = "#0000CC";
                    
$forecolour = "#0000CC";
                }
                else {
                    
$forecolour = $ve['r_fontcolour'];
                }
                
$message = "<font face=\"" . stripslashes($ve['r_fontface']) . "\" size=\"" . stripslashes($ve['r_fontsize']) . "\" color=\"" . stripslashes($ve['r_fontcolour']) . "\"><p>&nbsp;</p></font>\n" . $message;
            }
            
// Find any embedded images and replace their ID in the body of the message so we can view them
            
if (is_array($embeddedattachments)) {
                for(
$x=0; $x<sizeof($embeddedattachments); $x++) {
                    
// Note this calls the same file as attachment download but we must set submit=inline to allow display rather than download
                    
$message = str_replace("cid:" . $embeddedattachments[$x]["id"], "attachment.php?submit=inline&amp;id=$id&amp;pid=" . $embeddedattachments[$x]["pid"]  . "&amp;f=" . $_GET['f'] . "&amp;" . strip_tags(SID), $message);
                }
            }
            
$messagebox = str_replace ("[compose_message]", $message, $messagebox);
            
$messagebox = str_replace ("[wysiwyg_content]", urlencode($message), $messagebox);
        }

        
$preattachments = 0;
        
$embedattachments = 0;

        
// Display attachments from a forwarded message
        
if (($mode == "fwd" || ($_SESSION['folder'] == $IMAPDrafts && !empty($id))) && sizeof($_SESSION['cafwd']) >= 1) {
            
$preattachments = 1;
            
$pretmp = $_SESSION['cafwd'];
            if (
is_array($pretmp)) {
                while(list(
$key, $value) = each($pretmp)) {
                    
$filedisplay = $PageAttachment;
                    
$filedisplay = str_replace("[attachment_id]", $key, $filedisplay);
                    
$filedisplay = str_replace("[attachment_pid]", '', $filedisplay);
                    
$filedisplay = str_replace("[iflink]", '', $filedisplay);
                    
$filedisplay = str_replace("[/iflink]", '', $filedisplay);
                    if (
$_SESSION['cafwd'][$key]["type"] == 'message/rfc822') {
                        
$filedisplay = str_replace("[attachment_link]", "view.rfc822.php?id=" . $id . "&amp;pid=" . $_SESSION['cafwd'][$key]["pid"] . "&amp;f=" . urlencode($_SESSION['folder']) . $MainSettings->SessAppend_noecho($TransIDEnabled, 0), $filedisplay);
                    }
                    elseif (
$_SESSION['cafwd'][$key]["type"] == 'text/calendar') {
                        
$filedisplay = str_replace("[attachment_link]", "view.ics.php?id=" . $id . "&amp;pid=" . $_SESSION['cafwd'][$key]["pid"] . "&amp;f=" . urlencode($_SESSION['folder']) . $MainSettings->SessAppend_noecho($TransIDEnabled, 0), $filedisplay);
                    }
                    else {
                        
$filedisplay = str_replace("[attachment_link]", "attachment.php?id=" . $id . "&amp;pid=" . $_SESSION['cafwd'][$key]["pid"] . "&amp;f=" . urlencode($_SESSION['folder']) . $MainSettings->SessAppend_noecho($TransIDEnabled, 0), $filedisplay);
                    }
                    if (
$_SESSION['cafwd'][$x]["type"] == 'message/rfc822' && $loadedrfc822 == 0) {
                        require_once (
"./includes/rfc822.inc.php");
                        require_once (
"./includes/3rdparty/MIME/mimeDecode.inc.php");
                        
$loadedrfc822 = 1;

                        
$headerfull = $IMAPConnection->WM_IMAPRFCHeader($id);
                        
$bodyfull = $IMAPConnection->WM_IMAPGetBody($id, -1, -1, 1);

                        
$RFC822Message = new RFC822($_SESSION);
                        
$RFC822Parts = $RFC822Message->GetParts($headerfull, $bodyfull);

                        
$params['include_bodies'] = true;
                        
$params['decode_bodies']  = true;
                        
$params['decode_headers'] = true;
                    }
                    if (
$_SESSION['cafwd'][$key]["type"] == 'message/rfc822') {
                        
$RFC822Content = $RFC822Parts[$_SESSION['cafwd'][$key]["pid"]];

                        
$RFCDecode = new Mail_mimeDecode($RFC822Content);
                        
$ReturnMessage = $RFCDecode->decode($params);
                    }

                    if (isset(
$_SESSION['cafwd'][$key]["name"])) {
                        
$filename = $_SESSION['cafwd'][$key]["name"];
                    }
                    else {
                        if (isset(
$_SESSION['cafwd'][$key]["description"])) {
                            
$filename = $_SESSION['cafwd'][$key]["description"];
                        }
                        else {
                            
$filename = $lang['SCompose']['NoAttachmentName'];
                        }
                    }

                    
$filedisplay = str_replace("[attachment_filename]", $filename, $filedisplay);
                    
$filedisplay = str_replace("[attachment_size]", ceil($_SESSION['cafwd'][$key]["size"]/1024) . " Kb", $filedisplay);
                    
$filedisplay = str_replace("[attachment_type]", strip_tags($_REQUEST['mode']), $filedisplay);
                    include_once (
"./includes/files.inc.php");
                    
$filedisplay = str_replace("[attachment_icon]",'<img src="' . attachmentIcons($_SESSION['cafwd'][$key]["type"]) . '" alt="' . $_SESSION['cafwd'][$key]["type"] . '" />', $filedisplay);
                    
$preattachedlist .= $filedisplay;
                    unset(
$filedisplay);
                }
            }
            unset (
$pretmp);
            
$PageCompose = str_replace("[preattached2]", $preattachedlist, $PageCompose);
            unset (
$preattachedlist);            
            
$preattachments = 1;
        }
        elseif (
$id <> "") {
            
// Else display embedded attachments in a reply
            // Don't give a link to preview these as they are already in the message
            
$pretmp = $_SESSION['cafwd'];
            if (
is_array($pretmp)) {
                while(list(
$key, $value) = each($pretmp)) {
                    
$filedisplay = $PageAttachment;
                    
$filedisplay = str_replace("[attachment_id]", $key, $filedisplay);
                    
$filedisplay = str_replace("[attachment_pid]", '', $filedisplay);
                    
$filedisplay = preg_replace("/(\[)(iflink)(])(\r\n)*(.*)(\[\/iflink\])/siU", "", $filedisplay);
                    if (isset(
$_SESSION['cafwd'][$key]["name"])) {
                        
$filename = $_SESSION['cafwd'][$key]["name"];
                    }
                    else {
                        if (isset(
$_SESSION['cafwd'][$key]["description"])) {
                            
$filename = $_SESSION['cafwd'][$key]["description"];
                        }
                        else {
                            
$filename = $lang['SCompose']['NoAttachmentName'];
                        }
                    }
                    
$filedisplay = str_replace("[attachment_filename]", $filename, $filedisplay);
                    
$filedisplay = str_replace("[attachment_size]", ceil($_SESSION['cafwd'][$key]["size"]/1024) . " Kb", $filedisplay);
                    include_once (
"./includes/files.inc.php");
                    
$filedisplay = str_replace("[attachment_icon]",'<img src="' . attachmentIcons($_SESSION['cafwd'][$key]["type"]) . '" alt="' . $_SESSION['cafwd'][$key]["type"] . '" />', $filedisplay);
                    
$embedattachedlist .= $filedisplay;
                    unset(
$filedisplay);

                }
                unset (
$pretmp);
            }
            
$PageCompose = str_replace("[embeddedattached2]", $embedattachedlist, $PageCompose);
            unset (
$embedattachedlist);
            
$embedattachments = 1;
        }

        
// Display attachments added from this compose session
        
if ($_SESSION['ca'] && is_array($_SESSION['ca'])) {
            for(
$i=0; $i<sizeof($_SESSION['ca']); $i++) {
                
$filedisplay = $PageAttachment;
                
$filedisplay = str_replace("[attachment_id]", $i, $filedisplay);
                
$filedisplay = str_replace("[attachment_pid]", '', $filedisplay);
                
$filedisplay = str_replace("[iflink]", '', $filedisplay);
                
$filedisplay = str_replace("[/iflink]", '', $filedisplay);
                
$filedisplay = str_replace("[ifremoveable]", '', $filedisplay);
                
$filedisplay = str_replace("[/ifremoveable]", '', $filedisplay);
                
$filedisplay = str_replace("[attachment_link]", "attachment.php?id=$i&amp;pid=&amp;sa=1&amp;f=" . urlencode($folder) . $MainSettings->SessAppend_noecho($TransIDEnabled, 0), $filedisplay);
                
$filedisplay = str_replace("[attachment_filename]", $_SESSION['ca'][$i]['name'], $filedisplay);
                
$filedisplay = str_replace("[attachment_size]", ceil(strlen($_SESSION['ca'][$i]['contents'])/1024). " Kb", $filedisplay);
                
$filedisplay = str_replace("[attachment_type]", 'standard', $filedisplay);
                include_once (
"./includes/files.inc.php");
                
$filedisplay = str_replace("[attachment_icon]",'<img src="' . attachmentIcons($_SESSION['ca'][$i]["type"]) . '" alt="' . $_SESSION['ca'][$i]["type"] . '" />', $filedisplay);
                
$attachmentlist .= $filedisplay;
                unset(
$filedisplay);
            }
            
$PageCompose = str_replace("[attached2]", $attachmentlist, $PageCompose);
            unset (
$attachmentlist);
            
$PageCompose = str_replace("[iffileattachments]", '', $PageCompose);
            
$PageCompose = str_replace("[/iffileattachments]", '', $PageCompose);
            
$PageCompose = preg_replace("/(\[)(ifhideattachments)(])(\r\n)*(.*)(\[\/ifhideattachments\])/siU", "", $PageCompose);
        }
        else {
            
$PageCompose = preg_replace("/(\[)(iffileattachments)(])(\r\n)*(.*)(\[\/iffileattachments\])/siU", "", $PageCompose);
        }

        if (
$preattachments == 1) {
            
$PageCompose = str_replace("[ifpreattached]", "", $PageCompose);
            
$PageCompose = str_replace("[/ifpreattached]", "", $PageCompose);
            
$PageCompose = preg_replace("/(\[)(ifhideattachments)(])(\r\n)*(.*)(\[\/ifhideattachments\])/siU", "", $PageCompose);
        }
        else {
            
$PageCompose = preg_replace("/(\[)(ifpreattached)(])(\r\n)*(.*)(\[\/ifpreattached\])/siU", "", $PageCompose);
        }

        if (
$embedattachments == 1) {
            
$PageCompose = str_replace("[ifembeddedattached]", "", $PageCompose);
            
$PageCompose = str_replace("[/ifembeddedattached]", "", $PageCompose);
            
$PageCompose = preg_replace("/(\[)(ifhideattachments)(])(\r\n)*(.*)(\[\/ifhideattachments\])/siU", "", $PageCompose);
        }
        else {
            
$PageCompose = preg_replace("/(\[)(ifembeddedattached)(])(\r\n)*(.*)(\[\/ifembeddedattached\])/siU", "", $PageCompose);
        }

        
$PageCompose = str_replace("[ifattachments]", "", $PageCompose);
        
$PageCompose = str_replace("[/ifattachments]", "", $PageCompose);
        
$PageCompose = str_replace("[ifhideattachments]", "", $PageCompose);
        
$PageCompose = str_replace("[/ifhideattachments]", "", $PageCompose);

    }
    else {
        
// This is the compose form if sending attachments is disabled
        
if ($edit == "text" || $edit == "html") {
            
$message = $MainSettings->CheckSlashes($message);
            if (((
$postmode == "html") || ($postmode == "wysiwyg")) && ($edit == "text")) {
                
$message = str_replace ("<BR>", "\n", $message);
                
$message = str_replace ("<BR />", "\n", $message);
                
$message = str_replace ("<br>", "\n", $message);
                
$message = str_replace ("<br />", "\n", $message);
                
$message = str_replace ("</p>", "\n\n", $message);
                
$message = str_replace ("</P>", "\n\n", $message);
                
$message = strip_tags ($message);
            }
            elseif ((
$postmode == "text") && (($edit == "html") || ($edit == "wysiwyg"))) {
                
$message = nl2br ($message);
            }
            if (
$message == "" && $GetSignature <> "") {
                
$message = $crlf . $GetSignature;
            }
            
$compose_form = "<form action=\"compose.php\" method=\"post\" name=\"composeform\">$session_formdetails";
            
$messagebox = "<textarea name=\"body\" cols=\"65\" rows=\"15\" id=\"body\" class=\"compose\">" . $message . "</textarea>";
            
$PageCompose = str_replace("[iftextactive]", "", $PageCompose);
            
$PageCompose = str_replace("[/iftextactive]", "", $PageCompose);
            
$PageCompose = preg_replace("/(\[)(ifie)(])(\r\n)*(.*)(\[\/ifie\])/siU", "", $PageCompose);
            
$PageCompose = preg_replace("/(\[)(ifmozilla)(])(\r\n)*(.*)(\[\/ifmozilla\])/siU", "", $PageCompose);
            
$PageCompose = preg_replace("/(\[)(ifwysiwygactive)(])(\r\n)*(.*)(\[\/ifwysiwygactive\])/siU", "", $PageCompose);
        }
        else {
            
$message = $MainSettings->CheckSlashes($message);
            if ((
$postmode == "text") && (($edit == "html") || ($edit == "wysiwyg"))) {
                
$message = nl2br ($message);
            }

            if (
$allowbrowser == 1 && ($bd['browser'] == "Mozilla" || $bd['browser'] == "Opera")) {
                
$compose_form = "<form action=\"compose.php\" method=\"post\" enctype=\"multipart/form-data\" name=\"composeform\" onsubmit=\"ReFormat(this);\">$session_formdetails";
                
$PageHeader = str_replace("<body", "<body onload=\"InitializeEditor();\"", $PageHeader);
                
$PageHeader = str_replace("<BODY", "<body onload=\"InitializeEditor();\"", $PageHeader);
            }
            else {
                
$compose_form = "<form action=\"compose.php\" method=\"post\" enctype=\"multipart/form-data\" name=\"composeform\" onsubmit=\"ReFormat(this);\">$session_formdetails";
                
$PageHeader = str_replace("<body", "<body onload=\"InitializeEditor();\"", $PageHeader);
                
$PageHeader = str_replace("<BODY", "<body onload=\"InitializeEditor();\"", $PageHeader);
            }

            if (
$allowbrowser == 1 && ($bd['browser'] == "Mozilla" || $bd['browser'] == "Opera")) {
                
$messagebox = $getFile->fileRead('wysiwyg_mozilla');
                
$messagebox = LangReplace('SWYSIWYG', $messagebox, $lang);
                
$messagebox = str_replace("[parseelements]", "?" . strip_tags(SID), $messagebox);
                
$PageCompose = str_replace("[ifmozilla]", "", $PageCompose);
                
$PageCompose = str_replace("[/ifmozilla]", "", $PageCompose);
                
$PageCompose = str_replace("[ifwysiwygactive]", "", $PageCompose);
                
$PageCompose = str_replace("[/ifwysiwygactive]", "", $PageCompose);
                
$PageCompose = preg_replace("/(\[)(ifie)(])(\r\n)*(.*)(\[\/ifie\])/siU", "", $PageCompose);
                
$PageCompose = preg_replace("/(\[)(iftextactive)(])(\r\n)*(.*)(\[\/iftextactive\])/siU", "", $PageCompose);
            }
            elseif (
$allowbrowser == 1 && ($bd['browser'] <> "Mozilla" && $bd['browser'] <> "Opera")) {
                
$messagebox = $getFile->fileRead('wysiwyg_ie');
                
$messagebox = LangReplace('SWYSIWYG', $messagebox, $lang);
                
$messagebox = str_replace("[session_force]", strip_tags(SID), $messagebox);
                
$PageCompose = str_replace("[ifie]", "", $PageCompose);
                
$PageCompose = str_replace("[/ifie]", "", $PageCompose);
                
$PageCompose = str_replace("[ifwysiwygactive]", "", $PageCompose);
                
$PageCompose = str_replace("[/ifwysiwygactive]", "", $PageCompose);
                
$PageCompose = preg_replace("/(\[)(ifmozilla)(])(\r\n)*(.*)(\[\/ifmozilla\])/siU", "", $PageCompose);
                
$PageCompose = preg_replace("/(\[)(iftextactive)(])(\r\n)*(.*)(\[\/iftextactive\])/siU", "", $PageCompose);
            }
            else {
                
$messagebox = $lang['SErrors']['WYSIWYGError'];
            }

            if ((
$message == "")  && ($id == "") && ($mode == "")) {
                if (
$GetSignature <> "") {
                    
$GetSignature = "<br />" . $GetSignature;
                }
                
$message = "<p><font face=\"arial, helvetica\" size=\"2\" color=\"#000000\">$GetSignature</font></p>";
            }
            elseif ((
$message <> "")  && ($id <> "")) {
                
$message = "<p><font face=\"arial, helvetica\" size=\"2\" color=\"#0000CC\">&nbsp;</font></p>\n" . $message;
            }
            
$messagebox = str_replace ("[compose_message]", $message, $messagebox);
            
$messagebox = str_replace ("[wysiwyg_content]", urlencode($message), $messagebox);
        }
        
$compose_attachments = "";
        
$PageCompose = preg_replace("/(\[)(ifattachments)(])(\r\n)*(.*)(\[\/ifattachments\])/siU", "", $PageCompose);
    }

    
$nosuggestions = 1;
    if (!empty(
$_POST['spellcheck'])) {
        require (
'./includes/spellcheck.inc.php');
        
$CheckSpelling = new SpellChecker($DefaultLang, $AvailLangs[$DefaultLang]['spell']['charset']);
        
$openspelling = $CheckSpelling->OpenDictionary();

        
// Split by non word characer.  We can grab the offset here to do a replace once rather than replace all
        // However for HTML we first have to remove tags so that they won't get spell checked
        // This means the offset will be wrong
        //  PREG_SPLIT_OFFSET_CAPTURE
        
$tmpmessage = str_replace ("<BR>", "\n", $message);
        
$tmpmessage = str_replace ("<BR />", "\n", $tmpmessage);
        
$tmpmessage = str_replace ("<br>", "\n", $tmpmessage);
        
$tmpmessage = str_replace ("<br />", "\n", $tmpmessage);
        
$tmpmessage = str_replace ("</p>", "\n", $tmpmessage);
        
$tmpmessage = str_replace ("</P>", "\n", $tmpmessage);
        
$tmpmessage = strip_tags(stripslashes($tmpmessage));
        
$tmpmessage = unhtmlentities($tmpmessage);
        
$checkwords = preg_split('/[\W\s]+?/', $tmpmessage, -1);
        
$misspelled = array();
        
$suggestions = array();
        
$wordoffset = array();
        
// As we can't use replace once then we will have to make the array unique to prevent duplicates
        
$uniquecheckwords = array_unique($checkwords);
        
sort($uniquecheckwords);
        unset (
$checkwords);
        if (
is_array($uniquecheckwords)) {
            for (
$i=0; $i<sizeof($uniquecheckwords); $i++) {
                
$misspelled[$i] = $CheckSpelling->check($uniquecheckwords[$i]);
                
// $wordoffset[$i] = $uniquecheckwords[$i][1];
                
if ($misspelled[$i] == FALSE) {
                    
$nosuggestions = 0;
                    
$suggestions[$i] = $CheckSpelling->suggest($uniquecheckwords[$i]);
                }
                else {
                    
$suggestions[$i] = '';
                }
            }
        }
        
$CheckSpelling->close();

        if (
$nosuggesions == 0) {
            
// We have found misspelt words, now display suggestions
            
$PageSpellSuggestions = $getFile->fileRead('spellsuggestions');
            for (
$i=0; $i<sizeof($misspelled); $i++) {
                if (
$misspelled[$i] == FALSE) {
                    
// This has been flagged as misspelt
                    
$currentwordtmp = $PageSpellSuggestions;
                    
$currentwordtmp = str_replace("[spelling_misspeltword]", $uniquecheckwords[$i] . "<input type=\"hidden\" name=\"spell[]\" value=\"" . htmlspecialchars($uniquecheckwords[$i]) . "\" />", $currentwordtmp);
                    
$spellsuggest = "<select name=\"suggest[]\"><option value=\"" . htmlspecialchars($uniquecheckwords[$i]) . "\" selected=\"selected\">" . $lang['SCompose']['SpellKeepAs'] . htmlspecialchars($uniquecheckwords[$i]) . "</option>";
                    if (
is_array($suggestions[$i])) {
                        for (
$j=0; $j<sizeof($suggestions[$i]); $j++) {
                            
$spellsuggest .= "<option value=\"" . htmlspecialchars($suggestions[$i][$j]) . "\">" . $lang['SCompose']['SpellReplaceWith'] . $suggestions[$i][$j] . "</option>";
                        }
                    }
                    
$spellsuggest .= "</select>";
                    
$currentwordtmp = str_replace("[spelling_suggestions]", $spellsuggest, $currentwordtmp);
                    
$currentwordtmp = str_replace("[spelling_replacewith]", "<input type=\"text\" name=\"othersuggest[]\" />", $currentwordtmp);
                    
$suggestionoutput .= $currentwordtmp;
                    unset (
$currentwordtmp);
                    unset (
$spellsuggest);
                }
            }            
        }
    }

    
// Conditional template variable setup
    
if ($_SESSION['servertype'] == "imap" || $_SESSION['servertype'] == "imapssl") {
        
$PageCompose = str_replace("[ifimap]", "", $PageCompose);
        
$PageCompose = str_replace("[/ifimap]", "", $PageCompose);
    }
    else {
        
$PageCompose = preg_replace("/(\[)(ifimap)(])(\r\n)*(.*)(\[\/ifimap\])/siU", "", $PageCompose);
    }

    if (
$UseDatabase == 1) {
        
$PageCompose = str_replace("[ifdatabase]", "", $PageCompose);
        
$PageCompose = str_replace("[/ifdatabase]", "", $PageCompose);
    }
    else {
        
$PageCompose = preg_replace("/(\[)(ifdatabase)(])(\r\n)*(.*)(\[\/ifdatabase\])/siU", "", $PageCompose);
    }

    if (
$EnableContacts == 1 && $UseDatabase == 1) {
        
$PageCompose = str_replace("[ifcontacts]", "", $PageCompose);
        
$PageCompose = str_replace("[/ifcontacts]", "", $PageCompose);
    }
    else {
        
$PageCompose = preg_replace("/(\[)(ifcontacts)(])(\r\n)*(.*)(\[\/ifcontacts\])/siU", "", $PageCompose);
    }

    if (
$_POST['savesent'] == 1) {
        
$imap_savemessage = "<input type=\"checkbox\" name=\"savesent\" value=\"1\" checked=\"checked\" id=\"savesent\" />";
    }
    elseif ((
$AllowSentMail == 1) && ($_SESSION['servertype'] == "imap" || $_SESSION['servertype'] == "imapssl")) {
        
$imap_savemessage = "<input type=\"checkbox\" name=\"savesent\" value=\"1\" checked=\"checked\" id=\"savesent\" />";
    }
    elseif ((
$AllowSentMail <> 1) && ($_SESSION['servertype'] == "imap" || $_SESSION['servertype'] == "imapssl")) {
        
$imap_savemessage = "<input type=\"checkbox\" name=\"savesent\" value=\"1\" id=\"savesent\" />";
    }

    if (
$_POST['saverecipients'] == 1) {
        
$imap_saverecipients = "<input type=\"checkbox\" name=\"saverecipients\" value=\"1\" checked=\"checked\" id=\"saverecipients\" />";
    }
    elseif ((
$SaveRecipients == 1) && ($UseDatabase == 1)) {
        
$imap_saverecipients = "<input type=\"checkbox\" name=\"saverecipients\" value=\"1\" checked=\"checked\" id=\"saverecipients\" />";
    }
    elseif ((
$SaveRecipients <> 1) && ($UseDatabase == 1)) {
        
$imap_saverecipients = "<input type=\"checkbox\" name=\"saverecipients\" value=\"1\" id=\"saverecipients\" />";
    }

    if (
$_POST['receipt'] == 1) {
        
$bt_read_receipt = "<input type=\"checkbox\" name=\"receipt\" value=\"1\" id=\"receipt\" checked=\"checked\" />";
    }
    else {
        
$bt_read_receipt = "<input type=\"checkbox\" name=\"receipt\" value=\"1\" id=\"receipt\" />";
    }

    
$bt_priorities .= "<input type=\"radio\" name=\"priority\" value=\"1\" id=\"pri-high\"";
    if (
$_POST['priority'] == 1) {
        
$bt_priorities .= " checked=\"checked\"";
    }
    
$bt_priorities .= " /> <label for=\"pri-high\">" . $lang['SCompose']['Priority'][1] . "</label> <input type=\"radio\" name=\"priority\" value=\"2\"";
    if (
$_POST['priority'] == 2 || !$_POST['priority']) {
        
$bt_priorities .= " checked=\"checked\"";
    }
    
$bt_priorities .= " id=\"pri-normal\" /> <label for=\"pri-normal\">" . $lang['SCompose']['Priority'][2] . "</label> <input type=\"radio\" name=\"priority\" value=\"3\" id=\"pri-low\"";
    if (
$_POST['priority'] == 3) {
        
$bt_priorities .= " checked=\"checked\"";
    }
    
$bt_priorities .= " /> <label for=\"pri-low\">" . $lang['SCompose']['Priority'][3] . "</label>";

    if (
$allowbrowser == 1) {
        
// Leave veditorbutton variable in for older template compatibility
        
$veditorbutton = '<input type="submit" name="wysiwyg" value="' . $lang['SCompose']['ComposeWYSIWYG'] . '" class="button" />';
        
$PageCompose = str_replace("[ifwysiwyg]", "", $PageCompose);
        
$PageCompose = str_replace("[/ifwysiwyg]", "", $PageCompose);

    }
    else {
        
$veditorbutton = '';
        
$PageCompose = preg_replace("/(\[)(ifwysiwyg)(])(\r\n)*(.*)(\[\/ifwysiwyg\])/siU", "", $PageCompose);
    }

    if (
$enablespellcheck == 1) {
        
$PageCompose = str_replace("[ifspellcheck]", "", $PageCompose);
        
$PageCompose = str_replace("[/ifspellcheck]", "", $PageCompose);

    }
    else {
        
$PageCompose = preg_replace("/(\[)(ifspellcheck)(])(\r\n)*(.*)(\[\/ifspellcheck\])/siU", "", $PageCompose);
    }
    if (!empty(
$_POST['spellcheck'])) {
        
$PageCompose = str_replace("[ifspellsuggest]", "", $PageCompose);
        
$PageCompose = str_replace("[/ifspellsuggest]", "", $PageCompose);

        if (
$nosuggestions == 0) {
            
$PageCompose = str_replace("[spellcheck_suggestions]", $suggestionoutput, $PageCompose);
        }
        else {
            
$PageCompose = str_replace("[spellcheck_suggestions]", $lang['SCompose']['SpellNoErrors'], $PageCompose);
        }

    }
    else {
        
$PageCompose = preg_replace("/(\[)(ifspellsuggest)(])(\r\n)*(.*)(\[\/ifspellsuggest\])/siU", "", $PageCompose);
    }


    if (
$UseDatabase == 1) {
        
$AliasList = $MySQLConnection->DB_GetAliasList();
        if (
is_array($AliasList)) {
            
$PageCompose = str_replace("[ifalias]", "", $PageCompose);
            
$PageCompose = str_replace("[/ifalias]", "", $PageCompose);
            
$PageCompose = preg_replace("/(\[)(ifnoalias)(])(\r\n)*(.*)(\[\/ifnoalias\])/siU", "", $PageCompose);

            while(list(
$key, $value) = each($AliasList)) {
                
$aliaslistdisplay .= "<option value=\"" . urlencode('"' . $AliasList[$key]['name'] . '" <' . $AliasList[$key]['email'] . '>') . "\">&quot;" . $AliasList[$key]['name'] . "&quot; &lt;" . $AliasList[$key]['email'] . "&gt;</option>";
            }
        }
        else {
            
$PageCompose = str_replace("[ifnoalias]", "", $PageCompose);
            
$PageCompose = str_replace("[/ifnoalias]", "", $PageCompose);
            
$PageCompose = preg_replace("/(\[)(ifalias)(])(\r\n)*(.*)(\[\/ifalias\])/siU", "", $PageCompose);
            
$aliaslistdisplay = '';
        }
    }
    else {
        
$PageCompose = str_replace("[ifnoalias]", "", $PageCompose);
        
$PageCompose = str_replace("[/ifnoalias]", "", $PageCompose);
        
$PageCompose = preg_replace("/(\[)(ifalias)(])(\r\n)*(.*)(\[\/ifalias\])/siU", "", $PageCompose);
        
$aliaslistdisplay = '';
    }

    if (
$edit == "text" || $edit == "html") {
        
$PageCompose = preg_replace("/(\[)(ifwysiwygmode)(])(\r\n)*(.*)(\[\/ifwysiwygmode\])/siU", "", $PageCompose);
    }
    else {
        
$PageCompose = str_replace("[ifwysiwygmode]", "", $PageCompose);
        
$PageCompose = str_replace("[/ifwysiwygmode]", "", $PageCompose);
    }

    if (!isset(
$addressbook_to)) {
        
$addressbook_to = "";
    }
    if (!isset(
$addressbook_cc)) {
        
$addressbook_cc = "";
    }
    if (!isset(
$addressbook_bcc)) {
        
$addressbook_bcc = "";
    }

    if (isset(
$pname) && ($pname <> "")) {
        
$listemailcurrent = '"' . $pname . '" &lt;' . $_SESSION['currentemailaddress'] . '&gt;';
    }
    else {
        
$listemailcurrent = $_SESSION['currentemailaddress'];
    }

    if (isset(
$DisplayBcc) && ($DisplayBcc <> 1)) {
        
$PageCompose = preg_replace("/(\[)(ifbcc)(])(\r\n)*(.*)(\[\/ifbcc\])/siU", "", $PageCompose);
    }
    else {
        
$PageCompose = str_replace("[ifbcc]", "", $PageCompose);
        
$PageCompose = str_replace("[/ifbcc]", "", $PageCompose);
    }
    if (isset(
$DisplayRT) && ($DisplayRT <> 1)) {
        if (
$DefaultReplyTo) {
            
$hiddenrt = '<input type="hidden" id="reply_to" name="replyto" value="' . str_replace('"', "&quot;", $DefaultReplyTo) . '" />';
        }
        else {
            
$hiddenrt = '<input type="hidden" id="reply_to" name="replyto" value="' . str_replace('"', "&quot;", $_SESSION['currentemailaddress']) . '" />';
        }
        
$PageCompose = preg_replace("/(\[)(ifreplyto)(])(\r\n)*(.*)(\[\/ifreplyto\])/esiU", '\$hiddenrt', $PageCompose);
    }
    else {
        
$PageCompose = str_replace("[ifreplyto]", "", $PageCompose);
        
$PageCompose = str_replace("[/ifreplyto]", "", $PageCompose);
    }

    if (empty(
$errormessage)) {
        
$PageCompose = preg_replace("/(\[)(iferror)(])(\r\n)*(.*)(\[\/iferror\])/siU", "", $PageCompose);
    }
    else {
        
$PageCompose = str_replace("[iferror]", "", $PageCompose);
        
$PageCompose = str_replace("[/iferror]", "", $PageCompose);
    }

    if (
$AutoC == 1) {
        
$PageCompose = str_replace("[ifajax]", "", $PageCompose);
        
$PageCompose = str_replace("[/ifajax]", "", $PageCompose);
        
$fieldssender['to'] = "<input type=\"text\" name=\"to\" onkeyup=\"loadxmlac(this.value, this);\" autocomplete=\"off\" size=\"40\" id=\"to_input\" value=\"" . str_replace('"', "&quot;", stripslashes($sendto)) . "\" />";
        
$fieldssender['cc'] = "<input type=\"text\" name=\"cc\" onkeyup=\"loadxmlac(this.value, this);\" autocomplete=\"off\" size=\"40\" id=\"cc_input\" value=\"" . str_replace('"', "&quot;", stripslashes($sendcc)) . "\" />";
        
$fieldssender['bcc'] = "<input type=\"text\" name=\"bcc\" onkeyup=\"loadxmlac(this.value, this);\" autocomplete=\"off\" size=\"40\" id=\"bcc_input\" value=\"" . str_replace('"', "&quot;", stripslashes($sendbcc)) . "\" />";
    }
    else {
        
$PageCompose = preg_replace("/(\[)(ifajax)(])(\r\n)*(.*)(\[\/ifajax\])/siU", "", $PageCompose);
        
$fieldssender['to'] = "<input type=\"text\" name=\"to\" size=\"40\" id=\"to_input\" value=\"" . str_replace('"', "&quot;", stripslashes($sendto)) . "\" />";
        
$fieldssender['cc'] = "<input type=\"text\" name=\"cc\" size=\"40\" id=\"cc_input\" value=\"" . str_replace('"', "&quot;", stripslashes($sendcc)) . "\" />";
        
$fieldssender['bcc'] = "<input type=\"text\" name=\"bcc\" size=\"40\" id=\"bcc_input\" value=\"" . str_replace('"', "&quot;", stripslashes($sendbcc)) . "\" />";
    }

    if (
$AutoS == 1) {
        
$PageCompose = str_replace("[ifautosave]", "", $PageCompose);
        
$PageCompose = str_replace("[/ifautosave]", "", $PageCompose);
    }
    else {
        
$PageCompose = preg_replace("/(\[)(ifautosave)(])(\r\n)*(.*)(\[\/ifautosave\])/siU", "", $PageCompose);
    }

    if (
is_array($headerdetails) && $headerdetails['messageid'] <> '') {
        
$replyid = "<input type=\"hidden\" name=\"mid\" value=\"" . $headerdetails['messageid'] . "\" />";
    }

    if (
$edit == "text") {
        
$PageCompose = str_replace("[txactive]", "active", $PageCompose);
        
$PageCompose = str_replace("[htactive]", "inactive", $PageCompose);
        
$PageCompose = str_replace("[wgactive]", "inactive", $PageCompose);
    }
    elseif (
$edit == "html") {
        
$PageCompose = str_replace("[txactive]", "inactive", $PageCompose);
        
$PageCompose = str_replace("[htactive]", "active", $PageCompose);
        
$PageCompose = str_replace("[wgactive]", "inactive", $PageCompose);
    }
    elseif (
$edit == "wysiwyg") {
        
$PageCompose = str_replace("[txactive]", "inactive", $PageCompose);
        
$PageCompose = str_replace("[htactive]", "inactive", $PageCompose);
        
$PageCompose = str_replace("[wgactive]", "active", $PageCompose);
    }

    
// Compose Form variable definitions and replacements
    
$CodeSearch = array (
        
"[compose_form]",
        
"[compose_fromencode]",
        
"[compose_attachments]",
        
"[compose_replyto]",
        
"[compose_to]",
        
"[compose_cc]",
        
"[compose_bcc]",
        
"[compose_subject]",
        
"[compose_body]",
        
"[session_force]",
        
"[session_force2]",
        
"[session_js]",
        
"[compose_from]",
        
"[compose_menu]",
        
"[compose_hidden]",
        
"[compose_mode]",
        
"[compose_priority]",
        
"[compose_readreceipt]",
        
"[imap_savemessage]",
        
"[v-editor_button]",
        
"[addressbook_to]",
        
"[addressbook_cc]",
        
"[addressbook_bcc]",
        
"[error_message]",
        
"[imap_saverecipients]",
        
"[wysiwyg_forecolor]",
        
"[wysiwyg_fontface]",
        
"[wysiwyg_fontsize]",
        
"[wysiwyg_browser]",
        
"[AliasList]",
        
"[compose_timestamp]",
        
"[attachmentmode]",
        
"[attachmentid]"
    
);

    
$CodeReplace = array (
        
$compose_form,
        
urlencode(unhtmlentities($listemailcurrent)),
        
$compose_attachments,
        
"<input type=\"text\" name=\"replyto\" id=\"reply_to\" size=\"40\" value=\"" . str_replace('"', "&quot;", $ReplyTo) . "\" />",
        
$fieldssender['to'],
        
$fieldssender['cc'],
        
$fieldssender['bcc'],
        
"<input type=\"text\" name=\"subject\" size=\"40\" id=\"subject_input\" value=\"" . str_replace('"', "&quot;", stripslashes($subj2)) . "\" />",
        
stripslashes($messagebox),
        
"?" . strip_tags(SID),
        
"&amp;" . strip_tags(SID),
        
strip_tags(SID),
        
$listemailcurrent,
        
$PageComposeMenu,
        
$replyid . "<input type=\"hidden\" name=\"edit\" value=\"$edit\" /><input type=\"hidden\" name=\"mode\" value=\"$mode\" /><input type=\"hidden\" name=\"msgid\" value=\"$id\" /><input type=\"hidden\" name=\"id\" value=\"$id\" /><input type=\"hidden\" name=\"f\" value=\"" . $_SESSION['folder'] . "\" />",
        
$currentmode,
        
$bt_priorities,
        
$bt_read_receipt,
        
$imap_savemessage,
        
$veditorbutton,
        
$addressbook_to,
        
$addressbook_cc,
        
$addressbook_bcc,
        
$errormessage,
        
$imap_saverecipients,
        
$forecolour,
        
$fontface,
        
$fontsize,
        
$bd["browser"],
        
$aliaslistdisplay,
        
time(),
        
strip_tags($_GET['mode']),
        
$id
    
);

    unset (
$fieldssender);

    
$PageCompose = str_replace ($CodeSearch, $CodeReplace, $PageCompose);
    
$PageCompose = LangReplace('SCompose', $PageCompose, $lang);

    
header ("Content-Type: text/html; charset=" . $_SESSION['DefaultCharSet']);
    echo
$PageHeader;
    echo
$PageCompose;
}

// Close our IMAP connection
$IMAPConnection->WM_IMAPClose();

if (
$UseDatabase == 1) {
    
// Close MySQL connection
    
$MySQLCloseConnection = $MySQLConnection->DB_CloseConnection();
}

echo
$PageFooter;
?>

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 1.0 pre-release build #16 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.0093 ]--