/** * @access public * @param string $host[optional] = null * @return CWmServerConsole */ function CWmServerConsole($host = null) { $this->Settings =& WMSettings::CreateInstance(); $this->_admHost = $host !== null ? $host : $this->Settings->Settings->WmServerHost; $this->_admPort = $this->Settings->AdminPort; $this->_admLogin = $this->Settings->AdminLogin; $this->_admPassword = $this->Settings->AdminPassword; $this->_log =& CLog::CreateInstance(); if (!$this->Settings->IsLoad) { $this->_setError(str_replace('\\', '/', getGlobalError())); } }
/** * @access private * @param resource $link * @param CLog $log * @return bool */ function IsSuccess(&$link, &$log, &$out, $isLog = true) { $out = ''; $line = ''; $result = true; do { $line = @fgets($link, 1024); if ($isLog) { $log->WriteLine('[SMTP] <<: ' . trim($line)); } if ($line === false) { $result = false; setGlobalError('[SMTP] Error: IsSuccess fgets error'); break; } else { $out .= $line; $line = str_replace("\r", '', str_replace("\n", '', str_replace(CRLF, '', $line))); if (substr($line, 0, 1) != '2' && substr($line, 0, 1) != '3') { $result = false; $error = '[SMTP] Error <<: ' . $line; setGlobalError($error); //setGlobalError(substr($line, 3)); break; } } } while (substr($line, 3, 1) == '-'); if (!$result && $log->Enabled) { $log->WriteLine(getGlobalError(), LOG_LEVEL_ERROR); } return $result; }
$error = isset($GLOBALS[ErrorDesc]) ? '<b>ERROR:</b> ' . getGlobalError() : ''; $nextButton = '<input type="button" value="Close" style="font-weight: bold" disabled="disabled"/>'; $bodyText = ' <h1>Step 2</h1><br /> <font color="red"><b>Warning!</b></font><br /> When creating index, an error in database occured!' . $error; } } elseif ($is_good && strlen($is_good) > 0) { $error = isset($GLOBALS[ErrorDesc]) ? '<b>ERROR:</b> ' . getGlobalError() : ''; $nextButton = '<input type="button" value="Close" style="font-weight: bold" disabled="disabled"/>'; $bodyText = ' <h1>Step 2</h1><br /> <font color="red"><b>Warning!</b></font><br /> When creating the table (<b>' . $is_good . '</b>) , an error in database occured!' . $error; } else { $error = isset($GLOBALS[ErrorDesc]) ? '<b>ERROR:</b> ' . getGlobalError() : ''; $nextButton = '<input type="button" value="Close" style="font-weight: bold" disabled="disabled"/>'; $bodyText = ' <h1>Step 2</h1><br /> <font color="red"><b>Warning!</b></font><br /> When creating the table, an error in database occured!<br />' . $error; } break; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" /> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>MailBee WebMail Pro</title> </head>
<?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(ConvertUtils::ClearUtf8($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']); if (!$fs->SaveAttach($attachment, $attfolder, $tempname)) { $log->WriteLine('Save temp Attachment error: ' . getGlobalError()); } $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) { echo '<a href="#" onclick="PrevImg(\'view-image.php?tn=' . urlencode($tempname) . '\')">View</a>'; }
/** * @return string */ function getError() { return isset($GLOBALS[ErrorDesc]) ? '<br /><font color="red">' . ConvertUtils::WMHtmlSpecialChars(getGlobalError()) . '</font>' : ''; }
/** * @param obj $dbStorage * @param obj $settings * @param string $tableName * @param int $number */ function CreateTableOnUpdate(&$dbStorage, &$settings, $tableName, $number) { global $UpdateIsGood; echo '<font color="black" sise="3" face="verdana"><br /><b>' . $number . '</b>. Start create <b>' . $settings->DbPrefix . $tableName . '</b> table: <br />'; if (!$dbStorage->IsTableExist($settings->DbPrefix, $tableName)) { if ($dbStorage->CreateOneTable($settings->DbPrefix, $tableName)) { echo '<font color="green"> - ' . $settings->DbPrefix . $tableName . ' create successful</font><br />'; } else { $error = isset($GLOBALS[ErrorDesc]) ? '<br /><b>ERROR:</b> ' . getGlobalError() : ''; echo '<font color="red"> - ' . $settings->DbPrefix . $tableName . ' don\'t create' . $error . '</font><br />'; $UpdateIsGood = false; } } else { echo '<font color="grey"> - ' . $settings->DbPrefix . $tableName . ' already exist</font><br />'; } }
/** * @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; }
/** * @param XmlDomNode $_xmlRes * @param Account $_account * @param int $_lastId * @param int $_currId */ function GetAccountList($_dbStorage, &$_xmlRes, $_account, $_lastId, $_currId = '') { $_currId = $_currId ? $_currId : $_account->Id; if ($_dbStorage->Connect()) { $_accounts = null; if (USE_DB) { $_accounts =& $_dbStorage->SelectAccounts($_account->IdUser); } else { $_accounts = array($_account->Id => array()); } if (null !== $_accounts) { $_acctsNode = new XmlDomNode('accounts'); $_acctsNode->AppendAttribute('last_id', $_lastId); $_acctsNode->AppendAttribute('curr_id', $_currId); foreach ($_accounts as $_acct_id => $_acctArray) { $_f_account = Account::LoadFromDb($_acct_id, true, false); CXmlProcessing::GetAccount($_acctsNode, $_f_account, $_dbStorage); unset($_f_account); } $_xmlRes->XmlRoot->AppendChild($_acctsNode); } else { CXmlProcessing::PrintErrorAndExit(PROC_CANT_GET_ACCT_LIST, $_xmlRes); } } else { CXmlProcessing::PrintErrorAndExit(getGlobalError(), $_xmlRes); } }
/** * @param string $email * @return int */ protected function _CheckCountOfUserAccounts($email) { 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'); } $acct = null; $dbStorage =& DbStorageCreator::CreateDatabaseStorage($acct, $settings); if ($dbStorage->Connect()) { return $dbStorage->CheckCountOfUserAccounts($email); } throw new WebMailModelException(getGlobalError()); }
function DoSaveMessage() { $_dbStorage = $_settings = $_xmlObj = $_xmlRes = $_accountId = null; $this->_initFuncArgs($_dbStorage, $_settings, $_xmlObj, $_xmlRes, $_accountId); $_account =& CXmlProcessing::AccountCheckAndLoad($_xmlRes, $_accountId, false, false); $_message =& CXmlProcessing::CreateMessage($_account, $_xmlObj, $_xmlRes); /* suggestion */ $_mNode =& $_xmlObj->XmlRoot->GetChildNodeByTagName('message'); $_hNode =& $_mNode->GetChildNodeByTagName('headers'); $_gNode =& $_hNode->GetChildNodeByTagName('groups'); $_toNode =& $_hNode->GetChildNodeByTagName('to'); $_ccNode =& $_hNode->GetChildNodeByTagName('cc'); $_bccNode =& $_hNode->GetChildNodeByTagName('bcc'); $_emailsString = ''; $_gids = array(); if ($_gNode != null) { $_gKeys = array_keys($_gNode->Children); foreach ($_gKeys as $_key) { $_oneGNode =& $_gNode->Children[$_key]; $_gids[] = isset($_oneGNode->Attributes['id']) ? (int) $_oneGNode->Attributes['id'] : -1; unset($_oneGNode); } } $_result = true; $_processor = new MailProcessor($_account); if (!$_processor->DbStorage->Connect()) { CXmlProcessing::PrintErrorAndExit(getGlobalError(), $_xmlRes); } /* reply */ CXmlProcessing::ReplySetFlag($_mNode, $_processor); /* update group frequency */ $_processor->DbStorage->UpdateGroupsFrequency($_gids); $_folders =& $_processor->GetFolders(); $_folder =& $_folders->GetFolderByType(FOLDERTYPE_Drafts); $_from =& $_message->GetFrom(); $_message->OriginalMailMessage = $_message->ToMailString(); $_message->Flags |= MESSAGEFLAGS_Seen; $_messageIdUidSet = array(); $_messageIdUidSet[$_message->IdMsg] = $_message->Uid; $_messageIdSet = null; $_isFromDrafts = $_message->IdMsg != -1; if ($_isFromDrafts) { $_messageIdSet = array($_message->IdMsg); } if ($_result) { $_result = $_isFromDrafts ? $_processor->UpdateMessage($_message, $_folder) : $_processor->SaveMessage($_message, $_folder); $_messageIdUidSet[$_message->IdMsg] = $_message->Uid; if ($_result) { if ($_processor->SetFlags($_messageIdUidSet, $_folder, MESSAGEFLAGS_Seen, ACTION_Set)) { //if ($_messageIdSet !== null && $_account->MailProtocol == MAILPROTOCOL_IMAP4) //{ // if ($_processor->PurgeFolder($_folder) && USE_DB) // { // $_processor->DbStorage->DeleteMessages($_messageIdSet, false, $_folder); // } //} } } if (USE_DB) { $_processor->DbStorage->UpdateMailboxSize(); } } else { $_result = false; } if ($_result) { $_updateNode = new XmlDomNode('update'); $_updateNode->AppendAttribute('value', 'save_message'); if ($_message) { $_updateNode->AppendAttribute('id', $_message->IdMsg); $_uidNode = new XmlDomNode('uid', $_message->Uid, true); $_updateNode->AppendChild($_uidNode); } $_xmlRes->XmlRoot->AppendChild($_updateNode); } else { CXmlProcessing::PrintErrorAndExit(PROC_CANT_SAVE_MSG, $_xmlRes); } }
/** * @access private * @param resource $link * @param CLog $log * @return bool */ function IsSuccess(&$link, &$log) { $result = true; do { $line = @fgets($link, 1024); if ($line === false) { $result = false; setGlobalError('SMTP IsSuccess fgets error'); break; } else { $line = str_replace("\r", '', str_replace("\n", '', str_replace(CRLF, '', $line))); if (substr($line, 0, 1) != '2' && substr($line, 0, 1) != '3') { $result = false; $error = '[SMTP] Error <<: ' . $line; setGlobalError($error); break; } } } while (substr($line, 3, 1) == '-'); if (!$result) { $log->WriteLine(getGlobalError()); } return $result; }
require_once WM_ROOTPATH . 'common/class_settings.php'; require_once WM_ROOTPATH . 'common/class_account.php'; require_once WM_ROOTPATH . 'common/class_log.php'; require_once WM_ROOTPATH . 'common/class_convertutils.php'; require_once WM_ROOTPATH . 'common/class_tempfiles.php'; ConvertUtils::SetLimits(); $log =& CLog::CreateInstance(); @ob_start(); $settings =& Settings::CreateInstance(); if (!$settings || !$settings->isLoad) { $Error_Desc = 'Can\'t Load Settings file'; } else { if (!$settings->IncludeLang()) { $Error_Desc = 'Can\'t Load Language file'; } else { $Error_Desc = getGlobalError(); } } $account = null; $tempFiles = null; if (!isset($_SESSION[ACCOUNT_ID])) { $Error_Desc = UnknownUploadError; } if (empty($Error_Desc)) { $account =& Account::LoadFromDb($_SESSION[ACCOUNT_ID]); if ($account) { $tempFiles =& CTempFiles::CreateInstance($account); } else { $Error_Desc = UnknownUploadError; } }
_localPrintErrorAndExit('', $_xmlResponse, 3); } $_action = $_xmlRequest->GetParamValueByName('action'); $_request = $_xmlRequest->GetParamValueByName('request'); $BackgroundXmlParam = (int) $_xmlRequest->GetParamValueByName('background'); if (!isset($_SESSION[ACCOUNT_ID]) && $_action != 'login' && $_action != 'registration' && $_action != 'resetpassword') { $_xmlResponse->XmlRoot->AppendChild(new XmlDomNode('session_error')); _localPrintXML($_xmlResponse, $_startTime); } $_accountId = isset($_SESSION[ACCOUNT_ID]) ? $_SESSION[ACCOUNT_ID] : null; if (!$_settings->IncludeLang()) { _localPrintErrorAndExit('', $_xmlResponse, 6); } $_dbStorage =& DbStorageCreator::CreateDatabaseStorage($_null); if (!$_dbStorage || !$_dbStorage->Connect()) { _localPrintErrorAndExit(getGlobalError(), $_xmlResponse); } $_args = array('_dbStorage' => &$_dbStorage, '_settings' => &$_settings, '_xmlRequest' => &$_xmlRequest, '_xmlResponse' => &$_xmlResponse, '_accountId' => $_accountId); if (CProcessingSwitch::UseMethod($_action, $_request, $_args)) { _localPrintXML($_xmlResponse, $_startTime); } else { _localPrintErrorAndExit(WebMailException, $_xmlResponse); } function _localPrintErrorAndExit($_errorString, &$_xmlObj, $_code = null) { CXmlProcessing::PrintErrorAndExit($_errorString, $_xmlObj, $_code); } function _localPrintXML(&$_xmlRes, $_startTime) { CXmlProcessing::PrintXML($_xmlRes, $_startTime); }
/** * @param string $string */ function SetError($string = null) { $this->_errorMessage = $string ? $string : getGlobalError(); }
$Account->DefaultOutCharset = $DefaultOutCharset; $Account->DefaultTimeZone = $DefaultTimeZone; $Account->ViewMode = $ViewMode; $Account->DefaultSkin = $DefaultSkin; $Account->DefaultLanguage = $DefaultLanguage; $Account->DefaultDateFormat = $AcctDateFormat; $Account->DefaultTimeFormat = $AcctTimeFormat; } $validate = $Account->ValidateData(); if ($validate !== true) { SetError(PROC_CANT_UPDATE_ACCT . ': ' . $validate); } elseif ($Account->Update(null)) { SetReport(ReportSettingsUpdatedSuccessfuly); $_SESSION[SESSION_LANG] = $DefaultLanguage; } else { SetError(PROC_CANT_UPDATE_ACCT . ': ' . getGlobalError()); } header('Location: ' . BASEFILE); break; default: case 'none': header('Location: ' . BASEFILE . '?' . SCREEN . '=' . SCREEN_MAILBOX); break; } break; default: case 'none': header('Location: ' . BASEFILE . '?' . SCREEN . '=' . SCREEN_MAILBOX); break; } /**
/** * @param Account $account * @param XmlDocument $xmlObj * @return WebMailMessage */ function &CreateMessage(&$account, &$xmlObj) { global $log; $messageNode =& $xmlObj->XmlRoot->GetChildNodeByTagName('message'); $headersNode =& $messageNode->GetChildNodeByTagName('headers'); $message =& new WebMailMessage(); $GLOBALS[MailDefaultCharset] = $account->GetUserCharset(); $GLOBALS[MailInputCharset] = $account->GetUserCharset(); $GLOBALS[MailOutputCharset] = $account->GetDefaultOutCharset(); $message->Headers->SetHeaderByName(MIMEConst_MimeVersion, '1.0'); $message->Headers->SetHeaderByName(MIMEConst_XMailer, 'MailBee WebMail Pro PHP'); $message->Headers->SetHeaderByName(MIMEConst_XOriginatingIp, isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0'); $message->IdMsg = $messageNode->GetAttribute('id', -1); $message->SetPriority($messageNode->GetAttribute('priority', 3)); $message->Uid = $messageNode->GetChildValueByTagName('uid'); $serverAddr = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['SERVER_NAME'] : 'cantgetservername'; $message->Headers->SetHeaderByName(MIMEConst_MessageID, '<' . substr(session_id(), 0, 7) . '.' . md5(time()) . '@' . $serverAddr . '>'); $temp = $headersNode->GetChildValueByTagName('from'); if ($temp) { $message->SetFromAsString(ConvertUtils::WMBackHtmlSpecialChars($temp)); } $temp = $headersNode->GetChildValueByTagName('to'); if ($temp) { $message->SetToAsString(ConvertUtils::WMBackHtmlSpecialChars($temp)); } $temp = $headersNode->GetChildValueByTagName('cc'); if ($temp) { $message->SetCcAsString(ConvertUtils::WMBackHtmlSpecialChars($temp)); } $temp = $headersNode->GetChildValueByTagName('bcc'); if ($temp) { $message->SetBccAsString(ConvertUtils::WMBackHtmlSpecialChars($temp)); } $message->SetSubject(ConvertUtils::WMBackHtmlSpecialChars($headersNode->GetChildValueByTagName('subject'))); $message->SetDate(new CDateTime(time())); $bodyNode =& $messageNode->GetChildNodeByTagName('body'); if ($bodyNode->Attributes['is_html']) { $message->TextBodies->HtmlTextBodyPart = str_replace("\n", CRLF, str_replace("\r", '', ConvertUtils::WMBackHtmlNewCode($bodyNode->Value))); } else { $message->TextBodies->PlainTextBodyPart = str_replace("\n", CRLF, str_replace("\r", '', ConvertUtils::WMBackHtmlNewCode($bodyNode->Value))); } $attachmentsNode =& $messageNode->GetChildNodeByTagName('attachments'); if ($attachmentsNode != null) { $fs =& new FileSystem(INI_DIR . '/temp', $account->Email, $account->Id); $attfolder =& new Folder($_SESSION[ACCOUNT_ID], -1, $_SESSION['attachtempdir']); foreach (array_keys($attachmentsNode->Children) as $key) { $attachNode =& $attachmentsNode->Children[$key]; $attachCid = 'attach.php?tn=' . $attachNode->GetChildValueByTagName('temp_name'); $replaceCid = md5(time() . $attachNode->GetChildValueByTagName('name')); $mime_type = $attachNode->GetChildValueByTagName('mime_type'); if ($mime_type == '') { $mime_type = ConvertUtils::GetContentTypeFromFileName($attachNode->GetChildValueByTagName('name')); } if (!$message->Attachments->AddFromFile($fs->GetFolderFullPath($attfolder) . '/' . $attachNode->GetChildValueByTagName('temp_name'), $attachNode->GetChildValueByTagName('name'), $mime_type, (bool) $attachNode->Attributes['inline'])) { $log->WriteLine('Error Get tempfile for Attachment: ' . getGlobalError()); } if ($bodyNode->Attributes['is_html']) { if (strpos($message->TextBodies->HtmlTextBodyPart, $attachCid) !== false) { $attachment =& $message->Attachments->GetLast(); $attachment->MimePart->Headers->SetHeaderByName(MIMEConst_ContentID, '<' . $replaceCid . '>'); $message->TextBodies->HtmlTextBodyPart = str_replace($attachCid, 'cid:' . $replaceCid, $message->TextBodies->HtmlTextBodyPart); $attachname = ConvertUtils::EncodeHeaderString($attachNode->GetChildValueByTagName('name'), $account->GetUserCharset(), $GLOBALS[MailOutputCharset]); $attachment->MimePart->Headers->SetHeaderByName(MIMEConst_ContentDisposition, MIMEConst_InlineLower . ';' . CRLF . "\t" . MIMEConst_FilenameLower . '="' . $attachname . '"', false); } } } } return $message; }
/** * @param PageBuilder $pagebuilder * @return ContactsList */ function ContactsList(&$pagebuilder) { if (!defined('WM_ROOTPATH')) { define('WM_ROOTPATH', dirname(__FILE__) . '/../'); } require_once WM_ROOTPATH . 'class_contacts.php'; $this->_pagebuilder =& $pagebuilder; $this->_proc =& $pagebuilder->_proc; $this->_pagebuilder->AddJSFile('./classic/base.cpageswitcher.js'); $this->_pagebuilder->AddJSText(' var selection; function MailGroup(id) { var form = CreateChildWithAttrs(document.body, "form", [["method", "POST"]]); form.action = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_NEWOREDIT . '"; CreateChildWithAttrs(form, "input", [["type", "hidden"], ["name", "groupid"], ["value", id]]); form.submit(); } function DoDeleteButton() { var i, hideinput, count; var obj = GetSelectedData(); count = obj.contacts.length + obj.groups.length; if (count && count > 0) { if (!confirm(Lang.ConfirmAreYouSure)) { return false; } var form = CreateChildWithAttrs(document.body, "form", [["action", "' . ACTIONFILE . '?action=delete&req=contacts"], ["method", "POST"]]); count = obj.groups.length; for(i = 0; i < count; i++) { hideinput = CreateChildWithAttrs(form, "input", [["type", "hidden"]]); hideinput.name = "groups[" + obj.groups[i] + "]"; } count = obj.contacts.length; for(i = 0; i < count; i++) { hideinput = CreateChildWithAttrs(form, "input", [["type", "hidden"]]); hideinput.name = "contacts[" + obj.contacts[i] + "]"; } form.submit(); } } function AddContactsToGroup(groupid, groupname) { var obj = GetSelectedData(); count = obj.contacts.length; if (count && count > 0) { var form = CreateChild(document.body, "form"); form.action = "' . ACTIONFILE . '?action=move&req=contacts"; form.method = "POST"; hideinput = CreateChildWithAttrs(form, "input", [["type", "hidden"]]); hideinput.name = "groupId"; hideinput.value = groupid; hideinput2 = CreateChildWithAttrs(form, "input", [["type", "hidden"]]); hideinput2.name = "groupName"; hideinput2.value = groupname; for(i = 0; i < count; i++) { hideinput = CreateChildWithAttrs(form, "input", [["type", "hidden"]]); hideinput.name = "contacts[" + obj.contacts[i] + "]"; } form.submit(); } } function DoNewMessageButton(contactId) { if (contactId) { var cid = ParseCId(contactId); if (cid && cid.type == "c") { var form = CreateChild(document.body, "form"); form.action = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_NEWOREDIT . '"; form.method = "POST"; hideinput = CreateChildWithAttrs(form, "input", [["type", "hidden"]]); hideinput.name = "contacts[" + cid.cid + "]"; form.submit(); } return true; } else { var obj = GetSelectedData(true); count = obj.contacts.length; if (count && count > 0) { var form = CreateChild(document.body, "form"); form.action = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_NEWOREDIT . '"; form.method = "POST"; for(i = 0; i < count; i++) { hideinput = CreateChildWithAttrs(form, "input", [["type", "hidden"]]); hideinput.name = "contacts[" + obj.contacts[i] + "]"; } form.submit(); } else { document.location = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_NEWOREDIT . '"; } } } function GetSelectedData(param) { if (!param) { param = false; } var groups = Array(); var contacts = Array(); var ch_array = selection.GetCheckedLines(); if (!ch_array) return false; var count = ch_array.length; if (count < 1 && !param) { alert(Lang.AlertNoContactsGroupsSelected); } for (var i = 0; i < count; i++) { var record = ParseCId(ch_array[i]); if (record && record.type == "g") { groups.push(record.cid); } else { contacts.push(record.cid); } } return {groups: groups, contacts: contacts} } '); $pageNumber = isset($this->_proc->sArray[CONTACT_PAGE]) ? $this->_proc->sArray[CONTACT_PAGE] : 1; $sortField = isset($this->_proc->sArray[CONTACT_FLD]) ? $this->_proc->sArray[CONTACT_FLD] : 1; $sortOrder = isset($this->_proc->sArray[CONTACT_ORD]) ? $this->_proc->sArray[CONTACT_ORD] : 1; $backOrder = (int) (!(bool) $sortOrder); if (isset($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) && strlen($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) > 0) { $GLOBALS['contactCount'] = $this->_proc->db->SelectAddressContactsAndGroupsCount(0, $this->_proc->account->IdUser, $this->_proc->sArray[SEARCH_ARRAY][S_TEXT], $this->_proc->sArray[CONTACT_ID]); $contacts =& $this->_proc->db->SearchContactsAndGroups($pageNumber, $this->_proc->sArray[SEARCH_ARRAY][S_TEXT], $this->_proc->sArray[CONTACT_ID], $sortField, $sortOrder, 0); if ($contacts == null) { SetOnlineError(getGlobalError()); } } else { $GLOBALS['contactCount'] = $this->_proc->db->SelectAddressContactsAndGroupsCount(0, $this->_proc->account->IdUser); $contacts =& $this->_proc->db->LoadContactsAndGroups($pageNumber, $sortField, $sortOrder); if ($contacts == null) { SetOnlineError(getGlobalError()); } } if (!$contacts || $contacts->Count() < 1) { if ($pageNumber != 1) { $pageNumber = floor(($GLOBALS['contactCount'][0] + $GLOBALS['contactCount'][1]) / $this->_proc->account->ContactsPerPage); $pageNumber = $pageNumber < 1 ? 1 : $pageNumber; $contacts = $this->_proc->db->LoadContactsAndGroups($pageNumber, $sortField, $sortOrder); } } $this->_pagebuilder->AddInitText(' PageSwitcher = new CPageSwitcher("' . $this->_pagebuilder->SkinName() . '"); PageSwitcher.Build(); PageSwitcher.Show(' . $pageNumber . ', ' . $this->_proc->account->ContactsPerPage . ', ' . ($GLOBALS['contactCount'][0] + $GLOBALS['contactCount'][1]) . ', "document.location = \'?' . CONTACT_PAGE . '=", "\';"); CContactsList = new CContactsList(); '); $imgArray = array(' ', '', ''); $imgArray[$sortField] = $sortOrder == 0 ? ' <img src="./skins/' . $this->_pagebuilder->SkinName() . '/menu/order_arrow_down.gif">' : ' <img src="./skins/' . $this->_pagebuilder->SkinName() . '/menu/order_arrow_up.gif">'; $this->text = ' <div id="contacts" class="wm_contacts_list"> <div class = "wm_contact_list_div" id="contact_list_div"> <div class="wm_inbox_headers" id="contact_list_headers"> <div style="left: 0px; width: 22px;" ><input type="checkbox" id="allcheck"></div> <div style="left: 23px; width: 1px;" class="wm_inbox_headers_separate_noresize"></div> <div class="wm_control" style="left: 25px; width: 22px;" onclick="document.location=\'' . BASEFILE . '?' . CONTACT_ORD . '=' . $backOrder . '&' . CONTACT_FLD . '=0\'" > ' . $imgArray[0] . ' </div> <div style="left: 48px; width: 1px;" class="wm_inbox_headers_separate_noresize"></div> <div style="left: 50px; width: 138px;" class="wm_inbox_headers_from_subject wm_control" onclick="document.location=\'' . BASEFILE . '?' . CONTACT_ORD . '=' . $backOrder . '&' . CONTACT_FLD . '=1\'" > ' . JS_LANG_Name . ' ' . $imgArray[1] . ' </div> <div style="left: 188px; width: 1px;" class="wm_inbox_headers_separate_noresize"></div> <div style="left: 190px; width: 138px;" class="wm_inbox_headers_from_subject wm_control" onclick="document.location=\'' . BASEFILE . '?' . CONTACT_ORD . '=' . $backOrder . '&' . CONTACT_FLD . '=2\'" > ' . JS_LANG_Email . ' ' . $imgArray[2] . ' </div> </div> <div class="wm_inbox_lines"> <table id="list" style="width: 100%; text-align: center;">'; if ($contacts != null && $contacts->Count() > 0) { foreach (array_keys($contacts->Instance()) as $key) { $contact =& $contacts->Get($key); $temp = $contact->IsGroup ? '<img src="skins/' . $this->_pagebuilder->SkinName() . '/contacts/group.gif" />' : ' '; $recordType = $contact->IsGroup ? 'g' : 'c'; if (isset($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) && strlen($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) > 0) { $cname = preg_replace('/' . preg_quote($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) . '/i', '<font>$0</font>', ConvertUtils::WMHtmlSpecialChars($contact->Name)); $cemail = preg_replace('/' . preg_quote($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) . '/i', '<font>$0</font>', ConvertUtils::WMHtmlSpecialChars($contact->Email)); } else { $cname = ConvertUtils::WMHtmlSpecialChars($contact->Name); $cemail = ConvertUtils::WMHtmlSpecialChars($contact->Email); } $this->text .= '<tr class="wm_inbox_read_item" id="' . $recordType . '_' . $contact->Id . '">'; $this->text .= '<td style="width: 22px; text-align: center;" id="none"><input type="checkbox"></td><td style="width: 24px; text-align: center;">' . $temp . '</td>'; $this->text .= '<td class="wm_inbox_from_subject" style="width: 140px;"><nobr>' . $cname . '</nobr></td>'; $this->text .= '<td class="wm_inbox_from_subject" style="width: 330px;"><nobr>' . $cemail . '</nobr></td></tr>'; } } else { $this->text .= '<div class="wm_inbox_info_message" id="list">' . InfoNoContactsGroups . '<br /><div class="wm_view_message_info">' . InfoNewContactsGroups . '</div></div>'; } $this->text .= '</table></div> </div> </div>'; }
parent.SetStateTextHandler(parent.Lang.LoggingToServer); </script> <?php @ob_flush(); $processor =& new MailProcessor($account); $folders =& $processor->GetFolders(); $processor->MailStorage->DownloadedMessagesHandler = 'ShowDownloadedMessageNumber'; @flush(); ?> <script type="text/javascript"> parent.SetStateTextHandler(parent.Lang.GettingMsgsNum); </script> <?php @ob_flush(); if (!$processor->Synchronize($folders)) { $errorDesc = getGlobalError(); } } @flush(); ?> <script type="text/javascript"> <?php print 'parent.EndCheckMailHandler("' . str_replace('"', '\\"', trim($errorDesc)) . '");'; if ($errorDesc) { SetError($errorDesc); } ?> </script> <?php @ob_flush(); ?>
/** * @param string $text */ function SetOnlineError($text = null) { if ($text === null) { $_SESSION[INFORMATION] = getGlobalError(); } else { $_SESSION[INFORMATION] = $text; if (isset($GLOBALS[ErrorDesc])) { $_SESSION[INFORMATION] .= "\r\n" . getGlobalError(); } } $_SESSION[ISINFOERROR] = true; }