本文整理汇总了PHP中CApi::DecodeKeyValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CApi::DecodeKeyValues方法的具体用法?PHP CApi::DecodeKeyValues怎么用?PHP CApi::DecodeKeyValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CApi
的用法示例。
在下文中一共展示了CApi::DecodeKeyValues方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PopulateContent
/**
* @param \CHelpdeskUser $oUser
* @param \CApiHelpdeskManager $oApiHelpdesk
* @param \CApiFilestorageManager $oApiFilestorage
*/
public function PopulateContent($oUser, $oApiHelpdesk, $oApiFilestorage)
{
$aHash = \CApi::DecodeKeyValues($this->Hash);
if (isset($aHash['StorageType'], $aHash['Path'], $aHash['Name']) && $oApiHelpdesk && $oApiFilestorage)
{
$oHelpdeskUserFromAttachment = null;
if (isset($aHash['HelpdeskUserID'], $aHash['HelpdeskTenantID']))
{
if ($oUser && $aHash['HelpdeskUserID'] === $oUser->IdHelpdeskUser)
{
$oHelpdeskUserFromAttachment = $oUser;
}
else
{
$oHelpdeskUserFromAttachment = $oApiHelpdesk->GetUserById(
$aHash['HelpdeskTenantID'], $aHash['HelpdeskUserID']);
}
}
if ($oHelpdeskUserFromAttachment && $oApiFilestorage->FileExists(
$oHelpdeskUserFromAttachment, $aHash['StorageType'], $aHash['Path'], $aHash['Name']
))
{
$mResult = $oApiFilestorage->GetFile(
$oHelpdeskUserFromAttachment, $aHash['StorageType'], $aHash['Path'], $aHash['Name']
);
if (is_resource($mResult))
{
$this->Content = stream_get_contents($mResult);
}
}
}
}
示例2: Get
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;
}
示例3: AjaxSocialRegister
public function AjaxSocialRegister()
{
$sTenantHash = trim($this->getParamValue('TenantHash', ''));
if ($this->oApiCapability->isHelpdeskSupported()) {
$sNotificationEmail = trim($this->getParamValue('NotificationEmail', ''));
if (isset($_COOKIE["p7social"])) {
$aSocial = \CApi::DecodeKeyValues($_COOKIE["p7social"]);
} else {
$aSocial = array('type' => '', 'id' => '', 'name' => '', 'email' => '');
}
$sSocialType = $aSocial['type'];
$sSocialId = $aSocial['id'];
$sSocialName = $aSocial['name'];
$sEmail = $aSocial['email'];
if (0 !== strlen($sEmail)) {
$sNotificationEmail = $sEmail;
}
if (0 === strlen($sNotificationEmail)) {
throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::InvalidInputParameter);
}
$mIdTenant = $this->oApiIntegrator->getTenantIdByHash($sTenantHash);
if (!is_int($mIdTenant)) {
throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::InvalidInputParameter);
}
$bResult = false;
try {
$bResult = $this->oApiIntegrator->registerSocialAccount($mIdTenant, $sTenantHash, $sNotificationEmail, $sSocialId, $sSocialType, $sSocialName);
} catch (\Exception $oException) {
$iErrorCode = \ProjectCore\Notifications::UnknownError;
if ($oException instanceof \CApiManagerException) {
switch ($oException->getCode()) {
case \Errs::HelpdeskManager_UserAlreadyExists:
$iErrorCode = \ProjectCore\Notifications::HelpdeskUserAlreadyExists;
break;
case \Errs::HelpdeskManager_UserCreateFailed:
$iErrorCode = \ProjectCore\Notifications::CanNotCreateHelpdeskUser;
break;
case \Errs::Db_ExceptionError:
$iErrorCode = \ProjectCore\Notifications::DataBaseError;
break;
}
}
throw new \ProjectCore\Exceptions\ClientException($iErrorCode);
}
if ($bResult) {
$bResult = false;
$oUser = \CApi::Manager('integrator')->getAhdSocialUser($sTenantHash, $sSocialId);
if ($oUser) {
\CApi::Manager('integrator')->setHelpdeskUserAsLoggedIn($oUser, false);
$bResult = true;
}
}
return $this->DefaultResponse(null, __FUNCTION__, $bResult);
}
return $this->FalseResponse(null, __FUNCTION__);
}
示例4: Handle
//.........这里部分代码省略.........
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])) {
$sIncMailServer = preg_replace('/:[\\d]+$/', $sIncMailServer, '');
示例5: Init
public static function Init(&$aAppData, $sTenantHash)
{
@setcookie('p7tenantHash', $sTenantHash);
$oTenant = self::GetTenantFromCookieOrHash($sTenantHash);
$oApiIntegratorManager = \CApi::Manager('integrator');
if ($oTenant) {
foreach ($oTenant->getSocials() as $oSocial) {
$aAppData['Social' . $oSocial->SocialName] = $oSocial->SocialAllow;
$aAppData['Social' . $oSocial->SocialName . 'Id'] = $oSocial->SocialId;
/*
if (!empty($oSocial->SocialApiKey))
{
$aAppData['Social' . $oSocial->SocialName . 'ApiKey'] = $oSocial->SocialApiKey;
}
*/
// $aAppData['Social' . $oSocial->SocialName . 'Secret'] = $oSocial->SocialSecret;
$aAppData['Social' . $oSocial->SocialName . 'Scopes'] = $oSocial->SocialScopes;
}
}
if (isset($_COOKIE['p7social'])) {
$aSocial = \CApi::DecodeKeyValues($_COOKIE['p7social']);
$oUser = $oApiIntegratorManager->getAhdSocialUser($sTenantHash, $aSocial['id']);
if (strlen($aSocial['email'])) {
$sSocialType = isset($aSocial['type']) ? $aSocial['type'] : '';
$sSocialId = isset($aSocial['id']) ? $aSocial['id'] : '';
$sSocialName = isset($aSocial['name']) ? $aSocial['name'] : '';
$sNotificationEmail = isset($aSocial['email']) ? $aSocial['email'] : '';
if (!$oUser) {
$mIdTenant = $oApiIntegratorManager->getTenantIdByHash($sTenantHash);
if (!is_int($mIdTenant)) {
throw new \Core\Exceptions\ClientException(\Core\Notifications::InvalidInputParameter);
}
$bResult = false;
try {
$bResult = $oApiIntegratorManager->registerSocialAccount($mIdTenant, $sTenantHash, $sNotificationEmail, $sSocialId, $sSocialType, $sSocialName);
} catch (\Exception $oException) {
$iErrorCode = \Core\Notifications::UnknownError;
if ($oException instanceof \CApiManagerException) {
switch ($oException->getCode()) {
case \Errs::HelpdeskManager_UserAlreadyExists:
$iErrorCode = \Core\Notifications::HelpdeskUserAlreadyExists;
break;
case \Errs::HelpdeskManager_UserCreateFailed:
$iErrorCode = \Core\Notifications::CanNotCreateHelpdeskUser;
break;
case \Errs::Db_ExceptionError:
$iErrorCode = \Core\Notifications::DataBaseError;
break;
}
}
throw new \Core\Exceptions\ClientException($iErrorCode);
}
}
$oUser = $oApiIntegratorManager->getAhdSocialUser($sTenantHash, $aSocial['id']);
}
if ($oUser) {
$oApiIntegratorManager->setHelpdeskUserAsLoggedIn($oUser, false);
@setcookie('p7social', '', time() - 1);
} else {
$aAppData['SocialEmail'] = $aSocial['email'];
$aAppData['SocialIsLoggedIn'] = true;
}
}
}
示例6: resetCookies
public function resetCookies()
{
$sAccountHash = !empty($_COOKIE[self::AUTH_KEY]) ? $_COOKIE[self::AUTH_KEY] : '';
if (0 < strlen($sAccountHash)) {
$aAccountHashTable = CApi::DecodeKeyValues($sAccountHash);
if (isset($aAccountHashTable['sign-me']) && $aAccountHashTable['sign-me']) {
@setcookie(self::AUTH_KEY, CApi::EncodeKeyValues($aAccountHashTable), time() + 60 * 60 * 24 * 30, $this->getCookiePath(), null, null, true);
}
$sToken = !empty($_COOKIE[self::TOKEN_KEY]) ? $_COOKIE[self::TOKEN_KEY] : null;
if (null !== $sToken) {
@setcookie(self::TOKEN_KEY, $sToken, time() + 60 * 60 * 24 * 30, $this->getCookiePath(), null, null, true);
}
}
$sHelpdeskHash = !empty($_COOKIE[self::AUTH_HD_KEY]) ? $_COOKIE[self::AUTH_HD_KEY] : '';
if (0 < strlen($sHelpdeskHash)) {
$aHelpdeskHashTable = CApi::DecodeKeyValues($sHelpdeskHash);
if (isset($aHelpdeskHashTable['sign-me']) && $aHelpdeskHashTable['sign-me']) {
@setcookie(self::AUTH_HD_KEY, CApi::EncodeKeyValues($aHelpdeskHashTable), time() + 60 * 60 * 24 * 30, $this->getCookiePath(), null, null, true);
}
}
}
示例7: Init
public static function Init(&$aAppData, $sTenantHash)
{
$oTenant = self::GetTenantFromCookieByHash($sTenantHash);
$oApiIntegratorManager = \CApi::Manager('integrator');
$bFacebookAllow = $bGoogleAllow = $bTwitterAllow = $bDropboxAllow = false;
$sGoogleId = $sGoogleApiKey = $sDropboxKey = $sDropboxSecret = '';
if ($oTenant) {
$bFacebookAllow = $oTenant->SocialFacebookAllow;
$bGoogleAllow = $oTenant->SocialGoogleAllow;
$sGoogleId = $oTenant->SocialGoogleId;
$sGoogleApiKey = $oTenant->SocialGoogleApiKey;
$bTwitterAllow = $oTenant->SocialTwitterAllow;
$bDropboxAllow = $oTenant->SocialDropboxAllow;
$sDropboxKey = $oTenant->SocialDropboxKey;
$sDropboxSecret = $oTenant->SocialDropboxSecret;
}
$aAppData['SocialFacebook'] = $bFacebookAllow;
$aAppData['SocialGoogle'] = $bGoogleAllow;
$aAppData['SocialGoogleId'] = $sGoogleId;
$aAppData['SocialGoogleApiKey'] = $sGoogleApiKey;
$aAppData['SocialTwitter'] = $bTwitterAllow;
$aAppData['SocialDropbox'] = $bDropboxAllow;
$aAppData['SocialDropboxKey'] = $sDropboxKey;
$aAppData['SocialDropboxSecret'] = $sDropboxSecret;
@setcookie('TenantHash', $sTenantHash);
if (isset($_COOKIE['Social'])) {
$aSocial = \CApi::DecodeKeyValues($_COOKIE['Social']);
$oUser = $oApiIntegratorManager->GetAhdSocialUser($sTenantHash, $aSocial['id']);
// @setcookie ('Social', '', time() - 1);
if (strlen($aSocial['email'])) {
$sSocialType = $aSocial['type'];
$sSocialId = $aSocial['id'];
$sSocialName = $aSocial['name'];
$sNotificationEmail = $aSocial['email'];
if (!$oUser) {
$mIdTenant = $oApiIntegratorManager->GetTenantIdByHash($sTenantHash);
if (!is_int($mIdTenant)) {
throw new \ProjectSeven\Exceptions\ClientException(\ProjectSeven\Notifications::InvalidInputParameter);
}
$bResult = false;
try {
$bResult = $oApiIntegratorManager->RegisterSocialAccount($mIdTenant, $sTenantHash, $sNotificationEmail, $sSocialId, $sSocialType, $sSocialName);
} catch (\Exception $oException) {
$iErrorCode = \ProjectSeven\Notifications::UnknownError;
if ($oException instanceof \CApiManagerException) {
switch ($oException->getCode()) {
case \Errs::HelpdeskManager_UserAlreadyExists:
$iErrorCode = \ProjectSeven\Notifications::HelpdeskUserAlreadyExists;
break;
case \Errs::HelpdeskManager_UserCreateFailed:
$iErrorCode = \ProjectSeven\Notifications::CanNotCreateHelpdeskUser;
break;
case \Errs::Db_ExceptionError:
$iErrorCode = \ProjectSeven\Notifications::DataBaseError;
break;
}
}
throw new \ProjectSeven\Exceptions\ClientException($iErrorCode);
}
}
$oUser = $oApiIntegratorManager->GetAhdSocialUser($sTenantHash, $aSocial['id']);
}
if ($oUser) {
$oApiIntegratorManager->SetHelpdeskUserAsLoggedIn($oUser, false);
@setcookie('Social', '', time() - 1);
} else {
$aAppData['SocialEmail'] = $aSocial['email'];
$aAppData['SocialIsLoggined'] = true;
}
}
}
示例8: Handle
//.........这里部分代码省略.........
$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>'));
}
}
if (empty($sResult)) {
示例9: EntryDownload
/**
*
* @return mixed
*/
public function EntryDownload()
{
$mResult = false;
$aPaths = \System\Service::GetPaths();
$sMethod = empty($aPaths[2]) ? '' : $aPaths[2];
try {
if (!empty($sMethod)) {
$sRawKey = empty($aPaths[3]) ? '' : $aPaths[3];
$aParameters = CApi::DecodeKeyValues($sRawKey);
$aParameters['AuthToken'] = empty($aPaths[4]) ? '' : $aPaths[4];
$aParameters['SharedHash'] = empty($aPaths[5]) ? '' : $aPaths[5];
$mResult = $this->CallMethod($sMethod, $aParameters, true);
}
} catch (\Exception $oException) {
\CApi::LogException($oException);
$this->oHttp->StatusHeader(404);
}
return $mResult;
}
示例10: file_get_contents
<?php
include_once __DIR__ . '/libraries/afterlogic/api.php';
include_once CApi::LibrariesPath() . '/ProjectSeven/Notifications.php';
$sContents = file_get_contents('php://input');
$aInputData = array();
if (strlen($sContents) > 0) {
parse_str($sContents, $aInputData);
} else {
$aInputData = isset($_REQUEST) && is_array($_REQUEST) ? $_REQUEST : array();
}
//$sMethod = isset($aInputData['method']) ? $aInputData['method'] : '';
$sMethod = strlen($_SERVER['PATH_INFO']) > 0 ? $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['PATH_INFO'] : '';
$sToken = isset($aInputData['token']) ? $aInputData['token'] : '';
$aSecret = CApi::DecodeKeyValues($sToken);
$bMethod = in_array($sMethod, array('GET /token', 'POST /account', 'PUT /account/update', 'DELETE /account', 'PUT /account/enable', 'PUT /account/disable', 'PUT /account/password', 'GET /account/list', 'GET /account/exists', 'GET /account', 'POST /domain', 'PUT /domain/update', 'DELETE /domain', 'GET /domain/list', 'GET /domain/exists', 'GET /domain'));
$aResult = array('method' => $sMethod);
if (!CApi::GetConf('labs.rest', true)) {
$aResult['message'] = 'rest api disabled';
$aResult['errorCode'] = \ProjectSeven\Notifications::RestApiDisabled;
$aResult['result'] = false;
} else {
if (class_exists('CApi') && CApi::IsValid() && $bMethod) {
/* @var $oApiDomainsManager CApiDomainsManager */
$oApiDomainsManager = CApi::Manager('domains');
/* @var $oApiTenantsManager CApiTenantsManager */
$oApiTenantsManager = CApi::Manager('tenants');
/* @var $oApiUsersManager CApiUsersManager */
$oApiUsersManager = CApi::Manager('users');
/* @var $oApiIntegratorManager CApiIntegratorManager */
$oApiIntegratorManager = CApi::Manager('integrator');