Esempio n. 1
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;
 }
Esempio n. 2
0
 /**
  * @param XmlDomNode $_xmlRes
  * @param Account $_account
  */
 function GetAccount(&$_xmlRes, &$_account, &$_dbStorage)
 {
     if ($_account) {
         $_accountNode = new XmlDomNode('account');
         $_accountNode->AppendAttribute('id', $_account->Id);
         $_accountNode->AppendAttribute('linked', (int) ($_account->IdDomain > 0));
         $_accountNode->AppendAttribute('def_acct', (int) $_account->DefaultAccount);
         $_accountNode->AppendAttribute('def_order', $_account->DefaultOrder);
         $_accountNode->AppendAttribute('mail_protocol', $_account->MailProtocol);
         $_accountNode->AppendAttribute('mail_inc_port', $_account->MailIncPort);
         $_accountNode->AppendAttribute('mail_out_port', $_account->MailOutPort);
         $_accountNode->AppendAttribute('mail_out_auth', (int) $_account->MailOutAuthentication);
         $_accountNode->AppendAttribute('use_friendly_nm', (int) $_account->UseFriendlyName);
         $_accountNode->AppendAttribute('mails_on_server_days', $_account->MailsOnServerDays);
         $_accountNode->AppendAttribute('mail_mode', $_account->MailMode);
         $_accountNode->AppendAttribute('getmail_at_login', (int) $_account->GetMailAtLogin);
         $_accountNode->AppendAttribute('signature_opt', (int) $_account->SignatureOptions);
         $_accountNode->AppendAttribute('signature_type', (int) $_account->SignatureType);
         $_accountNode->AppendAttribute('save_mail', (int) $_account->SaveInSent);
         $_accountNode->AppendAttribute('size', $_account->MailboxSize);
         $_accountNode->AppendAttribute('is_internal', (int) $_account->IsInternal);
         if ($_account->MailProtocol == MAILPROTOCOL_POP3) {
             $syncType = $_dbStorage->GetFolderSyncTypeByIdAcct($_account->Id, FOLDERTYPE_Inbox);
             $_accountNode->AppendAttribute('inbox_sync_type', $syncType);
         }
         $email = $_account->Email;
         /* custom class */
         wm_Custom::StaticUseMethod('ChangeAccountEmailToFake', array(&$email));
         $_accountNode->AppendChild(new XmlDomNode('email', $email, true));
         $_accountNode->AppendChild(new XmlDomNode('friendly_name', $_account->FriendlyName, true));
         $_accountNode->AppendChild(new XmlDomNode('mail_inc_host', $_account->MailIncHost, true));
         $_accountNode->AppendChild(new XmlDomNode('mail_inc_login', $_account->MailIncLogin, true));
         $_accountNode->AppendChild(new XmlDomNode('mail_inc_pass', $_account->MailIncPassword === '' ? '' : DUMMYPASSWORD, true));
         $_accountNode->AppendChild(new XmlDomNode('mail_out_host', $_account->MailOutHost, true));
         $_accountNode->AppendChild(new XmlDomNode('mail_out_login', $_account->MailOutLogin, true));
         $_accountNode->AppendChild(new XmlDomNode('mail_out_pass', $_account->MailOutPassword === '' ? '' : DUMMYPASSWORD, true));
         $_accountNode->AppendChild(new XmlDomNode('signature', $_account->Signature, true));
         $_xmlRes->AppendChild($_accountNode);
         unset($_accountNode);
     }
 }
Esempio n. 3
0
 /**
  * @param string $name
  * return bool
  */
 function StaticMethodExist($name)
 {
     $c =& wm_Custom::CreateInstance();
     return $c->MethodExist($name);
 }
