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 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); } }
$sug->AppendAttribute('value', $suggestWord); $node->AppendChild($sug); unset($sug); } $node->AppendAttribute('action', 'suggest'); $response->XmlRoot->AppendChild($node); break; } } print $response->ToString(); } else { // if error ocured $response = new XmlDocument(); $response->CreateElement('webmail'); $node = new XmlDomNode('spellcheck'); $node->AppendAttribute('action', 'error'); $node->AppendAttribute('errorstr', $sp->_error); $node->AppendChild($err); $response->XmlRoot->AppendChild($node); print $response->ToString(); } /** * @param string $string * @return string */ function obLogResponse($string) { global $log; $log->WriteLine(">>>[Spellchecker]>>>\r\n" . $string); return $string; }
$sp->ForgotChar($suggestTmp); $suggest = array_unique(array_merge($suggest, $suggestTmp)); if (count($suggest) < MAX_SUGGEST_WORDS - 1) { $sp->ExtraChar($suggestTmp); $suggest = array_unique(array_merge($suggest, $suggestTmp)); if (count($suggest) < MAX_SUGGEST_WORDS - 1) { $sp->TwoWords($suggestTmp); $suggest = array_unique(array_merge($suggest, $suggestTmp)); } } } } } $node = new XmlDomNode('spellcheck'); foreach ($suggest as $suggestWord) { $node->AppendChild(new XmlDomNode('word', $suggestWord, true)); } $node->AppendAttribute('action', 'suggest'); $response->XmlRoot->AppendChild($node); break; } } print $response->ToString(); } else { /* if error ocured */ $response = new XmlDocument(); $response->CreateElement('webmail'); $node = new XmlDomNode('spellcheck'); $node->AppendAttribute('action', 'error'); $node->AppendAttribute('errorstr', $sp->_error); $response->XmlRoot->AppendChild($node);
function DoOperationMessagesFunction() { $_dbStorage = $_settings = $_xmlObj = $_xmlRes = $_accountId = null; $this->_initFuncArgs($_dbStorage, $_settings, $_xmlObj, $_xmlRes, $_accountId); $_account =& CXmlProcessing::AccountCheckAndLoad($_xmlRes, $_accountId, false, false); $_processor = new MailProcessor($_account); $_messagesRequestNode =& $_xmlObj->XmlRoot->GetChildNodeByTagName('messages'); if (!$_messagesRequestNode) { CXmlProcessing::PrintErrorAndExit(WebMailException, $_xmlRes); } $_getmsg = isset($_messagesRequestNode->Attributes['getmsg']) && $_messagesRequestNode->Attributes['getmsg'] == '1'; $_folderNodeRequest =& $_messagesRequestNode->GetChildNodeByTagName('folder'); if (isset($_folderNodeRequest->Attributes['id'])) { $_folder = new Folder($_accountId, $_folderNodeRequest->Attributes['id'], ConvertUtils::WMBackHtmlSpecialChars($_folderNodeRequest->GetChildValueByTagName('full_name'))); } else { CXmlProcessing::PrintErrorAndExit(WebMailException, $_xmlRes); } $_processor->GetFolderInfo($_folder, true); $_toFolderNodeRequest =& $_messagesRequestNode->GetChildNodeByTagName('to_folder'); if (isset($_toFolderNodeRequest->Attributes['id'])) { $_toFolder = new Folder($_accountId, $_toFolderNodeRequest->Attributes['id'], ConvertUtils::WMBackHtmlSpecialChars($_toFolderNodeRequest->GetChildValueByTagName('full_name'))); } else { CXmlProcessing::PrintErrorAndExit(WebMailException, $_xmlRes); } $_processor->GetFolderInfo($_toFolder, true); $_operationNode = new XmlDomNode('operation_messages'); $_toFolderNode = new XmlDomNode('to_folder', $_toFolder->FullName, true); $_toFolderNode->AppendAttribute('id', $_toFolder->IdDb); $_operationNode->AppendChild($_toFolderNode); $_folderNode = new XmlDomNode('folder', $_folder->FullName, true); $_folderNode->AppendAttribute('id', $_folder->IdDb); $_operationNode->AppendChild($_folderNode); $_messagesNode = new XmlDomNode('messages'); $_messagesNode->AppendAttribute('getmsg', $_getmsg ? '1' : '0'); $_messageIdUidSet = array(); $_folders = array(); $_messagesKeys = array_keys($_messagesRequestNode->Children); foreach ($_messagesKeys as $_nodeKey) { $_messageNode =& $_messagesRequestNode->Children[$_nodeKey]; if ($_messageNode->TagName != 'message') { continue; } if (!isset($_messageNode->Attributes['id']) || !isset($_messageNode->Attributes['charset']) || !isset($_messageNode->Attributes['size'])) { continue; } $_msgId = $_messageNode->Attributes['id']; $_msgCharset = $_messageNode->Attributes['charset']; $_msgSize = $_messageNode->Attributes['size']; $_msgUid = $_messageNode->GetChildValueByTagName('uid', true); $_msgFolder =& $_messageNode->GetChildNodeByTagName('folder'); if (!isset($_msgFolder->Attributes['id'])) { continue; } $_msgFolderId = $_msgFolder->Attributes['id']; $_folders[$_msgFolderId] = $_msgFolder->GetChildValueByTagName('full_name', true); if (!isset($_messageIdUidSet[$_msgFolderId])) { $_messageIdUidSet[$_msgFolderId] = array(); } $_messageIdUidSet[$_msgFolderId][$_msgId] = $_msgUid; $_message = new XmlDomNode('message'); $_message->AppendAttribute('id', $_msgId); $_message->AppendAttribute('charset', $_msgCharset); $_message->AppendAttribute('size', $_msgSize); $_message->AppendChild(new XmlDomNode('uid', $_msgUid, true)); $_msgFolderNode = new XmlDomNode('folder', $_folders[$_msgFolderId], true); $_msgFolderNode->AppendAttribute('id', $_msgFolderId); $_message->AppendChild($_msgFolderNode); $_messagesNode->AppendChild($_message); unset($_messageNode, $_msgFolder, $_message, $_msgFolderNode); } $_operationNode->AppendChild($_messagesNode); $_errorString = $_typeString = ''; $_request = $_xmlObj->GetParamValueByName('request'); switch ($_request) { case 'mark_all_read': $_messageIdUidSet = null; if ($_processor->SetFlags($_messageIdUidSet, $_folder, MESSAGEFLAGS_Seen, ACTION_Set)) { $_typeString = 'mark_all_read'; } else { $_errorString = PROC_CANT_MARK_ALL_MSG_READ; } break; case 'mark_all_unread': $_messageIdUidSet = null; if ($_processor->SetFlags($_messageIdUidSet, $_folder, MESSAGEFLAGS_Seen, ACTION_Remove)) { $_typeString = 'mark_all_unread'; } else { $_errorString = PROC_CANT_MARK_ALL_MSG_UNREAD; } break; case 'purge': if (!$_settings->Imap4DeleteLikePop3 && $_account->MailProtocol == MAILPROTOCOL_IMAP4) { if ($_processor->PurgeFolder($_folder)) { $_typeString = 'purge'; } else { $_errorString = PROC_CANT_PURGE_MSGS; } } else { if ($_processor->EmptyTrash()) { $_typeString = 'purge'; } else { $_errorString = PROC_CANT_PURGE_MSGS; } } break; case 'clear_spam': if ($_processor->EmptySpam()) { $_typeString = 'clear_spam'; } else { $_errorString = PROC_CANT_PURGE_MSGS; } break; } $_deleteFolderAppendError = false; $_foldersArray = array(); foreach ($_folders as $_idFolder => $_fullNameFolder) { if (isset($_foldersArray[$_idFolder])) { $_folder =& $_foldersArray[$_idFolder]; } else { $_folder = new Folder($_accountId, $_idFolder, $_fullNameFolder); $_processor->GetFolderInfo($_folder, true); $_foldersArray[$_idFolder] =& $_folder; } switch ($_request) { case 'no_move_delete': if ($_processor->DeleteMessages($_messageIdUidSet[$_idFolder], $_folder, true)) { $_typeString = 'no_move_delete'; } else { $_errorString = PROC_CANT_DEL_MSGS; } break; case 'delete': if ($_processor->DeleteMessages($_messageIdUidSet[$_idFolder], $_folder)) { $_typeString = 'delete'; } else { if ($_processor->IsMoveError) { $_typeString = 'delete'; $_deleteFolderAppendError = true; } $_errorString = PROC_CANT_DEL_MSGS; } break; case 'undelete': if ($_processor->SetFlags($_messageIdUidSet[$_idFolder], $_folder, MESSAGEFLAGS_Deleted, ACTION_Remove)) { $_typeString = 'undelete'; } else { $_errorString = PROC_CANT_UNDEL_MSGS; } break; case 'mark_read': if ($_processor->SetFlags($_messageIdUidSet[$_idFolder], $_folder, MESSAGEFLAGS_Seen, ACTION_Set)) { $_typeString = 'mark_read'; } else { $_errorString = PROC_CANT_MARK_MSGS_READ; } break; case 'mark_unread': if ($_processor->SetFlags($_messageIdUidSet[$_idFolder], $_folder, MESSAGEFLAGS_Seen, ACTION_Remove)) { $_typeString = 'mark_unread'; } else { $_errorString = PROC_CANT_MARK_MSGS_UNREAD; } break; case 'flag': if ($_processor->SetFlags($_messageIdUidSet[$_idFolder], $_folder, MESSAGEFLAGS_Flagged, ACTION_Set)) { $_typeString = 'flag'; } else { $_errorString = PROC_CANT_SET_MSG_FLAGS; } break; case 'unflag': if ($_processor->SetFlags($_messageIdUidSet[$_idFolder], $_folder, MESSAGEFLAGS_Flagged, ACTION_Remove)) { $_typeString = 'unflag'; } else { $_errorString = PROC_CANT_REMOVE_MSG_FLAGS; } break; case 'copy_to_folder': // TODO if ($_processor->MoveMessages($_messageIdUidSet[$_idFolder], $_folder, $_toFolder)) { $_typeString = 'copy_to_folder'; } else { $_errorString = PROC_CANT_CHANGE_MSG_FLD; } break; case 'move_to_folder': if ($_processor->MoveMessages($_messageIdUidSet[$_idFolder], $_folder, $_toFolder)) { $_typeString = 'move_to_folder'; } else { $_errorString = PROC_CANT_CHANGE_MSG_FLD; } break; case 'spam': if ($_processor->SpamMessages($_messageIdUidSet[$_idFolder], $_folder, true)) { $_typeString = 'spam'; } else { $_errorString = PROC_CANT_SET_MSG_AS_SPAM; } break; case 'not_spam': if ($_processor->SpamMessages($_messageIdUidSet[$_idFolder], $_folder, false)) { $_typeString = 'not_spam'; } else { $_errorString = PROC_CANT_SET_MSG_AS_NOTSPAM; } break; } unset($_folder); if (strlen($_errorString) > 0) { break; } } if (strlen($_errorString) == 0 && strlen($_typeString) > 0) { $_operationNode->AppendAttribute('type', $_typeString); $_xmlRes->XmlRoot->AppendChild($_operationNode); } else { if ($_deleteFolderAppendError) { $_operationNode->AppendAttribute('type', $_typeString); $_messagesNode->AppendAttribute('no_move', '1'); $_xmlRes->XmlRoot->AppendChild($_operationNode); } else { if (strlen($_errorString) == 0) { $_errorString = WebMailException; } $_xmlRes->XmlRoot->AppendChild(new XmlDomNode('error', $_errorString, true)); } } }
/** * @return bool */ function SaveToXml() { $xmlDocument =& new XmlDocument(); $xmlDocument->CreateElement('Settings'); $xmlDocument->XmlRoot->AppendAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema'); $xmlDocument->XmlRoot->AppendAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $common = new XmlDomNode('Common'); $common->AppendChild(new XmlDomNode('SiteName', ConvertUtils::WMHtmlSpecialChars($this->WindowTitle))); $common->AppendChild(new XmlDomNode('LicenseKey', ConvertUtils::WMHtmlSpecialChars($this->LicenseKey))); $common->AppendChild(new XmlDomNode('AdminPassword', ConvertUtils::WMHtmlSpecialChars($this->AdminPassword))); $common->AppendChild(new XmlDomNode('DBType', (int) $this->DbType)); $common->AppendChild(new XmlDomNode('DBLogin', ConvertUtils::WMHtmlSpecialChars($this->DbLogin))); $common->AppendChild(new XmlDomNode('DBPassword', ConvertUtils::WMHtmlSpecialChars($this->DbPassword))); $common->AppendChild(new XmlDomNode('DBName', ConvertUtils::WMHtmlSpecialChars($this->DbName))); $common->AppendChild(new XmlDomNode('DBDSN', ConvertUtils::WMHtmlSpecialChars($this->DbDsn))); $common->AppendChild(new XmlDomNode('DBHost', ConvertUtils::WMHtmlSpecialChars($this->DbHost))); $common->AppendChild(new XmlDomNode('UseCustomConnectionString', (int) $this->UseCustomConnectionString)); $common->AppendChild(new XmlDomNode('DBCustomConnectionString', ConvertUtils::WMHtmlSpecialChars($this->DbCustomConnectionString))); $common->AppendChild(new XmlDomNode('DBPrefix', ConvertUtils::WMHtmlSpecialChars($this->DbPrefix))); $common->AppendChild(new XmlDomNode('DefaultSkin', ConvertUtils::WMHtmlSpecialChars($this->DefaultSkin))); $common->AppendChild(new XmlDomNode('AllowUsersChangeSkin', (int) $this->AllowUsersChangeSkin)); $common->AppendChild(new XmlDomNode('DefaultLanguage', ConvertUtils::WMHtmlSpecialChars($this->DefaultLanguage))); $common->AppendChild(new XmlDomNode('AllowUsersChangeLanguage', (int) $this->AllowUsersChangeLanguage)); $xmlDocument->XmlRoot->AppendChild($common); $webmail = new XmlDomNode('WebMail'); $webmail->AppendChild(new XmlDomNode('IncomingMailProtocol', (int) $this->IncomingMailProtocol)); $webmail->AppendChild(new XmlDomNode('IncomingMailServer', ConvertUtils::WMHtmlSpecialChars($this->IncomingMailServer))); $webmail->AppendChild(new XmlDomNode('IncomingMailPort', (int) $this->IncomingMailPort)); $webmail->AppendChild(new XmlDomNode('OutgoingMailServer', ConvertUtils::WMHtmlSpecialChars($this->OutgoingMailServer))); $webmail->AppendChild(new XmlDomNode('OutgoingMailPort', (int) $this->OutgoingMailPort)); $webmail->AppendChild(new XmlDomNode('ReqSmtpAuth', (int) $this->ReqSmtpAuth)); $webmail->AppendChild(new XmlDomNode('AllowAdvancedLogin', (int) $this->AllowAdvancedLogin)); $webmail->AppendChild(new XmlDomNode('HideLoginMode', (int) $this->HideLoginMode)); $webmail->AppendChild(new XmlDomNode('DefaultDomainOptional', ConvertUtils::WMHtmlSpecialChars($this->DefaultDomainOptional))); $webmail->AppendChild(new XmlDomNode('ShowTextLabels', (int) $this->ShowTextLabels)); $webmail->AppendChild(new XmlDomNode('AutomaticCorrectLoginSettings', (int) $this->AutomaticCorrectLoginSettings)); $webmail->AppendChild(new XmlDomNode('EnableLogging', (int) $this->EnableLogging)); $webmail->AppendChild(new XmlDomNode('DisableErrorHandling', (int) $this->DisableErrorHandling)); $webmail->AppendChild(new XmlDomNode('AllowAjax', (int) $this->AllowAjax)); $webmail->AppendChild(new XmlDomNode('MailsPerPage', (int) $this->MailsPerPage)); $webmail->AppendChild(new XmlDomNode('EnableAttachmentSizeLimit', (int) $this->EnableAttachmentSizeLimit)); $webmail->AppendChild(new XmlDomNode('AttachmentSizeLimit', ConvertUtils::WMHtmlSpecialChars($this->AttachmentSizeLimit))); $webmail->AppendChild(new XmlDomNode('EnableMailboxSizeLimit', (int) $this->EnableMailboxSizeLimit)); $webmail->AppendChild(new XmlDomNode('MailboxSizeLimit', ConvertUtils::WMHtmlSpecialChars($this->MailboxSizeLimit))); $webmail->AppendChild(new XmlDomNode('DefaultTimeZone', ConvertUtils::WMHtmlSpecialChars($this->DefaultTimeZone))); $webmail->AppendChild(new XmlDomNode('AllowUsersChangeTimeZone', (int) $this->AllowUsersChangeTimeZone)); $webmail->AppendChild(new XmlDomNode('DefaultUserCharset', ConvertUtils::GetCodePageNumber($this->DefaultUserCharset))); $webmail->AppendChild(new XmlDomNode('AllowUsersChangeCharset', (int) $this->AllowUsersChangeCharset)); $webmail->AppendChild(new XmlDomNode('AllowDHTMLEditor', (int) $this->AllowDhtmlEditor)); $webmail->AppendChild(new XmlDomNode('AllowUsersChangeEmailSettings', (int) $this->AllowUsersChangeEmailSettings)); $webmail->AppendChild(new XmlDomNode('AllowDirectMode', (int) $this->AllowDirectMode)); $webmail->AppendChild(new XmlDomNode('DirectModeIsDefault', (int) $this->DirectModeIsDefault)); $webmail->AppendChild(new XmlDomNode('AllowNewUsersRegister', (int) $this->AllowNewUsersRegister)); $webmail->AppendChild(new XmlDomNode('AllowUsersAddNewAccounts', (int) $this->AllowUsersAddNewAccounts)); $webmail->AppendChild(new XmlDomNode('StoreMailsInDb', (int) $this->StoreMailsInDb)); $webmail->AppendChild(new XmlDomNode('EnableWmServer', (int) $this->EnableWmServer)); $webmail->AppendChild(new XmlDomNode('WmServerRootPath', ConvertUtils::WMHtmlSpecialChars($this->WmServerRootPath))); $webmail->AppendChild(new XmlDomNode('WmServerHost', ConvertUtils::WMHtmlSpecialChars($this->WmServerHost))); $webmail->AppendChild(new XmlDomNode('WmAllowManageXMailAccounts', (int) $this->WmAllowManageXMailAccounts)); $webmail->AppendChild(new XmlDomNode('AllowContacts', (int) $this->AllowContacts)); $webmail->AppendChild(new XmlDomNode('AllowCalendar', (int) $this->AllowCalendar)); $xmlDocument->XmlRoot->AppendChild($webmail); $calendar = new XmlDomNode('Calendar'); $calendar->AppendChild(new XmlDomNode('DefaultTimeFormat', (int) $this->Cal_DefaultTimeFormat)); $calendar->AppendChild(new XmlDomNode('DefaultDateFormat', (int) $this->Cal_DefaultDateFormat)); $calendar->AppendChild(new XmlDomNode('ShowWeekends', (int) $this->Cal_ShowWeekends)); $calendar->AppendChild(new XmlDomNode('WorkdayStarts', (int) $this->Cal_WorkdayStarts)); $calendar->AppendChild(new XmlDomNode('WorkdayEnds', (int) $this->Cal_WorkdayEnds)); $calendar->AppendChild(new XmlDomNode('ShowWorkDay', (int) $this->Cal_ShowWorkDay)); $calendar->AppendChild(new XmlDomNode('WeekStartsOn', (int) $this->Cal_WeekStartsOn)); $calendar->AppendChild(new XmlDomNode('DefaultTab', (int) $this->Cal_DefaultTab)); $calendar->AppendChild(new XmlDomNode('DefaultCountry', ConvertUtils::WMHtmlSpecialChars($this->Cal_DefaultCountry))); $calendar->AppendChild(new XmlDomNode('DefaultTimeZone', (int) $this->Cal_DefaultTimeZone)); $calendar->AppendChild(new XmlDomNode('AllTimeZones', (int) $this->Cal_AllTimeZones)); $xmlDocument->XmlRoot->AppendChild($calendar); return $xmlDocument->SaveToFile(INI_DIR . '/settings/settings.xml'); }