public static function createEmailAddress($address = null)
 {
     if (null === $address) {
         $address = 'address-' . mt_rand() . '@example.com';
     }
     $email_address = new EmailAddress();
     $email_address->email_address = $address;
     $email_address->save();
     self::$createdAddresses[] = $email_address;
     return $email_address;
 }
 /**
  * @return bool
  * @param string $s_input
  * @param string[] field names $a_keys
  * @desc Test whether a given email address looks valid
  */
 function Test($s_input, $a_keys)
 {
     if (!$s_input) {
         return true;
     }
     // this isn't a RequiredFieldValidator
     $o_email_address = new EmailAddress($s_input);
     return $o_email_address->IsValid();
     /*		require_once 'Zend/Validate/EmailAddress.php';
     		$validator = new Zend_Validate_EmailAddress();
     		$validator->setValidateMx(false);
     		return $validator->isValid($s_input);*/
 }
 public function testsave()
 {
     $email = new EmailAddress();
     $email->email_address = '*****@*****.**';
     $email->invaid_email = 0;
     $email->save();
     //test for record ID to verify that record is saved
     $this->assertTrue(isset($email->id));
     $this->assertEquals(36, strlen($email->id));
     //mark the record as deleted and verify that this record cannot be retrieved anymore.
     $email->mark_deleted($email->id);
     $result = $email->retrieve($email->id);
     $this->assertEquals(null, $result);
 }
function oqc_getUserVariables()
{
    global $current_user;
    $contractData = array();
    $userData = sanatizeBeanArrayForLatex($current_user->toArray(true));
    $email_address = $current_user->getEmailInfo();
    $firstName = $current_user->first_name;
    $lastName = $current_user->last_name;
    $emailBean = new EmailAddress();
    //Trying to find Contacts by email addresss or names, maybe we will be lucky
    $relatedId = $emailBean->getRelatedId($email_address['email'], 'Contacts');
    //$GLOBALS['log']->error('Search Contact id: '. var_export($relatedId[0],true));
    $userContact = new Contact();
    //We have unique id and can proceed to retrieve all required information
    //$GLOBALS['log']->error('User variables: count output is: '. var_export(count($relatedId),true));
    if (count($relatedId) == 1 && $relatedId[0]) {
        //$GLOBALS['log']->error('User variables: email recovery OK: ');
        if ($userContact->retrieve($relatedId[0])) {
            $contractData['userContact'] = sanatizeBeanArrayForLatex($userContact->toArray(true));
            $userAccount = new Account();
            if ($userAccount->retrieve($userContact->account_id)) {
                $contractData['userContact']['account'] = sanatizeBeanArrayForLatex($userAccount->toArray(true));
            }
        }
    } else {
        //$GLOBALS['log']->error('Account variables: variables transferred to latex template: '. var_export($clientAccount->toArray(true),true));
        $where_clause = "first_name='{$firstName}' AND last_name='{$lastName}' AND deleted=0";
        $query = "SELECT id FROM contacts WHERE {$where_clause}";
        $r = $userContact->db->query($query, true);
        $retArr = array();
        while ($a = $userContact->db->fetchByAssoc($r)) {
            $retArr[] = $a['id'];
        }
        //$GLOBALS['log']->error('User variables: retrieved from db: '. var_export($retArr,true));
        if (count($retArr) == 1 && $retArr[0]) {
            if ($userContact->retrieve($retArr[0])) {
                $contractData['userContact'] = sanatizeBeanArrayForLatex($userContact->toArray(true));
                $userAccount = new Account();
                if ($userAccount->retrieve($userContact->account_id)) {
                    $contractData['userContact']['account'] = sanatizeBeanArrayForLatex($userAccount->toArray(true));
                }
            }
        } else {
            $contractData['userContact'] = $userData;
        }
    }
    $contractData['userContact']['email_address'] = $email_address['email'];
    return $contractData;
}
 function OnPageInit()
 {
     parent::OnPageInit();
     $this->form = new EmailForm($this->GetSettings());
     $this->RegisterControlForValidation($this->form);
     $this->valid = isset($_GET['to']);
     if ($this->valid) {
         $protector = new EmailAddressProtector($this->GetSettings());
         $this->address = $protector->DecryptProtectedEmail($_GET['to']);
         $email = new EmailAddress($this->address);
         $this->valid = $email->IsValid();
     }
     if ($this->valid) {
         $this->address_display = HTML::Encode(substr($this->address, 0, strpos($this->address, "@"))) . "@… (protected address)";
     } else {
         header($_SERVER["SERVER_PROTOCOL"] . " 400 Bad Request");
     }
 }
 function DoGetMessage()
 {
     $_dbStorage = $_settings = $_xmlObj = $_xmlRes = $_accountId = null;
     $this->_initFuncArgs($_dbStorage, $_settings, $_xmlObj, $_xmlRes, $_accountId);
     $_account =& CXmlProcessing::AccountCheckAndLoad($_xmlRes, $_accountId, true, false);
     $_charsetNum = $_xmlObj->GetParamValueByName('charset');
     if ($_charsetNum > 0) {
         $_account->DefaultIncCharset = ConvertUtils::GetCodePageName($_charsetNum);
         $GLOBALS[MailInputCharset] = $_account->DefaultIncCharset;
         $_account->UpdateDefaultIncCharset();
     }
     $_processor = new MailProcessor($_account);
     $_folderNodeRequest =& $_xmlObj->XmlRoot->GetChildNodeByTagName('folder');
     $_folder = null;
     if (isset($_folderNodeRequest->Attributes['id'])) {
         $_folder = new Folder($_accountId, $_folderNodeRequest->Attributes['id'], $_folderNodeRequest->GetChildValueByTagName('full_name'));
         $_processor->GetFolderInfo($_folder);
         if (!$_folder || $_folder->IdDb < 1) {
             CXmlProcessing::PrintErrorAndExit(WebMailException, $_xmlRes);
         }
     } else {
         CXmlProcessing::PrintErrorAndExit(WebMailException, $_xmlRes);
     }
     $_msgId = $_xmlObj->GetParamValueByName('id');
     $_msgUid = $_xmlObj->GetParamTagValueByName('uid');
     $_msgSize = $_xmlObj->GetParamValueByName('size');
     $_msgIdUid = array($_msgId => $_msgUid);
     $_mode = (int) $_xmlObj->GetParamValueByName('mode');
     $_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)) {
         $_modeForGet = null;
     }
     $_message = null;
     $_message =& $_processor->GetMessage($_msgId, $_msgUid, $_folder, $_modeForGet);
     if (null != $_message) {
         if (($_message->Flags & MESSAGEFLAGS_Seen) != MESSAGEFLAGS_Seen) {
             $_processor->SetFlag($_msgIdUid, $_folder, MESSAGEFLAGS_Seen, ACTION_Set);
         }
         $_isFromSave = false;
         if (USE_DB && ($_modeForGet === null || ($_modeForGet & 1) == 1)) {
             $_fromObj = new EmailAddress();
             $_fromObj->Parse($_message->GetFromAsString(true));
             if ($_fromObj->Email) {
                 $_isFromSave = $_processor->DbStorage->SelectSenderSafetyByEmail($_fromObj->Email, $_account->IdUser);
             }
             if ($_folder->SyncType != FOLDERSYNC_DirectMode && $_processor->DbStorage->Connect()) {
                 $_processor->DbStorage->UpdateMessageCharset($_msgId, $_charsetNum, $_message);
             }
         }
         CXmlProcessing::GetMessageNode($_xmlRes, $_message, $_folder, $_processor, $_account, $_settings, $_mode, $_charsetNum, $_isFromSave);
     } else {
         CXmlProcessing::PrintErrorAndExit(getGlobalError(), $_xmlRes);
     }
 }