Esempio n. 4
0
 /**
  * @return FolderCollection
  */
 function &GetFolders()
 {
     if (!$this->_dbConnection->Execute($this->_commandCreator->GetFolders($this->Account->Id))) {
         $null = null;
         return $null;
     }
     $folders = array();
     while (false !== ($row = $this->_dbConnection->GetNextRecord())) {
         $folder = new Folder($this->Account->Id, (int) $row->id_folder, substr($row->full_path, 0, -1), substr($row->name, 0, -1));
         $folder->IdParent = $row->id_parent;
         $folder->Type = (int) $row->type;
         $folder->SyncType = (int) $row->sync_type;
         $folder->Hide = (bool) abs($row->hide);
         $folder->FolderOrder = (int) $row->fld_order;
         $folder->MessageCount = (int) $row->message_count;
         $folder->UnreadMessageCount = (int) $row->unread_message_count;
         $folder->Size = GetGoodBigInt($row->folder_size);
         $folder->Level = (int) $row->level;
         $folders[] =& $folder;
         unset($folder);
     }
     $folderCollection = new FolderCollection();
     $this->_addLevelToFolderTree($folderCollection, $folders);
     /* custom class */
     wm_Custom::StaticUseMethod('ChangeDbFoldersAfterGet', array(&$folderCollection));
     return $folderCollection;
 }
Esempio n. 5
0
 /**
  * @access private
  */
 function Settings($param = true)
 {
     if (!is_null($param)) {
         die('can\'t call Settings class.');
     }
     $this->UseDsn = false;
     $this->WmServerHost = '127.0.0.1';
     $this->AllowUsersChangeAccountsDef = false;
     $this->WmAllowManageXMailAccounts = false;
     $this->AllowContacts = true;
     $this->AllowCalendar = true;
     $this->UseCaptcha = true;
     $this->Cal_DefaultTimeFormat = 1;
     $this->Cal_DefaultTimeZone = 38;
     $this->Cal_DefaultDateFormat = 1;
     $this->Cal_ShowWeekends = true;
     $this->Cal_WorkdayStarts = 9;
     $this->Cal_WorkdayEnds = 18;
     $this->Cal_ShowWorkDay = 1;
     $this->Cal_WeekStartsOn = 0;
     $this->Cal_DefaultTab = 2;
     $this->Cal_DefaultCountry = 'US';
     $this->Cal_AllTimeZones = false;
     $this->Cal_AllowReminders = false;
     $this->Cal_AutoAddInvitation = 0;
     $this->Imap4DeleteLikePop3 = true;
     $this->AllowLanguageOnLogin = true;
     $this->AllowInsertImage = true;
     $this->AllowBodySize = false;
     $this->MaxBodySize = 600;
     $this->MaxSubjectSize = 255;
     $this->AllowRegistration = false;
     $this->AllowPasswordReset = false;
     $this->GlobalAddressBook = GLOBAL_ADDRESS_BOOK_OFF;
     $this->EnableMobileSync = false;
     $this->MobileSyncUrl = '';
     $this->MobileSyncContactDataBase = 'card';
     $this->MobileSyncCalendarDataBase = 'cal';
     $this->FlagsLangSelect = false;
     $this->ViewMode = 1;
     $this->SaveInSent = 0;
     $this->isLoad = false;
     $this->_langIsInclude = false;
     $this->Dev = null;
     $settingsCacher = new SettingsCacher();
     $settingsRaw = $settingsCacher->Load();
     if (false === $settingsRaw) {
         $settingsRaw = $settingsCacher->LoadRoot();
         if ($settingsRaw == false) {
             setGlobalError($settingsCacher->GetError());
         } else {
             $settingsCacher->Save($settingsRaw);
         }
     } else {
         if (is_array($settingsRaw)) {
             $this->_loadFromArray($settingsRaw);
             $this->isLoad = true;
         }
     }
     if (is_string($settingsRaw)) {
         $xmlDocument = new XmlDocument();
         if ($xmlDocument->LoadFromString($settingsRaw)) {
             $this->_loadFromXML($xmlDocument->XmlRoot);
             $this->isLoad = true;
         }
     }
     if ($this->isLoad) {
         if (!@function_exists('imagecreatefrompng')) {
             $this->UseCaptcha = false;
         }
         $xmlDomainSettings =& DomainSettings::CreateInstance();
         $xmlDomainSettings->UpdateSettingsByDomain($this);
         /* custom class */
         wm_Custom::StaticUseMethod('ChangeSettingsAfterLoad', array(&$this));
     }
 }
