本文整理汇总了PHP中CApi::Cacher方法的典型用法代码示例。如果您正苦于以下问题:PHP CApi::Cacher方法的具体用法?PHP CApi::Cacher怎么用?PHP CApi::Cacher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CApi
的用法示例。
在下文中一共展示了CApi::Cacher方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AjaxSystemDoServerInitializations
/**
* @return array
*/
public function AjaxSystemDoServerInitializations()
{
$oAccount = $this->getAccountFromParam();
$bResult = false;
$oApiIntegrator = \CApi::Manager('integrator');
if ($oAccount && $oApiIntegrator) {
$oApiIntegrator->resetCookies();
}
$oApiHelpdesk = \CApi::Manager('helpdesk');
if ($this->oApiCapability->isGlobalContactsSupported($oAccount, true)) {
$oApiContacts = $this->ApiContacts();
if ($oApiContacts && method_exists($oApiContacts, 'synchronizeExternalContacts')) {
$bResult = $oApiContacts->synchronizeExternalContacts($oAccount);
}
}
$oCacher = \CApi::Cacher();
$bDoGC = false;
$bDoHepdeskClear = false;
if ($oCacher && $oCacher->IsInited()) {
$iTime = $oCacher->GetTimer('Cache/ClearFileCache');
if (0 === $iTime || $iTime + 60 * 60 * 24 < time()) {
if ($oCacher->SetTimer('Cache/ClearFileCache')) {
$bDoGC = true;
}
}
if ($oApiHelpdesk) {
$iTime = $oCacher->GetTimer('Cache/ClearHelpdeskUsers');
if (0 === $iTime || $iTime + 60 * 60 * 24 < time()) {
if ($oCacher->SetTimer('Cache/ClearHelpdeskUsers')) {
$bDoHepdeskClear = true;
}
}
}
}
if ($bDoGC) {
\CApi::Log('GC: FileCache / Start');
$this->ApiFileCache()->gc();
$oCacher->gc();
\CApi::Log('GC: FileCache / End');
}
if ($bDoHepdeskClear && $oApiHelpdesk) {
\CApi::Log('GC: clear Unregistred Users');
$oApiHelpdesk->clearUnregistredUsers();
\CApi::Log('GC: clear Online');
$oApiHelpdesk->clearAllOnline();
}
return $this->DefaultResponse($oAccount, __FUNCTION__, $bResult);
}
示例2: Handle
//.........这里部分代码省略.........
} else {
if (!isset($_FILES) || !is_array($_FILES) || 0 === count($_FILES)) {
$sError = 'size';
} else {
$sError = 'unknown';
}
}
}
if (!is_array($aResponseItem) && empty($sError)) {
throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::UnknownError);
}
} catch (\Exception $oException) {
\CApi::LogException($oException);
$aResponseItem = $this->oActions->ExceptionResponse(null, 'Upload', $oException);
$sError = 'exception';
}
if (0 < strlen($sError)) {
$aResponseItem['Error'] = $sError;
}
}
@ob_get_clean();
@header('Content-Type: text/html; charset=utf-8');
$sResult = \MailSo\Base\Utils::Php2js($aResponseItem);
} else {
if ('speclogon' === $sFirstPart || 'speclogoff' === $sFirstPart) {
\CApi::SpecifiedUserLogging('speclogon' === $sFirstPart);
\CApi::Location('./');
} else {
if ('sso' === $sFirstPart) {
$oApiIntegratorManager = \CApi::Manager('integrator');
try {
$sHash = $this->oHttp->GetRequest('hash');
if (!empty($sHash)) {
$sData = \CApi::Cacher()->get('SSO:' . $sHash, true);
$aData = \CApi::DecodeKeyValues($sData);
if (!empty($aData['Email']) && isset($aData['Password'], $aData['Login'])) {
$oAccount = $oApiIntegratorManager->loginToAccount($aData['Email'], $aData['Password'], $aData['Login']);
if ($oAccount) {
$oApiIntegratorManager->setAccountAsLoggedIn($oAccount);
}
}
} else {
$oApiIntegratorManager->logoutAccount();
}
} catch (\Exception $oExc) {
\CApi::LogException($oExc);
}
\CApi::Location('./');
} else {
if ('autodiscover' === $sFirstPart) {
$oSettings =& \CApi::GetSettings();
$sInput = \file_get_contents('php://input');
\CApi::Log('#autodiscover:');
\CApi::LogObject($sInput);
$aMatches = array();
$aEmailAddress = array();
\preg_match("/\\<AcceptableResponseSchema\\>(.*?)\\<\\/AcceptableResponseSchema\\>/i", $sInput, $aMatches);
\preg_match("/\\<EMailAddress\\>(.*?)\\<\\/EMailAddress\\>/", $sInput, $aEmailAddress);
if (!empty($aMatches[1]) && !empty($aEmailAddress[1])) {
$sIncMailServer = trim($oSettings->GetConf('WebMail/ExternalHostNameOfLocalImap'));
$sOutMailServer = trim($oSettings->GetConf('WebMail/ExternalHostNameOfLocalSmtp'));
if (0 < \strlen($sIncMailServer) && 0 < \strlen($sOutMailServer)) {
$iIncMailPort = 143;
$iOutMailPort = 25;
$aMatch = array();
if (\preg_match('/:([\\d]+)$/', $sIncMailServer, $aMatch) && !empty($aMatch[1]) && is_numeric($aMatch[1])) {
示例3: setAccountAsLoggedIn
/**
* @param CAccount $oAccount
* @param bool $bSignMe Default value is **false**.
*
* @return string
*/
public function setAccountAsLoggedIn(CAccount $oAccount, $bSignMe = false)
{
$aAccountHashTable = array('token' => 'auth', 'sign-me' => $bSignMe, 'id' => $oAccount->IdUser, 'login' => $oAccount->IncomingMailLogin);
$iTime = $bSignMe ? time() + 60 * 60 * 24 * 30 : 0;
$sAccountHashTable = \CApi::EncodeKeyValues($aAccountHashTable);
$_COOKIE[self::AUTH_KEY] = $sAccountHashTable;
@setcookie(self::AUTH_KEY, $sAccountHashTable, $iTime, $this->getCookiePath(), null, null, true);
$sAuthToken = \md5($oAccount->IdUser . $oAccount->IncomingMailLogin . \microtime(true) . \rand(10000, 99999));
return \CApi::Cacher()->Set('AUTHTOKEN:' . $sAuthToken, $sAccountHashTable) ? $sAuthToken : '';
}
示例4: GenerateSsoToken
/**
* @param string $sEmail
* @param string $sPassword
* @param string $sLogin = ''
* @return string
*/
public static function GenerateSsoToken($sEmail, $sPassword, $sLogin = '')
{
$sSsoHash = \md5($sEmail . $sPassword . $sLogin . \microtime(true) . \rand(10000, 99999));
return CApi::Cacher()->Set('SSO:' . $sSsoHash, CApi::EncodeKeyValues(array('Email' => $sEmail, 'Password' => $sPassword, 'Login' => $sLogin))) ? $sSsoHash : '';
}
示例5: Handle
//.........这里部分代码省略.........
} else {
$sError = 'unknown';
}
}
}
if (!is_array($aResponseItem) && empty($sError)) {
throw new \ProjectSeven\Exceptions\ClientException(\ProjectSeven\Notifications::UnknownError);
}
} catch (\Exception $oException) {
\CApi::LogException($oException);
$aResponseItem = $this->oActions->ExceptionResponse(null, 'Upload', $oException);
$sError = 'exception';
}
if (0 < strlen($sError)) {
$aResponseItem['Error'] = $sError;
}
@ob_get_clean();
if ('iframe' === $this->oHttp->GetPost('jua-post-type', '')) {
@header('Content-Type: text/html; charset=utf-8');
} else {
@header('Content-Type: application/json; charset=utf-8');
}
$sResult = \MailSo\Base\Utils::Php2js($aResponseItem);
} else {
if ('speclogon' === $sFirstPart || 'speclogoff' === $sFirstPart) {
\CApi::SpecifiedUserLogging('speclogon' === $sFirstPart);
\CApi::Location('./');
} else {
if ('sso' === $sFirstPart) {
$oApiIntegratorManager = \CApi::Manager('integrator');
try {
$sHash = $this->oHttp->GetRequest('hash');
if (!empty($sHash)) {
$sData = \CApi::Cacher()->Get('SSO:' . $sHash, true);
$aData = \CApi::DecodeKeyValues($sData);
if (!empty($aData['Email']) && isset($aData['Password'], $aData['Login'])) {
$oAccount = $oApiIntegratorManager->LoginToAccount($aData['Email'], $aData['Password'], $aData['Login']);
if ($oAccount) {
$oApiIntegratorManager->SetAccountAsLoggedIn($oAccount);
}
}
} else {
$oApiIntegratorManager->LogoutAccount();
}
} catch (\Exception $oExc) {
\CApi::LogException($oExc);
}
\CApi::Location('./');
} else {
if ('autodiscover' === $sFirstPart) {
$oSettings =& \CApi::GetSettings();
$sInput = \file_get_contents('php://input');
//$sInput = '<?'.'xml version="1.0" encoding="utf-8"?'.'><Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006"><Request><EMailAddress>test@afterlogic.com</EMailAddress><AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema></Request></Autodiscover>';
\CApi::Log('#autodiscover:');
\CApi::LogObject($sInput);
$aMatches = array();
$aEmailAddress = array();
\preg_match("/\\<AcceptableResponseSchema\\>(.*?)\\<\\/AcceptableResponseSchema\\>/i", $sInput, $aMatches);
\preg_match("/\\<EMailAddress\\>(.*?)\\<\\/EMailAddress\\>/", $sInput, $aEmailAddress);
if (!empty($aMatches[1]) && !empty($aEmailAddress[1])) {
$sIncMailServer = $oSettings->GetConf('WebMail/ExternalHostNameOfLocalImap');
$sOutMailServer = $oSettings->GetConf('WebMail/ExternalHostNameOfLocalSmtp');
if (0 < \strlen($sIncMailServer) && 0 < \strlen($sOutMailServer)) {
$sResult = \implode("\n", array('<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">', ' <Response xmlns="' . $aMatches[1] . '">', ' <Account>', ' <AccountType>email</AccountType>', ' <Action>settings</Action>', ' <Protocol>', ' <Type>IMAP</Type>', ' <Server>' . $sIncMailServer . '</Server>', ' <LoginName>' . $aEmailAddress[1] . '</LoginName>', ' <Port>143</Port>', ' <SSL>off</SSL>', ' <SPA>off</SPA>', ' <AuthRequired>on</AuthRequired>', ' </Protocol>', ' <Protocol>', ' <Type>SMTP</Type>', ' <Server>' . $sOutMailServer . '</Server>', ' <LoginName>' . $aEmailAddress[1] . '</LoginName>', ' <Port>25</Port>', ' <SSL>off</SSL>', ' <SPA>off</SPA>', ' <AuthRequired>on</AuthRequired>', ' </Protocol>', ' </Account>', ' </Response>', '</Autodiscover>'));
}
}
示例6: setAccountAsLoggedIn
/**
* @param CAccount $oAccount
* @param bool $bSignMe Default value is **false**.
*
* @return string
*/
public function setAccountAsLoggedIn(CAccount $oAccount, $bSignMe = false)
{
$aAccountHashTable = array('token' => 'auth', 'sign-me' => $bSignMe, 'id' => $oAccount->IdUser, 'email' => $oAccount->Email);
$iTime = $bSignMe ? time() + 60 * 60 * 24 * 30 : 0;
$sAccountHashTable = \CApi::EncodeKeyValues($aAccountHashTable);
$sAuthToken = \md5($oAccount->IdUser . $oAccount->IncomingMailLogin . \microtime(true) . \rand(10000, 99999));
return \CApi::Cacher()->Set('AUTHTOKEN:' . $sAuthToken, $sAccountHashTable) ? $sAuthToken : '';
}