function GetMessageNode(&$_xmlRes, &$_message, &$_folder, &$_processor, &$_account, &$_settings, $_mode, $_charsetNum, $_isFromSave)
 {
     $_safety = true;
     $_messageNode = new XmlDomNode('message');
     $_msgId = $_message->IdMsg;
     $_msgUid = $_message->Uid;
     $_messageInfo = new CMessageInfo();
     $_messageInfo->SetInfo($_msgId, $_msgUid, $_folder->IdDb, $_folder->FullName);
     $_messageClassType = $_message->TextBodies->ClassType();
     $_messageNode->AppendAttribute('id', $_msgId);
     $_messageNode->AppendAttribute('size', $_message->GetMailSize());
     $_messageNode->AppendAttribute('html', (int) (($_messageClassType & 2) == 2));
     $_messageNode->AppendAttribute('plain', (int) (($_messageClassType & 1) == 1));
     $_messageNode->AppendAttribute('priority', $_message->GetPriorityStatus());
     $_messageNode->AppendAttribute('mode', $_mode);
     $_messageNode->AppendAttribute('charset', $_charsetNum);
     $_messageNode->AppendAttribute('has_charset', (int) $_message->HasCharset);
     $_messageNode->AppendAttribute('downloaded', (int) $_message->Downloaded);
     $_messageNode->AppendAttribute('sensivity', $_message->GetSensitivity());
     $maf =& MessageActionFilters::CreateInstance();
     $mafNoReply = $maf->GetNoReplyEmails();
     $mafNoReplyAll = $maf->GetNoReplyAllEmails();
     $mafNoForward = $maf->GetNoForwardEmails();
     $fromEmail = $_message->GetFrom();
     $fromEmail = $fromEmail->Email;
     $_textCharset = $_message->GetTextCharset();
     $_rtl = 0;
     if (null !== $_textCharset) {
         switch (ConvertUtils::GetCodePageNumber($_textCharset)) {
             case 1255:
             case 1256:
             case 28596:
             case 28598:
                 $_rtl = 1;
                 break;
         }
     }
     $_messageNode->AppendAttribute('rtl', $_rtl);
     $_messageNode->AppendChild(new XmlDomNode('uid', $_msgUid, true));
     $_folderNode = new XmlDomNode('folder', $_folder->FullName, true);
     $_folderNode->AppendAttribute('id', $_folder->IdDb);
     $_messageNode->AppendChild($_folderNode);
     $_signature_html = '';
     $_signature_plain = '';
     if ($_account->SignatureOptions == SIGNATURE_OPTION_AddToAll) {
         if ($_account->SignatureType == 1) {
             $_signature_html = '<br />' . $_account->Signature;
             require_once WM_ROOTPATH . 'libs/class_converthtml.php';
             $_pars = new convertHtml($_account->Signature, false);
             $_signature_plain = CRLF . $_pars->get_text();
         } else {
             $_signature_plain = CRLF . $_account->Signature;
             $_signature_html = '<br />' . nl2br($_account->Signature);
         }
         $_signature_plain = ConvertUtils::WMHtmlSpecialChars($_signature_plain);
     }
     $_accountOffset = $_settings->AllowUsersChangeTimeZone ? $_account->GetDefaultTimeOffset() : $_account->GetDefaultTimeOffset($_settings->DefaultTimeZone);
     if (($_mode & 1) == 1) {
         $_headersNode = new XmlDomNode('headers');
         $_fromNode = new XmlDomNode('from');
         $_id_addr = -1;
         $_from4search =& $_message->GetFrom();
         if ($_from4search && USE_DB) {
             $_id_addr = $_processor->DbStorage->GetContactIdByEmail($_from4search->Email, $_account->IdUser);
         }
         if ($_id_addr > 0) {
             $_fromNode->AppendAttribute('contact_id', $_id_addr);
             $_bigContactNode = CXmlProcessing::GetContactNodeFromAddressBookRecord($_account, $_settings, $_id_addr);
             if (null != $_bigContactNode) {
                 $_xmlRes->XmlRoot->AppendChild($_bigContactNode);
             }
         }
         $_fromNode->AppendChild(new XmlDomNode('short', WebMailMessage::ClearForSend(trim($_from4search->DisplayName)), true));
         $_fromNode->AppendChild(new XmlDomNode('full', $_from4search->ToDecodedString(), true));
         $_headersNode->AppendChild($_fromNode);
         $_headersNode->AppendChild(new XmlDomNode('to', $_message->GetToAsString(true), true));
         $_headersNode->AppendChild(new XmlDomNode('cc', $_message->GetCcAsString(true), true));
         $_headersNode->AppendChild(new XmlDomNode('bcc', $_message->GetBccAsString(true), true));
         $_headersNode->AppendChild(new XmlDomNode('reply_to', $_message->GetReplyToAsString(true), true));
         $_headersNode->AppendChild(new XmlDomNode('subject', $_message->GetSubject(true), true));
         $_mailConfirmation = $_message->GetReadMailConfirmationAsString();
         if (strlen($_mailConfirmation) > 0) {
             $_headersNode->AppendChild(new XmlDomNode('mailconfirmation', $_mailConfirmation, true));
         }
         $_date =& $_message->GetDate();
         $_date->FormatString = $_account->DefaultDateFormat;
         $_date->TimeFormat = $_account->DefaultTimeFormat;
         $_headersNode->AppendChild(new XmlDomNode('short_date', $_date->GetFormattedShortDate($_accountOffset), true));
         $_headersNode->AppendChild(new XmlDomNode('full_date', $_date->GetFormattedFullDate($_accountOffset), true));
         $_headersNode->AppendChild(new XmlDomNode('time', $_date->GetFormattedTime($_accountOffset), true));
         $_messageNode->AppendChild($_headersNode);
     }
     $html_part = '';
     if (($_mode & 2) == 2 && ($_messageClassType & 2) == 2) {
         $html_part = ConvertUtils::ReplaceJSMethod($_message->GetCensoredHtmlWithImageLinks(true, $_messageInfo));
         if (($_account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG || $_account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG) && !$_isFromSave) {
             $html_part = ConvertUtils::HtmlBodyWithoutImages($html_part);
             if (isset($GLOBALS[GL_WITHIMG]) && $GLOBALS[GL_WITHIMG]) {
                 $GLOBALS[GL_WITHIMG] = false;
                 $_safety = false;
             }
         }
     }
     $modified_plain_text = '';
     if (($_mode & 4) == 4 || ($_mode & 2) == 2 && ($_messageClassType & 2) != 2) {
         $modified_plain_text = $_message->GetCensoredTextBody(true);
     }
     if (($_mode & 8) == 8) {
         if (($_account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG || $_account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG) && !$_isFromSave) {
             $_messageNode->AppendChild(new XmlDomNode('reply_html', ConvertUtils::AddToLinkMailToCheck(ConvertUtils::HtmlBodyWithoutImages(ConvertUtils::ReplaceJSMethod($_signature_html . $_message->GetRelpyAsHtml(true, $_accountOffset, $_messageInfo)))), true, true));
             if (isset($GLOBALS[GL_WITHIMG]) && $GLOBALS[GL_WITHIMG]) {
                 $GLOBALS[GL_WITHIMG] = false;
                 $_safety = false;
             }
         } else {
             $_messageNode->AppendChild(new XmlDomNode('reply_html', ConvertUtils::AddToLinkMailToCheck(ConvertUtils::ReplaceJSMethod($_signature_html . $_message->GetRelpyAsHtml(true, $_accountOffset, $_messageInfo))), true, true));
         }
     }
     if (($_mode & 16) == 16) {
         $_messageNode->AppendChild(new XmlDomNode('reply_plain', ConvertUtils::AddToLinkMailToCheck($_signature_plain . $_message->GetRelpyAsPlain(true, $_accountOffset)), true, true));
     }
     if (($_mode & 32) == 32) {
         if (($_account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG || $_account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG) && !$_isFromSave) {
             $_messageNode->AppendChild(new XmlDomNode('forward_html', ConvertUtils::AddToLinkMailToCheck(ConvertUtils::HtmlBodyWithoutImages(ConvertUtils::ReplaceJSMethod($_signature_html . $_message->GetRelpyAsHtml(true, $_accountOffset, $_messageInfo)))), true, true));
             if (isset($GLOBALS[GL_WITHIMG]) && $GLOBALS[GL_WITHIMG]) {
                 $GLOBALS[GL_WITHIMG] = false;
                 $_safety = false;
             }
         } else {
             $_messageNode->AppendChild(new XmlDomNode('forward_html', ConvertUtils::AddToLinkMailToCheck(ConvertUtils::ReplaceJSMethod($_signature_html . $_message->GetRelpyAsHtml(true, $_accountOffset, $_messageInfo))), true, true));
         }
     }
     if (($_mode & 64) == 64) {
         $_messageNode->AppendChild(new XmlDomNode('forward_plain', ConvertUtils::AddToLinkMailToCheck($_signature_plain . $_message->GetRelpyAsPlain(true, $_accountOffset)), true, true));
     }
     if (($_mode & 128) == 128) {
         $_messageNode->AppendChild(new XmlDomNode('full_headers', $_message->ClearForSend(ConvertUtils::ConvertEncoding($_message->OriginalHeaders, $GLOBALS[MailInputCharset], $_account->GetUserCharset())), true, true));
     }
     $_messageNode->AppendAttribute('safety', (int) $_safety);
     $_msqAttachLine = 'msg_id=' . $_msgId . '&msg_uid=' . urlencode($_msgUid) . '&folder_id=' . $_folder->IdDb . '&folder_fname=' . urlencode($_folder->FullName);
     $addAttachArray = array();
     if (($_mode & 256) == 256 || ($_mode & 8) == 8 || ($_mode & 16) == 16 || ($_mode & 32) == 32 || ($_mode & 64) == 64) {
         $_attachments =& $_message->Attachments;
         if ($_attachments && $_attachments->Count() > 0) {
             $tempFiles =& CTempFiles::CreateInstance($_account);
             $_attachmentsNode = new XmlDomNode('attachments');
             $_attachmentsKeys = array_keys($_attachments->Instance());
             foreach ($_attachmentsKeys as $_key) {
                 $attachArray = array();
                 $_attachment =& $_attachments->Get($_key);
                 $_tempname = $_message->IdMsg . '-' . $_key . '_' . ConvertUtils::ClearFileName($_attachment->GetTempName());
                 $_filename = ConvertUtils::ClearFileName(ConvertUtils::ClearUtf8($_attachment->GetFilenameFromMime(), $GLOBALS[MailInputCharset], $_account->GetUserCharset()));
                 $_size = 0;
                 $_isBodyStructureAttachment = false;
                 if ($_attachment->MimePart && $_attachment->MimePart->BodyStructureIndex !== null && $_attachment->MimePart->BodyStructureSize !== null) {
                     $_isBodyStructureAttachment = true;
                     $_size = $_attachment->MimePart->BodyStructureSize;
                 } else {
                     $_size = $tempFiles->SaveFile($_tempname, $_attachment->GetBinaryBody());
                     $_size = $_size < 0 ? 0 : $_size;
                 }
                 $attachArray['name'] = $_filename;
                 $attachArray['tempname'] = $_tempname;
                 $attachArray['size'] = $_size;
                 $_bodyStructureUrlAdd = '';
                 if ($_isBodyStructureAttachment) {
                     $_bodyStructureUrlAdd = 'bsi=' . urlencode($_attachment->MimePart->BodyStructureIndex);
                     if ($_attachment->MimePart->BodyStructureEncode !== null && strlen($_attachment->MimePart->BodyStructureEncode) > 0) {
                         $_bodyStructureUrlAdd .= '&bse=' . urlencode(ConvertUtils::GetBodyStructureEncodeType($_attachment->MimePart->BodyStructureEncode));
                     }
                 }
                 $_attachNode = new XmlDomNode('attachment');
                 $_attachNode->AppendAttribute('size', $_size);
                 $_attachNode->AppendAttribute('inline', $_attachment->IsInline ? '1' : '0');
                 $_attachNode->AppendChild(new XmlDomNode('filename', $_filename, true));
                 $viewUrl = substr(strtolower($_filename), -4) == '.eml' ? 'message-view.php?type=' . MESSAGE_VIEW_TYPE_ATTACH . '&tn=' . urlencode($_tempname) : 'view-image.php?img&tn=' . urlencode($_tempname) . '&filename=' . urlencode($_filename);
                 if ($_isBodyStructureAttachment) {
                     $viewUrl .= '&' . $_bodyStructureUrlAdd . '&' . $_msqAttachLine;
                 }
                 $_attachNode->AppendChild(new XmlDomNode('view', $viewUrl, true));
                 $linkUrl = 'attach.php?tn=' . urlencode($_tempname);
                 if ($_isBodyStructureAttachment) {
                     $linkUrl .= '&' . $_bodyStructureUrlAdd . '&' . $_msqAttachLine;
                 }
                 $downloadUrl = $linkUrl . '&filename=' . urlencode($_filename);
                 $attachArray['download'] = $downloadUrl;
                 $attachArray['link'] = $linkUrl;
                 $_attachNode->AppendChild(new XmlDomNode('download', $downloadUrl, true));
                 $_attachNode->AppendChild(new XmlDomNode('tempname', $_tempname, true));
                 $mime_type = ConvertUtils::GetContentTypeFromFileName($_filename);
                 $_attachNode->AppendChild(new XmlDomNode('mime_type', $mime_type, true));
                 $attachArray['mime_type'] = $mime_type;
                 $attachArray['download'] = $downloadUrl;
                 $addAttachArray[] = $attachArray;
                 $_attachmentsNode->AppendChild($_attachNode);
                 unset($_attachment, $_attachNode, $attachArray);
             }
             $_messageNode->AppendChild($_attachmentsNode);
         }
     }
     ChangeHtmlTextFromAttachment($html_part, $modified_plain_text, $addAttachArray);
     if (($_mode & 2) == 2 && ($_messageClassType & 2) == 2) {
         $_messageNode->AppendChild(new XmlDomNode('html_part', ConvertUtils::AddToLinkMailToCheck($html_part), true, true));
     }
     if (($_mode & 4) == 4 || ($_mode & 2) == 2 && ($_messageClassType & 2) != 2) {
         $_messageNode->AppendChild(new XmlDomNode('modified_plain_text', ConvertUtils::AddToLinkMailToCheck($modified_plain_text), true, true));
     }
     if (($_mode & 512) == 512) {
         $_messageNode->AppendChild(new XmlDomNode('unmodified_plain_text', $_message->GetNotCensoredTextBody(true), true, true));
     }
     $_messageNode->AppendChild(new XmlDomNode('save_link', 'attach.php?' . $_msqAttachLine, true));
     $_messageNode->AppendChild(new XmlDomNode('print_link', 'message-view.php?type=' . MESSAGE_VIEW_TYPE_PRINT . '&' . $_msqAttachLine . '&charset=' . $_charsetNum, true));
     $_messageNode->AppendAttribute('no_reply', count($mafNoReply) > 0 && in_array($fromEmail, $mafNoReply) ? '1' : '0');
     $_messageNode->AppendAttribute('no_reply_all', count($mafNoReplyAll) > 0 && in_array($fromEmail, $mafNoReplyAll) ? '1' : '0');
     $_messageNode->AppendAttribute('no_forward', count($mafNoForward) > 0 && in_array($fromEmail, $mafNoForward) ? '1' : '0');
     $_xmlRes->XmlRoot->AppendChild($_messageNode);
 }
 /**
  * @param string  $nputCharset
  */
 function ReparseAllHeader($inputCharset)
 {
     for ($i = 0, $c = $this->Headers->Count(); $i < $c; $i++) {
         $header =& $this->Headers->Get($i);
         if (!ConvertUtils::IsLatin($header->Value)) {
             $header->Value = ConvertUtils::ConvertEncoding($header->Value, $inputCharset, $GLOBALS[MailOutputCharset]);
             $header->IsParsed = true;
         }
     }
 }
