本文整理汇总了PHP中CApi::EncodeKeyValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CApi::EncodeKeyValues方法的具体用法?PHP CApi::EncodeKeyValues怎么用?PHP CApi::EncodeKeyValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CApi
的用法示例。
在下文中一共展示了CApi::EncodeKeyValues方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: EncodeHash
public function EncodeHash($oHelpdeskUser, $sThreadFolderName)
{
$this->Hash = \CApi::EncodeKeyValues(array(
'FilestorageFile' => true,
'HelpdeskTenantID' => $oHelpdeskUser->IdTenant,
'HelpdeskUserID' => $oHelpdeskUser->IdHelpdeskUser,
'StorageType' => \EFileStorageType::Corporate,
'Name' => $this->FileName,
'Path' => $sThreadFolderName
));
}
示例2: UploadHelpdeskFile
/**
* @return array
*/
public function UploadHelpdeskFile()
{
$oAccount = null;
$oUser = $this->getHelpdeskAccountFromParam($oAccount);
if (!$this->oApiCapability->isHelpdeskSupported() || !$this->oApiCapability->isFilesSupported()) {
throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::AccessDenied);
}
$aFileData = $this->getParamValue('FileData', null);
$iSizeLimit = 0;
$sError = '';
$aResponse = array();
if ($oUser) {
if (is_array($aFileData)) {
if (0 < $iSizeLimit && $iSizeLimit < (int) $aFileData['size']) {
$sError = 'size';
} else {
$sSavedName = 'upload-post-' . md5($aFileData['name'] . $aFileData['tmp_name']);
if ($this->ApiFileCache()->moveUploadedFile($oUser, $sSavedName, $aFileData['tmp_name'])) {
$sUploadName = $aFileData['name'];
$iSize = $aFileData['size'];
$sMimeType = \MailSo\Base\Utils::MimeContentType($sUploadName);
$aResponse['HelpdeskFile'] = array('Name' => $sUploadName, 'TempName' => $sSavedName, 'MimeType' => $sMimeType, 'Size' => (int) $iSize, 'Hash' => \CApi::EncodeKeyValues(array('TempFile' => true, 'HelpdeskTenantID' => $oUser->IdTenant, 'HelpdeskUserID' => $oUser->IdHelpdeskUser, 'Name' => $sUploadName, 'TempName' => $sSavedName)));
} else {
$sError = 'unknown';
}
}
} else {
$sError = 'unknown';
}
} else {
$sError = 'auth';
}
if (0 < strlen($sError)) {
$aResponse['Error'] = $sError;
}
return $this->DefaultResponse($oAccount, __FUNCTION__, $aResponse);
}
示例3: SetValuesToCookie
public static function SetValuesToCookie($aValues)
{
@setcookie("p7social", \CApi::EncodeKeyValues($aValues));
}
示例4: responseObject
/**
* @param \CAccount $oAccount
* @param mixed $mResponse
* @param string $sParent
* @param array $aParameters = array()
*
* @return mixed
*/
protected function responseObject($oAccount, $mResponse, $sParent, $aParameters = array())
{
$mResult = $mResponse;
if (is_object($mResponse)) {
$sClassName = get_class($mResponse);
if ('CApiMailMessage' === $sClassName) {
$iTrimmedLimit = \CApi::GetConf('labs.message-body-size-limit', 0);
$oAttachments = $mResponse->getAttachments();
$iInternalTimeStampInUTC = $mResponse->getInternalTimeStamp();
$iReceivedOrDateTimeStampInUTC = $mResponse->getReceivedOrDateTimeStamp();
$aFlags = $mResponse->getFlagsLowerCase();
$mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('Folder' => $mResponse->getFolder(), 'Uid' => $mResponse->getUid(), 'Subject' => $mResponse->getSubject(), 'MessageId' => $mResponse->getMessageId(), 'Size' => $mResponse->getSize(), 'TextSize' => $mResponse->getTextSize(), 'InternalTimeStampInUTC' => $iInternalTimeStampInUTC, 'ReceivedOrDateTimeStampInUTC' => $iReceivedOrDateTimeStampInUTC, 'TimeStampInUTC' => \CApi::GetConf('labs.use-date-from-headers', false) && 0 < $iReceivedOrDateTimeStampInUTC ? $iReceivedOrDateTimeStampInUTC : $iInternalTimeStampInUTC, 'From' => $this->responseObject($oAccount, $mResponse->getFrom(), $sParent, $aParameters), 'To' => $this->responseObject($oAccount, $mResponse->getTo(), $sParent, $aParameters), 'Cc' => $this->responseObject($oAccount, $mResponse->getCc(), $sParent, $aParameters), 'Bcc' => $this->responseObject($oAccount, $mResponse->getBcc(), $sParent, $aParameters), 'Sender' => $this->responseObject($oAccount, $mResponse->getSender(), $sParent, $aParameters), 'ReplyTo' => $this->responseObject($oAccount, $mResponse->getReplyTo(), $sParent, $aParameters), 'IsSeen' => in_array('\\seen', $aFlags), 'IsFlagged' => in_array('\\flagged', $aFlags), 'IsAnswered' => in_array('\\answered', $aFlags), 'IsForwarded' => false, 'HasAttachments' => $oAttachments && $oAttachments->hasNotInlineAttachments(), 'HasVcardAttachment' => $oAttachments && $oAttachments->hasVcardAttachment(), 'HasIcalAttachment' => $oAttachments && $oAttachments->hasIcalAttachment(), 'Priority' => $mResponse->getPriority(), 'DraftInfo' => $mResponse->getDraftInfo(), 'Sensitivity' => $mResponse->getSensitivity()));
$mResult['TrimmedTextSize'] = $mResult['TextSize'];
if (0 < $iTrimmedLimit && $mResult['TrimmedTextSize'] > $iTrimmedLimit) {
$mResult['TrimmedTextSize'] = $iTrimmedLimit;
}
$sLowerForwarded = strtolower(\CApi::GetConf('webmail.forwarded-flag-name', ''));
if (!empty($sLowerForwarded)) {
$mResult['IsForwarded'] = in_array($sLowerForwarded, $aFlags);
}
$mResult['Hash'] = \CApi::EncodeKeyValues(array('AccountID' => $oAccount ? $oAccount->IdAccount : 0, 'Folder' => $mResult['Folder'], 'Uid' => $mResult['Uid'], 'MimeType' => 'message/rfc822', 'FileName' => $mResult['Subject'] . '.eml'));
if ('MessageGet' === $sParent || 'MessagesGetBodies' === $sParent) {
$mResult['Headers'] = \MailSo\Base\Utils::Utf8Clear($mResponse->getHeaders());
$mResult['InReplyTo'] = $mResponse->getInReplyTo();
$mResult['References'] = $mResponse->getReferences();
$mResult['ReadingConfirmation'] = $mResponse->getReadingConfirmation();
if (!empty($mResult['ReadingConfirmation']) && in_array('$readconfirm', $aFlags)) {
$mResult['ReadingConfirmation'] = '';
}
$bHasExternals = false;
$aFoundedCIDs = array();
$sPlain = '';
$sHtml = trim($mResponse->getHtml());
if (0 === strlen($sHtml)) {
$sPlain = $mResponse->getPlain();
}
$aContentLocationUrls = array();
$aFoundedContentLocationUrls = array();
if ($oAttachments && 0 < $oAttachments->Count()) {
$aList =& $oAttachments->GetAsArray();
foreach ($aList as $oAttachment) {
if ($oAttachment) {
$sContentLocation = $oAttachment->getContentLocation();
if ($sContentLocation && 0 < \strlen($sContentLocation)) {
$aContentLocationUrls[] = $oAttachment->getContentLocation();
}
}
}
}
$iTextSizeLimit = 500000;
if ($iTextSizeLimit < \strlen($sHtml)) {
$iSpacePost = \strpos($sHtml, ' ', $iTextSizeLimit);
$sHtml = \substr($sHtml, 0, false !== $iSpacePost && $iSpacePost > $iTextSizeLimit ? $iSpacePost : $iTextSizeLimit);
}
if ($iTextSizeLimit < \strlen($sPlain)) {
$iSpacePost = \strpos($sPlain, ' ', $iTextSizeLimit);
$sPlain = \substr($sPlain, 0, false !== $iSpacePost && $iSpacePost > $iTextSizeLimit ? $iSpacePost : $iTextSizeLimit);
}
if (0 < \strlen($sHtml) && \CApi::GetConf('labs.webmail.display-inline-css', false)) {
include_once PSEVEN_APP_ROOT_PATH . 'libraries/other/CssToInlineStyles.php';
$oCssToInlineStyles = new \TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($sHtml);
$oCssToInlineStyles->setEncoding('utf-8');
$oCssToInlineStyles->setUseInlineStylesBlock(true);
$mResult['Html'] = \MailSo\Base\HtmlUtils::ClearHtml($oCssToInlineStyles->convert(), $bHasExternals, $aFoundedCIDs, $aContentLocationUrls, $aFoundedContentLocationUrls, false, true);
} else {
$mResult['Html'] = 0 === strlen($sHtml) ? '' : \MailSo\Base\HtmlUtils::ClearHtml($sHtml, $bHasExternals, $aFoundedCIDs, $aContentLocationUrls, $aFoundedContentLocationUrls, false, true);
}
$mResult['Trimmed'] = false;
$mResult['Plain'] = 0 === strlen($sPlain) ? '' : \MailSo\Base\HtmlUtils::ConvertPlainToHtml($sPlain);
$mResult['PlainRaw'] = \trim($sPlain);
$mResult['Rtl'] = 0 < \strlen($mResult['Plain']) ? \MailSo\Base\Utils::IsRTL($mResult['Plain']) : false;
if (0 < $iTrimmedLimit && 'Messages' === $sParent) {
if ($iTrimmedLimit < strlen($mResult['Plain'])) {
$iPos = strpos($mResult['Plain'], ' ', $iTrimmedLimit);
if (false !== $iPos && $iTrimmedLimit <= $iPos) {
$mResult['Plain'] = substr($mResult['Plain'], 0, $iPos);
$mResult['Trimmed'] = true;
}
}
if ($iTrimmedLimit < strlen($mResult['Html'])) {
$iPos = strpos($mResult['Html'], ' <', $iTrimmedLimit);
if (false !== $iPos && $iTrimmedLimit <= $iPos) {
$mResult['Html'] = substr($mResult['Html'], 0, $iPos) . '<!-- cutted -->';
$mResult['Trimmed'] = true;
}
}
}
$mResult['ICAL'] = $this->responseObject($oAccount, $mResponse->getExtend('ICAL'), $sParent, $aParameters);
$mResult['VCARD'] = $this->responseObject($oAccount, $mResponse->getExtend('VCARD'), $sParent, $aParameters);
$mResult['Safety'] = $mResponse->getSafety();
$mResult['HasExternals'] = $bHasExternals;
$mResult['FoundedCIDs'] = $aFoundedCIDs;
//.........这里部分代码省略.........
示例5: Set
public function Set($aData)
{
$sAccountHashTable = \CApi::EncodeKeyValues($aData);
$sAuthToken = \md5(\microtime(true) . \rand(10000, 99999));
return $this->Session->Set('AUTHTOKEN:' . $sAuthToken, $sAccountHashTable) ? $sAuthToken : '';
}
示例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: PopulateFileInfo
/**
* @param array $aData
*/
protected function PopulateFileInfo($sType, $sPath, $oFile)
{
$mResult = false;
if ($oFile) {
\api_Utils::PopulateGoogleDriveFileInfo($oFile);
$mResult = new \CFileStorageItem();
$mResult->IsExternal = true;
$mResult->TypeStr = $sType;
$mResult->IsFolder = $oFile->mimeType === "application/vnd.google-apps.folder";
$mResult->Id = $oFile->id;
$mResult->Name = $oFile->title;
$mResult->Path = '';
$mResult->Size = $oFile->fileSize;
$mResult->FullPath = $oFile->id;
// $oItem->Owner = $oSocial->Name;
$mResult->LastModified = date_timestamp_get(date_create($oFile->createdDate));
$mResult->Hash = \CApi::EncodeKeyValues(array('Type' => $sType, 'Path' => $sPath, 'Name' => $mResult->Id, 'Size' => $mResult->Size));
}
return $mResult;
}
示例8: 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 : '';
}
示例9: GetFiles
public function GetFiles($oAccount, $sType = \EFileStorageTypeStr::Personal, $sPath = '', $sPattern = '')
{
$oDirectory = null;
$aItems = array();
$aResult = array();
$oMin = $this->GetMinManager();
if ($oAccount && $this->Init($oAccount)) {
$oTenant = null;
$oApiTenants = \CApi::Manager('tenants');
if ($oApiTenants) {
$oTenant = 0 < $oAccount->IdTenant ? $oApiTenants->GetTenantById($oAccount->IdTenant) : $oApiTenants->GetDefaultGlobalTenant();
}
$sRootPath = $this->getRootPath($oAccount, $sType, true);
$oDirectory = $this->getDirectory($oAccount, $sType, $sPath);
if ($oDirectory !== null) {
if (!empty($sPattern) || is_numeric($sPattern)) {
$aItems = $oDirectory->Search($sPattern);
$aDirectoryInfo = $oDirectory->getChildrenProperties();
foreach ($aDirectoryInfo as $oDirectoryInfo) {
if (isset($oDirectoryInfo['Link']) && strpos($oDirectoryInfo['Name'], $sPattern) !== false) {
$aItems[] = new \afterlogic\DAV\FS\File($oDirectory->getPath() . '/' . $oDirectoryInfo['@Name']);
}
}
} else {
$aItems = $oDirectory->getChildren();
}
$iThumbnailLimit = 1024 * 1024 * 2;
// 2MB
foreach ($aItems as $oValue) {
$sFilePath = str_replace($sRootPath, '', dirname($oValue->getPath()));
$aProps = $oValue->getProperties(array('Owner', 'Shared', 'Name', 'Link', 'LinkType'));
$oItem = new \CFileStorageItem();
$oItem->Type = $sType;
$oItem->TypeStr = $sType;
$oItem->Path = $sFilePath;
$oItem->Name = $oValue->getName();
$oItem->Id = $oValue->getName();
$oItem->FullPath = $oItem->Name !== '' ? $oItem->Path . '/' . $oItem->Name : $oItem->Path;
$sID = '';
if ($oValue instanceof \afterlogic\DAV\FS\Directory) {
$sID = $this->GenerateShareHash($oAccount, $sType, $sFilePath, $oValue->getName());
$oItem->IsFolder = true;
}
if ($oValue instanceof \afterlogic\DAV\FS\File) {
$sID = $this->GenerateShareHash($oAccount, $sType, $sFilePath, $oValue->getName());
$oItem->IsFolder = false;
$oItem->Size = $oValue->getSize();
$oFileInfo = null;
if (isset($aProps['Link'])) {
$oItem->IsLink = true;
$iLinkType = api_Utils::GetLinkType($aProps['Link']);
$oItem->LinkType = $iLinkType;
$oItem->LinkUrl = $aProps['Link'];
if (isset($iLinkType) && $oTenant) {
if (\EFileStorageLinkType::GoogleDrive === $iLinkType) {
$oSocial = $oTenant->GetSocialByName('google');
if ($oSocial) {
$oFileInfo = \api_Utils::GetGoogleDriveFileInfo($aProps['Link'], $oSocial->SocialApiKey);
if ($oFileInfo) {
$oItem->Name = isset($oFileInfo->title) ? $oFileInfo->title : $oItem->Name;
$oItem->Size = isset($oFileInfo->fileSize) ? $oFileInfo->fileSize : $oItem->Size;
}
}
} else {
if (\EFileStorageLinkType::DropBox === $iLinkType) {
$aProps['Link'] = str_replace('www.dropbox.com', 'dl.dropboxusercontent.com', $aProps['Link']);
}
$oItem->Name = isset($aProps['Name']) ? $aProps['Name'] : basename($aProps['Link']);
$aRemoteFileInfo = \api_Utils::GetRemoteFileInfo($aProps['Link']);
$oItem->Size = $aRemoteFileInfo['size'];
}
}
} else {
$oItem->IsLink = false;
}
$oItem->LastModified = $oValue->getLastModified();
$oItem->ContentType = $oValue->getContentType();
if (!$oItem->ContentType) {
$oItem->ContentType = \api_Utils::MimeContentType($oItem->Name);
}
if (\CApi::GetConf('labs.allow-thumbnail', true)) {
if ($oItem->IsLink && $oItem->LinkType === \EFileStorageLinkType::GoogleDrive && isset($oFileInfo) && isset($oFileInfo->thumbnailLink)) {
$oItem->Thumb = true;
$oItem->ThumbnailLink = $oFileInfo->thumbnailLink;
} else {
$oItem->Thumb = $oItem->Size < $iThumbnailLimit && \api_Utils::IsGDImageMimeTypeSuppoted($oItem->ContentType, $oItem->Name);
}
}
$oItem->Iframed = !$oItem->IsFolder && !$oItem->IsLink && \CApi::isIframedMimeTypeSupported($oItem->ContentType, $oItem->Name);
$oItem->Hash = \CApi::EncodeKeyValues(array('Type' => $sType, 'Path' => $sFilePath, 'Name' => $oValue->getName(), 'FileName' => $oValue->getName(), 'MimeType' => $oItem->ContentType, 'Size' => $oValue->getSize(), 'Iframed' => $oItem->Iframed));
}
$mMin = $oMin->GetMinByID($sID);
$oItem->Shared = isset($aProps['Shared']) ? $aProps['Shared'] : empty($mMin['__hash__']) ? false : true;
$oItem->Owner = isset($aProps['Owner']) ? $aProps['Owner'] : $oAccount->Email;
if ($oItem && '.asc' === \strtolower(\substr(\trim($oItem->Name), -4))) {
$mResult = $this->GetFile($oAccount, $oItem->Type, $oItem->Path, $oItem->Name);
if (is_resource($mResult)) {
$oItem->Content = stream_get_contents($mResult);
}
}
//.........这里部分代码省略.........
示例10: isset
$oApiUsersManager = CApi::Manager('users');
/* @var $oApiIntegratorManager CApiIntegratorManager */
$oApiIntegratorManager = CApi::Manager('integrator');
if ($sMethod === 'GET /token') {
$oSettings = CApi::GetSettings();
$sLogin = isset($aInputData['login']) ? $aInputData['login'] : '';
$sPassword = isset($aInputData['password']) ? $aInputData['password'] : '';
if (0 < strlen($sLogin) && 0 < strlen($sPassword) && $oApiTenantsManager && $oSettings) {
$sSettingsLogin = $oSettings->GetConf('Common/AdminLogin');
$sSettingsPassword = $oSettings->GetConf('Common/AdminPassword');
$iTenantId = $oApiTenantsManager->GetTenantIdByLogin($sLogin, $sPassword);
if (!($sSettingsLogin === $sLogin && $sSettingsPassword === md5($sPassword) || $iTenantId > 0)) {
$aResult['message'] = getErrorMessage('incorrect login or password', $oApiUsersManager);
$aResult['errorCode'] = \ProjectSeven\Notifications::RestInvalidCredentials;
} else {
$aResult['result'] = CApi::EncodeKeyValues(array('login' => $sLogin, 'password' => $sPassword, 'tenantId' => $iTenantId, 'timestamp' => time()));
}
} else {
$aResult['message'] = 'invalid input parameters';
$aResult['errorCode'] = \ProjectSeven\Notifications::RestInvalidParameters;
}
} else {
if (!(isset($aSecret['login']) && isset($aSecret['password']))) {
$aResult['message'] = 'invalid token';
$aResult['errorCode'] = \ProjectSeven\Notifications::RestInvalidToken;
} else {
if (!isset($aSecret['timestamp']) || time() - $aSecret['timestamp'] > 3600) {
$aResult['message'] = 'token expired';
$aResult['errorCode'] = \ProjectSeven\Notifications::RestTokenExpired;
} else {
$iAuthTenantId = isset($aSecret['tenantId']) ? $aSecret['tenantId'] : 0;