/**
  * @return string
  */
 public function ServiceLang()
 {
     $sResult = '';
     @\header('Content-Type: application/javascript; charset=utf-8');
     if (!empty($this->aPaths[2])) {
         $sLanguage = $this->oActions->ValidateLanguage($this->aPaths[2]);
         $bCacheEnabled = $this->Config()->Get('labs', 'cache_system_data', true);
         if (!empty($sLanguage) && $bCacheEnabled) {
             $this->oActions->verifyCacheByKey($this->sQuery);
         }
         $sCacheFileName = '';
         if ($bCacheEnabled) {
             $sCacheFileName = \RainLoop\KeyPathHelper::LangCache($sLanguage, $this->oActions->Plugins()->Hash());
             $sResult = $this->Cacher()->Get($sCacheFileName);
         }
         if (0 === \strlen($sResult)) {
             $sResult = $this->compileLanguage($sLanguage, false);
             if ($bCacheEnabled && 0 < \strlen($sCacheFileName)) {
                 $this->Cacher()->Set($sCacheFileName, $sResult);
             }
         }
         if ($bCacheEnabled) {
             $this->oActions->cacheByKey($this->sQuery);
         }
     }
     return $sResult;
 }
 /**
  * @return string
  */
 public function ServiceSso()
 {
     $this->oHttp->ServerNoCache();
     $oException = null;
     $oAccount = null;
     $bLogout = true;
     $sSsoHash = $this->oHttp->GetRequest('hash', '');
     if (!empty($sSsoHash)) {
         $mData = null;
         $sSsoSubData = $this->Cacher()->Get(\RainLoop\KeyPathHelper::SsoCacherKey($sSsoHash));
         if (!empty($sSsoSubData)) {
             $mData = \RainLoop\Utils::DecodeKeyValuesQ($sSsoSubData);
             $this->Cacher()->Delete(\RainLoop\KeyPathHelper::SsoCacherKey($sSsoHash));
             if (\is_array($mData) && !empty($mData['Email']) && isset($mData['Password'], $mData['Time']) && (0 === $mData['Time'] || \time() - 10 < $mData['Time'])) {
                 $sEmail = \trim($mData['Email']);
                 $sPassword = $mData['Password'];
                 $aAdditionalOptions = isset($mData['AdditionalOptions']) && \is_array($mData['AdditionalOptions']) && 0 < \count($mData['AdditionalOptions']) ? $mData['AdditionalOptions'] : null;
                 try {
                     $oAccount = $this->oActions->LoginProcess($sEmail, $sPassword);
                     if ($oAccount instanceof \RainLoop\Model\Account && $aAdditionalOptions) {
                         $bNeedToSettings = false;
                         $oSettings = $this->SettingsProvider()->Load($oAccount);
                         if ($oSettings) {
                             $sLanguage = isset($aAdditionalOptions['Language']) ? $aAdditionalOptions['Language'] : '';
                             if ($sLanguage) {
                                 $sLanguage = $this->oActions->ValidateLanguage($sLanguage);
                                 if ($sLanguage !== $oSettings->GetConf('Language', '')) {
                                     $bNeedToSettings = true;
                                     $oSettings->SetConf('Language', $sLanguage);
                                 }
                             }
                         }
                         if ($bNeedToSettings) {
                             $this->SettingsProvider()->Save($oAccount, $oSettings);
                         }
                     }
                     $this->oActions->AuthToken($oAccount);
                     $bLogout = !$oAccount instanceof \RainLoop\Model\Account;
                 } catch (\Exception $oException) {
                     $this->oActions->Logger()->WriteException($oException);
                 }
             }
         }
     }
     if ($bLogout) {
         $this->oActions->SetAuthLogoutToken();
     }
     $this->oActions->Location('./');
     return '';
 }
