Пример #1
0
 /**
  * @param bool $bAdmin = true
  *
  * @return string
  */
 private function localAppData($bAdmin = false)
 {
     @\header('Content-Type: application/javascript; charset=utf-8');
     $this->oHttp->ServerNoCache();
     $sAuthAccountHash = '';
     if (!$bAdmin && 0 === \strlen($this->oActions->GetSpecAuthLogoutTokenWithDeletion())) {
         $sAuthAccountHash = $this->oActions->GetSpecAuthTokenWithDeletion();
         if (empty($sAuthAccountHash)) {
             $sAuthAccountHash = $this->oActions->GetSpecAuthToken();
         }
         if (empty($sAuthAccountHash)) {
             $oAccount = $this->oActions->GetAccountFromSignMeToken();
             if ($oAccount) {
                 try {
                     $this->oActions->CheckMailConnection($oAccount);
                     $this->oActions->AuthToken($oAccount);
                     $sAuthAccountHash = $this->oActions->GetSpecAuthToken();
                 } catch (\Exception $oException) {
                     $oException = null;
                     $this->oActions->ClearSignMeData($oAccount);
                 }
             }
         }
         $this->oActions->SetSpecAuthToken($sAuthAccountHash);
     }
     $sResult = $this->compileAppData($this->oActions->AppData($bAdmin, $sAuthAccountHash), false);
     $this->Logger()->Write($sResult, \MailSo\Log\Enumerations\Type::INFO, 'APPDATA');
     return $sResult;
 }
Пример #2
0
 /**
  * @return bool
  */
 public function RawContactsCsv()
 {
     $oAccount = $this->getAccountFromToken();
     \header('Content-Type: text/csv; charset=UTF-8');
     \header('Content-Disposition: attachment; filename="contacts.csv"', true);
     \header('Accept-Ranges: none', true);
     \header('Content-Transfer-Encoding: binary');
     $this->oHttp->ServerNoCache();
     return $this->AddressBookProvider($oAccount)->IsActive() ? $this->AddressBookProvider($oAccount)->Export($oAccount->ParentEmailHelper(), 'csv') : false;
 }
