本文整理汇总了PHP中CApi::Location方法的典型用法代码示例。如果您正苦于以下问题:PHP CApi::Location方法的具体用法?PHP CApi::Location怎么用?PHP CApi::Location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CApi
的用法示例。
在下文中一共展示了CApi::Location方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Handle
/**
* @return void
*/
public function Handle()
{
$sVersion = file_get_contents(PSEVEN_APP_ROOT_PATH . 'VERSION');
define('PSEVEN_APP_VERSION', $sVersion);
if (!class_exists('MailSo\\Version')) {
echo 'MailSo';
return '';
} else {
if (!class_exists('\\CApi') || !\CApi::IsValid()) {
echo 'AfterLogic API';
return '';
}
}
$sPathInfo = \trim(\trim($this->oHttp->GetServer('PATH_INFO', '')), ' /');
if (!empty($sPathInfo)) {
if ('dav' === \substr($sPathInfo, 0, 3)) {
$this->oActions->PathInfoDav();
return '';
}
}
/* @var $oApiIntegrator \CApiIntegratorManager */
$oApiIntegrator = \CApi::Manager('integrator');
// ------ Redirect to HTTPS
$oSettings =& \CApi::GetSettings();
$bRedirectToHttps = $oSettings->GetConf('Common/RedirectToHttps');
$bHttps = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== "off" || isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == "443";
if ($bRedirectToHttps && !$bHttps) {
header("Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
// ------
/* @var $oApiCapability \CApiCapabilityManager */
$oApiCapability = \CApi::Manager('capability');
$sResult = '';
$sQuery = \trim(\trim($this->oHttp->GetServer('QUERY_STRING', '')), ' /');
\CApi::Plugin()->RunQueryHandle($sQuery);
$iPos = \strpos($sQuery, '&');
if (0 < $iPos) {
$sQuery = \substr($sQuery, 0, $iPos);
}
$aPaths = explode('/', $sQuery);
if (0 < count($aPaths) && !empty($aPaths[0])) {
$sFirstPart = strtolower($aPaths[0]);
if ('ping' === $sFirstPart) {
@header('Content-Type: text/plain; charset=utf-8');
$sResult = 'Pong';
} else {
if ('pull' === $sFirstPart) {
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
pclose(popen("start /B git pull", "r"));
} else {
exec("git pull > /dev/null 2>&1 &");
}
\CApi::Location('./');
} else {
if ('ajax' === $sFirstPart) {
@ob_start();
$aResponseItem = null;
$sAction = $this->oHttp->GetPost('Action', null);
try {
\CApi::Log('AJAX: Action: ' . $sAction);
if ('SystemGetAppData' !== $sAction && \CApi::GetConf('labs.webmail.csrftoken-protection', true) && !$this->validateToken()) {
throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::InvalidToken);
} else {
if (!empty($sAction)) {
$sMethodName = 'Ajax' . $sAction;
$this->oActions->SetActionParams($this->oHttp->GetPostAsArray());
if (method_exists($this->oActions, $sMethodName) && is_callable(array($this->oActions, $sMethodName))) {
$aResponseItem = call_user_func(array($this->oActions, $sMethodName));
}
if (\CApi::Plugin()->JsonHookExists($sMethodName)) {
$aResponseItem = \CApi::Plugin()->RunJsonHook($this->oActions, $sMethodName, $aResponseItem);
}
}
}
if (!is_array($aResponseItem)) {
throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::UnknownError);
}
} catch (\Exception $oException) {
//if ($oException instanceof \ProjectCore\Exceptions\ClientException &&
// \ProjectCore\Notifications::AuthError === $oException->getCode())
//{
// $oApiIntegrator = /* @var $oApiIntegrator \CApiIntegratorManager */ \CApi::Manager('integrator');
// $oApiIntegrator->setLastErrorCode(\ProjectCore\Notifications::AuthError);
// $oApiIntegrator->logoutAccount();
//}
\CApi::LogException($oException);
$sAction = empty($sAction) ? 'Unknown' : $sAction;
$aAdditionalParams = null;
if ($oException instanceof \ProjectCore\Exceptions\ClientException) {
$aAdditionalParams = $oException->GetObjectParams();
}
$aResponseItem = $this->oActions->ExceptionResponse(null, $sAction, $oException, $aAdditionalParams);
}
@header('Content-Type: application/json; charset=utf-8');
\CApi::Plugin()->RunHook('ajax.response-result', array($sAction, &$aResponseItem));
$sResult = \MailSo\Base\Utils::Php2js($aResponseItem, \CApi::MailSoLogger());
// \CApi::Log('AJAX: Response: '.$sResult);
//.........这里部分代码省略.........
示例2: initAuth
/**
* @return void
*/
protected function initAuth()
{
$this->iAuthType = AP_SESS_AUTH_TYPE_NONE;
if ((isset($_GET['login']) || isset($_POST['login'])) && (CPost::Has('AdmloginInput') || CGet::Has('AdmloginInput')) && CPost::Has('AdmpasswordInput')) {
$sAdmloginInput = CPost::Get('AdmloginInput');
if (CGet::Has('AdmloginInput')) {
$sAdmloginInput = CGet::Get('AdmloginInput');
}
$sLoginSuffix = CPost::Get('LoginSuffix', '');
if (CGet::Has('LoginSuffix')) {
$sLoginSuffix = CGet::Get('LoginSuffix', '');
}
if ($this->CallModuleFunction('CCommonModule', 'AuthLogin', array($sAdmloginInput . $sLoginSuffix, CPost::Get('AdmpasswordInput')))) {
CApi::Location(AP_INDEX_FILE . '?enter');
} else {
CSession::Destroy();
CApi::Location(AP_INDEX_FILE . '?auth_error');
}
exit;
} else {
if ($this->bSessionIsStarted) {
$this->CallModuleFunction('CCommonModule', 'AuthCheckSet');
if ($this->IsTenantAuthType()) {
$aTabs =& $this->GetTabs();
$aNewTabs = array();
foreach ($aTabs as $aTabValue) {
if (in_array($aTabValue[0], array(CApi::I18N('ADMIN_PANEL/TABNAME_COMMON'), CApi::I18N('ADMIN_PANEL/TABNAME_DOMAINS'), CApi::I18N('ADMIN_PANEL/TABNAME_USERS')))) {
$aNewTabs[] = $aTabValue;
}
}
$aTabs = $aNewTabs;
}
} else {
CSession::Destroy();
CApi::Location(AP_INDEX_FILE . '?sess_error');
exit;
}
}
}
示例3: Process
public static function Process($mResult)
{
$sExternalServicesRedirect = '';
$sError = '';
$sErrorMessage = '';
if (isset($_COOKIE["external-services-redirect"])) {
$sExternalServicesRedirect = $_COOKIE["external-services-redirect"];
@setcookie('external-services-redirect', null);
}
if ($sExternalServicesRedirect === 'helpdesk') {
self::SetValuesToCookie($mResult);
$sTenantHash = self::GetTenantHashFromCookie();
\CApi::Location($sTenantHash ? './?helpdesk=' . $sTenantHash : './?helpdesk');
} else {
$oApiUsers = \CApi::Manager('users');
$oInviteAccount = null;
if (isset($_COOKIE["external-services-invite-hash"])) {
$oInviteAccount = $oApiUsers->getAccountById($_COOKIE["external-services-invite-hash"], true);
@setcookie('external-services-invite-hash', null);
}
$sEmail = trim($mResult['email']);
if (empty($sEmail) && $oInviteAccount) {
$mResult['email'] = $oInviteAccount->Email;
}
$oApiSocial = \CApi::Manager('social');
$oSocial = new \CSocial();
$oSocial->TypeStr = $mResult['type'];
$oSocial->AccessToken = isset($mResult['access_token']) ? $mResult['access_token'] : '';
$oSocial->RefreshToken = isset($mResult['refresh_token']) ? $mResult['refresh_token'] : '';
$oSocial->IdSocial = $mResult['id'];
$oSocial->Name = $mResult['name'];
$oSocial->Email = $mResult['email'];
if ($sExternalServicesRedirect === 'login') {
self::SetValuesToCookie($mResult);
$oSocialOld = $oApiSocial->getSocialById($oSocial->IdSocial, $oSocial->TypeStr);
if ($oSocialOld) {
if ($oInviteAccount && $oInviteAccount->IdAccount === $oSocialOld->IdAccount || !$oInviteAccount) {
if (!$oSocialOld->Disabled && $oSocialOld->issetScope('auth')) {
$oSocialOld->setScope('auth');
$oSocial->Scopes = $oSocialOld->Scopes;
$oApiSocial->updateSocial($oSocial);
$oInviteAccount = $oApiUsers->getAccountById($oSocialOld->IdAccount);
} else {
$bResult = false;
$sError = '?error=es-002';
if (!empty($mResult['email'])) {
$sError = $sError . '&email=' . $mResult['email'];
} else {
$sError = $sError . '&service=' . $mResult['type'];
}
}
} else {
$oInviteAccount = null;
$bResult = false;
$sError = '?error=es-003';
}
} else {
$oInviteAccount = $oApiUsers->getAccountByEmail($mResult['email']);
if ($oInviteAccount) {
$oSocial->IdAccount = $oInviteAccount->IdAccount;
$oSocial->setScopes($mResult['scopes']);
$oApiSocial->createSocial($oSocial);
} else {
$sError = '?error=es-002';
if (!empty($mResult['email'])) {
$sError = $sError . '&email=' . $mResult['email'];
} else {
$sError = $sError . '&service=' . $mResult['type'];
}
}
}
if ($oInviteAccount) {
$oApiIntegrator = \CApi::Manager('integrator');
$oApiIntegrator->setAccountAsLoggedIn($oInviteAccount, true);
$oApiUsers->updateAccountLastLoginAndCount($oInviteAccount->IdUser);
}
\CApi::Location2('./' . $sError);
} else {
$oInviteAccount = \api_Utils::GetDefaultAccount();
if ($oInviteAccount) {
$bResult = false;
$oSocial->IdAccount = $oInviteAccount->IdAccount;
$oSocialOld = $oApiSocial->getSocialById($oSocial->IdSocial, $oSocial->TypeStr);
if ($oSocialOld) {
if ($oSocialOld->IdAccount === $oSocial->IdAccount) {
if (in_array('null', $mResult['scopes']) || count($mResult['scopes']) === 0) {
$bResult = $oSocial->deleteSocial($oInviteAccount->IdAccount, $oSocial->TypeStr);
} else {
$oSocial->setScopes($mResult['scopes']);
$bResult = $oApiSocial->updateSocial($oSocial);
}
} else {
$bResult = false;
$oPlugin = \CApi::Plugin()->GetPluginByName('external-services');
if ($oPlugin) {
$sErrorMessage = $oPlugin->I18N('PLUGIN_EXTERNAL_SERVICES/INFO_ACCOUNT_ALREADY_ASSIGNED', $oInviteAccount);
}
}
} else {
if (!in_array('null', $mResult['scopes']) && count($mResult['scopes']) > 0) {
//.........这里部分代码省略.........
示例4: exit
*/
// remove the following line for real use
exit('remove this line');
// Example of logging into WebMail account using email and password for incorporating into another web application
// utilizing API
include_once __DIR__ . '/../libraries/afterlogic/api.php';
if (class_exists('CApi') && CApi::IsValid()) {
// data for logging into account
$sEmail = 'user@domain.com';
$sPassword = '12345';
try {
// Getting required API class
$oApiIntegratorManager = CApi::Manager('integrator');
// attempting to obtain object for account we're trying to log into
$oAccount = $oApiIntegratorManager->loginToAccount($sEmail, $sPassword);
if ($oAccount) {
// populating session data from the account
$oApiIntegratorManager->setAccountAsLoggedIn($oAccount);
// redirecting to WebMail
CApi::Location('../');
} else {
// login error
echo $oApiIntegratorManager->GetLastErrorMessage();
}
} catch (Exception $oException) {
// login error
echo $oException->getMessage();
}
} else {
echo 'AfterLogic API isn\'t available';
}
示例5: Process
public static function Process($mResult)
{
$sSocialRedirect = '';
if (isset($_COOKIE["SocialRedirect"])) {
$sSocialRedirect = $_COOKIE["SocialRedirect"];
@setcookie('SocialRedirect', null);
}
if ($sSocialRedirect === 'helpdesk') {
self::SetValuesToCookie($mResult);
$sTenantHash = self::GetTenantHashFromCookie();
if ($sTenantHash) {
\CApi::Location('./?helpdesk=' . $sTenantHash);
} else {
\CApi::Location('./?helpdesk');
}
} else {
$oAccount = \api_Utils::GetDefaultAccount();
if ($oAccount) {
$oApiSocial = \CApi::Manager('social');
$oSocial = new \CSocial();
$oSocial->IdAccount = $oAccount->IdAccount;
switch ($mResult['type']) {
case 'google':
$oSocial->Type = \ESocialType::Google;
$oSocial->AccessToken = $mResult['access_token'];
$oSocial->RefreshToken = $mResult['refresh_token'];
break;
case 'dropbox':
$oSocial->Type = \ESocialType::Dropbox;
$oSocial->AccessToken = $mResult['access_token'];
break;
}
$oSocial->IdSocial = $mResult['id'];
$oSocial->Name = $mResult['name'];
$bCreateResult = $oApiSocial->CreateSocial($oSocial);
echo "<script>" . "if (typeof(window.opener.servicesSettingsViewModelCallback) !== 'undefined')" . "{" . "window.opener.servicesSettingsViewModelCallback('" . $mResult['type'] . "', " . $bCreateResult . ");" . "window.close();" . "}" . "</script>";
}
}
}
示例6: Process
public static function Process($mResult)
{
$sSocialRedirect = '';
if (isset($_COOKIE["SocialRedirect"])) {
$sSocialRedirect = $_COOKIE["SocialRedirect"];
@setcookie('SocialRedirect', null);
}
if ($sSocialRedirect === 'helpdesk') {
self::SetValuesToCookie($mResult);
$sTenantHash = self::GetTenantHashFromCookie();
if ($sTenantHash) {
\CApi::Location('./?helpdesk=' . $sTenantHash);
} else {
\CApi::Location('./?helpdesk');
}
} else {
$oAccount = \api_Utils::GetDefaultAccount();
$oApiSocial = \CApi::Manager('social');
$oSocial = new \CSocial();
switch ($mResult['type']) {
case 'google':
$oSocial->Type = \ESocialType::Google;
$oSocial->AccessToken = $mResult['access_token'];
$oSocial->RefreshToken = $mResult['refresh_token'];
break;
case 'dropbox':
$oSocial->Type = \ESocialType::Dropbox;
$oSocial->AccessToken = $mResult['access_token'];
break;
}
$oSocial->IdSocial = $mResult['id'];
$oSocial->Name = $mResult['name'];
if ($sSocialRedirect === 'login') {
$oSocial->Scopes = 'LOGIN';
$oApiUsers = \CApi::Manager('users');
if (!$oApiSocial->SocialExists($oSocial->Type, $oSocial->IdSocial)) {
$oAccount = $oApiUsers->GetAccountOnLogin($mResult['email']);
if ($oAccount) {
$oSocial->IdAccount = $oAccount->IdAccount;
$oApiSocial->CreateSocial($oSocial);
} else {
// Account does not exist
}
} else {
$oSocial = $oApiSocial->GetSocialById($oSocial->IdSocial, $oSocial->Type);
if ($oSocial && $oSocial->IssetScope('auth')) {
$oAccount = $oApiUsers->GetAccountById($oSocial->IdAccount);
} else {
// Account already exist
}
}
$oApiIntegrator = \CApi::Manager('integrator');
$oApiIntegrator->SetAccountAsLoggedIn($oAccount, true);
\CApi::Location('./');
} else {
if ($oAccount) {
$oSocial->IdAccount = $oAccount->IdAccount;
$bCreateResult = $oApiSocial->CreateSocial($oSocial);
echo "<script>" . "if (typeof(window.opener.servicesSettingsViewModelCallback) !== 'undefined')" . "{" . "window.opener.servicesSettingsViewModelCallback('" . $mResult['type'] . "', " . $bCreateResult . ");" . "window.close();" . "}" . "</script>";
}
}
}
}
示例7: Handle
//.........这里部分代码省略.........
$aResponseItem = call_user_func(array($this->oActions, $sMethodName));
} else {
$sError = $this->oActions->convertUploadErrorToString($iError);
}
} else {
if (!isset($_FILES) || !is_array($_FILES) || 0 === count($_FILES)) {
$sError = 'size';
} 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);