Esempio n. 6
0
 /**
  * @param	array	$messageIdUidSet
  * @param	Folder	$fromFolder
  * @param	bool	$isSpam = true
  * @return	bool
  */
 function SpamMessages(&$messageIdUidSet, &$fromFolder, $isSpam = true)
 {
     $result = true;
     if (!$this->DbStorage->Connect() || !$this->MailStorage->Connect(true)) {
         return false;
     }
     $toFolder = null;
     $folders =& $this->DbStorage->GetFolders();
     if ($isSpam) {
         $toFolder =& $folders->GetFolderByType(FOLDERTYPE_Spam);
     } else {
         $toFolder =& $folders->GetFolderByType(FOLDERTYPE_Inbox);
     }
     if ($toFolder) {
         $needSystemSpamSet = true;
         /* custom class */
         wm_Custom::StaticUseMethod('MailStorageSpamMessages', array(&$this, &$needSystemSpamSet, &$messageIdUidSet, &$fromFolder, &$toFolder, &$isSpam));
         if ($needSystemSpamSet) {
             $this->MailStorage->SpamMessages($messageIdUidSet, $fromFolder, $isSpam);
         }
         $result = $this->MoveMessages($messageIdUidSet, $fromFolder, $toFolder);
     }
     return $result;
 }
Esempio n. 7
0
 function checkSystemFolderAndCreate(&$_settings, &$_newprocessor, &$_account, &$folders, $folderType, $folderName)
 {
     $createSystemFoldersInInbox = 0 === strpos($_account->NameSpace, 'INBOX');
     $createFoldersIfNotExist = CREATE_FOLDERS_IF_NOT_EXIST;
     /* custom class */
     wm_Custom::StaticUseMethod('ChangeValueOfSystemFoldersInInbox', array(&$createSystemFoldersInInbox));
     wm_Custom::StaticUseMethod('ChangeValueOfCreateFolderIfNotExist', array(&$createFoldersIfNotExist));
     $folderByName = $folders->GetFolderByName($folderName);
     $folderByType = $folders->GetFolderByType($folderType);
     if ($folderByName && !$folderByType) {
         if ($folderByName->Type !== $folderType) {
             $folderByName->Type = $folderType;
             if ($createFoldersIfNotExist && $folderByName->SyncType == FOLDERSYNC_DontSync) {
                 $folderByName->SetFolderSync($_account->GetDefaultFolderSync($_settings));
                 $_newprocessor->CreateFolder($folderByName);
             } else {
                 if ($_newprocessor->DbStorage->Connect()) {
                     $_newprocessor->DbStorage->UpdateFolder($folderByName);
                 }
             }
         }
     } else {
         if (!$folderByType) {
             $prefix = '';
             if ($createSystemFoldersInInbox) {
                 $inboxFolder = $folders->GetFolderByType(FOLDERTYPE_Inbox);
                 if ($inboxFolder) {
                     $prefix = $inboxFolder->FullName . $_account->Delimiter;
                 }
             }
             $folder = new Folder($_account->Id, -1, $prefix . $folderName, $folderName, FOLDERSYNC_DontSync, $folderType);
             if ($createFoldersIfNotExist) {
                 $folder->SetFolderSync($_account->GetDefaultFolderSync($_settings));
             }
             $_newprocessor->CreateFolder($folder);
         }
     }
 }
Esempio n. 8
0
<?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);
                }
            }
        }