Пример #3
0
 /**
  * @return \RainLoop\Service
  */
 private function localHandle()
 {
     if (!\class_exists('MailSo\\Version')) {
         return $this;
     }
     $this->oActions->BootStart();
     $sResult = '';
     $bCached = false;
     $sQuery = $this->oActions->ParseQueryAuthString();
     $this->oActions->Plugins()->RunHook('filter.http-query', array(&$sQuery));
     $aPaths = \explode('/', $sQuery);
     $this->oActions->Plugins()->RunHook('filter.http-paths', array(&$aPaths));
     $bAdmin = false;
     $sAdminPanelHost = $this->oActions->Config()->Get('security', 'admin_panel_host', '');
     if (empty($sAdminPanelHost)) {
         $bAdmin = !empty($aPaths[0]) && \in_array(\strtolower($aPaths[0]), array('admin', 'cp'));
     } else {
         if (empty($aPaths[0]) && \MailSo\Base\Utils::StrToLowerIfAscii($sAdminPanelHost) === \MailSo\Base\Utils::StrToLowerIfAscii($this->oHttp->GetHost())) {
             $bAdmin = true;
         }
     }
     if ($this->oHttp->IsPost()) {
         $this->oHttp->ServerNoCache();
     }
     if ($bAdmin && !$this->oActions->Config()->Get('security', 'allow_admin_panel', true)) {
         echo $this->oServiceActions->ErrorTemplates('Access Denied.', 'Access to the RainLoop Webmail Admin Panel is not allowed!', true);
         return $this;
     }
     $bIndex = true;
     if (0 < \count($aPaths) && !empty($aPaths[0]) && !$bAdmin && 'index' !== $aPaths[0]) {
         $bIndex = false;
         $sMethodName = 'Service' . $aPaths[0];
         if (\method_exists($this->oServiceActions, $sMethodName) && \is_callable(array($this->oServiceActions, $sMethodName))) {
             $this->oServiceActions->SetQuery($sQuery)->SetPaths($aPaths);
             $sResult = \call_user_func(array($this->oServiceActions, $sMethodName));
         } else {
             if (!$this->oActions->Plugins()->RunAdditionalPart($aPaths[0], $aPaths)) {
                 $bIndex = true;
             }
         }
     }
     if ($bIndex) {
         @\header('Content-Security-Policy:');
         @\header_remove('Content-Security-Policy');
         @header('Content-Type: text/html; charset=utf-8');
         $this->oHttp->ServerNoCache();
         if (!@\is_dir(APP_DATA_FOLDER_PATH) || !@\is_writable(APP_DATA_FOLDER_PATH)) {
             echo $this->oServiceActions->ErrorTemplates('Permission denied!', 'RainLoop Webmail cannot access to the data folder "' . APP_DATA_FOLDER_PATH . '"');
             return $this;
         }
         $aTemplateParameters = $this->indexTemplateParameters($bAdmin);
         $sCacheFileName = '';
         if ($this->oActions->Config()->Get('labs', 'cache_system_data', true)) {
             $sCacheFileName = 'TMPL:' . $aTemplateParameters['{{BaseHash}}'];
             $sResult = $this->oActions->Cacher()->Get($sCacheFileName);
         }
         if (0 === \strlen($sResult)) {
             //				$aTemplateParameters['{{BaseTemplates}}'] = $this->oServiceActions->compileTemplates($bAdmin, false);
             $sResult = \strtr(\file_get_contents(APP_VERSION_ROOT_PATH . 'app/templates/Index.html'), $aTemplateParameters);
             $sResult = \RainLoop\Utils::ClearHtmlOutput($sResult);
             if (0 < \strlen($sCacheFileName)) {
                 $this->oActions->Cacher()->Set($sCacheFileName, $sResult);
             }
         } else {
             $bCached = true;
         }
         $sResult .= '<!--';
         $sResult .= ' [time:' . \substr(\microtime(true) - APP_START, 0, 6);
         //			$sResult .= '][version:'.APP_VERSION;
         if ($this->oActions->IsOpen()) {
             $sResult .= '][AGPLv3';
         }
         $sResult .= '][cached:' . ($bCached ? 'true' : 'false');
         //			$sResult .= '][hash:'.$aTemplateParameters['{{BaseHash}}'];
         //			$sResult .= '][session:'.\md5(\RainLoop\Utils::GetShortToken());
         if (\RainLoop\Utils::IsOwnCloud()) {
             $sResult .= '][owncloud:true';
         }
         $sResult .= '] //-->';
     }
     // Output result
     echo $sResult;
     unset($sResult);
     $this->oActions->BootEnd();
     return $this;
 }
