/** * * @return string * @throws \System\Exceptions\AuroraApiException */ public function EntryApi() { @ob_start(); $aResponseItem = null; $sModule = $this->oHttp->GetPost('Module', null); $sMethod = $this->oHttp->GetPost('Method', null); $sParameters = $this->oHttp->GetPost('Parameters', null); $sFormat = $this->oHttp->GetPost('Format', null); try { if (isset($sModule, $sMethod)) { if (strtolower($sModule) === strtolower($this->GetName())) { \CApi::Log('API:'); \CApi::Log('Module: ' . $sModule); \CApi::Log('Method: ' . $sMethod); if (strtolower($sModule) !== 'core' && \CApi::GetConf('labs.webmail.csrftoken-protection', true) && !\CApi::validateAuthToken()) { throw new \System\Exceptions\AuroraApiException(\System\Notifications::InvalidToken); } else { if (!empty($sModule) && !empty($sMethod)) { $aParameters = isset($sParameters) && is_string($sParameters) ? @json_decode($sParameters, true) : array(); $sTenantName = $this->oHttp->GetPost('TenantName', ''); \CApi::setTenantName($sTenantName); if (!is_array($aParameters)) { $aParameters = array($aParameters); } $mUploadData = $this->getUploadData(); if (is_array($mUploadData)) { $aParameters['UploadData'] = $mUploadData; } $this->CallMethod($sMethod, $aParameters, true); $aResponseItem = $this->DefaultResponse($sMethod, \CApi::GetModuleManager()->GetResults()); } } if (!is_array($aResponseItem)) { throw new \System\Exceptions\AuroraApiException(\System\Notifications::UnknownError); } if ($sFormat !== 'Raw') { @header('Content-Type: application/json; charset=utf-8'); } } } else { throw new \System\Exceptions\AuroraApiException(\System\Notifications::InvalidInputParameter); } } catch (\Exception $oException) { \CApi::LogException($oException); $aAdditionalParams = null; if ($oException instanceof \System\Exceptions\AuroraApiException) { $aAdditionalParams = $oException->GetObjectParams(); } $aResponseItem = $this->ExceptionResponse($sMethod, $oException, $aAdditionalParams); } return \MailSo\Base\Utils::Php2js($aResponseItem, \CApi::MailSoLogger()); }