Esempio n. 9
0
 /**
  * @param Account $account
  * @param int $inboxSyncType = FOLDERSYNC_NewEntireMessages
  * @param bool $integrCall = false
  * @return bool
  */
 function CreateAccount(&$account, $inboxSyncType = FOLDERSYNC_NewEntireMessages, $integrCall = false, $mailStorage = null)
 {
     $null = $folders = null;
     $account->IdUser = $this->Id;
     $result = false;
     setGlobalError(PROC_ERROR_ACCT_CREATE);
     $dbStorage =& DbStorageCreator::CreateDatabaseStorage($account);
     if ($dbStorage->Connect()) {
         if (USE_DB && !$account->IsInternal) {
             $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();
         if ($settings->AllowDirectMode && $settings->DirectModeIsDefault) {
             $inboxSyncType = FOLDERSYNC_DirectMode;
         }
         $addFolders = null;
         /* load or create folder tree here */
         switch ($account->MailProtocol) {
             case MAILPROTOCOL_POP3:
                 $result = $account->IsInternal ? $dbStorage->UpdateOnlyAccoutnData($account) : $dbStorage->InsertAccountData($account);
                 if ($result) {
                     $folders = new FolderCollection();
                     $inboxFolder = new Folder($account->Id, -1, FOLDERNAME_Inbox, FOLDERNAME_Inbox);
                     $inboxFolder->SyncType = $inboxSyncType;
                     $folders->Add($inboxFolder);
                     $createSystemFoldersInInbox = false;
                     /* custom class */
                     wm_Custom::StaticUseMethod('ChangeValueOfSystemFoldersInInbox', array(&$createSystemFoldersInInbox));
                     $folderPrefix = '';
                     if ($createSystemFoldersInInbox) {
                         $folderPrefix = $inboxFolder->FullName . $account->Delimiter;
                         $inboxFolder->SubFolders = $inboxFolder->SubFolders ? $inboxFolder->SubFolders : new FolderCollection();
                         $addFolders =& $inboxFolder->SubFolders;
                     } else {
                         $addFolders =& $folders;
                     }
                     $addFolders->Add(new Folder($account->Id, -1, $folderPrefix . FOLDERNAME_SentItems, FOLDERNAME_SentItems, FOLDERSYNC_DontSync));
                     $addFolders->Add(new Folder($account->Id, -1, $folderPrefix . FOLDERNAME_Drafts, FOLDERNAME_Drafts, FOLDERSYNC_DontSync));
                     $addFolders->Add(new Folder($account->Id, -1, $folderPrefix . FOLDERNAME_Spam, FOLDERNAME_Spam, FOLDERSYNC_DontSync));
                     $addFolders->Add(new Folder($account->Id, -1, $folderPrefix . FOLDERNAME_Trash, FOLDERNAME_Trash, FOLDERSYNC_DontSync));
                 }
                 break;
             case MAILPROTOCOL_IMAP4:
                 setGlobalError(ACCT_CANT_CREATE_IMAP_ACCT);
                 if (null === $mailStorage) {
                     $mailStorage = new ImapStorage($account, $null);
                 }
                 if ($mailStorage->Connect()) {
                     if ($settings->TakeImapQuota) {
                         if ($mailStorage->IsQuotaSupport()) {
                             if ($account->ImapQuota === 1) {
                                 $mbl = $mailStorage->GetQuota();
                                 if (false !== $mbl) {
                                     $account->MailboxLimit = GetGoodBigInt($mbl);
                                 } else {
                                     $account->ImapQuota = -1;
                                 }
                             }
                         } else {
                             $account->ImapQuota = -1;
                         }
                     }
                     if (USE_DB) {
                         $result = $account->IsInternal ? $dbStorage->UpdateOnlyAccoutnData($account) : $dbStorage->InsertAccountData($account);
                         if (!$result) {
                             return false;
                         }
                     } else {
                         $result = true;
                     }
                     $folders =& $mailStorage->GetFolders();
                     if ($folders == null) {
                         if (USE_DB) {
                             $dbStorage->DeleteAccountData($account->Id);
                         }
                         setGlobalError(PROC_ERROR_ACCT_CREATE);
                         return false;
                     }
                     $inb =& $folders->GetFolderByType(FOLDERTYPE_Inbox);
                     if ($inb === null) {
                         if (USE_DB) {
                             $dbStorage->DeleteAccountData($account->Id);
                         }
                         setGlobalError(PROC_ERROR_ACCT_CREATE);
                         return false;
                     }
                     $folders->SetSyncTypeToAll($inboxSyncType);
                     if (!$result) {
                         return false;
                     }
                     $s = $d = $t = $sp = null;
                     $s =& $folders->GetFolderByType(FOLDERTYPE_SentItems);
                     $d =& $folders->GetFolderByType(FOLDERTYPE_Drafts);
                     $sp =& $folders->GetFolderByType(FOLDERTYPE_Spam);
                     if ($settings->Imap4DeleteLikePop3) {
                         $t =& $folders->GetFolderByType(FOLDERTYPE_Trash);
                     }
                     $account->NameSpace = $mailStorage->GetNameSpacePrefix();
                     $account->UpdateNameSpace();
                     $createSystemFoldersInInbox = 0 === strpos($account->NameSpace, $inb->FullName);
                     $createFoldersIfNotExist = $account->IsInternal ? true : CREATE_FOLDERS_IF_NOT_EXIST;
                     /* custom class */
                     wm_Custom::StaticUseMethod('ChangeValueOfSystemFoldersInInbox', array(&$createSystemFoldersInInbox));
                     wm_Custom::StaticUseMethod('ChangeValueOfCreateFolderIfNotExist', array(&$createFoldersIfNotExist));
                     $folderPrefix = '';
                     if ($createSystemFoldersInInbox) {
                         $folderPrefix = $inb->FullName . $account->Delimiter;
                         $inb->SubFolders = $inb->SubFolders ? $inb->SubFolders : new FolderCollection();
                         $addFolders =& $inb->SubFolders;
                     } else {
                         $addFolders =& $folders;
                     }
                     if ($s === null) {
                         $sentFolder = new Folder($account->Id, -1, $folderPrefix . FOLDERNAME_SentItems, FOLDERNAME_SentItems, FOLDERSYNC_DontSync);
                         if ($createFoldersIfNotExist) {
                             $sentFolder->SetFolderSync($inboxSyncType);
                             $mailStorage->CreateFolder($sentFolder);
                         }
                         $addFolders->Add($sentFolder);
                     }
                     if ($d === null) {
                         $draftsFolder = new Folder($account->Id, -1, $folderPrefix . FOLDERNAME_Drafts, FOLDERNAME_Drafts, FOLDERSYNC_DontSync);
                         if ($createFoldersIfNotExist) {
                             $draftsFolder->SetFolderSync($inboxSyncType);
                             $mailStorage->CreateFolder($draftsFolder);
                         }
                         $addFolders->Add($draftsFolder);
                     }
                     if ($sp === null) {
                         $spamFolder = new Folder($account->Id, -1, $folderPrefix . FOLDERNAME_Spam, FOLDERNAME_Spam, FOLDERSYNC_DontSync);
                         if ($createFoldersIfNotExist) {
                             $spamFolder->SetFolderSync($inboxSyncType);
                             $mailStorage->CreateFolder($spamFolder);
                         }
                         $addFolders->Add($spamFolder);
                     }
                     if ($settings->Imap4DeleteLikePop3 && $t === null) {
                         $trashFolder = new Folder($account->Id, -1, $folderPrefix . FOLDERNAME_Trash, FOLDERNAME_Trash, FOLDERSYNC_DontSync);
                         if ($createFoldersIfNotExist) {
                             $trashFolder->SetFolderSync($inboxSyncType);
                             $mailStorage->CreateFolder($trashFolder);
                         }
                         $addFolders->Add($trashFolder);
                     }
                     $mailStorage->Disconnect();
                 } else {
                     return false;
                 }
                 break;
             default:
                 return false;
         }
         if ($result && $folders) {
             $folders = $folders->SortRootTree();
             if (USE_DB) {
                 $result &= $dbStorage->CreateFolders($folders);
             }
         }
     }
     if ($result) {
         setGlobalError('');
         if ($account && $account->MailProtocol == MAILPROTOCOL_IMAP4 && $account->ImapQuota === 1) {
             $account->UpdateMailBoxLimit();
         }
     }
     return $result;
 }
Esempio n. 10
0
 function FilterCollection()
 {
     CollectionBase::CollectionBase();
     $filter = new Filter();
     $filter->Action = FILTERACTION_VirusDetect;
     $filter->Field = FILTERFIELD_XVirus;
     $filter->Condition = FILTERCONDITION_StartFrom;
     $filter->Filter = 'infected';
     $filter->Id = $filter->IdAcct = $filter->IdFolder = -1;
     $filter->IsSystem = true;
     $this->Add($filter);
     unset($filter);
     $filter = new Filter();
     $filter->Action = FILTERACTION_SpamDetect;
     $filter->Field = FILTERFIELD_XSpam;
     $filter->Condition = FILTERCONDITION_StartFrom;
     $filter->Filter = 'spam';
     $filter->Id = $filter->IdAcct = $filter->IdFolder = -1;
     $filter->IsSystem = true;
     $this->Add($filter);
     unset($filter);
     /* custom class */
     wm_Custom::StaticUseMethod('UpdateFilterCollectionCreate', array(&$this));
 }
Esempio n. 11
0
 /**
  * @param string $action
  * @param string $request
  * @param array $arg
  */
 function UseMethod($action, $request, &$arg)
 {
     $log =& CLog::CreateInstance();
     $c =& CProcessingSwitch::_createInstance();
     $name = $c->_prepareMethodName($action, $request);
     if ($c->_methodExist($name)) {
         $c->InitArgs($arg);
         $c->InitLog($log);
         /* custom class */
         wm_Custom::StaticUseMethod('ProcessingBeforeCallFunction', array($name, &$arg));
         $log->WriteLine('Do: CProcessingSwitch->' . $name);
         call_user_func(array(&$c, $name));
         /* custom class */
         wm_Custom::StaticUseMethod('ProcessingAfterCallFunction', array($name, &$arg));
         return true;
     } else {
         $log->WriteLine('Error: CProcessingSwitch->' . $name . ' not exist!', LOG_LEVEL_ERROR);
         return false;
     }
 }
Esempio n. 12
0
 /**
  * @return FolderCollection
  */
 function GetFolders()
 {
     ConvertUtils::SetLimits();
     $lastD = $this->Account->Delimiter;
     $folderCollection = new FolderCollection();
     $folders =& $this->_imapMail->list_mailbox($this->Account->Delimiter);
     $subsScrFolders = $this->_imapMail->list_subscribed_mailbox($this->Account->Delimiter);
     $existsIndex = array('VirusAdd' => true);
     $folderCollection = $this->GetFolderCollectionFromArrays($folders, $subsScrFolders, $this->Account->Delimiter, $existsIndex);
     if ($lastD != $this->Account->Delimiter) {
         $this->Account->UpdateDelimiter();
     }
     /* custom class */
     wm_Custom::StaticUseMethod('ChangeServerImapFoldersAfterGet', array(&$folderCollection));
     return $folderCollection;
 }
Esempio n. 13
0
 function open_connection()
 {
     if (!$this->_checkState_0('DISCONNECTED')) {
         return false;
     }
     if (empty($this->host) || empty($this->port)) {
         $this->error = 'Error : Either HOST or PORT is undifined!';
         return false;
     }
     $host = $this->host;
     $isSsl = strlen($host) > 6 && strtolower(substr($host, 0, 6)) == 'ssl://';
     if (function_exists('openssl_open') && ($isSsl || $this->port == 993)) {
         if (!$isSsl) {
             $host = 'ssl://' . $host;
         }
     } else {
         if ($isSsl) {
             $host = substr($host, 6);
         }
     }
     $errstr = '';
     $errno = 0;
     $sConnectTimeout = SOCKET_CONNECT_TIMEOUT;
     $sFgetTimeout = SOCKET_FGET_TIMEOUT;
     /* custom class */
     wm_Custom::StaticUseMethod('UpdateSocketTimeouts', array(&$sConnectTimeout, &$sFgetTimeout));
     $this->_log('IMAP4 : start connect to ' . $host . ':' . $this->port);
     $this->connection = @fsockopen($host, $this->port, $errno, $errstr, $sConnectTimeout);
     if (!$this->connection) {
         $this->error = 'Could not make a connection to server , Error : ' . $errstr . ' (' . $errno . ')';
         return false;
     }
     /* set socket timeout
      * it is valid for all other functions! */
     @socket_set_timeout($this->connection, $sFgetTimeout);
     /* socket_set_blocking($this->connection, true); */
     $this->get_line();
     $this->state = 'AUTHORIZATION';
     // $this->InitCapa();
     return true;
 }
Esempio n. 14
0
 function SetLimits()
 {
     if (wm_Custom::StaticMethodExist('SetLimits')) {
         wm_Custom::StaticUseMethod('SetLimits');
     } else {
         @ini_set('memory_limit', MEMORYLIMIT);
         @set_time_limit(TIMELIMIT);
         $log =& CLog::CreateInstance();
         $log->WriteLine('INI_SET: memory_limit/set_time_limit = ' . MEMORYLIMIT . '/' . TIMELIMIT);
     }
 }
Esempio n. 15
0
 /**
  * - $server ( Server IP or DNS )
  * - $port ( Server port default is "110" )
  * - $timeout ( Connection timeout for connect to server )
  * - $sock_timeout ( Socket timeout for all actions   (10 sec 500 msec) = (10,500))
  * 
  * If all right you get true, when not you get false and on $this->error = msg
  * 
  * @access public
  * @param string $server
  * @param string $port[optional] = 110
  * @param string $timeout[optional] = 20
  * @param string $sock_timeout[optional] = '10,500'
  * @return bool
  */
 function connect($server, $port = 110, $timeout = SOCKET_CONNECT_TIMEOUT, $sock_timeout = SOCKET_FGET_TIMEOUT)
 {
     if ($this->socket) {
         $this->error = 'POP3 connect() - Error: Connection also avalible!';
         $this->setGlobalErrorAndWriteLog();
         return false;
     }
     if (!trim($server)) {
         $this->error = 'POP3 connect() - Error: Please give a server address.';
         $this->setGlobalErrorAndWriteLog();
         return false;
     }
     if ($port < 1 && $port > 65535 || !trim($port)) {
         $this->error = 'POP3 connect() - Error: Port not set or out of range (1 - 65535)';
         $this->setGlobalErrorAndWriteLog();
         return false;
     }
     /*
     if(!ereg("([0-9]{2}),([0-9]{3})",$sock_timeout))
     {
         $this->error = "POP3 connect() - Error: Socket Timeout in invalid Format (Right Format xx,xxx \"10,500\")";
     			$this->setGlobalErrorAndWriteLog();
         return false;
     }
     */
     if (!$this->_checkstate('connect')) {
         return false;
     }
     $isSsl = strlen($server) > 6 && strtolower(substr($server, 0, 6)) == 'ssl://';
     if (function_exists('openssl_open') && ($isSsl || $port == 995)) {
         if (!$isSsl) {
             $server = 'ssl://' . $server;
         }
     } else {
         if ($isSsl) {
             $server = substr($server, 6);
         }
     }
     $errstr = '';
     $errno = 0;
     /* custom class */
     wm_Custom::StaticUseMethod('UpdateSocketTimeouts', array(&$timeout, &$sock_timeout));
     $this->_log->WriteLine('POP3 : start connect to ' . $server . ':' . $port);
     $this->socket = @fsockopen($server, $port, $errno, $errstr, $timeout);
     if (!$this->socket) {
         $this->error = 'POP3 connect() - Error: Can\'t connect to Server. Error: ' . $errno . ' -- ' . $errstr;
         $this->setGlobalErrorAndWriteLog();
         return false;
     }
     // set socket timeout
     // it is valid for all other functions!
     @socket_set_timeout($this->socket, $sock_timeout);
     /* @socket_set_blocking($this->socket, true); */
     $response = $this->_getnextstring();
     if (substr($response, 0, 1) != '+') {
         $this->_cleanup();
         $this->error = 'POP3 connect() - Error: ' . $response;
         $this->setGlobalErrorAndWriteLog();
         return false;
     }
     // get the server banner for APOP
     $this->apop_banner = $this->_parse_banner($response);
     $this->state = 'AUTHORIZATION';
     return true;
 }