Пример #4
0
 /**
  * @return string
  */
 public function FacebookPopupService()
 {
     $sResult = '';
     $sLoginUrl = '';
     $sSocialName = '';
     $mData = false;
     $sUserData = '';
     $aUserData = false;
     $bLogin = false;
     $iErrorCode = \RainLoop\Notifications::UnknownError;
     if (0 === \strlen($this->oActions->GetSpecAuthToken()) && $this->oHttp->HasQuery('rlah')) {
         $this->oActions->SetSpecAuthToken($this->oHttp->GetQuery('rlah', ''));
     }
     $oAccount = $this->oActions->GetAccount();
     $oFacebook = $this->FacebookConnector($oAccount);
     if ($oFacebook) {
         try {
             $oSession = $oFacebook->getSessionFromRedirect();
             if (!$oSession && !$this->oHttp->HasQuery('state')) {
                 $sLoginUrl = $oFacebook->getLoginUrl() . '&display=popup';
             } else {
                 if ($oSession) {
                     $oRequest = new \Facebook\FacebookRequest($oSession, 'GET', '/me');
                     $oResponse = $oRequest->execute();
                     $oGraphObject = $oResponse->getGraphObject();
                     $mData = $oGraphObject->getProperty('id');
                     $sSocialName = $oGraphObject->getProperty('name');
                     if ($oAccount) {
                         if ($mData && 0 < \strlen($mData)) {
                             $aUserData = array('Email' => $oAccount->Email(), 'Password' => $oAccount->Password());
                             $oSettings = $this->oActions->SettingsProvider()->Load($oAccount);
                             $oSettings->SetConf('FacebookSocialName', $sSocialName);
                             $oSettings->SetConf('FacebookAccessToken', \RainLoop\Utils::EncodeKeyValues(array('id' => $mData)));
                             $this->oActions->SettingsProvider()->Save($oAccount, $oSettings);
                             $this->oActions->StorageProvider()->Put(null, \RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY, $this->FacebookUserLoginStorageKey($oFacebook, $mData), \RainLoop\Utils::EncodeKeyValues($aUserData));
                             $iErrorCode = 0;
                         }
                     } else {
                         $bLogin = true;
                         if ($mData && 0 < \strlen($mData)) {
                             $sUserData = $this->oActions->StorageProvider()->Get(null, \RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY, $this->FacebookUserLoginStorageKey($oFacebook, $mData));
                             if ($sUserData) {
                                 $aUserData = \RainLoop\Utils::DecodeKeyValues($sUserData);
                             }
                         }
                         if ($aUserData && \is_array($aUserData) && !empty($aUserData['Email']) && isset($aUserData['Password'])) {
                             $oAccount = $this->oActions->LoginProcess($aUserData['Email'], $aUserData['Password']);
                             if ($oAccount instanceof \RainLoop\Account) {
                                 $this->oActions->AuthProcess($oAccount);
                                 $iErrorCode = 0;
                             }
                         } else {
                             $iErrorCode = \RainLoop\Notifications::SocialFacebookLoginAccessDisable;
                         }
                     }
                 }
             }
         } catch (\Exception $oException) {
             $this->oActions->Logger()->WriteException($oException, \MailSo\Log\Enumerations\Type::ERROR);
         }
     }
     if ($sLoginUrl) {
         $this->oActions->Location($sLoginUrl);
     } else {
         $this->oHttp->ServerNoCache();
         @\header('Content-Type: text/html; charset=utf-8');
         $sCallBackType = $bLogin ? '_login' : '';
         $sConnectionFunc = 'rl_' . \md5(\RainLoop\Utils::GetConnectionToken()) . '_facebook' . $sCallBackType . '_service';
         $sResult = '<script type="text/javascript" data-cfasync="false">opener && opener.' . $sConnectionFunc . ' && opener.' . $sConnectionFunc . '(' . $iErrorCode . '); self && self.close && self.close();</script>';
     }
     return $sResult;
 }
