public function Get($sAuthToken) { $mResult = false; if (strlen($sAuthToken) !== 0) { $sKey = $this->Session->get('AUTHTOKEN:' . $sAuthToken); } if (!empty($sKey) && is_string($sKey)) { $mResult = \CApi::DecodeKeyValues($sKey); } return $mResult; }
/** * @param string $sSearch * @param string $sFolderName * @param string|bool $sFolderHash * @param bool $bUseSortIfSupported = true * @param bool $bUseESearchOrESortRequest = false * @param \MailSo\Cache\CacheClient|null $oCacher = null * * @return Array|bool */ private function getSearchUidsResult($sSearch, $sFolderName, $sFolderHash, $bUseSortIfSupported = true, $bUseESearchOrESortRequest = false, $oCacher = null) { $bUidsFromCacher = false; $aResultUids = false; $bUseCacheAfterSearch = true; $sSerializedHash = ''; $bESortSupported = $bUseSortIfSupported && $bUseESearchOrESortRequest ? $this->oImapClient->IsSupported('ESORT') : false; $bESearchSupported = $bUseESearchOrESortRequest ? $this->oImapClient->IsSupported('ESEARCH') : false; $bUseSortIfSupported = $bUseSortIfSupported ? $this->oImapClient->IsSupported('SORT') : false; $sSearchCriterias = $this->getImapSearchCriterias($sSearch, 0, $bUseCacheAfterSearch); if ($bUseCacheAfterSearch && $oCacher && $oCacher->IsInited()) { $sSerializedHash = ($bUseSortIfSupported ? 'S' : 'N') . '/' . $this->oImapClient->GetLogginedUser() . '@' . $this->oImapClient->GetConnectedHost() . ':' . $this->oImapClient->GetConnectedPort() . '/' . $sFolderName . '/' . $sSearchCriterias; $sSerializedLog = '"' . $sFolderName . '" / ' . $sSearchCriterias . ''; $sSerialized = $oCacher->get($sSerializedHash); if (!empty($sSerialized)) { $aSerialized = @\unserialize($sSerialized); if (\is_array($aSerialized) && isset($aSerialized['FolderHash'], $aSerialized['Uids']) && \is_array($aSerialized['Uids']) && $sFolderHash === $aSerialized['FolderHash']) { if ($this->oLogger) { $this->oLogger->Write('Get Serialized UIDS from cache (' . $sSerializedLog . ') [count:' . \count($aSerialized['Uids']) . ']'); } $aResultUids = $aSerialized['Uids']; $bUidsFromCacher = true; } } } if (!\is_array($aResultUids)) { if ($bUseSortIfSupported) { if ($bESortSupported) { $aESorthData = $this->oImapClient->MessageSimpleESort(array('ARRIVAL'), $sSearchCriterias, array('ALL'), true, ''); if (isset($aESorthData['ALL'])) { $aResultUids = \MailSo\Base\Utils::ParseFetchSequence($aESorthData['ALL']); $aResultUids = \array_reverse($aResultUids); } unset($aESorthData); } else { $aResultUids = $this->oImapClient->MessageSimpleSort(array('REVERSE ARRIVAL'), $sSearchCriterias, true); } } else { if (!\MailSo\Base\Utils::IsAscii($sSearch)) { try { if ($bESearchSupported) { $aESearchData = $this->oImapClient->MessageSimpleESearch($sSearchCriterias, array('ALL'), true, '', 'UTF-8'); if (isset($aESearchData['ALL'])) { $aResultUids = \MailSo\Base\Utils::ParseFetchSequence($aESearchData['ALL']); $aResultUids = \array_reverse($aResultUids); } unset($aESearchData); } else { $aResultUids = $this->oImapClient->MessageSimpleSearch($sSearchCriterias, true, 'UTF-8'); } } catch (\MailSo\Imap\Exceptions\NegativeResponseException $oException) { $oException = null; $aResultUids = false; } } if (false === $aResultUids) { if ($bESearchSupported) { $aESearchData = $this->oImapClient->MessageSimpleESearch($sSearchCriterias, array('ALL'), true); if (isset($aESearchData['ALL'])) { $aResultUids = \MailSo\Base\Utils::ParseFetchSequence($aESearchData['ALL']); $aResultUids = \array_reverse($aResultUids); } unset($aESearchData); } else { $aResultUids = $this->oImapClient->MessageSimpleSearch($sSearchCriterias, true); } } } if (!$bUidsFromCacher && $bUseCacheAfterSearch && \is_array($aResultUids) && $oCacher && $oCacher->IsInited() && 0 < \strlen($sSerializedHash)) { $oCacher->Set($sSerializedHash, \serialize(array('FolderHash' => $sFolderHash, 'Uids' => $aResultUids))); if ($this->oLogger) { $this->oLogger->Write('Save Serialized UIDS to cache (' . $sSerializedLog . ') [count:' . \count($aResultUids) . ']'); } } } return $aResultUids; }