Exemple #3
0
 function GetFolderFullName($account)
 {
     return ConvertUtils::IsLatin($this->FullName) ? ConvertUtils::ConvertEncoding($this->FullName, CPAGE_UTF7_Imap, $account->GetUserCharset()) : ConvertUtils::ConvertEncoding($this->FullName, $account->DefaultIncCharset, $account->GetUserCharset());
 }
Exemple #4
0
/**
 * @param FolderCollection $folders
 * @param XmlDomNode $nodeTree
 * @param MailProcessor $processor
 */
function GetFoldersTreeXml(&$folders, &$nodeTree, &$processor)
{
    for ($i = 0, $count = $folders->Count(); $i < $count; $i++) {
        $folder =& $folders->Get($i);
        $folderNode =& new XmlDomNode('folder');
        $folderNode->AppendAttribute('id', $folder->IdDb);
        $folderNode->AppendAttribute('id_parent', $folder->IdParent);
        $folderNode->AppendAttribute('type', $folder->Type);
        $folderNode->AppendAttribute('sync_type', $folder->SyncType);
        $folderNode->AppendAttribute('hide', (int) $folder->Hide);
        $folderNode->AppendAttribute('fld_order', $folder->FolderOrder);
        if ($folder->SyncType == FOLDERSYNC_DirectMode) {
            $processor->GetFolderMessageCount($folder);
        }
        $folderNode->AppendAttribute('count', $folder->MessageCount);
        $folderNode->AppendAttribute('count_new', $folder->UnreadMessageCount);
        $folderNode->AppendAttribute('size', $folder->Size);
        if (ConvertUtils::IsLatin($folder->Name)) {
            $folderNode->AppendChild(new XmlDomNode('name', ConvertUtils::ConvertEncoding($folder->Name, CPAGE_UTF7_Imap, CPAGE_UTF8), true));
        } else {
            $folderNode->AppendChild(new XmlDomNode('name', ConvertUtils::ConvertEncoding($folder->Name, $processor->_account->DefaultIncCharset, CPAGE_UTF8), true));
        }
        $folderNode->AppendChild(new XmlDomNode('full_name', $folder->FullName, true));
        if ($folder->SubFolders != null && $folder->SubFolders->Count() > 0) {
            $foldersNode =& new XmlDomNode('folders');
            GetFoldersTreeXml($folder->SubFolders, $foldersNode, $processor);
            $folderNode->AppendChild($foldersNode);
        }
        $nodeTree->AppendChild($folderNode);
    }
}
    /**
     * @param PageBuilder $pageBuilder
     * @return MessageListTable
     */
    function MessageListTable(&$pagebuilder)
    {
        $this->_pagebuilder =& $pagebuilder;
        $this->_proc =& $pagebuilder->_proc;
        $this->sortField = Get::val('s_fld', 0);
        $this->sortOrder = Get::val('s_ord', 0);
        $this->page = $this->_proc->sArray[PAGE];
        $this->_proc->account->DefaultOrder = $this->sortField + $this->sortOrder;
        $this->folders =& $this->_proc->GetFolders();
        if (isset($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) && strlen($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) > 0) {
            if ($this->_proc->sArray[SEARCH_ARRAY][S_FOLDER] > -2) {
                $this->folder =& $this->folders->GetFolderById((int) $this->_proc->sArray[FOLDER_ID]);
                $this->_proc->processor->GetFolderInfo($this->folder);
                $this->folders =& new FolderCollection();
                $this->folders->Add($this->folder);
            } else {
                $this->folder = null;
            }
            $field = $this->_proc->sArray[SEARCH_ARRAY][S_MODE] == 'onlyheaders';
            $condition = ConvertUtils::ConvertEncoding($this->_proc->sArray[SEARCH_ARRAY][S_TEXT], $this->_proc->account->GetUserCharset(), $this->_proc->account->DbCharset);
            $this->messCount = (int) $this->_proc->processor->SearchMessagesCount($condition, $this->folders, $field);
            $this->messageCollection =& $this->_proc->processor->SearchMessages($this->page, $condition, $this->folders, $field, $this->messCount);
        } else {
            $cfolder =& $this->_proc->GetCurrentFolder();
            if ($cfolder) {
                $this->folder =& $cfolder;
                $this->messCount = (int) $this->folder->MessageCount;
                if ($this->_proc->account->MailsPerPage * ($this->page - 1) >= $this->messCount) {
                    $this->page = (int) ceil($this->messCount / $this->_proc->account->MailsPerPage);
                }
                $this->page = $this->page < 1 ? $this->page = 1 : $this->page;
                $this->messageCollection =& $this->_proc->processor->GetMessageHeaders($this->page, $this->folder);
            } else {
                $this->folder = null;
                $this->messCount = 0;
                $this->page = 1;
                $this->messageCollection =& new WebMailMessageCollection();
            }
        }
        if ($this->folder && $this->folders) {
            $this->folders->InitToFolder($this->folder);
        }
        if ($this->messageCollection === null) {
            $this->folder = null;
            $this->messCount = 0;
            $this->page = 1;
            $this->messageCollection =& new WebMailMessageCollection();
            SetOnlineError(PROC_CANT_GET_MSG_LIST);
        }
        $jsTempString = $this->_proc->currentFolder && $this->_proc->currentFolder->Type == FOLDERTYPE_Drafts ? 'BaseForm.Form.action = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_NEWOREDIT . '";' : 'BaseForm.Form.action = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_FULLSCREEN . '";';
        $flagjs = '
		var line = InboxLines.GetLinesById(id);
		if (line.Flagged) {
			InboxLines.SetParams([id], "Flagged", false, false);
		} else {
			InboxLines.SetParams([id], "Flagged", true, false);
		}
		DoFlagOneMessage(line);
';
        if ($this->_proc->account->MailProtocol != MAILPROTOCOL_IMAP4 && $this->_proc->currentFolder && $this->_proc->currentFolder->SyncType == FOLDERSYNC_DirectMode) {
            $flagjs = '';
        }
        $this->_pagebuilder->AddJSText('
		
function CheckThisLine(e, trobj)
{
	var id = trobj.id;

	e = e ? e : window.event;
	if (e.ctrlKey) {
		InboxLines.CheckCtrlLine(id);
	} else if (e.shiftKey) {
		InboxLines.CheckShiftLine(id);
	} else {
		if (Browser.Mozilla) {var elem = e.target;}
		else {var elem = e.srcElement;}
		
		if (!elem || id == "" || elem.id == "none") {
			return false;
		}
		
		var loverTag = elem.tagName.toLowerCase();
		
		if (loverTag == "a") {
			LoadMessageFull(id);
		} else if (loverTag == "input") {
			InboxLines.CheckCBox(id);
		} else if (loverTag == "img") {
			' . $flagjs . '
		} else if (isPreviewPane) {
			InboxLines.CheckLine(id);
			LoadMessage(id);
		}
	}
}		

function CheckThisLineDb(e, trobj)
{
	var id = trobj.id;

	e = e ? e : window.event;

	if (Browser.Mozilla) {
		var elem = e.target;
	} else {
		var elem = e.srcElement;
	}
	
	if (!elem || id == "" || elem.id == "none" || elem.tagName.toLowerCase() == "input") {
		return false;
	}
	LoadMessageFull(id);
}

function LoadMessageFull(lineid)
{
	var parseObj = ParseLineId(lineid);
	var obj = InboxLines.GetLinesById(lineid);

	' . $jsTempString . '
	BaseForm.Form.target = "_self";
	BaseForm.MessId.value = obj.MsgId;
	BaseForm.MessUid.value = obj.MsgUid;
	BaseForm.FolderId.value = obj.MsgFolderId;
	BaseForm.FolderName.value = obj.MsgFolderFullName;
	BaseForm.Charset.value = parseObj.charset;
	BaseForm.Plain.value = "-1";
	BaseForm.Form.submit();
}
	
function LoadMessage(lineid)
{
	if (tempReq != lineid){
		InfoPanel._isError = false;
		InfoPanel.SetInfo(Lang.Loading);
		InfoPanel.Show();
		
		tempReq = lineid;
		var parseObj = ParseLineId(lineid);
		var obj = InboxLines.GetLinesById(lineid);
		
		BaseForm.MessId.value = obj.MsgId;
		BaseForm.MessUid.value = obj.MsgUid;
		BaseForm.FolderId.value = obj.MsgFolderId;
		BaseForm.FolderName.value = obj.MsgFolderFullName;
		BaseForm.Charset.value = parseObj.charset;
		BaseForm.Plain.value = "-1";
		BaseForm.Form.submit();
	}
}

function DoForwardButton()
{
	var lineobjs = InboxLines.GetCheckedLinesObj();
	if (lineobjs && lineobjs.length == 1) {
		var obj = lineobjs[0];
		var parseObj = ParseLineId(obj.Id);

		BaseForm.Form.action = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_NEWOREDIT . '";
		BaseForm.Form.target = "_self";
		BaseForm.MessId.value = obj.MsgId;
		BaseForm.MessUid.value = obj.MsgUid;
		BaseForm.FolderId.value = obj.MsgFolderId;
		BaseForm.FolderName.value = obj.MsgFolderFullName;
		BaseForm.Charset.value = parseObj.charset;
		BaseForm.Plain.value = "-1";
		BaseForm.Type.value = "forward";
		BaseForm.Form.submit();
	}
}

function DoReplyButton()
{
	var lineobjs = InboxLines.GetCheckedLinesObj();
	if (lineobjs && lineobjs.length == 1) {
		var obj = lineobjs[0];
		var parseObj = ParseLineId(obj.Id);

		BaseForm.Form.action = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_NEWOREDIT . '";
		BaseForm.Form.target = "_self";
		BaseForm.MessId.value = obj.MsgId;
		BaseForm.MessUid.value = obj.MsgUid;
		BaseForm.FolderId.value = obj.MsgFolderId;
		BaseForm.FolderName.value = obj.MsgFolderFullName;
		BaseForm.Charset.value = parseObj.charset;
		BaseForm.Plain.value = "-1";
		BaseForm.Type.value = "reply";
		BaseForm.Form.submit();
	}
}

function DoReplyAllButton()
{
	var lineobjs = InboxLines.GetCheckedLinesObj();
	if (lineobjs && lineobjs.length == 1) {
		var obj = lineobjs[0];
		var parseObj = ParseLineId(obj.Id);

		BaseForm.Form.action = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_NEWOREDIT . '";
		BaseForm.Form.target = "_self";
		BaseForm.MessId.value = obj.MsgId;
		BaseForm.MessUid.value = obj.MsgUid;
		BaseForm.FolderId.value = obj.MsgFolderId;
		BaseForm.FolderName.value = obj.MsgFolderFullName;
		BaseForm.Charset.value = parseObj.charset;
		BaseForm.Plain.value = "-1";
		BaseForm.Type.value = "replytoall";
		BaseForm.Form.submit();
	}
}


function ChangeCharset(newCharset)
{
	var idline = BaseForm.MessId.value + sep + BaseForm.MessUid.value + sep + BaseForm.FolderId.value + sep + BaseForm.Charset.value + sep;
	var newidline = BaseForm.MessId.value + sep + BaseForm.MessUid.value + sep + BaseForm.FolderId.value + sep + newCharset + sep;
	BaseForm.Charset.value = newCharset;
	
	for (var i=0; i<InboxLines.length; i++) {
		if (InboxLines.lines[i].Id == idline) {
			InboxLines.lines[i].Id = newidline;
			InboxLines.lines[i]._tr.id = newidline;
		}
	}
} 

function ParseLineId(lineid)
{
	var IdArray = lineid.split(sep);
	if (IdArray.length > 3) {
		var objcharset = (IdArray[3]) ? IdArray[3] : -1;
		return {id: IdArray[0], uid: IdArray[1], folder_id: IdArray[2], charset: objcharset}
	}
	return null;
}

	');
        $this->_pagebuilder->AddInitText('	
PageSwitcher.Show(' . $this->page . ', ' . $this->_proc->account->MailsPerPage . ', ' . $this->messCount . ', "document.location.replace(\'?s_ord=' . $this->sortOrder . '&s_fld=' . $this->sortField . '&page=", "\');");
tempReq = "";

function CBaseForm()
{
	this.Form = document.getElementById("messform");
	this.MessId = document.getElementById("m_id");
	this.MessUid = document.getElementById("m_uid");
	this.FolderId = document.getElementById("f_id");
	this.FolderName = document.getElementById("f_name");
	this.Charset = document.getElementById("charset");
	this.Plain = document.getElementById("plain");
	this.Type = document.getElementById("mtype");
}
BaseForm = new CBaseForm();
');
    }
Exemple #6
0
		return false;
	}

	function ChangeBody(type)
	{
		parent.BaseForm.Plain.value = type;
		parent.BaseForm.Form.submit();
		return false;
	}	
	
	</script>
	</head>
	<body onresize="ResizeElements('all');" style="background: #E9F2F8;" scroll="no" style="overflow: hidden;">
	<div class="wm_hide" id="headersCont">
		<div id="headersDiv" class="wm_message_rfc822"><pre><?php 
            echo ConvertUtils::WMHtmlSpecialChars($message->msg->ClearForSend(ConvertUtils::ConvertEncoding($message->msg->OriginalHeaders, $GLOBALS[MailInputCharset], $account->GetUserCharset())));
            ?>
</pre>
		</div>
		<div class="wm_hide_headers"><a href="#" onclick="return FullHeaders.Hide();">Close</a></div>
	</div>
	<table class="wm_mail_container" id="wm_mail_container" border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td colspan="3" id="td_message_headers">
				<table class="wm_view_message" id="message_headers">
					<tr>
						<td class="wm_view_message_title">From:</td>
						<td>
							<span id="fromSpan"><?php 
            echo ConvertUtils::WMHtmlSpecialChars($message->PrintFrom(true));
            ?>
Exemple #7
0
     }
     break;
 case 'rename':
     switch ($REQ) {
         case 'folder':
             if ($sarray && in_array($sarray[EDIT_ACCOUNT_ID], $Accounts)) {
                 $editAccount =& Account::LoadFromDb($sarray[EDIT_ACCOUNT_ID]);
                 if ($editAccount->IsDemo) {
                     header('Location: ' . BASEFILE);
                     exit;
                 }
                 $editProcessor =& new MailProcessor($editAccount);
                 if (!ConvertUtils::CheckDefaultWordsFileName(Post::val('fname', 'errorName')) || !ConvertUtils::CheckFileName(Post::val('fname', 'erorrName'))) {
                     SetError(PROC_CANT_UPD_FLD);
                 }
                 $folderName = ConvertUtils::ConvertEncoding(ConvertUtils::ClearFileName(Post::val('fname', 'errorName')), $editAccount->GetUserCharset(), CPAGE_UTF7_Imap);
                 $folders =& $editProcessor->GetFolders();
                 $folderList =& $folders->CreateFolderListFromTree();
                 $folder =& new Folder($editAccount->Id, Post::val('folderid', -1), '-');
                 $editProcessor->GetFolderInfo($folder);
                 $hasError = false;
                 foreach (array_keys($folderList->Instance()) as $key) {
                     $listFolder =& $folderList->Get($key);
                     if ($listFolder->Name == $folderName) {
                         $hasError = true;
                         break;
                     }
                 }
                 if ($hasError) {
                     SetError(PROC_FOLDER_EXIST);
                 }
 /**
  * @return string
  */
 function SetEncodedBodyFromText($body, $charset = '')
 {
     //if ($charset == '') $charset = $GLOBALS[MailDefaultCharset];
     if ($charset == '') {
         $charset = $GLOBALS[MailInputCharset];
     }
     $body = preg_replace('/(<meta\\s.*)(charset\\s?=)([^"\'>\\s]*)/i', '$1$2' . $GLOBALS[MailOutputCharset], $body);
     $body = ConvertUtils::ConvertEncoding($body, $charset, $GLOBALS[MailOutputCharset]);
     $ContentTransferEncoding = MIMEConst_QuotedPrintableLower;
     if ($ContentTransferEncoding == MIMEConst_QuotedPrintableLower) {
         $this->Headers->SetHeaderByName(MIMEConst_ContentTransferEncoding, MIMEConst_QuotedPrintable);
         $this->_body = ConvertUtils::quotedPrintableWithLinebreak($body);
     } elseif ($ContentTransferEncoding == MIMEConst_Base64Lower) {
         $this->Headers->SetHeaderByName(MIMEConst_ContentTransferEncoding, MIMEConst_Base64);
         $this->_body = ConvertUtils::base64WithLinebreak($body);
     } else {
         $this->_body = $body;
     }
 }
 /**
  * @param Folder $folders
  * @param DbStorage $dbStorage
  * @param int $lastIdMsg
  * @return bool
  */
 function _synchronizeFolderWithOpenDbConnection(&$folder, &$dbStorage, $lastIdMsg)
 {
     $result = true;
     if ($folder->SyncType == FOLDERSYNC_DontSync || $folder->SyncType == FOLDERSYNC_DirectMode || $folder->Hide) {
         return true;
     }
     if (!$this->_imapMail->examine_mailbox($folder->FullName)) {
         return false;
     }
     //Get uid, flags and size from imap Server
     $paramsMessages = $this->_imapMail->getParamsMessages();
     $imapFlags = array();
     $imapUids = array();
     $imapSizes = array();
     $dbUids = array();
     $imapUidFlags = array();
     if (!is_array($paramsMessages)) {
         return false;
     }
     foreach ($paramsMessages as $key => $value) {
         $imapFlags[$key] = $value["flag"];
         $imapUids[$key] = $value["uid"];
         $imapSizes[$key] = $value["size"];
         $imapUidFlags[$value["uid"]] = $value["flag"];
         $imapUidSizes[$value["uid"]] = $value["size"];
     }
     $dbUidsIdMsgsFlags =& $dbStorage->SelectIdMsgAndUidByIdMsgDesc($folder);
     foreach ($dbUidsIdMsgsFlags as $value) {
         $dbUidsFlag[$value[1]] = $value[2];
         $dbUids[] = $value[1];
     }
     //Array need added to DB
     $newUids = array_diff($imapUids, $dbUids);
     //Array delete from DB
     $uidsToDelete = array_diff($dbUids, $imapUids);
     //Intersect uids
     $currentUids = array_intersect($imapUids, $dbUids);
     if ($folder->SyncType == FOLDERSYNC_AllHeadersOnly || $folder->SyncType == FOLDERSYNC_AllEntireMessages) {
         //Update messages whith different flags
         foreach ($currentUids as $currentUid) {
             $flagBD = $dbUidsFlag[$currentUid];
             $flagImap = $this->getIntFlags($imapUidFlags[$currentUid]);
             if ($flagBD != $flagImap) {
                 $dbStorage->UpdateMessageFlags(array($currentUid), true, $folder, $flagImap, $this->Account);
             }
         }
     }
     if ($this->DownloadedMessagesHandler != null) {
         if (ConvertUtils::IsLatin($folder->Name)) {
             $foldername = ConvertUtils::ConvertEncoding($folder->Name, CPAGE_UTF7_Imap, $this->Account->GetUserCharset());
         } else {
             $foldername = ConvertUtils::ConvertEncoding($folder->Name, $this->Account->DefaultIncCharset, $this->Account->GetUserCharset());
         }
         ShowDownloadedMessageNumber($foldername, count($newUids));
         ShowDownloadedMessageNumber();
     }
     //Delete from DB
     if (count($uidsToDelete) > 0 && ($folder->SyncType == FOLDERSYNC_AllHeadersOnly || $folder->SyncType == FOLDERSYNC_AllEntireMessages)) {
         //$result &= $dbStorage->DeleteMessages($uidsToDelete, true, $folder);
         $result &= $dbStorage->SetMessagesFlags($uidsToDelete, true, $folder, MESSAGEFLAGS_Deleted, ACTION_Set);
     }
     $result &= $dbStorage->UpdateMailboxSize();
     $maxEnvelopesPerSession = 1;
     //Get size all messages in DB
     $mailBoxesSize = $dbStorage->SelectMailboxesSize();
     $syncCycles = ceil(count($newUids) / $maxEnvelopesPerSession);
     for ($i = 0; $i < $syncCycles; $i++) {
         $mailBoxesSize += $imapSizes[$i + 1];
         if ($this->_settings->EnableMailboxSizeLimit && $this->Account->MailboxLimit < $mailBoxesSize) {
             $result = false;
             setGlobalError(ErrorGetMailLimit);
             break;
         }
         $listPartToDownload = $i != $syncCycles - 1 ? array_slice($newUids, $i * $maxEnvelopesPerSession, $maxEnvelopesPerSession) : array_slice($newUids, $i * $maxEnvelopesPerSession);
         //Synchronize
         if ($folder->SyncType == FOLDERSYNC_NewEntireMessages || $folder->SyncType == FOLDERSYNC_AllEntireMessages) {
             $mailMessageCollection =& $this->LoadMessages($listPartToDownload, true, $folder, $imapUids, $imapUidFlags, $imapUidSizes);
         } elseif ($folder->SyncType == FOLDERSYNC_NewHeadersOnly || $folder->SyncType == FOLDERSYNC_AllHeadersOnly) {
             $mailMessageCollection =& $this->_loadMessageHeaders($listPartToDownload, $imapUids, $imapUidFlags, $imapUidSizes);
         }
         //Write to DB
         if ($mailMessageCollection != null && $mailMessageCollection->Count() > 0) {
             if (!$this->ApplyFilters($mailMessageCollection, $dbStorage, $folder)) {
                 $result = false;
                 break;
             }
         }
     }
     $result &= $dbStorage->UpdateMailboxSize();
     return $result;
 }
 function DoGetMessages()
 {
     $_dbStorage = $_settings = $_xmlObj = $_xmlRes = $_accountId = null;
     $this->_initFuncArgs($_dbStorage, $_settings, $_xmlObj, $_xmlRes, $_accountId);
     $_acct_id = $_xmlObj->GetParamValueByName('id_acct');
     if (strlen($_acct_id) == 0) {
         $_acct_id = $_accountId;
     }
     CXmlProcessing::CheckAccountAccess($_acct_id, $_xmlRes);
     $_account =& CXmlProcessing::AccountCheckAndLoad($_xmlRes, $_acct_id, false, false);
     $_processor = new MailProcessor($_account);
     $_page = 1;
     $_folderNode =& $_xmlObj->XmlRoot->GetChildNodeByTagName('folder');
     $log =& CLog::CreateInstance();
     $_folders = $_folder = null;
     if (isset($_folderNode->Attributes['id'])) {
         $_folder = new Folder($_account->Id, $_folderNode->Attributes['id'], $_folderNode->GetChildValueByTagName('full_name'));
         if (!USE_DB) {
             $_folder->SyncType = FOLDERSYNC_DirectMode;
         }
     } else {
         CXmlProcessing::PrintErrorAndExit(PROC_CANT_GET_MSG_LIST, $_xmlRes);
     }
     $_searchNode =& $_xmlObj->XmlRoot->GetChildNodeByTagName('look_for');
     if (!isset($_searchNode->Attributes['fields'])) {
         CXmlProcessing::PrintErrorAndExit(PROC_CANT_GET_MSG_LIST, $_xmlRes);
     }
     $_sortField = $_xmlObj->GetParamValueByName('sort_field');
     $_sortOrder = $_xmlObj->GetParamValueByName('sort_order');
     if ($_sortField + $_sortOrder != $_account->DefaultOrder) {
         $_account->DefaultOrder = $_sortField + $_sortOrder;
         $_account->UpdateDefaultOrder();
     }
     if ($_searchNode->Value === '' || $_searchNode->Value === null) {
         $_processor->GetFolderInfo($_folder);
         $_processor->GetFolderMessageCount($_folder);
         if (ceil($_folder->MessageCount / $_account->MailsPerPage) < (int) $_xmlObj->GetParamValueByName('page')) {
             $_page = $_xmlObj->GetParamValueByName('page') - 1;
             $_page = $_page < 1 ? 1 : $_page;
         } else {
             $_page = $_xmlObj->GetParamValueByName('page');
         }
         $_messageCollection =& $_processor->GetMessageHeaders($_page, $_folder);
     } else {
         if ($_folder->IdDb == -1) {
             if (USE_DB) {
                 $_folders =& $_processor->GetFolders();
             } else {
                 $_Allfolders =& $_processor->GetFolders();
                 $_folder = $_Allfolders->GetFolderByType(FOLDERTYPE_Inbox);
             }
         } else {
             $_processor->GetFolderInfo($_folder);
             $_folders = new FolderCollection();
             $_folders->Add($_folder);
         }
         $_page = (int) $_xmlObj->GetParamValueByName('page');
         $log->WriteLine(print_r($_folder, true));
         if ($_account->MailProtocol == MAILPROTOCOL_IMAP4 && $_folder->SyncType == FOLDERSYNC_DirectMode && $_folder->IdDb > 0) {
             $_processor->GetFolderInfo($_folder);
             $msgCount = 0;
             $_messageCollection =& $_processor->DmImapSearchMessages($_page, $_searchNode->Value, $_folder, (bool) (!$_searchNode->Attributes['fields']), $msgCount);
             $_folder->MessageCount = $msgCount;
         } else {
             if ($_account->MailProtocol == MAILPROTOCOL_IMAP4 && (bool) $_searchNode->Attributes['fields'] && $_folder->IdDb > 0 && ($_folder->SyncType == FOLDERSYNC_AllHeadersOnly || $_folder->SyncType == FOLDERSYNC_NewHeadersOnly)) {
                 $_processor->GetFolderInfo($_folder);
                 $msgCount = 0;
                 $_messageCollection =& $_processor->HeadersFullImapSearchMessages($_page, $_searchNode->Value, $_folder, $msgCount);
                 $_folder->MessageCount = $msgCount;
             } else {
                 $_folder->MessageCount = $_processor->SearchMessagesCount(ConvertUtils::ConvertEncoding($_searchNode->Value, $_account->GetUserCharset(), $_account->DbCharset), $_folders, (bool) (!$_searchNode->Attributes['fields']));
                 $_messageCollection =& $_processor->SearchMessages($_page, ConvertUtils::ConvertEncoding($_searchNode->Value, $_account->GetUserCharset(), $_account->DbCharset), $_folders, (bool) (!$_searchNode->Attributes['fields']), $_folder->MessageCount);
             }
         }
     }
     CXmlProcessing::GetMessagesList($_xmlRes, $_messageCollection, $_account, $_settings, $_processor, $_folder, $_searchNode->Value, $_searchNode->Attributes['fields'], $_page, $_sortField, $_sortOrder);
 }
 function CreateSelectFolderTreeForFilters(&$folders, $id = -1)
 {
     $out = '';
     for ($i = 0, $count = $folders->Count(); $i < $count; $i++) {
         $folder =& $folders->Get($i);
         if (ConvertUtils::IsLatin($folder->Name)) {
             $foldername = ConvertUtils::ConvertEncoding($folder->Name, CPAGE_UTF7_Imap, $this->setaccount->_pagebuilder->_proc->account->GetUserCharset());
         } else {
             $foldername = ConvertUtils::ConvertEncoding($folder->Name, $this->setaccount->_pagebuilder->_proc->account->DefaultIncCharset, $this->setaccount->_pagebuilder->_proc->account->GetUserCharset());
         }
         $out .= $id == $folder->IdDb ? '<option value="' . $folder->IdDb . '" selected="selected">' . str_repeat('&nbsp;', $folder->Level * 3) . $foldername . '</option>' . "\r\n" : '<option value="' . $folder->IdDb . '">' . str_repeat('&nbsp;', $folder->Level * 3) . $foldername . '</option>';
         if ($folder->SubFolders != null && $folder->SubFolders->Count() > 0) {
             $out .= $this->CreateSelectFolderTreeForFilters($folder->SubFolders, $id);
         }
     }
     return $out;
 }
 /**
  * @param string $password
  * @param Account $account
  * @return string
  */
 function DecodePassword($password, $account)
 {
     $result = '';
     $passwordLen = strlen($password);
     if (strlen($password) > 0 && strlen($password) % 2 == 0) {
         $decodeByte = chr(hexdec(substr($password, 0, 2)));
         $plainBytes = $decodeByte;
         $startIndex = 2;
         $currentByte = 1;
         do {
             $hexByte = substr($password, $startIndex, 2);
             $plainBytes .= chr(hexdec($hexByte)) ^ $decodeByte;
             $startIndex += 2;
             $currentByte++;
         } while ($startIndex < $passwordLen);
         //$result = $plainBytes;
         $result = ConvertUtils::ConvertEncoding($plainBytes, CPAGE_UTF8, $account->GetUserCharset());
     }
     return $result;
 }
 /**
  * @param FolderCollection $folderCollection
  * @return String
  */
 function CreateFolderTree($folderCollection)
 {
     $out = '';
     for ($i = 0, $c = $folderCollection->Count(); $i < $c; $i++) {
         $folder =& $folderCollection->Get($i);
         if ($folder->Hide) {
             continue;
         }
         if ($folder->SyncType == FOLDERSYNC_DirectMode && $this->_pagebuilder->_proc->account->MailProtocol == MAILPROTOCOL_POP3) {
             continue;
         }
         $foldername = '';
         if (ConvertUtils::IsLatin($folder->Name)) {
             $foldername = ConvertUtils::ConvertEncoding($folder->Name, CPAGE_UTF7_Imap, $this->_pagebuilder->_proc->account->GetUserCharset());
         } else {
             $foldername = ConvertUtils::ConvertEncoding($folder->Name, $this->_pagebuilder->_proc->account->DefaultIncCharset, $this->_pagebuilder->_proc->account->GetUserCharset());
         }
         $out .= '<div onclick="MoveToFolder(\'' . $folder->IdDb . '\');" class="wm_menu_item" onmouseover="this.className=\'wm_menu_item_over\';" onmouseout="this.className=\'wm_menu_item\';">' . str_repeat('&nbsp;', (int) $folder->Level * 4);
         switch ($folder->Type) {
             default:
             case FOLDERTYPE_Custom:
                 $out .= ConvertUtils::WMHtmlSpecialChars($foldername);
                 break;
             case FOLDERTYPE_Inbox:
                 $out .= FolderInbox;
                 break;
             case FOLDERTYPE_Drafts:
                 $out .= FolderDrafts;
                 break;
             case FOLDERTYPE_SentItems:
                 $out .= FolderSentItems;
                 break;
             case FOLDERTYPE_Trash:
                 $out .= FolderTrash;
                 break;
         }
         $out .= '</div>';
         if ($folder->SubFolders != null && $folder->SubFolders->Count() > 0) {
             $out .= $this->CreateFolderTree($folder->SubFolders);
         }
     }
     return $out;
 }