Пример #5
0
 /**
  * @return \RainLoop\Service
  */
 public function Handle()
 {
     if (!\class_exists('MailSo\\Version')) {
         return $this;
     }
     $this->oActions->BootStart();
     $this->oActions->ParseQueryAuthString();
     $bCached = false;
     $sResult = '';
     $sQuery = \trim(\trim($this->oHttp->GetServer('QUERY_STRING', '')), ' /');
     $iPos = \strpos($sQuery, '&');
     if (0 < $iPos) {
         $sQuery = \substr($sQuery, 0, $iPos);
     }
     $this->oActions->Plugins()->RunHook('filter.http-query', array(&$sQuery));
     $aPaths = \explode('/', $sQuery);
     $this->oActions->Plugins()->RunHook('filter.http-paths', array(&$aPaths));
     $bAdmin = false;
     $sAdminPanelHost = $this->oActions->Config()->Get('security', 'admin_panel_host', '');
     if (empty($sAdminPanelHost)) {
         $bAdmin = !empty($aPaths[0]) && \in_array(\strtolower($aPaths[0]), array('admin', 'cp'));
     } else {
         if (empty($aPaths[0]) && \MailSo\Base\Utils::StrToLowerIfAscii($sAdminPanelHost) === \MailSo\Base\Utils::StrToLowerIfAscii($this->oHttp->GetHost())) {
             $bAdmin = true;
         }
     }
     if ($bAdmin && !$this->oActions->Config()->Get('security', 'allow_admin_panel', true)) {
         echo $this->oActions->ErrorTemplates('Access Denied.', 'Access to the RainLoop Webmail Admin Panel is not allowed!', true);
         return $this;
     }
     $bIndex = true;
     if (0 < \count($aPaths) && !empty($aPaths[0]) && !$bAdmin && 'index' !== $aPaths[0]) {
         $bIndex = false;
         $sMethodName = 'Service' . $aPaths[0];
         if (\method_exists($this->oServiceActions, $sMethodName) && \is_callable(array($this->oServiceActions, $sMethodName))) {
             $this->oServiceActions->SetQuery($sQuery)->SetPaths($aPaths);
             $sResult = \call_user_func(array($this->oServiceActions, $sMethodName));
         } else {
             if (!$this->oActions->Plugins()->RunAdditionalPart($aPaths[0], $aPaths)) {
                 $bIndex = true;
             }
         }
     }
     if ($bIndex) {
         @header('Content-Type: text/html; charset=utf-8');
         $this->oHttp->ServerNoCache();
         $aData = $this->startUpData($bAdmin);
         $sCacheFileName = '';
         if ($this->oActions->Config()->Get('labs', 'cache_system_data', true)) {
             $sCacheFileName = 'TMPL:' . $aData['Hash'];
             $sResult = $this->oActions->Cacher()->Get($sCacheFileName);
         }
         if (0 === \strlen($sResult)) {
             $sJsBoot = \file_get_contents(APP_VERSION_ROOT_PATH . 'static/js/boot.js');
             $sResult = \strtr(\file_get_contents(APP_VERSION_ROOT_PATH . 'app/templates/Index.html'), array('{{BaseRandHash}}' => \md5(\rand(1000, 9000) . \microtime(true)), '{{BaseAppDataScriptLink}}' => $bAdmin ? './?/AdminAppData/' : './?/AppData/', '{{BaseAppFaviconIcoFile}}' => $aData['FaviconIcoLink'], '{{BaseAppFaviconPngFile}}' => $aData['FaviconPngLink'], '{{BaseAppAppleTouchFile}}' => $aData['AppleTouchLink'], '{{BaseAppMainCssLink}}' => $aData['AppCssLink'], '{{BaseAppBootScriptSource}}' => $sJsBoot, '{{BaseAppLibsScriptLink}}' => $aData['LibJsLink'], '{{BaseAppEditorScriptLink}}' => $aData['EditorJsLink'], '{{BaseAppMainScriptLink}}' => $aData['AppJsLink'], '{{BaseAppLoadingDescription}}' => \htmlspecialchars($aData['LoadingDescription'], ENT_QUOTES | ENT_IGNORE, 'UTF-8'), '{{BaseDir}}' => \in_array($aData['Language'], array('ar', 'he', 'ur')) ? 'rtl' : 'ltr'));
             $sResult = \RainLoop\Utils::ClearHtmlOutput($sResult);
             if (0 < \strlen($sCacheFileName)) {
                 $this->oActions->Cacher()->Set($sCacheFileName, $sResult);
             }
         } else {
             $bCached = true;
         }
         $sResult .= '<!--';
         $sResult .= ' [version:' . APP_VERSION;
         $sResult .= '][time:' . \substr(\microtime(true) - APP_START, 0, 6);
         $sResult .= '][cached:' . ($bCached ? 'true' : 'false');
         $sResult .= '][session:' . \md5(\RainLoop\Utils::GetShortToken());
         $sResult .= '] -->';
     }
     // Output result
     echo $sResult;
     unset($sResult);
     $this->oActions->BootEnd();
     return $this;
 }