Пример #3
0
 /**
  * @param bool $bAdmin
  *
  * @return array
  */
 private function startUpData($bAdmin)
 {
     $sLanguage = 'en';
     $sTheme = 'Default';
     if (!$bAdmin) {
         list($sLanguage, $sTheme) = $this->oActions->GetLanguageAndTheme();
     }
     $sLanguage = $this->oActions->ValidateLanguage($sLanguage);
     $sTheme = $this->oActions->ValidateTheme($sTheme);
     $bAppJsDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_js', false);
     $bAppCssDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_css', false);
     $sStaticPrefix = APP_WEB_STATIC_PATH;
     return array('Language' => $sLanguage, 'Theme' => $sTheme, 'Hash' => $this->generateIndexCacheHash($bAppJsDebug, $bAdmin), 'LoadingDescription' => $this->oActions->Config()->Get('webmail', 'loading_description', 'RainLoop'), 'FaviconIcoLink' => $sStaticPrefix . 'favicon.ico', 'FaviconPngLink' => $sStaticPrefix . 'favicon.png', 'AppleTouchLink' => $sStaticPrefix . 'apple-touch-icon.png', 'AppCssLink' => $sStaticPrefix . 'css/app' . ($bAppCssDebug ? '' : '.min') . '.css', 'LibJsLink' => $sStaticPrefix . 'js/libs.js', 'EditorJsLink' => $sStaticPrefix . 'ckeditor/ckeditor.js', 'AppJsLink' => $sStaticPrefix . 'js/' . ($bAdmin ? 'admin' : 'app') . ($bAppJsDebug ? '' : '.min') . '.js');
 }
 /**
  * @param bool $bAdmin
  *
  * @return array
  */
 private function indexTemplateParameters($bAdmin)
 {
     $sLanguage = 'en';
     $sTheme = 'Default';
     if (!$bAdmin) {
         list($sLanguage, $sTheme) = $this->oActions->GetLanguageAndTheme();
     }
     $sLanguage = $this->oActions->ValidateLanguage($sLanguage);
     $sTheme = $this->oActions->ValidateTheme($sTheme);
     $bAppJsDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_js', false);
     $bAppCssDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_css', false);
     $sStaticPrefix = APP_WEB_STATIC_PATH;
     $aData = array('Language' => $sLanguage, 'Theme' => $sTheme, 'LoadingDescription' => $this->oActions->Config()->Get('webmail', 'loading_description', 'RainLoop'), 'FaviconIcoLink' => $sStaticPrefix . 'favicon.ico', 'FaviconPngLink' => $sStaticPrefix . 'favicon.png', 'AppleTouchLink' => $sStaticPrefix . 'apple-touch-icon.png', 'AppCssLink' => $sStaticPrefix . 'css/app' . ($bAppCssDebug ? '' : '.min') . '.css', 'BootJsLink' => $sStaticPrefix . 'js/min/boot.js', 'LibJsLink' => $sStaticPrefix . 'js/min/libs.js', 'EditorJsLink' => $sStaticPrefix . 'ckeditor/ckeditor.js', 'OpenPgpJsLink' => $sStaticPrefix . 'js/min/openpgp.min.js', 'AppJsLink' => $sStaticPrefix . 'js/' . ($bAppJsDebug ? '' : 'min/') . ($bAdmin ? 'admin' : 'app') . '.js');
     $aTemplateParameters = array('{{BaseAppDataScriptLink}}' => $bAdmin ? './?/AdminAppData/' : './?/AppData/', '{{BaseAppFaviconIcoFile}}' => $aData['FaviconIcoLink'], '{{BaseAppFaviconPngFile}}' => $aData['FaviconPngLink'], '{{BaseAppAppleTouchFile}}' => $aData['AppleTouchLink'], '{{BaseAppMainCssLink}}' => $aData['AppCssLink'], '{{BaseAppBootScriptLink}}' => $aData['BootJsLink'], '{{BaseAppLibsScriptLink}}' => $aData['LibJsLink'], '{{BaseAppEditorScriptLink}}' => $aData['EditorJsLink'], '{{BaseAppOpenPgpScriptLink}}' => $aData['OpenPgpJsLink'], '{{BaseAppMainScriptLink}}' => $aData['AppJsLink'], '{{BaseAppLoadingDescription}}' => \htmlspecialchars($aData['LoadingDescription'], ENT_QUOTES | ENT_IGNORE, 'UTF-8'), '{{BaseDir}}' => \in_array($aData['Language'], array('ar', 'he', 'ur')) ? 'rtl' : 'ltr');
     $aTemplateParameters['{{BaseHash}}'] = \md5(\implode('~', array(\md5($this->oActions->Config()->Get('cache', 'index', '')), $this->oActions->Plugins()->Hash(), APP_WEB_PATH, APP_VERSION)) . \implode('~', $aTemplateParameters));
     return $aTemplateParameters;
 }