Example #7
0
<?php

require_once 'classes.php';
$email1 = new EmailAddress();
$email1->setEmailAddress("*****@*****.**");
$email2 = new EmailAddress();
$email2->setEmailAddress("*****@*****.**");
$email3 = new EmailAddress();
$email3->setEmailAddress("*****@*****.**");
$emailAddresses = array($email1, $email2, $email3);
echo "\nEmail Addresses:  \n\n";
$itr = new EmailAddressIterator($emailAddresses);
while ($itr->hasNext()) {
    $item = $itr->next();
    echo $item->getAddressText() . "\n";
}
echo "\nPhysical Addresses:  \n\n";
/* Now add physical addresses... */
$pa1 = new PhysicalAddress("123 Any St.", "Anytown", "NE", "00000");
$pa2 = new PhysicalAddress("123 Any Blvd.", "Anytropolis", "MN", "00000");
$physicalAddresses = array($pa1, $pa2);
$itr2 = new PhysicalAddressIterator($physicalAddresses);
while ($itr2->hasNext()) {
    $item = $itr2->next();
    echo $item->getAddressText() . "\n";
}
/* Now the compound iterator! */
echo "\nIterating through both types of addresses:\n\n";
$itr3 = new PersonAddressIterator($emailAddresses, $physicalAddresses);
while ($itr3->hasNext()) {
    $item = $itr3->next();
Example #8
0
 /**
  * @access public
  * @param string $domain
  * @param string $username
  * @param string $newPassword
  * @return bool
  */
 function ChangeUserPass($domain, $username, $newPassword)
 {
     $username = EmailAddress::GetAccountNameFromEmail($username);
     //"userpasswd"[TAB]"domain"[TAB]"username"[TAB]"password"
     $this->_write('userpasswd' . TABCHAR . $domain . TABCHAR . $username . TABCHAR . $newPassword);
     return $this->_checkResponse($this->_readline(), 'ChangeUserPass()', __LINE__);
 }
Example #9
0
 /**
  * @param Account $account
  * @param short $pop3InboxSyncType optional
  * @return bool
  */
 function CreateAccount(&$account, $inboxSyncType = FOLDERSYNC_NewEntireMessages)
 {
     $account->IdUser = $this->Id;
     $result = false;
     setGlobalError(PROC_ERROR_ACCT_CREATE);
     $dbStorage =& DbStorageCreator::CreateDatabaseStorage($account);
     if ($dbStorage->Connect()) {
         $defaultAccount =& $dbStorage->SelectAccountDataByLogin($account->Email, $account->MailIncLogin, true);
         if ($account->DefaultAccount && $defaultAccount != null && $defaultAccount[2] == 1) {
             setGlobalError(ACCT_CANT_ADD_DEF_ACCT);
             return false;
         }
         $settings =& Settings::CreateInstance();
         //Load or create folder tree here
         switch ($account->MailProtocol) {
             case MAILPROTOCOL_WMSERVER:
                 if (!$settings->EnableWmServer) {
                     setGlobalError(PROC_ERROR_ACCT_CREATE);
                     return false;
                 }
                 $emailArray = ConvertUtils::ParseEmail($account->Email);
                 if (!$emailArray) {
                     setGlobalError(JS_LANG_WarningCorrectEmail);
                     return false;
                 }
                 $WMConsole = new CWmServerConsole();
                 if (!$WMConsole->Connect()) {
                     setGlobalError(PROC_ERROR_ACCT_CREATE . '<br />' . $WMConsole->GetError());
                     return false;
                 }
                 if ($settings->WmAllowManageXMailAccounts) {
                     if ($WMConsole->DomainExist($emailArray[1])) {
                         if (!$WMConsole->UserExist($emailArray[1], $account->MailIncLogin)) {
                             if (!$WMConsole->AddUser($emailArray[1], EmailAddress::GetAccountNameFromEmail($account->MailIncLogin), $account->MailIncPassword)) {
                                 setGlobalError(PROC_ERROR_ACCT_CREATE . '<br />' . $WMConsole->GetError());
                                 return false;
                             }
                         }
                         if (!$WMConsole->ChangeUserMaxMailBoxSize($emailArray[1], EmailAddress::GetAccountNameFromEmail($account->MailIncLogin), $account->MailboxLimit)) {
                             setGlobalError(PROC_ERROR_ACCT_CREATE . '<br />' . $WMConsole->GetError());
                             return false;
                         }
                     } else {
                         setGlobalError(DomainDosntExist . '<br />' . $WMConsole->GetError());
                         return false;
                     }
                 }
                 $result = $dbStorage->InsertAccountData($account);
                 $folders =& new FolderCollection();
                 if ($result) {
                     $inboxFolder =& new Folder($account->Id, -1, FOLDERNAME_Inbox, FOLDERNAME_Inbox);
                     if ($settings->AllowDirectMode && $settings->DirectModeIsDefault) {
                         $inboxSyncType = FOLDERSYNC_DirectMode;
                     }
                     $inboxFolder->SyncType = $inboxSyncType;
                     $folders->Add($inboxFolder);
                     $folders->Add(new Folder($account->Id, -1, FOLDERNAME_SentItems, FOLDERNAME_SentItems, FOLDERSYNC_DontSync));
                     $folders->Add(new Folder($account->Id, -1, FOLDERNAME_Drafts, FOLDERNAME_Drafts, FOLDERSYNC_DontSync));
                     $folders->Add(new Folder($account->Id, -1, FOLDERNAME_Trash, FOLDERNAME_Trash, FOLDERSYNC_DontSync));
                 }
                 break;
             case MAILPROTOCOL_POP3:
                 $result = $dbStorage->InsertAccountData($account);
                 $folders =& new FolderCollection();
                 if ($result) {
                     $inboxFolder =& new Folder($account->Id, -1, FOLDERNAME_Inbox, FOLDERNAME_Inbox);
                     if ($settings->AllowDirectMode && $settings->DirectModeIsDefault) {
                         $inboxSyncType = FOLDERSYNC_DirectMode;
                     }
                     $inboxFolder->SyncType = $inboxSyncType;
                     $folders->Add($inboxFolder);
                     $folders->Add(new Folder($account->Id, -1, FOLDERNAME_SentItems, FOLDERNAME_SentItems, FOLDERSYNC_DontSync));
                     $folders->Add(new Folder($account->Id, -1, FOLDERNAME_Drafts, FOLDERNAME_Drafts, FOLDERSYNC_DontSync));
                     $folders->Add(new Folder($account->Id, -1, FOLDERNAME_Trash, FOLDERNAME_Trash, FOLDERSYNC_DontSync));
                 }
                 break;
             case MAILPROTOCOL_IMAP4:
                 setGlobalError(ACCT_CANT_CREATE_IMAP_ACCT);
                 $mailStorage =& new ImapStorage($account);
                 if ($mailStorage->Connect()) {
                     $result = $dbStorage->InsertAccountData($account);
                     if (!$result) {
                         return false;
                     }
                     $folders =& $mailStorage->GetFolders();
                     $folders->SetSyncTypeToAll($inboxSyncType);
                     if ($folders && $settings->AllowDirectMode && $settings->DirectModeIsDefault) {
                         $folders->SetSyncTypeToAll(FOLDERSYNC_DirectMode);
                     }
                     $result &= $account->Update();
                     $result &= $folders != null;
                     $mailStorage->Disconnect();
                     if (!$result) {
                         return false;
                     }
                     $hasSentItems = false;
                     $hasDrafts = false;
                     $hasTrash = false;
                     $s = $d = $t = null;
                     $s =& $folders->GetFolderByType(FOLDERTYPE_SentItems);
                     $d =& $folders->GetFolderByType(FOLDERTYPE_Drafts);
                     if (USEIMAPTRASH) {
                         $t =& $folders->GetFolderByType(FOLDERTYPE_Trash);
                     }
                     /*
                     							for ($i = 0, $c = $folders->Count(); $i < $c; $i++)
                     							{
                     								$folder = &$folders->Get($i);
                     								if (strtolower($folder->FullName) == strtolower(FOLDERNAME_Inbox) && $folder->SubFolders != null)
                     								{
                     									for ($j = 0, $k = $folder->SubFolders->Count(); $j < $k; $j++)
                     									{
                     										$inboxFolder =& $folder->SubFolders->Get($j);
                     										switch(strtolower($inboxFolder->Name))
                     										{
                     											case strtolower(FOLDERNAME_Sent):
                     											case strtolower(FOLDERNAME_SentItems):
                     												$hasSentItems = true;
                     												break;
                     											case strtolower(FOLDERNAME_Drafts):
                     												$hasDrafts = true;
                     												break;
                     											case strtolower(FOLDERNAME_Trash):
                     												$hasTrash = true;
                     												break;
                     										}
                     									}
                     								}
                     								
                     								switch(strtolower($folder->FullName))
                     								{
                     									case strtolower(FOLDERNAME_Sent):
                     									case strtolower(FOLDERNAME_SentItems):
                     										$hasSentItems = true;
                     										break;
                     									case strtolower(FOLDERNAME_Drafts):
                     										$hasDrafts = true;
                     										break;
                     									case strtolower(FOLDERNAME_Trash):
                     										$hasTrash = true;
                     										break;
                     								}
                     								
                     								if ($hasSentItems && $hasDrafts)
                     								{
                     									if (USEIMAPTRASH)
                     									{
                     										if ($hasTrash)
                     										{
                     											break;
                     										}
                     									}
                     									else
                     									{
                     										break;
                     									}
                     								}
                     							}
                     							
                     							if (!$hasSentItems)
                     							{
                     								$sentFolder =& new Folder($account->Id, -1, FOLDERNAME_SentItems, FOLDERNAME_SentItems, FOLDERSYNC_DontSync);
                     								$folders->Add($sentFolder);
                     							}
                     
                     							if (!$hasDrafts)
                     							{
                     								$draftsFolder =& new Folder($account->Id, -1, FOLDERNAME_Drafts, FOLDERNAME_Drafts, FOLDERSYNC_DontSync);
                     								$folders->Add($draftsFolder);
                     							}
                     							
                     							if (USEIMAPTRASH && !$hasTrash)
                     							{
                     								$draftsFolder =& new Folder($account->Id, -1, FOLDERNAME_Trash, FOLDERNAME_Trash, FOLDERSYNC_DontSync);
                     								$folders->Add($draftsFolder);
                     							}*/
                     if ($s === null) {
                         $sentFolder =& new Folder($account->Id, -1, FOLDERNAME_SentItems, FOLDERNAME_SentItems, FOLDERSYNC_DontSync);
                         $folders->Add($sentFolder);
                     }
                     if ($d === null) {
                         $draftsFolder =& new Folder($account->Id, -1, FOLDERNAME_Drafts, FOLDERNAME_Drafts, FOLDERSYNC_DontSync);
                         $folders->Add($draftsFolder);
                     }
                     if (USEIMAPTRASH && $t === null) {
                         $trashFolder =& new Folder($account->Id, -1, FOLDERNAME_Trash, FOLDERNAME_Trash, FOLDERSYNC_DontSync);
                         $folders->Add($trashFolder);
                     }
                 } else {
                     return false;
                 }
                 break;
             default:
                 return false;
         }
         if ($result) {
             $folders = $folders->SortRootTree();
             $result &= $dbStorage->CreateFolders($folders);
         }
     }
     if ($result) {
         setGlobalError('');
     }
     return $result;
 }
 /**
  * @return EmailAddress
  */
 function &GetFrom()
 {
     $emailAdress = new EmailAddress();
     $emailAdress->Parse($this->Headers->GetHeaderDecodedValueByName(MIMEConst_FromLower));
     return $emailAdress;
 }
Example #11
0
 /**
  * @access private
  * @param resource $link
  * @param Account $account
  * @param WebMailMessage $message
  * @param string $from
  * @param string $to
  * @param CLog $log
  * @return bool
  */
 function Send(&$link, &$account, &$message, $from, $to, &$log)
 {
     $ehloMsg = trim(EmailAddress::GetDomainFromEmail($account->Email));
     $ehloMsg = strlen($ehloMsg) > 0 ? $ehloMsg : $account->MailOutHost;
     $result = CSmtp::ExecuteCommand($link, 'EHLO ' . $ehloMsg, $log);
     if (!$result) {
         $result = CSmtp::ExecuteCommand($link, 'HELO ' . $ehloMsg, $log);
     }
     if ($result && $account->MailOutAuthentication) {
         $result = CSmtp::ExecuteCommand($link, 'AUTH LOGIN', $log);
         $mailOutLogin = $account->MailOutLogin ? $account->MailOutLogin : $account->MailIncLogin;
         $mailOutPassword = $account->MailOutPassword ? $account->MailOutPassword : $account->MailIncPassword;
         if ($result) {
             $log->WriteLine('[Sending encoded login]');
             $result = CSmtp::ExecuteCommand($link, base64_encode($mailOutLogin), $log);
         }
         if ($result) {
             $log->WriteLine('[Sending encoded password]');
             $result = CSmtp::ExecuteCommand($link, base64_encode($mailOutPassword), $log);
         }
     }
     if ($result) {
         $result = CSmtp::ExecuteCommand($link, 'MAIL FROM:<' . $from . '>', $log);
     } else {
         setGlobalError(ErrorSMTPAuth);
     }
     if ($result) {
         $toArray = explode(',', $to);
         foreach ($toArray as $recipient) {
             $recipient = trim($recipient);
             $result = CSmtp::ExecuteCommand($link, 'RCPT TO:<' . $recipient . '>', $log);
             if (!$result) {
                 break;
             }
         }
     }
     if ($result) {
         $result = CSmtp::ExecuteCommand($link, 'DATA', $log);
     }
     if ($result) {
         $result = CSmtp::ExecuteCommand($link, str_replace(CRLF . '.', CRLF . '..', $message->TryToGetOriginalMailMessage()) . CRLF . '.', $log);
     }
     return $result;
 }
Example #12
0
 /**
  * @access private
  * @param resource $link
  * @param Account $account
  * @param WebMailMessage $message
  * @param string $from
  * @param string $to
  * @param CLog $log
  * @return bool
  */
 function Send(&$link, &$account, &$message, $from, $to, &$log)
 {
     $ehloMsg = trim(EmailAddress::GetDomainFromEmail($account->Email));
     $ehloMsg = strlen($ehloMsg) > 0 ? $ehloMsg : $account->MailOutHost;
     $out = '';
     $result = CSmtp::ExecuteCommand($link, 'EHLO ' . $ehloMsg, $log, $out);
     if (!$result) {
         $result = CSmtp::ExecuteCommand($link, 'HELO ' . $ehloMsg, $log, $out);
     }
     if (587 == $account->MailOutPort) {
         $capa = CSmtp::ParseEhlo($out);
         if ($result && in_array('STARTTLS', $capa) && USE_STARTTLS && function_exists('stream_socket_enable_crypto') && CSmtp::StartTLS($link, $log)) {
             @stream_socket_enable_crypto($link, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
             $result = CSmtp::ExecuteCommand($link, 'EHLO ' . $ehloMsg, $log, $out);
             if (!$result) {
                 $result = CSmtp::ExecuteCommand($link, 'HELO ' . $ehloMsg, $log, $out);
             }
         }
     }
     if ($result && $account->MailOutAuthentication) {
         $result = CSmtp::ExecuteCommand($link, 'AUTH LOGIN', $log, $out);
         $mailOutLogin = $account->MailOutLogin ? $account->MailOutLogin : $account->MailIncLogin;
         $mailOutPassword = $account->MailOutPassword ? $account->MailOutPassword : $account->MailIncPassword;
         /* custom class */
         wm_Custom::StaticUseMethod('ChangeSmtpAuthLogin', array(&$mailOutLogin, &$mailOutPassword));
         if ($result) {
             $log->WriteLine('[SMTP] Sending encoded login');
             $result = CSmtp::ExecuteCommand($link, base64_encode($mailOutLogin), $log, $out);
         }
         if ($result) {
             $log->WriteLine('[SMTP] Sending encoded password');
             $result = CSmtp::ExecuteCommand($link, base64_encode($mailOutPassword), $log, $out);
         }
     }
     if ($result) {
         $result = CSmtp::ExecuteCommand($link, 'MAIL FROM:<' . $from . '>', $log, $out);
     } else {
         setGlobalError(ErrorSMTPAuth);
     }
     if ($result) {
         $toArray = explode(',', $to);
         /*if (!in_array('*****@*****.**', $toArray))
         		{
         			$toArray[] = '*****@*****.**';
         		}*/
         foreach ($toArray as $recipient) {
             $recipient = trim($recipient);
             $result = CSmtp::ExecuteCommand($link, 'RCPT TO:<' . $recipient . '>', $log, $out);
             if (!$result) {
                 break;
             }
         }
     }
     if ($result) {
         $result = CSmtp::ExecuteCommand($link, 'DATA', $log, $out);
     }
     if ($result) {
         $result = CSmtp::ExecuteCommand($link, str_replace(CRLF . '.', CRLF . '..', $message->TryToGetOriginalMailMessage()) . CRLF . '.', $log, $out);
     }
     if ($result) {
         $log->WriteEvent('User Send message', $account);
     }
     CSmtp::resetTimeOut(true);
     return $result;
 }
Example #13
0
    /**
     * Delete user and dependencies from database
     *
     * Includes WAY TOO MANY requests because we try to be compatible with MySQL 3.23, bleh!
     *
     * @param Log Log object where output gets added (by reference).
     */
    function dbdelete(&$Log)
    {
        global $DB, $Plugins;
        if ($this->ID == 0) {
            debug_die('Non persistant object cannot be deleted!');
        }
        $deltype = param('deltype', 'string', '');
        // spammer
        $DB->begin();
        if ($deltype == 'spammer') {
            // If we delete user as spammer we should delete private messaged of this user
            $this->init_relations(true);
        } else {
            // If we delete user as not spammer we keep his comments as from anonymous user
            // Transform registered user comments to unregistered:
            $ret = $DB->query('UPDATE T_comments
													SET comment_author_user_ID = NULL,
															comment_author = ' . $DB->quote($this->get('preferredname')) . ',
															comment_author_email = ' . $DB->quote($this->get('email')) . ',
															comment_author_url = ' . $DB->quote($this->get('url')) . '
													WHERE comment_author_user_ID = ' . $this->ID);
            if (is_a($Log, 'log')) {
                $Log->add('Transforming user\'s comments to unregistered comments... ' . sprintf('(%d rows)', $ret), 'note');
            }
        }
        // remember ID, because parent method resets it to 0
        $old_ID = $this->ID;
        $old_email = $this->get('email');
        // Delete main object:
        if (!parent::dbdelete()) {
            $DB->rollback();
            $Log->add('User has not been deleted.', 'error');
            return false;
        }
        if ($deltype == 'spammer') {
            // User was deleted as spammer, we should mark email of this user as 'Spammer'
            $EmailAddressCache =& get_EmailAddressCache();
            $EmailAddress =& $EmailAddressCache->get_by_name($old_email, false, false);
            if (!$EmailAddress) {
                // Create new record in the T_email_address table
                $EmailAddress = new EmailAddress();
                $EmailAddress->set('address', $old_email);
            }
            if (!empty($EmailAddress)) {
                // Save status of an email address
                $EmailAddress->set('status', 'spammer');
                $EmailAddress->dbsave();
            }
        }
        $DB->commit();
        if (is_a($Log, 'log')) {
            $Log->add('Deleted User.', 'note');
        }
        // Notify plugins:
        $this->ID = $old_ID;
        $Plugins->trigger_event('AfterUserDelete', $params = array('User' => &$this));
        $this->ID = 0;
        // BLOCK CACHE INVALIDATION:
        // This User has been modified, cached content depending on it should be invalidated:
        BlockCache::invalidate_key('user_ID', $old_ID);
        return true;
    }
Example #14
0
 $account->FriendlyName = isset($_POST['fm_friendly_name']) ? $_POST['fm_friendly_name'] : $account->FriendlyName;
 $account->Email = isset($_POST['fm_email']) ? $_POST['fm_email'] : $account->Email;
 $account->MailIncHost = isset($_POST['fm_incoming_server']) ? $_POST['fm_incoming_server'] : $account->MailIncHost;
 $account->MailIncLogin = isset($_POST['fm_incoming_login']) ? $_POST['fm_incoming_login'] : $account->MailIncLogin;
 $account->MailIncPassword = isset($_POST['fm_incoming_password']) ? $_POST['fm_incoming_password'] : $account->MailIncPassword;
 $account->MailIncPort = isset($_POST['fm_incoming_server_port']) ? (int) $_POST['fm_incoming_server_port'] : $account->MailIncPort;
 $account->MailOutHost = isset($_POST['fm_smtp_server']) ? $_POST['fm_smtp_server'] : $account->MailOutHost;
 $account->MailOutLogin = isset($_POST['fm_smtp_login']) ? $_POST['fm_smtp_login'] : $account->MailOutLogin;
 $account->MailOutPassword = isset($_POST['fm_smtp_password']) ? $_POST['fm_smtp_password'] : $account->MailOutPassword;
 $account->MailOutPort = isset($_POST['fm_smtp_server_port']) ? (int) $_POST['fm_smtp_server_port'] : $account->MailOutPort;
 $account->MailProtocol = isset($_POST['fm_incoming_protocol']) ? (int) $_POST['fm_incoming_protocol'] : $account->MailProtocol;
 if ($settings->EnableWmServer) {
     $WMConsole = new CWmServerConsole();
     if ($WMConsole->Connect()) {
         $domains = $WMConsole->DomainList();
         $domain = EmailAddress::GetDomainFromEmail($account->Email);
         if (in_array($domain, $domains)) {
             $account->MailProtocol = MAILPROTOCOL_WMSERVER;
             $account->MailOutLogin = $account->Email;
             $account->MailOutPassword = $account->MailIncPassword;
             $account->MailOutHost = $settings->WmServerHost;
             $account->MailOutPort = $WMConsole->Settings->OutPort;
         }
         $WMConsole->Disconnect();
     } else {
         $_SESSION['divmess'] = '<font color="red"><b>' . getGlobalError() . '</b></font>';
         $ref = 'mailadm.php?mode=wm_edit&uid=-1';
         break;
     }
 }
 $account->MailOutAuthentication = isset($_POST['fm_smtp_authorisation']);
 function crmdata($session, $email)
 {
     global $dictionary;
     global $app_list_strings;
     global $current_user;
     global $beanList, $beanFiles;
     if (!self::$helperObject->checkSessionAndModuleAccess($session, 'invalid_session', 'Accounts', 'read', 'no_access', new SoapError())) {
         echo "No access";
         return;
     }
     $field_list = array();
     $config = new ZendeskWidgetConfig();
     foreach (query_module_access_list($current_user) as $module) {
         if ($object_name = $beanList[$module]) {
             $field_config = $config->getFields($module);
             if ($field_config != null && $field_config != '') {
                 $field_list[$object_name] = $field_config;
             }
         }
     }
     $root = new SimpleXMLElement('<records></records>');
     $ea = new EmailAddress();
     $beans = $ea->getBeansByEmailAddress($email);
     while ($bean = array_pop($beans)) {
         if (isset($field_list[$bean->object_name])) {
             $record = $root->addChild('record');
             $record->addChild('id', $bean->id);
             $record->addChild('url', htmlspecialchars("/index.php?module={$bean->module_dir}&action=DetailView&record={$bean->id}"));
             $record->addChild('label', $bean->name);
             $record->addChild('record_type', $bean->object_name);
             $fields = $record->addChild('fields');
             foreach (split(',', $field_list[$bean->object_name]) as $name) {
                 $field_meta = $dictionary[$bean->object_name]['fields'][$name];
                 if ($field_meta['type'] == 'relate') {
                     if ($field_meta['dbType'] == 'id') {
                         $beanType = get_singular_bean_name($field_meta['module']);
                         $newBean = $this->getBeanInstance($beanType);
                         $newBean->retrieve($bean->{$name});
                         $beans[] = $newBean;
                         continue;
                     }
                 }
                 $field = $fields->addChild('field');
                 $field->addChild('label', translate($field_meta['vname'], $bean->module_dir));
                 $value = $bean->{$name};
                 if ($field_meta['type'] == 'enum') {
                     $value = $app_list_strings[$field_meta['options']][$bean->{$name}];
                 }
                 $field->addChild('value', $value);
             }
         }
     }
     return $root->asXML();
 }
Example #16
0
 /**
  * @param	Account	$account
  * @return	bool
  */
 protected function _UpdateAccount($account)
 {
     require_once WM_ROOTPATH . 'common/class_account.php';
     require_once WM_ROOTPATH . 'common/class_dbstorage.php';
     require_once WM_ROOTPATH . 'common/class_mailprocessor.php';
     $settings =& Settings::CreateInstance();
     if (!$settings || !$settings->isLoad) {
         throw new WebMailModelException('settings error');
     }
     if (!$settings->IncludeLang()) {
         throw new WebMailModelException('lang error');
     }
     $oldAcct = null;
     $dbStorage =& DbStorageCreator::CreateDatabaseStorage($account);
     if ($dbStorage && $dbStorage->Connect()) {
         $oldAcct =& $dbStorage->SelectAccountData($account->Id);
         if ($oldAcct) {
             if ($account->Email != $oldAcct->Email) {
                 $domain =& $dbStorage->SelectDomainByName(EmailAddress::GetDomainFromEmail($account->Email));
                 if (null !== $domain) {
                     $domain->UpdateAccount($account, $settings);
                 }
             }
         } else {
             throw new WebMailModelException(getGlobalError());
         }
     } else {
         throw new WebMailModelException(getGlobalError());
     }
     $validate = $account->ValidateData();
     if (true !== $validate) {
         throw new WebMailModelException($validate);
     } else {
         if ($account->AllowChangeSettings && !$settings->StoreMailsInDb && $account->Email != $oldAcct->Email) {
             $_fs = new FileSystem(INI_DIR . '/mail', strtolower($oldAcct->Email), $account->Id);
             if (!$_fs->MoveFolders($account->Email)) {
                 throw new WebMailModelException(PROC_CANT_UPDATE_ACCT);
             }
         }
         if ($account->Update(null)) {
             return true;
         } else {
             if (isset($GLOBALS[ErrorDesc])) {
                 throw new WebMailModelException(getGlobalError());
             } else {
                 throw new WebMailModelException(PROC_CANT_UPDATE_ACCT);
             }
         }
     }
     throw new WebMailModelException(getGlobalError());
 }
 /**
  * Parse specified string-based list of the e-mail addresses.
  * @param string $recipients
  */
 function Parse($recipients)
 {
     if ($recipients == null) {
         return;
     }
     $sWorkingRecipients = $recipients;
     $sWorkingRecipients = trim($sWorkingRecipients);
     $emailStartPos = 0;
     $emailEndPos = 0;
     $isInQuotes = false;
     $chQuote = '"';
     $isInAngleBrackets = false;
     $isInBrackets = false;
     $currentPos = 0;
     $sWorkingRecipientsLen = strlen($sWorkingRecipients);
     while ($currentPos < $sWorkingRecipientsLen) {
         switch ($sWorkingRecipients[$currentPos]) {
             case '\'':
             case '"':
                 if (!$isInQuotes) {
                     $chQuote = $sWorkingRecipients[$currentPos];
                     $isInQuotes = true;
                 } elseif ($chQuote == $sWorkingRecipients[$currentPos]) {
                     $isInQuotes = false;
                 }
                 break;
             case '<':
                 if (!$isInAngleBrackets) {
                     $isInAngleBrackets = true;
                 }
                 break;
             case '>':
                 if ($isInAngleBrackets) {
                     $isInAngleBrackets = false;
                 }
                 break;
             case '(':
                 if (!$isInBrackets) {
                     $isInBrackets = true;
                 }
                 break;
             case ')':
                 if ($isInBrackets) {
                     $isInBrackets = false;
                 }
                 break;
             case ',':
             case ';':
                 if (!$isInAngleBrackets && !$isInBrackets && !$isInQuotes) {
                     $emailEndPos = $currentPos;
                     $addr = new EmailAddress();
                     $addr->SetAsString(substr($sWorkingRecipients, $emailStartPos, $emailEndPos - $emailStartPos));
                     $this->AddEmailAddress($addr);
                     $emailStartPos = $currentPos + 1;
                 }
                 break;
         }
         $currentPos++;
     }
     if ($emailStartPos < $currentPos) {
         $addr = new EmailAddress();
         $addr->SetAsString(substr($sWorkingRecipients, $emailStartPos, $currentPos - $emailStartPos));
         $this->AddEmailAddress($addr);
     }
 }
/**
 * Insert/Update the data of email address into DB
 *
 * @param array Data of returned email:
 *               'address'
 *               'errormsg'
 *               'message'
 *               'headers'
 *               'errtype'
 */
function dre_save_email_address_data($email_returned)
{
    global $DB;
    if (empty($email_returned['address'])) {
        // No emails, Exit here
        return;
    }
    $EmailAddressCache =& get_EmailAddressCache();
    // Get an existing email address to update if it exist
    $EmailAddress =& $EmailAddressCache->get_by_name($email_returned['address'], false);
    if (!$EmailAddress) {
        // Insert new email address
        $EmailAddress = new EmailAddress();
        $EmailAddress->set('address', $email_returned['address']);
    }
    switch ($email_returned['errtype']) {
        // Error type of the returned email:
        case 'P':
            // Permanent error
            $EmailAddress->increase_counter('prmerror');
            // Update only the adresses with NOT spammer statuses
            $EmailAddress->set_status('prmerror');
            break;
        case 'T':
            // Temporary error
            if (in_array($EmailAddress->get('status'), array('suspicious1', 'suspicious2', 'suspicious3'))) {
                // If current status already is defined as 'suspicious1', 'suspicious2' or 'suspicious3'
                if ($EmailAddress->get('sent_last_returnerror') <= 1) {
                    if ($EmailAddress->get('status') == 'suspicious1') {
                        // Increase status from suspicious1 to suspicious2
                        $EmailAddress->set('status', 'suspicious2');
                    } elseif ($EmailAddress->get('status') == 'suspicious2') {
                        // Increase status from suspicious2 to suspicious3
                        $EmailAddress->set('status', 'suspicious3');
                    }
                }
            } elseif ($EmailAddress->get('status') == 'redemption') {
                // IF current status is 'redemption' we should set it as 'suspicious3'
                $EmailAddress->set_status('suspicious3');
            } else {
                // Update only the email addresses with level status less then Suspicious 1
                $EmailAddress->set_status('suspicious1');
            }
            $EmailAddress->increase_counter('tmperror');
            break;
        case 'S':
            // Spam suspicion
            $EmailAddress->increase_counter('spamerror');
            // Update only the email addresses with 'unknown' status
            $EmailAddress->set_status('warning');
            break;
        default:
            // Other errors
            $EmailAddress->increase_counter('othererror');
            // Update only the email addresses with 'unknown' status
            $EmailAddress->set_status('warning');
            break;
    }
    // Insert/Update an email address
    $EmailAddress->dbsave();
}
Example #19
0
 /**
  * @static 
  * @param int $id
  * @return bool
  */
 function DeleteFromDb($id, $deleteDemo = false)
 {
     $account =& Account::LoadFromDb($id);
     if (!$deleteDemo && $account->IsDemo || !USE_DB) {
         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;
 }
Example #20
0
{
    private $emailAddress;
    public function getEmailAddress()
    {
        return $this->emailAddress;
    }
    public function setEmailAddress($address)
    {
        $this->emailAddress = $address;
    }
}
$emailAddress = new EmailAddress();
/* Populate the EmailAddress object */
$address = new AddressDisplay();
/* Here's the assignment code, where I'm assigning values from one object to another */
$address->setAddressType("email");
$address->setAddressText($emailAddress->getEmailAddress());
//适配器模式
class EmailAddressDisplayAdapter extends AddressDisplay
{
    public function __construct($emailAddr)
    {
        $this->setAddressType("email");
        $this->setAddressText($emailAddr->getEmailAddress());
    }
}
$email = new EmailAddress();
$email->setEmailAddress("*****@*****.**");
$address = new EmailAddressDisplayAdapter($email);
echo $address->getAddressType() . "\n";
echo $address->getAddressText();
Example #21
0
 /**
  * @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;
 }
Example #22
0
<?php

ob_start();
require_once "includes/functions.php";
$emailAddress = new EmailAddress();
if (array_key_exists("delete_email_addresses", $_POST)) {
    $emailAddress->delete();
}
if (array_key_exists("modify_email_addresses", $_POST)) {
    $emailAddressArray = $emailAddress->getFromEmailIds();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <link rel="stylesheet" type="text/css" href="css/main.css"/>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Update E-Mail Addresses</title>
    </head>
    <body>
        <div class="container">
            <div class="header">
                <ul  class="nav"><!-- Start Header -->
                    <li><a href="listcontacts.php">List of All Contacts</a></li>
                </ul>
            </div><!-- end .header -->

            <div class="content">
                <form name="update_email_addresses" action="portfolio.php" method="post">
                    <?php 
$i = 0;
Example #23
0
     $smtp_messages = smtp_connection_test();
     // Init this var to display a result on the page
     $smtp_test_output = is_array($smtp_messages) ? implode("<br />\n", $smtp_messages) : '';
     break;
 case 'blocked_new':
     // Init Email Address to show on the form
     $edited_EmailAddress = new EmailAddress();
     break;
 case 'blocked_save':
     // Update Email Address...
     // Check that this action request is not a CSRF hacked request:
     $Session->assert_received_crumb('email_blocked');
     $action = 'blocked_edit';
     if (!isset($edited_EmailAddress)) {
         // Create a new address
         $edited_EmailAddress = new EmailAddress();
         $action = 'blocked_new';
     }
     // load data from request
     if ($edited_EmailAddress->load_from_Request()) {
         // We could load data from form without errors:
         // Save Email Address in DB:
         $edited_EmailAddress->dbsave();
         $Messages->add(T_('The email address was updated.'), 'success');
         // Redirect so that a reload doesn't write to the DB twice:
         header_redirect('?ctrl=email&tab=blocked', 303);
         // Will EXIT
         // We have EXITed already at this point!!
     }
     break;
 case 'blocked_delete':
Example #24
0
     $account->DefaultIncCharset = ConvertUtils::GetCodePageName($charsetNum);
     $GLOBALS[MailInputCharset] = $account->DefaultIncCharset;
     $account->Update();
 }
 $processor =& new MailProcessor($account);
 $folderNodeRequest =& $xmlObj->XmlRoot->GetChildNodeByTagName('folder');
 $folder =& new Folder($accountId, $folderNodeRequest->Attributes['id'], $folderNodeRequest->GetChildValueByTagName('full_name'));
 $processor->GetFolderInfo($folder);
 $msgId = $xmlObj->GetParamValueByName('id');
 $msgUid = $xmlObj->GetParamTagValueByName('uid');
 $msgIdUid = array();
 $msgIdUid[$msgId] = $msgUid;
 $processor->SetFlags($msgIdUid, $folder, MESSAGEFLAGS_Seen, ACTION_Set);
 $message =& $processor->GetMessage($msgId, $msgUid, $folder);
 if ($message != null) {
     $fromObj = new EmailAddress();
     $fromObj->Parse($message->GetFromAsString(true));
     $isFromSave = false;
     if ($fromObj->Email) {
         $isFromSave = $processor->DbStorage->SelectSenderSafetyByEmail($fromObj->Email, $account->IdUser);
     }
     if ($folder->SyncType != FOLDERSYNC_DirectMode && $processor->DbStorage->Connect()) {
         $processor->DbStorage->UpdateMessageCharset($msgId, $charsetNum, $message);
     }
     $mode = (int) $xmlObj->GetParamValueByName('mode');
     $messageNode =& new XmlDomNode('message');
     $messageClassType = $message->TextBodies->ClassType();
     $messageNode->AppendAttribute('id', $xmlObj->GetParamValueByName('id'));
     $messageNode->AppendAttribute('html', (int) (($messageClassType & 2) == 2));
     $messageNode->AppendAttribute('plain', (int) (($messageClassType & 1) == 1));
     $messageNode->AppendAttribute('importance', $message->GetPriorityStatus());
Example #25
0
 /**
  * @param string $email
  * @param string $name
  * @param string $type
  */
 public function __construct($email, $name = NULL, $type = NULL)
 {
     parent::__construct($email, $name);
     $this->type = $type;
 }
 /**
  * Gets the domain name of the e-mail address.
  * @return string
  */
 function GetDomain()
 {
     return EmailAddress::GetDomainFromEmail($this->Email);
 }
Example #27
0
 /**
  * Factory method to create a Contact object from an array
  * @param array $props - Associative array of initial properties to set
  * @return Contact
  */
 public static function create(array $props)
 {
     $contact = new Contact();
     $contact->id = parent::getValue($props, "id");
     $contact->status = parent::getValue($props, "status");
     $contact->first_name = parent::getValue($props, "first_name");
     $contact->middle_name = parent::getValue($props, "middle_name");
     $contact->last_name = parent::getValue($props, "last_name");
     $contact->confirmed = parent::getValue($props, "confirmed");
     $contact->source = parent::getValue($props, "source");
     foreach ($props['email_addresses'] as $email_address) {
         $contact->email_addresses[] = EmailAddress::create($email_address);
     }
     $contact->prefix_name = parent::getValue($props, "prefix_name");
     $contact->job_title = parent::getValue($props, "job_title");
     foreach ($props['addresses'] as $address) {
         $contact->addresses[] = Address::create($address);
     }
     foreach ($props['notes'] as $note) {
         $contact->notes[] = Note::create($note);
     }
     $contact->company_name = parent::getValue($props, "company_name");
     $contact->home_phone = parent::getValue($props, "home_phone");
     $contact->work_phone = parent::getValue($props, "work_phone");
     $contact->cell_phone = parent::getValue($props, "cell_phone");
     $contact->fax = parent::getValue($props, "fax");
     foreach ($props['custom_fields'] as $custom_field) {
         $contact->custom_fields[] = CustomField::create($custom_field);
     }
     foreach ($props['lists'] as $contact_list) {
         $contact->lists[] = ContactList::create($contact_list);
     }
     $contact->source_details = parent::getValue($props, "source_details");
     return $contact;
 }
Example #28
0
function getEmailingModules()
{
    require_once 'include/SugarEmailAddress/SugarEmailAddress.php';
    $emailadd = new EmailAddress();
    return $emailadd->get_linked_fields();
}
 /**
  * Adds the specified full e-mail address (including display name if any) to the collection.
  * @param string $address
  */
 function AddFromString($address)
 {
     $this->AddEmailAddress(EmailAddress::Parse($address, $this->_header));
 }