/** * @param Account $account; * @param int $messId * @param string $messUid * @param int $folderId * @param string $folderFullName * @return GetMessageBase */ function GetMessageBase(&$account, $messId, $messUid, $folderId, $folderFullName, $charset) { $this->messId = $messId; $this->messUid = $messUid; $this->folderId = $folderId; $this->folderFullName = $folderFullName; $this->charset = $charset; $this->accountId = $account->Id; $this->account =& $account; $this->processor = new MailProcessor($this->account); $this->folder = new Folder($this->accountId, $folderId, $folderFullName); $this->processor->GetFolderInfo($this->folder); $msgIdUid = array(); if (!empty($messId) && !empty($messUid)) { $msgIdUid[$messId] = $messUid; } $charsetNum = -1; if ($charset != -1) { $GLOBALS[MailInputCharset] = $charset; $charsetNum = ConvertUtils::GetCodePageNumber($charset); } $this->msg =& $this->processor->GetMessage($messId, $messUid, $this->folder); if ($this->msg) { if (!(($this->msg->Flags & MESSAGEFLAGS_Seen) == MESSAGEFLAGS_Seen)) { $this->processor->SetFlag($msgIdUid, $this->folder, MESSAGEFLAGS_Seen, ACTION_Set); } if ($this->folder->SyncType != FOLDERSYNC_DirectMode && $this->processor->DbStorage->Connect()) { $this->processor->DbStorage->UpdateMessageCharset($messId, $charsetNum, $this->msg); } } }
/** * @return FolderCollection */ function &GetFolders() { if ($this->folders != null) { return $this->folders; } $this->folders =& $this->processor->GetFolders(); return $this->folders; }
/** * @param WebMailMessageCollection $messageCollection * @param DbStorage $dbStorage * @param Folder $folder * @return bool */ function ApplyFilters(&$messageCollection, &$dbStorage, &$folder) { $filters =& $dbStorage->SelectFilters($this->Account->Id); $lastIdMsg = $dbStorage->SelectLastIdMsg(); $mailBoxesSize = $dbStorage->SelectMailboxesSize(); $result = true; foreach (array_keys($messageCollection->Instance()) as $key) { $message =& $messageCollection->Get($key); $needToSave = true; if ($this->_settings->EnableMailboxSizeLimit && $this->Account->MailboxLimit < $mailBoxesSize + $message->Size) { setGlobalError(ErrorGetMailLimit); return false; } $mailBoxesSize += $message->Size; $lastIdMsg += rand(1, 10); $message->IdMsg = $lastIdMsg; if ($folder->SyncType == FOLDERSYNC_NewEntireMessages || $folder->SyncType == FOLDERSYNC_AllEntireMessages) { $result &= $dbStorage->SaveMessage($message, $folder); } elseif ($folder->SyncType == FOLDERSYNC_NewHeadersOnly || $folder->SyncType == FOLDERSYNC_AllHeadersOnly) { $result &= $dbStorage->SaveMessageHeader($message, $folder, false); } } if ($folder->Type == FOLDERTYPE_Inbox && $result && isset($GLOBALS['useFilters'])) { $mailProcessor = new MailProcessor($this->Account); foreach (array_keys($filters->Instance()) as $key) { $filter =& $filters->Get($key); $action = $filter->GetActionToApply($message); $uidArray = array($message->Uid); $messageIdUidSet[$message->IdMsg] = $message->Uid; switch ($action) { case FILTERACTION_DeleteFromServerImmediately: $result &= $mailProcessor->DeleteMessages($messageIdUidSet, $folder); break; case FILTERACTION_MoveToFolder: $toFolder =& new Folder($filter->IdAcct, $filter->IdFolder, ''); $dbStorage->GetFolderInfo($toFolder); $result &= $mailProcessor->MoveMessages($messageIdUidSet, $folder, $toFolder); break; case FILTERACTION_MarkGrey: $result &= $mailProcessor->SetFlags($messageIdUidSet, $folder, MESSAGEFLAGS_Grayed, ACTION_Set); break; } } } return $result; }
/** * @param int $messId * @param string $messUid * @param int $folderId * @param string $folderFullName * @param bool $isFull * @return GetMessageBase */ function GetMessageBase(&$account, $messId, $messUid, $folderId, $folderFullName, $charset, $isFull = false) { $this->messId = $messId; $this->messUid = $messUid; $this->folderId = $folderId; $this->folderFullName = $folderFullName; $this->charset = $charset; if (isset($_SESSION[ACCOUNT_ID])) { $this->accountId = $_SESSION[ACCOUNT_ID]; } if (!isset($_SESSION['attachtempdir'])) { $_SESSION['attachtempdir'] = md5(session_id()); } $this->account =& $account; $this->processor =& new MailProcessor($this->account); $this->folder =& new Folder($this->accountId, $folderId, $folderFullName); $this->processor->GetFolderInfo($this->folder); $msgIdUid = array(); if (!empty($messId) && !empty($messUid)) { $msgIdUid[$messId] = $messUid; } $this->processor->SetFlags($msgIdUid, $this->folder, MESSAGEFLAGS_Seen, ACTION_Set); if ($charset != -1) { $GLOBALS[MailInputCharset] = $charset; $charsetNum = ConvertUtils::GetCodePageNumber($charset); } else { $charsetNum = -1; } $this->msg =& $this->processor->GetMessage($messId, $messUid, $this->folder); if (!$this->msg) { return false; } if ($this->folder->SyncType != FOLDERSYNC_DirectMode && $this->processor->DbStorage->Connect()) { $this->processor->DbStorage->UpdateMessageCharset($messId, $charsetNum, $this->msg); } }
/** * @param XmlDomNode $_mNode * @param MailProcessor $_processor */ function ReplySetFlag(&$_mNode, &$_processor) { $_replyNode =& $_mNode->GetChildNodeByTagName('reply_message'); if ($_replyNode && isset($_replyNode->Attributes['action'])) { $_rFlag = null; switch ($_replyNode->Attributes['action']) { case 'reply': $_rFlag = MESSAGEFLAGS_Answered; break; case 'forward': $_rFlag = MESSAGEFLAGS_Forwarded; break; } if (null !== $_rFlag && isset($_replyNode->Attributes['id'])) { $_rId = (int) $_replyNode->Attributes['id']; $_rUid = $_replyNode->GetChildValueByTagName('uid', true); $_rFolderNode =& $_replyNode->GetChildNodeByTagName('folder'); if ($_rFolderNode && isset($_rFolderNode->Attributes['id'])) { $_rFolderId = (int) $_rFolderNode->Attributes['id']; $_rFolderFullName = $_rFolderNode->GetChildValueByTagName('full_name', true); $_processor->SetFlagFromReply($_rId, $_rUid, $_rFolderId, $_rFolderFullName, $_rFlag); } } } }
/** * @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); } }
$subjectString = $message->PrintSubject(true); $attachString = null; $textCharset = $message->msg->GetTextCharset(); $fullBodyText = $bodytype === 1 ? ConvertUtils::ReplaceJSMethod($message->PrintHtmlBody(true)) : $message->PrintPlainBody(); break; case MESSAGE_VIEW_TYPE_ATTACH: if ($tempNameFromGet) { $tempFiles =& CTempFiles::CreateInstance($account); $GLOBALS[MailDefaultCharset] = $account->GetDefaultIncCharset(); $GLOBALS[MailOutputCharset] = $account->GetUserCharset(); $message = $messageBody = null; if ($tempFiles->IsFileExist($tempNameFromGet)) { $messageBody = $tempFiles->LoadFile($tempNameFromGet); } else { if (isset($_GET['bsi'])) { $processor = new MailProcessor($account); $folder = new Folder($account->Id, $folder_id, $folder_name); $messageBody = $processor->GetBodyPartByIndex($_GET['bsi'], $mes_uid, $folder); $encode = 'base64'; if (isset($_GET['bse']) && strlen($messageBody) > 0) { $encode = ConvertUtils::GetBodyStructureEncodeString($_GET['bse']); $messageBody = ConvertUtils::DecodeBodyByType($messageBody, $encode); } $tempFiles->SaveFile($tempNameFromGet, $messageBody); } } if ($messageBody) { $message = new WebMailMessage(); $message->LoadMessageFromRawBody($messageBody, true); } if ($message) {
$foldersForInboxSynchronize->Add($inboxFolder); if (!$processor->Synchronize($foldersForInboxSynchronize)) { $errorDesc = getGlobalError(); } $processor->MailStorage->Disconnect(); } else { $errorDesc = ''; } $errorDesc = trim($errorDesc); echo '<script> parent.SetUpdatedFolders(' . Folders4UpdateToJsArray() . ', false); parent.EndCheckMailHandler("' . ConvertUtils::ClearJavaScriptString($errorDesc, '"') . '"); </script>' . CRLF; } else { ShowLoggingToServer(); $processor = new MailProcessor($account); $folders =& $processor->GetFolders(); $processor->MailStorage->DownloadedMessagesHandler = 'ShowDownloadedMessageNumber'; $processor->MailStorage->UpdateFolderHandler = 'AddFolder4Update'; if (!$processor->Synchronize($folders)) { $errorDesc = getGlobalError(); } ShowLoggingOffFromServer(); $processor->MailStorage->Disconnect(); $errorDesc = trim($errorDesc); echo '<script> parent.SetUpdatedFolders(' . Folders4UpdateToJsArray() . '); parent.EndCheckMailHandler("' . ConvertUtils::ClearJavaScriptString($errorDesc, '"') . '"); </script>' . CRLF; } }
/** * @param Settings $_settings * @param MySqlStorage $_dbStorage * @param CWebMailLoginInfo $loginInfo * @param Account $refAccount * @param string $errorString */ function Init(&$_settings, &$_dbStorage, &$loginInfo, &$refAccount, &$errorString) { $accountCustomValues = array(); $_log =& CLog::CreateInstance(); $_isNoLoginField = false; $_sendSettingsList = false; /* custom class */ wm_Custom::StaticUseMethod('ChangeLoginInfoBeforeInit', array(&$loginInfo)); $_infoEmail = trim($loginInfo->getEmail()); $_infoLogin = trim($loginInfo->getLogin()); $_infoPassword = $loginInfo->getPassword(); $_infoAdvancedLogin = $loginInfo->getAdvancedLogin(); $_infoLang = trim($loginInfo->getLanguage()); $_domain = $loginInfo->getDomainsSelectValue(); $_email = $_login = $_optLogin = ''; if ($_infoAdvancedLogin && $_settings->AllowAdvancedLogin) { $_email = $_infoEmail; $_login = $_infoLogin; } else { switch ($_settings->HideLoginMode) { case 0: $_email = $_infoEmail; $_login = $_infoLogin; break; case 10: $_email = $_infoEmail; $_isNoLoginField = true; $_emailAddress = new EmailAddress(); $_emailAddress->SetAsString($_email); $_optLogin = $_emailAddress->GetAccountName(); break; case 11: $_email = $_infoEmail; $_isNoLoginField = true; $_optLogin = $_email; break; case 20: case 21: $_login = $_infoLogin; $loginArray = ConvertUtils::ParseEmail($_login); if (20 == $_settings->HideLoginMode) { if (is_array($loginArray) && 2 === count($loginArray)) { $_email = $_login; } else { $_email = $_login . '@'; $_email .= $_domain && $_settings->UseMultipleDomainsSelection ? $_domain : $_settings->DefaultDomainOptional; } } else { $_email = is_array($loginArray) && 2 === count($loginArray) ? $loginArray[0] . '@' : $_login . '@'; $_email .= $_domain && $_settings->UseMultipleDomainsSelection ? $_domain : $_settings->DefaultDomainOptional; } break; case 22: case 23: $loginArray = ConvertUtils::ParseEmail($_infoLogin); $_login = is_array($loginArray) && isset($loginArray[0]) ? $loginArray[0] . '@' : $_infoLogin . '@'; $_login .= $_domain && $_settings->UseMultipleDomainsSelection ? $_domain : $_settings->DefaultDomainOptional; $_email = $_login; } } /* custom class */ wm_Custom::StaticUseMethod('ChangeLoginDuringInit', array(&$_login, &$_email)); $bReturn = true; wm_Custom::StaticUseMethod('LdapCustomLoginFunction', array(&$_login, &$_email, &$_infoPassword, &$accountCustomValues, &$errorString, &$bReturn)); if (!$bReturn) { return false; } $_loginArray = null; if (USE_DB) { if ($_isNoLoginField) { $_loginArray =& Account::LoadFromDbOnlyByEmail($_email); if (is_array($_loginArray) && count($_loginArray) > 3) { $_eAccount =& Account::LoadFromDb((int) $_loginArray[0]); if ($_eAccount) { if ($_loginArray[5]) { $errorString = 'Your account is inactive, please contact the system administrator on this.'; return false; } $_login = ConvertUtils::DecodePassword($_loginArray[1], $_eAccount) == $_infoPassword ? $_loginArray[4] : $_optLogin; } else { $_login = $_optLogin; } } else { $_login = $_optLogin; } /* custom class */ wm_Custom::StaticUseMethod('ChangeLoginInfoAfterInit', array(&$_login, &$_email)); } else { /* custom class */ wm_Custom::StaticUseMethod('ChangeLoginInfoAfterInit', array(&$_login, &$_email)); $_loginArray =& Account::LoadFromDbByLogin($_email, $_login); if ($_loginArray[4]) { $errorString = 'Your account is inactive, please contact the system administrator on this.'; return false; } } } if (!$_dbStorage || !$_dbStorage->Connect()) { $_sendSettingsList = false; $errorString = getGlobalError(); return false; } if ($_loginArray === false) { $errorString = getGlobalError(); return false; } else { if ($_loginArray === null) { if ($_settings->AllowNewUsersRegister) { if (!NumOLCallBackFunction($_settings, $_dbStorage, $errorString)) { return false; } $_account = new Account(); $_account->DefaultAccount = true; $_account->Email = $_email; $_account->MailIncLogin = $_login; $_account->MailIncPassword = $_infoPassword; if (strlen($_infoLang) > 0) { $_account->DefaultLanguage = $_infoLang; } $_account->CustomValues = $accountCustomValues; if ($_infoAdvancedLogin && $_settings->AllowAdvancedLogin) { $_account->MailProtocol = $loginInfo->getMailProtocol(); $_account->MailIncPort = $loginInfo->getMailIncPort(); $_account->MailOutPort = $loginInfo->getMailOutPort(); $_account->MailOutAuthentication = $loginInfo->getMailOutAuth(); $_account->MailIncHost = $loginInfo->getMailIncHost(); $_account->MailOutHost = $loginInfo->getMailOutHost(); } else { $_account->MailProtocol = (int) $_settings->IncomingMailProtocol; $_account->MailIncPort = (int) $_settings->IncomingMailPort; $_account->MailOutPort = (int) $_settings->OutgoingMailPort; $_account->MailOutAuthentication = (bool) $_settings->ReqSmtpAuth; $_account->MailIncHost = $_settings->IncomingMailServer; $_account->MailOutHost = $_settings->OutgoingMailServer; } if (DEMOACCOUNTALLOW && $_email == DEMOACCOUNTEMAIL) { $_account->MailIncPassword = DEMOACCOUNTPASS; } /* custom class */ wm_Custom::StaticUseMethod('InitLdapSettingsAccountOnLogin', array(&$_account)); if (0 < strlen($_infoLang)) { $_account->DefaultLanguage = $_infoLang; } /* custom class */ wm_Custom::StaticUseMethod('ChangeAccountBeforeCreateOnLogin', array(&$_account)); if (USE_DB) { $_domain =& $_dbStorage->SelectDomainByName(EmailAddress::GetDomainFromEmail($_account->Email)); if (null !== $_domain) { $_domain->UpdateAccount($_account, $_settings); } } $_validate = $_account->ValidateData(); if ($_validate !== true) { $errorString = $_validate; return false; } else { if ($_account->IsInternal) { $errorString = ErrorPOP3IMAP4Auth; $_log->WriteLine('LOGIN Error: IsInternal = true', LOG_LEVEL_WARNING); return false; } $_processor = new MailProcessor($_account); if ($_processor->MailStorage->Connect(true)) { $_user =& User::CreateUser($_account); if ($_user && $_account) { if (!USE_DB) { $_account->Id = 1; } $_account->IdUser = $_user->Id; } $_inboxSyncType = $_account->GetDefaultFolderSync($_settings); if ($_user != null && $_user->CreateAccount($_account, $_inboxSyncType, false, $_processor->MailStorage)) { if ($_settings->EnableMobileSync && function_exists('mcrypt_encrypt')) { // create Funambol user for loginable user require_once WM_ROOTPATH . 'common/class_funambol_sync_users.php'; $fnSyncUsers = new FunambolSyncUsers($_account); $fnSyncUsers->PerformSync(); } $_SESSION[ACCOUNT_ID] = $_account->Id; $_SESSION[USER_ID] = $_account->IdUser; $_SESSION[SESSION_LANG] = $_account->DefaultLanguage; $_sendSettingsList = true; if (!USE_DB) { Account::SaveInSession($_account); } $_log->WriteEvent('User login', $_account); self::AfterLoginAction($_account, $_processor, $_settings); } else { if ($_user) { User::DeleteUserSettings($_user->Id); } $_error = getGlobalError(); $_error = strlen($_error) > 0 ? $_error : CantCreateUser; $errorString = $_error; return false; } } else { $errorString = getGlobalError(); return false; } } } else { $_log->WriteLine('LOGIN Error: AllowNewUsersRegister = false', LOG_LEVEL_WARNING); $errorString = ErrorPOP3IMAP4Auth; return false; } } else { if ($_loginArray[2] == 0) { $errorString = PROC_CANT_LOG_NONDEF; return false; } else { if (USE_DB) { $_newAccount =& Account::LoadFromDb($_loginArray[0]); if (!$_newAccount) { $errorString = getGlobalError(); return false; } else { $_deleted = $_dbStorage->GetAUserDeleted($_newAccount->IdUser); if (false === $_deleted) { $errorString = getGlobalError(); return false; } else { if (1 === $_deleted) { $errorString = ErrorMaximumUsersLicenseIsExceeded; return false; } } $_mailIncPass = $_infoPassword; if (DEMOACCOUNTALLOW && $_email == DEMOACCOUNTEMAIL) { $_mailIncPass = DEMOACCOUNTPASS; } $_useLangUpdate = false; if (strlen($_infoLang) > 0 && $_newAccount->DefaultLanguage != $_infoLang) { $_newAccount->DefaultLanguage = $_infoLang; $_useLangUpdate = true; } $_account = null; $bIsPasswordCorrect = ConvertUtils::DecodePassword($_loginArray[1], $_newAccount) == $_mailIncPass; $_account =& $_newAccount; $_account->MailIncPassword = $_mailIncPass; $_newprocessor = new MailProcessor($_account); if ($_newprocessor->MailStorage->Connect(true)) { if (!$bIsPasswordCorrect && !$_account->Update()) { return ErrorPOP3IMAP4Auth; } $_SESSION[ACCOUNT_ID] = $_account->Id; $_SESSION[USER_ID] = $_account->IdUser; $_SESSION[SESSION_LANG] = $_account->DefaultLanguage; $tempFiles =& CTempFiles::CreateInstance($_account); $tempFiles->ClearAccount(); unset($tempFiles); $_sendSettingsList = true; $_log->WriteEvent('User login', $_account); if ($_account->MailProtocol == MAILPROTOCOL_IMAP4 && $_account->ImapQuota === 1) { $quota = $_newprocessor->GetQuota(); if ($quota !== false && $quota !== $_account->MailboxLimit) { $_account->MailboxLimit = GetGoodBigInt($quota); $_account->UpdateMailBoxLimit(); } } self::AfterLoginAction($_account, $_newprocessor, $_settings); } else { $errorString = ErrorPOP3IMAP4Auth; return false; } } } } } } if ($_sendSettingsList && USE_DB) { if (!$_dbStorage->UpdateLastLoginAndLoginsCount($_account->IdUser)) { $_sendSettingsList = false; $errorString = getGlobalError(); return false; } } if (isset($_account)) { $refAccount = $_account; } return true; }
function ProcessDeleteAccountEnd($acctId, &$dbStorage) { $account = null; if ($dbStorage->Connect()) { $account =& $dbStorage->SelectAccountData($acctId); } if ($account) { $processor = new MailProcessor($account); return $processor->DeleteAccount(); } return false; }
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)); } } }
header('Cache-control: public'); if ($openMode == 'view') { require_once WM_ROOTPATH . 'common/class_mailprocessor.php'; $mes_id = isset($_GET['msg_id']) ? (int) $_GET['msg_id'] : -1; $mes_uid = isset($_GET['msg_uid']) ? $_GET['msg_uid'] : ''; $folder_id = isset($_GET['folder_id']) ? (int) $_GET['folder_id'] : -1; $folder_name = isset($_GET['folder_full_name']) ? $_GET['folder_full_name'] : ''; $mes_charset = isset($_GET['charset']) ? (int) $_GET['charset'] : -1; $msgSize = isset($_GET['size']) ? (int) $_GET['size'] : 0; $mode = isset($_GET['mode']) ? (int) $_GET['mode'] : 0; if ($mes_charset > 0) { $account->DefaultIncCharset = ConvertUtils::GetCodePageName($mes_charset); $GLOBALS[MailInputCharset] = $_account->DefaultIncCharset; $account->UpdateDefaultIncCharset(); } $processor = new MailProcessor($account); $folder = null; if (!empty($folder_id) && !empty($folder_name)) { $folder = new Folder($account->Id, $folder_id, $folder_name); $processor->GetFolderInfo($folder); if (!$folder || $folder->IdDb < 1) { ///!!!! } } else { ///!!!! } $msgIdUid = array($mes_id => $mes_uid); $_messageInfo = new CMessageInfo(); $_messageInfo->SetInfo($mes_id, $mes_uid, $folder->IdDb, $folder->FullName); $modeForGet = $mode; if (empty($msgSize) || (int) $msgSize < BODYSTRUCTURE_MGSSIZE_LIMIT || $folder && FOLDERTYPE_Drafts == $folder->Type || (($mode & 8) == 8 || ($mode & 16) == 16 || ($mode & 32) == 32 || ($mode & 64) == 64)) {
/** * @param PageBuilder $pagebuilder * @return SettingsAccount */ function SettingsAccount(&$pagebuilder) { $this->_pagebuilder =& $pagebuilder; $this->_proc =& $pagebuilder->_proc; $screen = $this->_proc->sArray[SCREEN]; if ($this->_proc->sArray[EDIT_ACCOUNT_ID] != $this->_proc->account->Id) { if (array_key_exists($this->_proc->sArray[EDIT_ACCOUNT_ID], $this->_proc->accounts)) { $this->_editAccount =& Account::LoadFromDb($this->_proc->sArray[EDIT_ACCOUNT_ID]); $this->_editProccessor =& new MailProcessor($this->_editAccount); $this->_editFolders =& $this->_editProccessor->GetFolders(); } else { $this->_editAccount =& $this->_proc->account; $this->_editProccessor =& $this->_proc->processor; $this->_editFolders =& $this->_proc->GetFolders(); } } else { $this->_editAccount =& $this->_proc->account; $this->_editProccessor =& $this->_proc->processor; $this->_editFolders =& $this->_proc->GetFolders(); } $this->data['allowNewAccount'] = !$this->_proc->settings->AllowUsersAddNewAccounts || !$this->_editAccount->AllowChangeSettings ? '' : ' <input type="button" value="' . JS_LANG_AddNewAccount . '" onclick="document.location=\'' . BASEFILE . '?' . SCREEN . '=' . SET_ACCOUNT_ADDACC . '\';" class="wm_button" ID="Button4" NAME="Button2"/>'; $this->data['accountsTable'] = ''; $accounts =& $this->_proc->GetAccounts(); foreach ($accounts as $keyid => $value) { $isCurrent = $keyid == $this->_editAccount->Id; $class = $isCurrent ? ' class="wm_settings_list_select"' : ' class="wm_control"'; $name = $isCurrent ? '<b>' . $value[4] . '</b>' : $value[4]; //$name .= ($value[6]) ? ' (default)' : ''; $onclick = $isCurrent ? '' : ' onclick="document.location=\'' . BASEFILE . '?' . EDIT_ACCOUNT_ID . '=' . $keyid . '\';"'; $deleteHref = $this->_proc->account->IsDemo ? '<a href="#" onclick="return DoAlert();">' . JS_LANG_Delete . '</a>' : '<a href="' . ACTIONFILE . '?action=delete&req=account&acctid=' . $keyid . '" onclick="return confirm(\'' . ConfirmDeleteAccount . '\');">' . JS_LANG_Delete . '</a>'; $deleteHref = $this->_editAccount->AllowChangeSettings ? $deleteHref : ''; $this->data['accountsTable'] .= ' <tr' . $class . '> <td' . $onclick . '>' . $name . '</td> <td style="width: 10px;">' . $deleteHref . '</td> </tr>'; } if ($screen == SET_ACCOUNT_ADDACC && !$this->_proc->settings->AllowUsersAddNewAccounts) { $screen = SET_ACCOUNT_PROF; } $this->_main =& new SettingsAccountForms($screen, $this); $this->data['tabSwitcher'] = ''; if ($screen != SET_ACCOUNT_ADDACC) { $this->data['tabSwitcher'] .= ' <div class="wm_settings_accounts_info"> <div class="wm_settings_switcher_indent"></div>'; $this->data['tabSwitcher'] .= $screen == SET_ACCOUNT_MFOLDERS ? '<div class="wm_settings_switcher_select_item">' . JS_LANG_ManageFolders . '</div>' : '<div class="wm_settings_switcher_item"><a href="' . BASEFILE . '?' . SCREEN . '=' . SET_ACCOUNT_MFOLDERS . '">' . JS_LANG_ManageFolders . '</a></div>'; $this->data['tabSwitcher'] .= $screen == SET_ACCOUNT_SIGNATURE ? '<div class="wm_settings_switcher_select_item">' . JS_LANG_Signature . '</div>' : '<div class="wm_settings_switcher_item"><a href="' . BASEFILE . '?' . SCREEN . '=' . SET_ACCOUNT_SIGNATURE . '">' . JS_LANG_Signature . '</a></div>'; $this->data['tabSwitcher'] .= $screen == SET_ACCOUNT_FILTERS ? '<div class="wm_settings_switcher_select_item"> ' . JS_LANG_Filters . ' </div>' : '<div class="wm_settings_switcher_item"> <a href="' . BASEFILE . '?' . SCREEN . '=' . SET_ACCOUNT_FILTERS . '">' . JS_LANG_Filters . '</a> </div>'; if ($this->_editAccount->AllowChangeSettings) { $this->data['tabSwitcher'] .= $screen == SET_ACCOUNT_PROF ? '<div class="wm_settings_switcher_select_item">' . JS_LANG_Properties . '</div>' : '<div class="wm_settings_switcher_item"><a href="' . BASEFILE . '?' . SCREEN . '=' . SET_ACCOUNT_PROF . '">' . JS_LANG_Properties . '</a></div>'; } $this->data['tabSwitcher'] .= '</div>'; } }
/** * @param int $idAcct * @return bool */ protected function _DeleteAccount($idAcct) { require_once WM_ROOTPATH . 'common/class_mailprocessor.php'; require_once WM_ROOTPATH . 'common/class_account.php'; require_once WM_ROOTPATH . 'common/class_dbstorage.php'; $settings =& Settings::CreateInstance(); if (!$settings || !$settings->isLoad) { throw new WebMailModelException('settings error'); } if (!$settings->IncludeLang()) { throw new WebMailModelException('lang error'); } $account = null; $dbStorage =& DbStorageCreator::CreateDatabaseStorage($account, $settings); if ($dbStorage->Connect()) { $account =& $dbStorage->SelectAccountData($idAcct); } if ($account) { $processor = new MailProcessor($account); if ($processor->DeleteAccount()) { return true; } } throw new WebMailModelException('Can\'t delete account'); }
$account =& Account::LoadFromDb($_SESSION[ACCOUNT_ID]); if (!$account) { exit; } $data = ''; if (isset($_GET['msg_id'], $_GET['msg_uid'], $_GET['folder_id'], $_GET['folder_fname'])) { $folder = new Folder($_SESSION[ACCOUNT_ID], $_GET['folder_id'], $_GET['folder_fname']); $dbStorage =& DbStorageCreator::CreateDatabaseStorage($account); if (USE_DB && $dbStorage->Connect()) { $dbStorage->GetFolderInfo($folder); } else { if (!USE_DB) { $folder->SyncType = FOLDERSYNC_DirectMode; } } $processor = new MailProcessor($account); if (isset($_GET['bsi'], $_GET['tn'])) { $tempName = ConvertUtils::ClearFileName($_GET['tn']); $tempFiles =& CTempFiles::CreateInstance($account); if ($tempFiles->IsFileExist($tempName)) { $data = $tempFiles->LoadFile($tempName); } else { $data = $processor->GetBodyPartByIndex($_GET['bsi'], $_GET['msg_uid'], $folder); $encode = 'none'; if (isset($_GET['bse']) && strlen($data) > 0) { $encode = ConvertUtils::GetBodyStructureEncodeString($_GET['bse']); $data = ConvertUtils::DecodeBodyByType($data, $encode); } $tempFiles->SaveFile($tempName, $data); } AddAttachmentHeaders($account->GetUserCharset(), $tempName);