Пример #5
0
 /**
  * @param bool $bAdmin
  *
  * @return array
  */
 private function indexTemplateParameters($bAdmin)
 {
     $sLanguage = 'en';
     $sTheme = 'Default';
     if (!$bAdmin) {
         list($sLanguage, $sTheme) = $this->oActions->GetLanguageAndTheme();
     }
     $sLanguage = $this->oActions->ValidateLanguage($sLanguage);
     $sTheme = $this->oActions->ValidateTheme($sTheme);
     $bAppJsDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_js', false);
     $bAppCssDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_css', false);
     $sStaticPrefix = \RainLoop\Utils::WebStaticPath();
     $aData = array('Language' => $sLanguage, 'Theme' => $sTheme, 'FaviconIcoLink' => $sStaticPrefix . 'favicon.ico', 'FaviconPngLink' => $sStaticPrefix . 'favicon.png', 'AppleTouchLink' => $sStaticPrefix . 'apple-touch-icon.png', 'AppCssLink' => $sStaticPrefix . 'css/app' . ($bAppCssDebug ? '' : '.min') . '.css', 'BootJsLink' => $sStaticPrefix . 'js/min/boot.js', 'ComponentsJsLink' => $sStaticPrefix . 'js/' . ($bAppJsDebug ? '' : 'min/') . 'components.js', 'LibJsLink' => $sStaticPrefix . 'js/min/libs.js', 'EditorJsLink' => $sStaticPrefix . 'ckeditor/ckeditor.js', 'OpenPgpJsLink' => $sStaticPrefix . 'js/min/openpgp.min.js', 'AppJsCommonLink' => $sStaticPrefix . 'js/' . ($bAppJsDebug ? '' : 'min/') . 'common.js', 'AppJsLink' => $sStaticPrefix . 'js/' . ($bAppJsDebug ? '' : 'min/') . ($bAdmin ? 'admin' : 'app') . '.js');
     $aTemplateParameters = array('{{BaseAppDataScriptLink}}' => $bAdmin ? './?/AdminAppData/' : './?/AppData/', '{{BaseAppFaviconIcoFile}}' => $aData['FaviconIcoLink'], '{{BaseAppFaviconPngFile}}' => $aData['FaviconPngLink'], '{{BaseAppAppleTouchFile}}' => $aData['AppleTouchLink'], '{{BaseAppMainCssLink}}' => $aData['AppCssLink'], '{{BaseAppBootScriptLink}}' => $aData['BootJsLink'], '{{BaseAppComponentsScriptLink}}' => $aData['ComponentsJsLink'], '{{BaseAppLibsScriptLink}}' => $aData['LibJsLink'], '{{BaseAppEditorScriptLink}}' => $aData['EditorJsLink'], '{{BaseAppOpenPgpScriptLink}}' => $aData['OpenPgpJsLink'], '{{BaseAppMainCommonScriptLink}}' => $aData['AppJsCommonLink'], '{{BaseAppMainScriptLink}}' => $aData['AppJsLink'], '{{BaseDir}}' => \in_array($aData['Language'], array('ar', 'he', 'ur')) ? 'rtl' : 'ltr');
     $aTemplateParameters['{{BaseHash}}'] = \md5(\implode('~', array(\md5($this->oActions->Config()->Get('cache', 'index', '')), $this->oActions->Plugins()->Hash(), \RainLoop\Utils::WebVersionPath(), APP_VERSION)) . \implode('~', $aTemplateParameters));
     return $aTemplateParameters;
 }