/** * @return BaseProcessor */ function BaseProcessor() { if (!Session::has(ACCOUNT_ID)) { $this->SetError(1); } $accountId = Session::val(ACCOUNT_ID); $this->sArray = Session::val(SARRAY, array()); $this->settings =& Settings::CreateInstance(); if (!$this->settings || !$this->settings->isLoad) { $this->SetError(3); } if ($accountId) { if (Get::has(CHANGE_ACCID)) { $oldaccount =& Account::LoadFromDb(Session::val(ACCOUNT_ID, -1)); $accountId = Get::val(CHANGE_ACCID); if (!isset($_SESSION['attachtempdir'])) { $_SESSION['attachtempdir'] = md5(session_id()); } $fs =& new FileSystem(INI_DIR . '/temp', $oldaccount->Email, $oldaccount->Id); $attfolder =& new Folder($oldaccount->Id, -1, $_SESSION['attachtempdir']); $fs->DeleteDir($attfolder); unset($fs, $attfolder); $this->sArray[ACCOUNT_ID] = $accountId; $this->account =& Account::LoadFromDb($accountId); if (!$this->account || $this->account->IdUser != $oldaccount->IdUser) { $this->account = null; } else { $_SESSION[ACCOUNT_ID] = $accountId; unset($_SESSION[SARRAY]); $this->sArray = array(); } } else { $this->sArray[ACCOUNT_ID] = $accountId; $this->account =& Account::LoadFromDb($accountId); } if (!$this->account) { $this->SetError(2); } } else { $this->SetError(1); } if (!isset($this->sArray[ACCOUNT_ID]) || $this->sArray[ACCOUNT_ID] != $accountId) { $this->sArray[EDIT_ACCOUNT_ID] = $accountId; } $this->processor =& new MailProcessor($this->account); if (!$this->processor->DbStorage || !$this->processor->DbStorage->Connect()) { $this->SetError(5); } $this->db =& $this->processor->DbStorage; $this->accounts =& $this->GetAccounts(); $skins =& FileSystem::GetSkinsList(); $hasDefSettingsSkin = false; $normalSkin = false; foreach ($skins as $skinName) { if ($skinName == $this->settings->DefaultSkin) { $hasDefSettingsSkin = true; } if ($skinName == $this->account->DefaultSkin) { $normalSkin = true; break; } } if (!$normalSkin) { $this->account->DefaultSkin = $hasDefSettingsSkin ? $this->settings->DefaultSkin : ($this->account->DefaultSkin = $skins[0]); } $_SESSION[ATTACH_DIR] = Session::val(ATTACH_DIR, md5(session_id())); if (isset($this->sArray[SCREEN])) { $screen = Get::val(SCREEN, $this->sArray[SCREEN]); $this->sArray[SCREEN] = $screen; if ($this->account->AllowChangeSettings == false && ($screen == SET_ACCOUNT_PROF || $screen == SET_ACCOUNT_ADDACC)) { $this->sArray[SCREEN] = SCREEN_MAILBOX; } if (!$this->settings->AllowContacts && $screen == SCREEN_CONTACTS) { $this->sArray[SCREEN] = SCREEN_MAILBOX; } } else { $this->sArray[SCREEN] = Get::val(SCREEN, SCREEN_MAILBOX); } if (isset($this->sArray[FOLDER_ID])) { $this->sArray[FOLDER_ID] = Get::val(FOLDER_ID, $this->sArray[FOLDER_ID]); } else { $this->sArray[FOLDER_ID] = Get::val(FOLDER_ID, -1); } if (Get::has(FOLDER_ID) || Get::has(SCREEN)) { if (isset($this->sArray[SEARCH_ARRAY])) { unset($this->sArray[SEARCH_ARRAY]); } } if (Session::has(GOTOFOLDER)) { $this->sArray[GOTOFOLDER] = Session::val(GOTOFOLDER, ''); unset($_SESSION[GOTOFOLDER]); } if (isset($this->sArray[PAGE])) { $this->sArray[PAGE] = Get::val(PAGE, $this->sArray[PAGE]); } else { $this->sArray[PAGE] = 1; } if (Get::has(S_GETMODE)) { $this->sArray[SEARCH_ARRAY][S_TEXT] = Get::val(S_GETMODE, 'mini') == 'mini' ? Post::val('smallLookFor', '') : Post::val('bigLookFor', ''); if (!empty($this->sArray[SEARCH_ARRAY][S_TEXT])) { $this->sArray[SEARCH_ARRAY][S_FOLDER] = Post::val('qfolder', -2); $this->sArray[SEARCH_ARRAY][S_MODE] = Post::val('qmmode', 'onlyheaders'); $this->sArray[FOLDER_ID] = $this->sArray[SEARCH_ARRAY][S_FOLDER]; $this->sArray[PAGE] = 1; } else { if (Post::val('qfolder', -2) < 1) { $this->sArray[FOLDER_ID] = -1; } unset($this->sArray[SEARCH_ARRAY]); $this->sArray[PAGE] = 1; } } if (Get::has(S_GETMODECONTACT)) { $this->sArray[SEARCH_ARRAY][S_TEXT] = Get::val(S_GETMODECONTACT, 'mini') == 'mini' ? Post::val('smallLookFor', '') : Post::val('bigLookFor', ''); $this->sArray[CONTACT_ID] = Post::val(CONTACT_ID, -1); $this->sArray[CONTACT_PAGE] = 1; } if (isset($this->sArray[SEARCH_ARRAY][S_FOLDER])) { $this->sArray[FOLDER_ID] = $this->sArray[SEARCH_ARRAY][S_FOLDER]; } if (isset($this->sArray[EDIT_ACCOUNT_ID])) { $this->sArray[EDIT_ACCOUNT_ID] = Get::val(EDIT_ACCOUNT_ID, $this->sArray[EDIT_ACCOUNT_ID]); } else { $this->sArray[EDIT_ACCOUNT_ID] = $accountId; } if (Get::has(EDIT_ACCOUNT_ID)) { $this->sArray[SCREEN] = $this->sArray[SCREEN] == SET_ACCOUNT_ADDACC ? SET_ACCOUNT_PROF : $this->sArray[SCREEN]; } $this->sArray[CONTACT_PAGE] = isset($this->sArray[CONTACT_PAGE]) ? Get::val(CONTACT_PAGE, $this->sArray[CONTACT_PAGE]) : Get::val(CONTACT_PAGE, 1); $this->sArray[CONTACT_ORD] = isset($this->sArray[CONTACT_ORD]) ? Get::val(CONTACT_ORD, $this->sArray[CONTACT_ORD]) : Get::val(CONTACT_ORD, 0); if (isset($this->sArray[CONTACT_FLD])) { if (Get::val(CONTACT_FLD, $this->sArray[CONTACT_FLD]) != $this->sArray[CONTACT_FLD]) { $this->sArray[CONTACT_ORD] = 0; } $this->sArray[CONTACT_FLD] = Get::val(CONTACT_FLD, $this->sArray[CONTACT_FLD]); } else { $this->sArray[CONTACT_FLD] = Get::val(CONTACT_FLD, 0); } if (isset($_COOKIE['wm_vert_resizer']) || isset($_COOKIE['wm_horiz_resizer']) || isset($_COOKIE['wm_hide_folders'])) { if (isset($_COOKIE['wm_vert_resizer']) && strlen($_COOKIE['wm_vert_resizer']) > 0) { $this->account->VertResizer = (int) $_COOKIE['wm_vert_resizer']; setcookie('wm_vert_resizer', '0', time() - 24 * 3600); } if (isset($_COOKIE['wm_horiz_resizer']) && strlen($_COOKIE['wm_horiz_resizer']) > 0) { $this->account->HorizResizer = (int) $_COOKIE['wm_horiz_resizer']; setcookie('wm_horiz_resizer', '0', time() - 24 * 3600); } if (isset($_COOKIE['wm_hide_folders']) && strlen($_COOKIE['wm_hide_folders']) > 0) { $this->account->HideFolders = (bool) $_COOKIE['wm_hide_folders']; setcookie('wm_hide_folders', '0', time() - 24 * 3600); } $this->account->Update(); } $this->FillData(); $this->UpdateSession(); }
/** * @param string $email * @param string $login * @param int $startPage * @param string $password optional * @return bool */ function UserLoginByEmail($email, $login, $startPage = START_PAGE_IS_MAILBOX, $password = null, $toEmail = null, $separated = false) { $newAccount = new Account(); $settings =& Settings::CreateInstance(); if (!$settings || !$settings->isLoad) { $this->SetError(PROC_CANT_GET_SETTINGS); return false; } $url = 'webmail.php?check=1'; switch ($startPage) { default: $url .= '&start=' . START_PAGE_IS_MAILBOX; break; case START_PAGE_IS_NEW_MESSAGE: $url .= '&start=' . START_PAGE_IS_NEW_MESSAGE; if ($toEmail && strlen($toEmail) > 0) { $url .= '&to=' . $toEmail; } break; case START_PAGE_IS_MAILBOX: case START_PAGE_IS_SETTINGS: case START_PAGE_IS_CONTACTS: $url .= '&start=' . $startPage; break; case START_PAGE_IS_CALENDAR: if ($separated) { $url = 'calendar.php'; } else { $url .= '&start=' . $startPage; } break; } $loginArray =& Account::LoadFromDbByLogin($email, $login); if ($loginArray != null) { if ($loginArray[2] == '1') { if ($password === null) { $this->SetLoginInfo($loginArray[0], $loginArray[3], null, $separated); $this->ChangeLocation($url); return true; } else { if ($password == ConvertUtils::DecodePassword($loginArray[1], $newAccount)) { $this->SetLoginInfo($loginArray[0], $loginArray[3], null, $separated); $this->ChangeLocation($url); return true; } else { $account =& Account::LoadFromDb($loginArray[0]); $account->MailIncPassword = $password; $newprocessor = new MailProcessor($account); if ($newprocessor->MailStorage->Connect(true)) { if ($account->Update()) { $this->SetLoginInfo($account->Id, $account->IdUser, $account->DefaultLanguage, $separated); $this->ChangeLocation($url); return true; } else { $this->SetError(getGlobalError()); } } else { $this->SetError(PROC_WRONG_ACCT_PWD); } } } } else { $this->SetError(PROC_CANT_LOG_NONDEF); } } else { $this->SetError(ErrorPOP3IMAP4Auth); } return false; }
/** * @param XmlDomNode $xmlObj * @param AddressBookRecord $addressBookRecord * @param int $accountId */ function UpdateContactFromRequest(&$xmlObj, &$addressBookRecord, $accountId) { $contactNode =& $xmlObj->GetChildNodeByTagName('contact'); $account =& Account::LoadFromDb($accountId); $addressBookRecord->IdUser = $account->IdUser; if (array_key_exists('id', $contactNode->Attributes)) { $addressBookRecord->IdAddress = $contactNode->Attributes['id']; } $addressBookRecord->PrimaryEmail = $contactNode->Attributes['primary_email']; $addressBookRecord->UseFriendlyName = (bool) $contactNode->Attributes['use_friendly_nm']; $addressBookRecord->FullName = $contactNode->GetChildValueByTagName('fullname', true); $birthdayNode =& $contactNode->GetChildNodeByTagName('birthday'); $personalNode =& $contactNode->GetChildNodeByTagName('personal'); $addressBookRecord->HomeEmail = $personalNode->GetChildValueByTagName('email', true); $addressBookRecord->HomeStreet = $personalNode->GetChildValueByTagName('street', true); $addressBookRecord->HomeCity = $personalNode->GetChildValueByTagName('city', true); $addressBookRecord->HomeState = $personalNode->GetChildValueByTagName('state', true); $addressBookRecord->HomeZip = $personalNode->GetChildValueByTagName('zip', true); $addressBookRecord->HomeCountry = $personalNode->GetChildValueByTagName('country', true); $addressBookRecord->HomeFax = $personalNode->GetChildValueByTagName('fax', true); $addressBookRecord->HomePhone = $personalNode->GetChildValueByTagName('phone', true); $addressBookRecord->HomeMobile = $personalNode->GetChildValueByTagName('mobile', true); $addressBookRecord->HomeWeb = $personalNode->GetChildValueByTagName('web', true); $businessNode =& $contactNode->GetChildNodeByTagName('business', true); $addressBookRecord->BusinessEmail = $businessNode->GetChildValueByTagName('email', true); $addressBookRecord->BusinessCompany = $businessNode->GetChildValueByTagName('company', true); $addressBookRecord->BusinessJobTitle = $businessNode->GetChildValueByTagName('job_title', true); $addressBookRecord->BusinessDepartment = $businessNode->GetChildValueByTagName('department', true); $addressBookRecord->BusinessOffice = $businessNode->GetChildValueByTagName('office', true); $addressBookRecord->BusinessStreet = $businessNode->GetChildValueByTagName('street', true); $addressBookRecord->BusinessCity = $businessNode->GetChildValueByTagName('city', true); $addressBookRecord->BusinessState = $businessNode->GetChildValueByTagName('state', true); $addressBookRecord->BusinessZip = $businessNode->GetChildValueByTagName('zip', true); $addressBookRecord->BusinessCountry = $businessNode->GetChildValueByTagName('country', true); $addressBookRecord->BusinessFax = $businessNode->GetChildValueByTagName('fax', true); $addressBookRecord->BusinessPhone = $businessNode->GetChildValueByTagName('phone', true); $addressBookRecord->BusinessWeb = $businessNode->GetChildValueByTagName('web', true); $otherNode =& $contactNode->GetChildNodeByTagName('other', true); $addressBookRecord->OtherEmail = $otherNode->GetChildValueByTagName('email', true); $addressBookRecord->Notes = $otherNode->GetChildValueByTagName('notes', true); $addressBookRecord->BirthdayDay = $birthdayNode->Attributes['day']; $addressBookRecord->BirthdayMonth = $birthdayNode->Attributes['month']; $addressBookRecord->BirthdayYear = $birthdayNode->Attributes['year']; }
} else { if ($error == '2') { $errorDesc = PROC_CANT_LOAD_ACCT; $errorClass = 'wm_login_error'; } else { if ($error == '3') { $errorDesc = PROC_CANT_GET_SETTINGS; $errorClass = 'wm_login_error'; } else { if ($error == '5') { $errorDesc = PROC_CANT_LOAD_DB; $errorClass = 'wm_login_error'; } else { if (isset($_COOKIE['awm_autologin_data'], $_COOKIE['awm_autologin_id'])) { require_once WM_ROOTPATH . 'common/class_account.php'; $account =& Account::LoadFromDb($_COOKIE['awm_autologin_id']); if ($account != null && $_COOKIE['awm_autologin_data'] == md5(ConvertUtils::EncodePassword($account->MailIncPassword, $account))) { $_SESSION[ACCOUNT_ID] = $account->Id; $_SESSION[USER_ID] = $account->IdUser; $_SESSION[SESSION_LANG] = $account->DefaultLanguage; header('Location: webmail.php?check=1'); exit; } } } } } } } $dbStorage =& DbStorageCreator::CreateDatabaseStorage($null); @header('Content-type: text/html; charset=utf-8');
$settings =& Settings::CreateInstance(); if (!$settings || !$settings->isLoad) { exit('<script>parent.changeLocation("' . LOGINFILE . '?error=3");</script>'); } elseif (!$settings->IncludeLang()) { exit('<script>parent.changeLocation("' . LOGINFILE . '?error=6");</script>'); } require_once WM_ROOTPATH . 'class_account.php'; require_once WM_ROOTPATH . 'classic/base_defines.php'; require_once WM_ROOTPATH . 'common/class_log.php'; require_once WM_ROOTPATH . 'classic/class_getmessagebase.php'; $log =& CLog::CreateInstance(); if (!Session::has(ACCOUNT_ID)) { exit('<script>parent.changeLocation("' . LOGINFILE . '?error=1");</script>'); } $_SESSION['attachtempdir'] = Session::val('attachtempdir', md5(session_id())); $account =& Account::LoadFromDb(Session::val(ACCOUNT_ID, -1)); if (!$account) { exit('<script>parent.changeLocation("' . LOGINFILE . '?error=2");</script>'); } $isNull = false; $mes_id = Get::val('msg_id', ''); $mes_uid = Get::val('msg_uid', ''); $folder_id = Get::val('folder_id', ''); $folder_name = Get::val('folder_fname', ''); $mes_charset = Get::val('charset', -1); if ($mes_uid) { $message =& new GetMessageBase($account, $mes_id, $mes_uid, $folder_id, $folder_name, $mes_charset); if (!$message->msg) { $isNull = true; } } else {
require_once WM_ROOTPATH . 'class_account.php'; require_once WM_ROOTPATH . 'class_folders.php'; require_once WM_ROOTPATH . 'class_mailprocessor.php'; require_once WM_ROOTPATH . 'class_webmailmessages.php'; @session_name('PHPWEBMAILSESSID'); @session_start(); function setContentLength($data) { header('Content-Length: ' . strlen($data)); return $data; } @ob_start('setContentLength'); if (!isset($_SESSION[ACCOUNT_ID])) { exit; } $account =& Account::LoadFromDb($_SESSION[ACCOUNT_ID]); if (!$account) { exit; } 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 ($dbStorage->Connect()) { $dbStorage->GetFolderInfo($folder); } $processor =& new MailProcessor($account); $message =& $processor->GetMessage($_GET['msg_id'], $_GET['msg_uid'], $folder); $data = $message->TryToGetOriginalMailMessage(); $fileNameToSave = trim(ConvertUtils::ClearFileName($message->GetSubject())); if (empty($fileNameToSave)) { $fileNameToSave = 'message';
} $domainStr = ''; if ($eximDomains && count($eximDomains) > 0) { $domainStr = GetDomainStringLine($eximDomains); } else { @header('Location: ./index.php'); exit; } $step = 1; if (isset($_SESSION[SESSION_RESET_STEP]) && $_SESSION[SESSION_RESET_STEP] > 0 && $_SESSION[SESSION_RESET_STEP] < 5) { $step = (int) $_SESSION[SESSION_RESET_STEP]; } $stepData = '{step:' . $step; $stepAccountEmail = $step2Question1 = $step2Question2 = ''; if (isset($_SESSION[SESSION_RESET_ACCT_ID]) && $_SESSION[SESSION_RESET_ACCT_ID] > 0) { $stepAccount =& Account::LoadFromDb($_SESSION[SESSION_RESET_ACCT_ID]); if ($stepAccount) { if (2 == $step) { $stepData .= ', email:\'' . ConvertUtils::ClearJavaScriptString($stepAccount->Email, '\'') . '\''; $stepData .= ', Q1:\'' . ConvertUtils::ClearJavaScriptString($stepAccount->Question1, '\'') . '\''; $stepData .= ', Q2:\'' . ConvertUtils::ClearJavaScriptString($stepAccount->Question2, '\'') . '\''; } else { if (3 == $step) { $stepData .= ', email:\'' . ConvertUtils::ClearJavaScriptString($stepAccount->Email, '\'') . '\''; $stepName = 'пользователь'; if (strlen($stepAccount->FriendlyName) > 0) { $stepName = $stepAccount->FriendlyName; } $stepData .= ', name:\'' . ConvertUtils::ClearJavaScriptString($stepName, '\'') . '\''; } else { if (4 == $step) {
} break; case 'delete': switch ($REQ) { case 'message': $folder =& new Folder($Account->Id, Post::val('folderId', -1), ''); $Processor->GetFolderInfo($folder); $messageIdUidSet = array(Post::val('messageId', -1) => Post::val('messageUid', '')); if (!$Processor->DeleteMessages($messageIdUidSet, $folder)) { SetError(PROC_CANT_DEL_MSGS, BASEFILE . '?' . SCREEN . '=' . SCREEN_MAILBOX); } header('Location: ' . BASEFILE . '?' . SCREEN . '=' . SCREEN_MAILBOX); break; case 'folders': 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); $result = true; if (isset($_POST['folders']) && is_array($_POST['folders'])) { foreach ($_POST['folders'] as $key => $value) { $folder =& new Folder($editAccount->Id, $key, $value); $editProcessor->GetFolderInfo($folder); $editProcessor->GetFolderMessageCount($folder); $childCount = $editProcessor->DbStorage->GetFolderChildCount($folder); if ($Account->MailProtocol == MAILPROTOCOL_IMAP4 && ($folder->MessageCount > 0 || $childCount != 0)) { $result = false; } else {
<link rel="shortcut icon" href="favicon.ico" /> </head> <body onload="parent.CheckEndCheckMailHandler();"> <?php $account =& Account::LoadFromDb($_SESSION[ACCOUNT_ID]); ConvertUtils::SetLimits(); $GLOBALS['useFilters'] = true; $type = isset($_POST['Type']) ? (int) $_POST['Type'] : 0; if (1 === $type) { $dbStorage =& DbStorageCreator::CreateDatabaseStorage($account); if ($dbStorage->Connect() && USE_DB) { $accounts =& $dbStorage->SelectAccounts($account->IdUser); if ($accounts !== null) { foreach ($accounts as $acct_id => $acctArray) { if ($acctArray[5]) { $newAcct =& Account::LoadFromDb($acct_id, false, false); $seeEmail = $newAcct->Email; /* custom class */ wm_Custom::StaticUseMethod('ChangeAccountEmailToFake', array(&$seeEmail)); echo '<script>parent.SetCheckingAccountHandler("' . $seeEmail . '");</script>' . CRLF; myFlush(true); ShowLoggingToServer(); $processor = new MailProcessor($newAcct); $folders =& $processor->GetFolders(); $processor->MailStorage->DownloadedMessagesHandler = 'ShowDownloadedMessageNumber'; if (!$processor->Synchronize($folders)) { $errorDesc .= getGlobalError(); } ShowLoggingOffFromServer(); $processor->MailStorage->Disconnect(); unset($newAcct, $folders, $processor);
/** * @param int $id * @return bool */ function AccountAccess($id) { if ($id == $_SESSION[ACCOUNT_ID]) { return true; } $result = false; if (isset($_SESSION[ACCOUNT_IDS]) && is_array($_SESSION[ACCOUNT_IDS])) { $result = in_array($id, $_SESSION[ACCOUNT_IDS]); } else { if (isset($_SESSION[ACCOUNT_ID])) { $_account = null; if (!isset($_SESSION[USER_ID])) { $_account =& Account::LoadFromDb($_SESSION[ACCOUNT_ID], false, false); if ($_account) { $_SESSION[USER_ID] = $_account->IdUser; } } if (isset($_SESSION[USER_ID])) { $_dbStorage =& DbStorageCreator::CreateDatabaseStorage($_account); if ($_dbStorage->Connect()) { $_SESSION[ACCOUNT_IDS] = $_dbStorage->GetAccountListByUserId($_SESSION[USER_ID]); $result = in_array($id, $_SESSION[ACCOUNT_IDS]); } } } } if (!$result) { $_log =& CLog::CreateInstance(); $_log->WriteLine('Access Error: Unauthorized access ' . $id . ' && ' . $_SESSION[ACCOUNT_ID], LOG_LEVEL_WARNING); } return $result; }
/** * @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 DoResetpassword() { $_dbStorage = $_settings = $_xmlObj = $_xmlRes = $_accountId = null; $this->_initFuncArgs($_dbStorage, $_settings, $_xmlObj, $_xmlRes, $_accountId); $isGdSupport = @function_exists('imagecreatefrompng'); $step = $_xmlObj->GetParamValueByName('step'); if ($step == 1) { $_SESSION[SESSION_RESET_STEP] = 1; unset($_SESSION[SESSION_RESET_ACCT_ID]); $captcha = $_xmlObj->GetParamTagValueByName('captcha'); if ($isGdSupport && (!isset($_SESSION['captcha_keystring']) || (string) $captcha !== (string) $_SESSION['captcha_keystring'])) { CXmlProcessing::PrintErrorAndExit(CaptchaError, $_xmlRes); } $login = $_xmlObj->GetParamTagValueByName('login'); $domain = $_xmlObj->GetParamTagValueByName('domain'); $email = $login . '@' . $domain; $_loginArray =& Account::LoadFromDbOnlyByEmail($email); if (is_array($_loginArray) && count($_loginArray) > 3) { $_eAccount =& Account::LoadFromDb((int) $_loginArray[0]); if ($_eAccount && $_eAccount->IsInternal) { if (strlen($_eAccount->Question1 . $_eAccount->Question2) > 0) { $_SESSION[SESSION_RESET_STEP] = 2; $_SESSION[SESSION_RESET_ACCT_ID] = $_eAccount->Id; $_resetNode = new XmlDomNode('reset'); $_resetNode->AppendAttribute('step', 2); $_resetNode->AppendChild(new XmlDomNode('email', $_eAccount->Email, true)); $_resetNode->AppendChild(new XmlDomNode('q1', $_eAccount->Question1, true)); $_resetNode->AppendChild(new XmlDomNode('q2', $_eAccount->Question2, true)); $_xmlRes->XmlRoot->AppendChild($_resetNode); return; } else { CXmlProcessing::PrintErrorAndExit(RegUnrecoverableAccount, $_xmlRes); } } else { CXmlProcessing::PrintErrorAndExit(WebMailException, $_xmlRes); } } else { CXmlProcessing::PrintErrorAndExit(RegUnknownAdress, $_xmlRes); } } else { if ($step == 2 && isset($_SESSION[SESSION_RESET_ACCT_ID], $_SESSION[SESSION_RESET_STEP]) && $_SESSION[SESSION_RESET_STEP] > 1) { $account =& Account::LoadFromDb($_SESSION[SESSION_RESET_ACCT_ID]); if ($account) { $answer1 = $_xmlObj->GetParamTagValueByName('answer1'); $answer2 = $_xmlObj->GetParamTagValueByName('answer2'); if ((string) $account->Answer1 === (string) $answer1 && (string) $account->Answer2 === (string) $answer2) { $_SESSION[SESSION_RESET_STEP] = 3; $_resetNode = new XmlDomNode('reset'); $_resetNode->AppendAttribute('step', 3); $_resetNode->AppendChild(new XmlDomNode('email', $account->Email, true)); $_resetNode->AppendChild(new XmlDomNode('name', $account->FriendlyName, true)); $_xmlRes->XmlRoot->AppendChild($_resetNode); return; } else { CXmlProcessing::PrintErrorAndExit(RegAnswersIncorrect, $_xmlRes); } } } else { if ($step == 3 && isset($_SESSION[SESSION_RESET_ACCT_ID], $_SESSION[SESSION_RESET_STEP]) && $_SESSION[SESSION_RESET_STEP] > 2) { $account =& Account::LoadFromDb($_SESSION[SESSION_RESET_ACCT_ID]); if ($account) { $password1 = $_xmlObj->GetParamTagValueByName('password1'); $password2 = $_xmlObj->GetParamTagValueByName('password2'); if ((string) $password1 === (string) $password2) { $account->MailIncPassword = $password1; $account->MailOutPassword = $password1; if ($account->UpdatePasswords()) { unset($_SESSION[SESSION_RESET_ACCT_ID], $_SESSION[SESSION_RESET_STEP]); $_resetNode = new XmlDomNode('reset'); $_resetNode->AppendAttribute('step', 4); $_xmlRes->XmlRoot->AppendChild($_resetNode); return true; } else { CXmlProcessing::PrintErrorAndExit(PROC_CANT_UPDATE_ACCT, $_xmlRes); } } else { CXmlProcessing::PrintErrorAndExit(WarningPassNotMatch, $_xmlRes); } } } } } CXmlProcessing::PrintErrorAndExit(WebMailException, $_xmlRes); }
/** * @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 string $email * @param string $login * @param string $password = null * @return bool */ protected function _UserLoginByEmail($email, $login, $password = null) { require_once WM_ROOTPATH . 'common/class_account.php'; require_once WM_ROOTPATH . 'common/class_dbstorage.php'; require_once WM_ROOTPATH . 'common/class_mailprocessor.php'; $newAccount = new Account(); $settings =& Settings::CreateInstance(); if (!$settings || !$settings->isLoad) { throw new WebMailModelException('settings error'); } if (!$settings->IncludeLang()) { throw new WebMailModelException('lang error'); } $loginArray =& Account::LoadFromDbByLogin($email, $login); if ($loginArray != null) { if ($loginArray[2] == '1') { if ($password === null) { @session_write_close(); @session_name('PHPWEBMAILSESSID'); @session_start(); $_SESSION[ACCOUNT_ID] = $loginArray[0]; $_SESSION[USER_ID] = $loginArray[3]; return true; } else { if ($password == ConvertUtils::DecodePassword($loginArray[1], $newAccount)) { @session_write_close(); @session_name('PHPWEBMAILSESSID'); @session_start(); $_SESSION[ACCOUNT_ID] = $loginArray[0]; $_SESSION[USER_ID] = $loginArray[3]; return true; } else { $account =& Account::LoadFromDb($loginArray[0]); $account->MailIncPassword = $password; $newprocessor = new MailProcessor($account); if ($newprocessor->MailStorage->Connect(true)) { if ($account->Update()) { @session_write_close(); @session_name('PHPWEBMAILSESSID'); @session_start(); $_SESSION[ACCOUNT_ID] = $account->Id; $_SESSION[USER_ID] = $account->IdUser; $_SESSION[SESSION_LANG] = $account->DefaultLanguage; return true; } else { throw new WebMailModelException(getGlobalError()); } } else { throw new WebMailModelException(ErrorPOP3IMAP4Auth); } } } } else { throw new WebMailModelException(PROC_CANT_LOG_NONDEF); } } else { throw new WebMailModelException(ErrorPOP3IMAP4Auth); } }
/** * @static * @param int $id * @return bool */ function DeleteFromDb($id, $deleteDemo = false) { $account =& Account::LoadFromDb($id); if (!$deleteDemo && $account->IsDemo) { return true; } $null = null; $dbStorage =& DbStorageCreator::CreateDatabaseStorage($null); if ($dbStorage->Connect()) { $settings =& Settings::CreateInstance(); if ($settings->EnableWmServer && $settings->WmAllowManageXMailAccounts) { if ($account && $account->MailProtocol == MAILPROTOCOL_WMSERVER) { $WMConsole = new CWmServerConsole(); if (!$WMConsole->Connect()) { setGlobalError(PROC_CANT_DEL_ACCT_BY_ID); return false; } $domain = ConvertUtils::ParseEmail($account->Email); if ($domain) { $WMConsole->DeleteUser($domain[1], EmailAddress::GetAccountNameFromEmail($account->MailIncLogin)); } } } if ($dbStorage->DeleteAccountData($id)) { return true; } else { setGlobalError(PROC_CANT_DEL_ACCT_BY_ID); } } return false; }
@header('Content-type: text/html; charset=utf-8'); defined('WM_ROOTPATH') || define('WM_ROOTPATH', dirname(__FILE__) . '/'); require_once WM_ROOTPATH . 'common/inc_top.php'; require_once WM_ROOTPATH . 'common/class_settings.php'; $settings =& Settings::CreateInstance(); if (!$settings || !$settings->isLoad) { header('Location: index.php?error=3'); exit; } if (!isset($_SESSION[ACCOUNT_ID])) { header('Location: index.php?error=2'); exit; } if (!isset($_SESSION[SESSION_LANG])) { require_once WM_ROOTPATH . 'common/class_account.php'; $_account = Account::LoadFromDb($_SESSION[ACCOUNT_ID], false, false); if (!$_account) { header('Location: index.php?error=2'); exit; } define('defaultLang', $_account->DefaultLanguage); } else { define('defaultLang', $_SESSION[SESSION_LANG]); } define('defaultTitle', $settings->WindowTitle); define('defaultSkin', $settings->DefaultSkin); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" /> <html> <head> <link rel="shortcut icon" href="favicon.ico" />
/** * @param XmlDomNode $_xmlRes * @param int $_idAcct * @param bool $_getSignature = null * @param bool $_getColumns = null * @return Account */ function &AccountCheckAndLoad($_xmlRes, $_idAcct, $_getSignature = null, $_getColumns = null) { if ($_getSignature === null) { $_getSignature = true; } if ($_getColumns === null) { $_getColumns = true; } $_account =& Account::LoadFromDb($_idAcct, $_getSignature, $_getColumns); if (!$_account) { CXmlProcessing::PrintErrorAndExit('', $_xmlRes, 2); } return $_account; }
$_GET['error'] = 3; } } $isCorrect = isset($_SESSION['passwordIsCorrect']) && (int) $_SESSION['passwordIsCorrect'] == 15; if ($isCorrect) { if ($mode == 'clearlog') { if (file_exists(INI_DIR . '/' . LOG_PATH . '/' . LOG_FILENAME)) { $_SESSION['divmess'] = @unlink(INI_DIR . '/' . LOG_PATH . '/' . LOG_FILENAME) ? MES_LOGCLEARSUCCESSFUL : MES_ERROR; } else { $_SESSION['divmess'] = MES_LOGCLEARSUCCESSFUL; } $ref = 'mailadm.php?mode=wm_debug'; } if ($mode == 'wm_delete') { if (isset($_GET['uid']) && $_GET['uid'] > -1) { $account =& Account::LoadFromDb($_GET['uid']); $account->DeleteFromDb($_GET['uid'], true); $fs = new FileSystem(INI_DIR . '/mail', $account->Email, $account->Id); $fs->DeleteAccountDirs(); $fs2 = new FileSystem(INI_DIR . '/temp', $account->Email, $account->Id); $fs2->DeleteAccountDirs(); unset($fs, $fs2); } $ref = 'mailadm.php?mode=wm_users'; } if ($mode == 'save') { $ref_mode = ''; $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : 'error'; switch ($form_id) { case 'error': $mode = 'login';
$dbStorage =& DbStorageCreator::CreateDatabaseStorage($account); if ($dbStorage->Connect()) { $accounts =& $dbStorage->SelectAccounts($account->IdUser); if ($accounts !== null) { foreach ($accounts as $acct_id => $acctArray) { if ($acctArray[5]) { @flush(); ?> <script type="text/javascript"> <?php echo 'parent.SetCheckingAccountHandler("' . $acctArray[4] . '");'; ?> </script> <?php @ob_flush(); $newAcct =& Account::LoadFromDb($acct_id); @flush(); ?> <script type="text/javascript"> parent.SetStateTextHandler(parent.Lang.LoggingToServer); </script> <?php @ob_flush(); $processor =& new MailProcessor($newAcct); $folders =& $processor->GetFolders(); $processor->MailStorage->DownloadedMessagesHandler = 'ShowDownloadedMessageNumber'; @flush(); ?> <script type="text/javascript"> parent.SetStateTextHandler(parent.Lang.GettingMsgsNum); </script>
/** * @param string $email * @param string $login * @param int $startPage * @param string $password optional * @return bool */ function UserLoginByEmail($email, $login, $startPage = START_PAGE_IS_MAILBOX, $password = null, $toEmail = null) { $newAccount = new Account(); $settings =& Settings::CreateInstance(); if (!$settings || !$settings->isLoad) { $this->SetError(PROC_CANT_GET_SETTINGS); return false; } $getTemp = ''; switch ($startPage) { default: $getTemp = '&start=' . START_PAGE_IS_MAILBOX; break; case START_PAGE_IS_NEW_MESSAGE: if ($toEmail && strlen($toEmail) > 0) { $getTemp = '&start=' . START_PAGE_IS_NEW_MESSAGE . '&to=' . $toEmail; } else { $getTemp = '&start=' . START_PAGE_IS_NEW_MESSAGE; } break; case START_PAGE_IS_MAILBOX: case START_PAGE_IS_SETTINGS: case START_PAGE_IS_CONTACTS: case START_PAGE_IS_CALENDAR: $getTemp = '&start=' . $startPage; break; } $loginArray =& Account::LoadFromDbByLogin($email, $login); if ($loginArray != null) { if ($loginArray[2] == '1') { if ($password == null) { $_SESSION[ACCOUNT_ID] = $loginArray[0]; $_SESSION[USER_ID] = $loginArray[3]; $this->ChangeLocation($settings, $getTemp); return true; } else { if ($password == ConvertUtils::DecodePassword($loginArray[1], $newAccount)) { $_SESSION[ACCOUNT_ID] = $loginArray[0]; $_SESSION[USER_ID] = $loginArray[3]; $this->ChangeLocation($settings, $getTemp); return true; } else { $account =& Account::LoadFromDb($loginArray[0]); $account->MailIncPassword = $password; $newprocessor =& new MailProcessor($account); if ($newprocessor->MailStorage->Connect()) { $_SESSION['id_account'] = $loginArray[0]; $_SESSION[SESSION_LANG] = $account->DefaultLanguage; if ($account->Update()) { $this->ChangeLocation($settings, $getTemp); return true; } else { $this->SetError(getGlobalError()); return false; } } else { $this->SetError(PROC_WRONG_ACCT_PWD); return false; } } } } else { $this->SetError(PROC_CANT_LOG_NONDEF); return false; } } if ($this->_errorMessage == '') { $this->SetError(); } return false; }