header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-type: application/octet-stream; charset=utf-8'); //header('Content-Type: application/force-download'); header('Content-Type: application/download'); header('Accept-Ranges: bytes'); header('Content-Disposition: attachment; filename="' . $fileNameToSave . '.eml"'); header('Content-Transfer-Encoding: binary'); } elseif (isset($_SESSION[ACCOUNT_ID], $_GET['tn'])) { $fs =& new FileSystem(INI_DIR . '/temp', $account->Email, $_SESSION[ACCOUNT_ID]); $folder =& new Folder($_SESSION[ACCOUNT_ID], -1, $_SESSION['attachtempdir']); $tempName = ConvertUtils::ClearFileName($_GET['tn']); $data = $fs->LoadBinaryAttach($folder, $tempName); if (isset($_GET['filename'])) { $filename = ConvertUtils::ClearFileName(urldecode($_GET['filename'])); $filename = $filename ? $filename : 'attachmentname'; // IE header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Type: application/octet-stream; charset=' . $account->GetUserCharset()); header('Content-Type: application/download'); header('Accept-Ranges: bytes'); header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Content-Transfer-Encoding: binary'); } else { header('Content-Type: ' . ConvertUtils::GetContentTypeFromFileName($tempName)); } } else { exit;
} if (($mode & 64) == 64) { $messageNode->AppendChild(new XmlDomNode('forward_plain', $signature_plain . $message->GetRelpyAsPlain(true), 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); if (($mode & 256) == 256 || ($mode & 32) == 32 || ($mode & 8) == 8) { $attachments =& $message->Attachments; if ($attachments != null && $attachments->Count() > 0) { $attachmentsNode =& new XmlDomNode('attachments'); foreach (array_keys($attachments->Instance()) as $key) { $attachment =& $attachments->Get($key); $tempname = $message->IdMsg . '-' . $key . '_' . ConvertUtils::ClearFileName($attachment->GetTempName()); $filename = ConvertUtils::ClearFileName(ConvertUtils::ClearUtf8($attachment->GetFilenameFromMime(), $GLOBALS[MailInputCharset], $account->GetUserCharset())); $fs =& new FileSystem(INI_DIR . '/temp', $account->Email, $account->Id); $attfolder =& new Folder($accountId, -1, $_SESSION['attachtempdir']); $fs->SaveAttach($attachment, $attfolder, $tempname); $attachNode =& new XmlDomNode('attachment'); //$attachNode->AppendAttribute('id', $key); $attachNode->AppendAttribute('size', strlen($attachment->MimePart->GetBinaryBody())); $attachNode->AppendAttribute('inline', $attachment->IsInline ? '1' : '0'); $attachNode->AppendChild(new XmlDomNode('filename', $filename, true)); $attachNode->AppendChild(new XmlDomNode('view', 'view-image.php?tn=' . urlencode($tempname), true)); $attachNode->AppendChild(new XmlDomNode('download', 'attach.php?tn=' . urlencode($tempname) . '&filename=' . urlencode($filename), true)); $attachNode->AppendChild(new XmlDomNode('tempname', $tempname, true)); $attachNode->AppendChild(new XmlDomNode('mime_type', ConvertUtils::GetContentTypeFromFileName($filename), true)); $attachmentsNode->AppendChild($attachNode); } $messageNode->AppendChild($attachmentsNode);
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); }
case 'account': $settings->EnableLogging = isset($_POST['intEnableLogging']) && (int) $_POST['intEnableLogging'] == 1 ? true : false; $settings->DisableErrorHandling = isset($_POST['intDisableErrorHandling']) && (int) $_POST['intDisableErrorHandling'] == 1 ? true : false; $_SESSION['divmess'] = $settings->SaveToXml() ? MES_SAVESUCCESSFUL : MES_ERROR . getError(); $ref = 'mailadm.php?mode=wm_debug'; break; case 'edit': $account = null; $dbstor =& DbStorageCreator::CreateDatabaseStorage($account); if (isset($_POST['uid']) && $_POST['uid'] > -1) { if ($dbstor->Connect()) { $account =& $dbstor->SelectAccountData($_POST['uid']); $account->MailboxLimit = isset($_POST['int_limit_mailbox']) ? $_POST['int_limit_mailbox'] : $account->MailboxLimit; $account->FriendlyName = isset($_POST['fm_friendly_name']) ? $_POST['fm_friendly_name'] : $account->FriendlyName; $account->Email = isset($_POST['fm_email']) ? $_POST['fm_email'] : $account->Email; $account->Email = ConvertUtils::ClearFileName($account->Email); $account->MailIncHost = isset($_POST['fm_incoming_server']) ? $_POST['fm_incoming_server'] : $account->MailIncHost; $account->MailIncLogin = isset($_POST['fm_incoming_login']) ? $_POST['fm_incoming_login'] : $account->MailIncLogin; $newPassword = isset($_POST['fm_incoming_password']) ? $_POST['fm_incoming_password'] : DUMMYPASSWORD; if ($newPassword != DUMMYPASSWORD) { $account->MailIncPassword = $newPassword; } $account->MailIncPort = isset($_POST['fm_incoming_server_port']) ? (int) $_POST['fm_incoming_server_port'] : $account->MailIncPort; $account->MailOutHost = isset($_POST['fm_smtp_server']) ? $_POST['fm_smtp_server'] : $account->MailOutHost; if ($account->MailOutHost == '') { $account->MailOutHost = $account->MailIncHost; } $account->MailOutLogin = isset($_POST['fm_smtp_login']) ? $_POST['fm_smtp_login'] : $account->MailOutLogin; $new2Password = isset($_POST['fm_smtp_password']) ? $_POST['fm_smtp_password'] : DUMMYPASSWORD; if ($new2Password != DUMMYPASSWORD) { $account->MailOutPassword = $new2Password;
</table> </td> </tr> <tr> <td id="td_attachments"> <?php $JSfilenameTrim = ''; if ($message->msg->Attachments != null && $message->msg->Attachments->Count() > 0) { echo '<div id="attachments" class="wm_message_attachments">'; $attachments =& $message->msg->Attachments; if ($attachments != null && $attachments->Count() > 0) { foreach (array_keys($attachments->Instance()) as $key) { $attachment =& $attachments->Get($key); $tempname = $message->msg->IdMsg . '-' . $key . '_' . ConvertUtils::ClearFileName($attachment->GetTempName()); //$filename = ConvertUtils::ConvertEncoding($attachment->GetFilenameFromMime(), $GLOBALS[MailInputCharset], $message->account->GetUserCharset()); $filename = ConvertUtils::ClearFileName($attachment->GetFilenameFromMime()); $filesize = GetFriendlySize(strlen($attachment->MimePart->GetBinaryBody())); $fs =& new FileSystem(INI_DIR . '/temp', $message->account->Email, $message->account->Id); $attfolder =& new Folder($message->account->Id, -1, $_SESSION['attachtempdir']); $fs->SaveAttach($attachment, $attfolder, $tempname); $ContentType = ConvertUtils::GetContentTypeFromFileName($filename); $JSfilenameTrim .= ' att = document.getElementById("at_' . $key . '"); if (att.innerHTML.length > 16) att.innerHTML = att.innerHTML.substring(0, 15) + "…"; '; echo ' <div style="float: left;"><a href="attach.php?tn=' . urlencode($tempname) . '&filename=' . urlencode($filename) . '"> <img src="./images/icons/' . GetAttachImg($filename) . '" title="Click to download ' . ConvertUtils::AttributeQuote($filename . ' (' . $filesize) . ')" /></a><br /> <span id="at_' . $key . '" title="Click to download ' . ConvertUtils::AttributeQuote($filename . ' (' . $filesize) . ')">' . $filename . '</span><br />'; if (strpos($ContentType, 'image') !== false) {
/** * @return bool */ function IncludeLang($langName = null) { if (!$this->isLoad) { return false; } if ($this->_langIsInclude) { return true; } $lang = $this->DefaultLanguage; if ($langName) { $lang = $langName; } else { $lang = isset($_SESSION[SESSION_LANG]) ? $_SESSION[SESSION_LANG] : $this->DefaultLanguage; } $lang = ConvertUtils::ClearFileName($lang); if (@file_exists(WM_ROOTPATH . 'lang/' . $lang . '.php')) { include_once WM_ROOTPATH . 'lang/' . $lang . '.php'; $_SESSION[SESSION_LANG] = $lang; $this->_langIsInclude = true; } elseif (@file_exists(WM_ROOTPATH . 'lang/English.php')) { include_once WM_ROOTPATH . 'lang/English.php'; $_SESSION[SESSION_LANG] = 'English'; $this->_langIsInclude = true; } return $this->_langIsInclude; }
} 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); }
function DoUpdateFolders() { $_dbStorage = $_settings = $_xmlObj = $_xmlRes = $_accountId = null; $this->_initFuncArgs($_dbStorage, $_settings, $_xmlObj, $_xmlRes, $_accountId); $_acctId = $_xmlObj->GetParamValueByName('id_acct'); CXmlProcessing::CheckAccountAccess($_acctId, $_xmlRes); $_account =& CXmlProcessing::AccountCheckAndLoad($_xmlRes, $_acctId); $_processor = new MailProcessor($_account); $_foldersNode =& $_xmlObj->XmlRoot->GetChildNodeByTagName('folders'); $_result = true; if (!$_processor->MailStorage->Connect()) { CXmlProcessing::PrintErrorAndExit(getGlobalError(), $_xmlRes); } $_serverFoldersName = array(); if ($_account->MailProtocol != MAILPROTOCOL_POP3) { $_tempFolders = $_processor->MailStorage->GetFolders(); $_serverFolders = $_tempFolders->CreateFolderListFromTree(); $_serverFoldersArray = $_serverFolders->Instance(); foreach ($_serverFoldersArray as $_sFolder) { $_serverFoldersName[] = strtolower($_sFolder->FullName); } unset($_tempFolders, $_serverFolders, $_serverFoldersArray, $_sFolder); } $aLSubList = null; $log =& CLog::CreateInstance(); $log->SetEventPrefixByAccount($_account); for ($_key = count($_foldersNode->Children) - 1; $_key >= 0; $_key--) { $_folderNode =& $_foldersNode->Children[$_key]; if (!ConvertUtils::CheckDefaultWordsFileName($_folderNode->GetChildValueByTagName('name')) || !ConvertUtils::CheckFileName($_folderNode->GetChildValueByTagName('name'))) { CXmlProcessing::PrintErrorAndExit(PROC_CANT_UPD_FLD, $_xmlRes); } $_newFolderName = ConvertUtils::ConvertEncoding(ConvertUtils::ClearFileName(ConvertUtils::WMBackHtmlSpecialChars($_folderNode->GetChildValueByTagName('name'))), $_account->GetUserCharset(), CPAGE_UTF7_Imap); $_newFolderHide = (bool) $_folderNode->GetAttribute('hide', false); $_newFolderType = (int) $_folderNode->GetAttribute('type', 0); $_newFolderType = $_newFolderType === 0 ? 10 : $_newFolderType; $_fullFolderName = $_folderNode->GetChildValueByTagName('full_name'); $_folder = new Folder($_acctId, $_folderNode->GetAttribute('id', -1), $_fullFolderName); $_processor->GetFolderInfo($_folder); $_isRename = false; if ($_folder->Name != $_newFolderName) { $log->WriteLine('personal folder (rename "' . $_folder->FullName . '" => "' . $_newFolderName . '")'); if (!$_account->IsDemo && null === $aLSubList) { $aLSubList = $_processor->GetLsubFolders(); } $_oldName = $_folder->Name; $_folder->Name = $_newFolderName; $_validate = $_folder->ValidateData(); if (true !== $_validate) { CXmlProcessing::PrintErrorAndExit($_validate, $_xmlRes); } else { $_folder->Name = $_oldName; } $_result &= $_account->IsDemo ? true : $_processor->RenameFolder($_folder, $_newFolderName, $_account->Delimiter, $aLSubList); $log->WriteEvent('User edit personal folder (rename "' . $_folder->FullName . '" => "' . $_newFolderName . '")'); $_isRename = true; } if ($_folder->Hide != $_newFolderHide) { $_folder->Hide = $_newFolderHide; $_processor->SetHide($_folder, $_newFolderHide); } if ($_folder->Type != $_newFolderType) { $_folder->Type = $_newFolderType; } $_folder->Name = $_newFolderName; $_folder->SyncType = (int) $_folderNode->GetAttribute('sync_type', FOLDERSYNC_DontSync); $_folder->FolderOrder = (int) $_folderNode->GetAttribute('fld_order', 0); if (!$_isRename && $_account->MailProtocol != MAILPROTOCOL_POP3 && !in_array(strtolower($_folder->FullName), $_serverFoldersName) && $_folder->SyncType != FOLDERSYNC_DontSync) { $_result &= $_processor->MailStorage->CreateFolder($_folder); } if ($_result) { $_result &= $_account->IsDemo || !USE_DB ? true : $_processor->DbStorage->UpdateFolder($_folder); } else { CXmlProcessing::PrintErrorAndExit(PROC_CANT_UPD_FLD, $_xmlRes); } } if ($_result) { $_folders =& $_processor->GetFolders(); $_foldersList = new XmlDomNode('folders_list'); $_foldersList->AppendAttribute('sync', -1); $_foldersList->AppendAttribute('id_acct', $_acctId); $_foldersList->AppendAttribute('namespace', $_account->NameSpace); CXmlProcessing::GetFoldersTreeXml($_folders, $_foldersList, $_processor); $_xmlRes->XmlRoot->AppendChild($_foldersList); } else { CXmlProcessing::PrintErrorAndExit(PROC_CANT_UPD_FLD, $_xmlRes); } }
function AddAttachmentHeaders($userCharset, $tempName) { if (isset($_GET['filename'])) { $filename = trim(ConvertUtils::ClearFileName(urldecode($_GET['filename']))); $filename = strlen($filename) > 0 ? $filename : 'attachmentname'; if (ConvertUtils::IsIE()) { $filename = rawurlencode($filename); } if (isset($_GET['img'])) { header('Content-Disposition: attachment; filename="' . $filename . '"; charset=' . $userCharset); header('Content-Type: ' . ConvertUtils::GetContentTypeFromFileName($tempName)); } else { AddFileNameHeaders($userCharset, $filename); } } else { header('Content-Type: ' . ConvertUtils::GetContentTypeFromFileName($tempName)); } }
/** * @param bool $replaceSpecialHtmlChars optional * @return string */ function GetCensoredHtmlWithImageLinks($replaceSpecialHtmlChars = false, $messageInfo = null) { $text = $this->GetCensoredHtmlBody($replaceSpecialHtmlChars); if ($this->Attachments->Count() == 0) { return $text; } for ($i = 0, $count = $this->Attachments->Count(); $i < $count; $i++) { $attach =& $this->Attachments->Get($i); $filename = ConvertUtils::ClearFileName(ConvertUtils::ClearUtf8($attach->GetFilenameFromMime(), $GLOBALS[MailInputCharset], CPAGE_UTF8)); $imgUrl = 'attach.php?img&tn=' . $this->IdMsg . '-' . $i . '_' . $attach->GetTempName() . '&filename=' . $filename; $contentLocation = $attach->MimePart->GetContentLocation(); $contentId = $attach->MimePart->GetContentID(); if (null !== $attach->MimePart->BodyStructureIndex && null !== $messageInfo) { $imgUrl .= '&' . $messageInfo->GetUrl() . '&bsi=' . urlencode($attach->MimePart->BodyStructureIndex); if (null !== $attach->MimePart->BodyStructureEncode && strlen($attach->MimePart->BodyStructureEncode) > 0) { $imgUrl .= '&bse=' . urlencode(ConvertUtils::GetBodyStructureEncodeType($attach->MimePart->BodyStructureEncode)); } } $patternArray = array('cid:' . $contentId, 'CID:' . $contentId, 'Cid:' . $contentId); if ($contentId !== '') { $text = str_replace($patternArray, $imgUrl, $text); } if ($contentLocation !== '' && $contentId === '') { $text = str_replace($contentLocation, $imgUrl, $text); } } return $text; }