示例#1
0
 /**
  * @param \RainLoop\Model\Account $oAccount
  * @param array $aFilters
  * @param string $sRaw = ''
  * @param bool $bRawIsActive = false
  *
  * @return bool
  */
 public function Save($oAccount, $aFilters, $sRaw = '', $bRawIsActive = false)
 {
     $oSieveClient = \MailSo\Sieve\ManageSieveClient::NewInstance()->SetLogger($this->oLogger);
     $oSieveClient->SetTimeOuts(10, (int) \RainLoop\Api::Config()->Get('labs', 'sieve_timeout', 10));
     if ($oAccount->SieveConnectAndLoginHelper($this->oPlugins, $oSieveClient, $this->oConfig)) {
         $aList = $oSieveClient->ListScripts();
         if ($bRawIsActive) {
             if (!empty($sRaw)) {
                 $oSieveClient->PutScript(self::SIEVE_FILE_NAME_RAW, $sRaw);
                 $oSieveClient->SetActiveScript(self::SIEVE_FILE_NAME_RAW);
             } else {
                 if (isset($aList[self::SIEVE_FILE_NAME_RAW])) {
                     $oSieveClient->DeleteScript(self::SIEVE_FILE_NAME_RAW);
                 }
             }
         } else {
             $sUserFilter = $this->collectionToFileString($aFilters);
             if (!empty($sUserFilter)) {
                 $oSieveClient->PutScript(self::SIEVE_FILE_NAME, $sUserFilter);
                 $oSieveClient->SetActiveScript(self::SIEVE_FILE_NAME);
             } else {
                 if (isset($aList[self::SIEVE_FILE_NAME])) {
                     $oSieveClient->DeleteScript(self::SIEVE_FILE_NAME);
                 }
             }
         }
         $oSieveClient->LogoutAndDisconnect();
         return true;
     }
     return false;
 }
 /**
  * @param string $sPath
  * @param string $sEmail
  * @param string $sPassword
  *
  * @return string
  */
 public static function getSsoHash($sPath, $sEmail, $sPassword)
 {
     $SsoHash = '';
     $sPath = rtrim(trim($sPath), '\\/') . '/index.php';
     if (file_exists($sPath)) {
         $_ENV['RAINLOOP_INCLUDE_AS_API'] = true;
         include $sPath;
         if (class_exists('\\RainLoop\\Api')) {
             $SsoHash = \RainLoop\Api::GetUserSsoHash($sEmail, $sPassword);
         }
     }
     return $SsoHash;
 }
 /**
  * @return void
  */
 private function __construct()
 {
     $this->oHttp = \MailSo\Base\Http::SingletonInstance();
     $this->oActions = \RainLoop\Api::Actions();
     $this->oServiceActions = new \RainLoop\ServiceActions($this->oHttp, $this->oActions);
     if ($this->oActions->Config()->Get('debug', 'enable', false)) {
         \error_reporting(E_ALL);
         \ini_set('display_errors', 1);
     }
     \RainLoop\Api::SetupDefaultMailSoConfig();
     $sServer = \trim($this->oActions->Config()->Get('security', 'custom_server_signature', ''));
     if (0 < \strlen($sServer)) {
         @\header('Server: ' . $sServer, true);
     }
     if ($this->oActions->Config()->Get('labs', 'force_https', false) && !$this->oHttp->IsSecure()) {
         @\header('Location: https://' . $this->oHttp->GetHost(false, false) . $this->oHttp->GetUrl(), true);
         exit;
     }
 }
示例#4
0
<?php

function arguments($argv)
{
    $_ARG = array();
    foreach ($argv as $arg) {
        if (ereg('--([^=]+)=(.*)', $arg, $reg)) {
            $_ARG[$reg[1]] = $reg[2];
        } elseif (ereg('^-([a-zA-Z0-9])', $arg, $reg)) {
            $_ARG[$reg[1]] = 'true';
        } else {
            $_ARG['input'][] = $arg;
        }
    }
    return $_ARG;
}
// get args:
$args = arguments($argv);
$_ENV['RAINLOOP_INCLUDE_AS_API'] = true;
include $args['index'];
$oConfig = \RainLoop\Api::Config();
$oConfig->SetPassword($args['password']);
echo $oConfig->Save() ? 'Admin password updated' : 'Admin password not updated';
 /**
  * @return string
  */
 public function ServiceExternalSso()
 {
     $sResult = '';
     $bLogout = true;
     $sKey = $this->oActions->Config()->Get('labs', 'external_sso_key', '');
     if ($this->oActions->Config()->Get('labs', 'allow_external_sso', false) && !empty($sKey) && $sKey === \trim($this->oHttp->GetRequest('SsoKey', ''))) {
         $sEmail = \trim($this->oHttp->GetRequest('Email', ''));
         $sPassword = $this->oHttp->GetRequest('Password', '');
         $sResult = \RainLoop\Api::GetUserSsoHash($sEmail, $sPassword);
         $bLogout = 0 === \strlen($sResult);
         switch (\strtolower($this->oHttp->GetRequest('Output', 'Plain'))) {
             case 'plain':
                 @\header('Content-Type: text/plain');
                 break;
             case 'json':
                 @\header('Content-Type: application/json; charset=utf-8');
                 $sResult = \MailSo\Base\Utils::Php2js(array('Action' => 'ExternalSso', 'Result' => $sResult), $this->Logger());
                 break;
         }
     }
     if ($bLogout) {
         $this->oActions->SetAuthLogoutToken();
     }
     return $sResult;
 }
 /**
  *
  * @param \RainLoop\Model\Account $oAccount
  * @param \MailSo\Mime\Message $oMessage
  * @param resource $rMessageStream
  * @param bool $bDsn = false
  * @param bool $bAddHiddenRcpt = true
  *
  * @throws \RainLoop\Exceptions\ClientException
  * @throws \MailSo\Net\Exceptions\ConnectionException
  */
 private function smtpSendMessage($oAccount, $oMessage, &$rMessageStream, &$iMessageStreamSize, $bDsn = false, $bAddHiddenRcpt = true)
 {
     $oRcpt = $oMessage->GetRcpt();
     if ($oRcpt && 0 < $oRcpt->Count()) {
         $this->Plugins()->RunHook('filter.smtp-message-stream', array($oAccount, &$rMessageStream, &$iMessageStreamSize));
         $this->Plugins()->RunHook('filter.message-rcpt', array($oAccount, &$oRcpt));
         try {
             $oFrom = $oMessage->GetFrom();
             $sFrom = $oFrom instanceof \MailSo\Mime\Email ? $oFrom->GetEmail() : '';
             $sFrom = empty($sFrom) ? $oAccount->Email() : $sFrom;
             $this->Plugins()->RunHook('filter.smtp-from', array($oAccount, $oMessage, &$sFrom));
             $aHiddenRcpt = array();
             if ($bAddHiddenRcpt) {
                 $this->Plugins()->RunHook('filter.smtp-hidden-rcpt', array($oAccount, $oMessage, &$aHiddenRcpt));
             }
             $bUsePhpMail = $oAccount->Domain()->OutUsePhpMail();
             $oSmtpClient = \MailSo\Smtp\SmtpClient::NewInstance()->SetLogger($this->Logger());
             $oSmtpClient->SetTimeOuts(10, (int) \RainLoop\Api::Config()->Get('labs', 'smtp_timeout', 60));
             $bLoggined = $oAccount->OutConnectAndLoginHelper($this->Plugins(), $oSmtpClient, $this->Config(), $bUsePhpMail);
             if ($bUsePhpMail) {
                 if (\MailSo\Base\Utils::FunctionExistsAndEnabled('mail')) {
                     $aToCollection = $oMessage->GetTo();
                     if ($aToCollection && $oFrom) {
                         $sRawBody = @\stream_get_contents($rMessageStream);
                         if (!empty($sRawBody)) {
                             $sMailTo = \trim($aToCollection->ToString(true));
                             $sMailSubject = \trim($oMessage->GetSubject());
                             $sMailSubject = 0 === \strlen($sMailSubject) ? '' : \MailSo\Base\Utils::EncodeUnencodedValue(\MailSo\Base\Enumerations\Encoding::BASE64_SHORT, $sMailSubject);
                             $sMailHeaders = $sMailBody = '';
                             list($sMailHeaders, $sMailBody) = \explode("\r\n\r\n", $sRawBody, 2);
                             unset($sRawBody);
                             if ($this->Config()->Get('labs', 'mail_func_clear_headers', true)) {
                                 $sMailHeaders = \MailSo\Base\Utils::RemoveHeaderFromHeaders($sMailHeaders, array(\MailSo\Mime\Enumerations\Header::TO_, \MailSo\Mime\Enumerations\Header::SUBJECT));
                             }
                             if ($this->Config()->Get('debug', 'enable', false)) {
                                 $this->Logger()->WriteDump(array($sMailTo, $sMailSubject, $sMailBody, $sMailHeaders));
                             }
                             $bR = $this->Config()->Get('labs', 'mail_func_additional_parameters', false) ? \mail($sMailTo, $sMailSubject, $sMailBody, $sMailHeaders, '-f' . $oFrom->GetEmail()) : \mail($sMailTo, $sMailSubject, $sMailBody, $sMailHeaders);
                             if (!$bR) {
                                 throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantSendMessage);
                             }
                         }
                     }
                 } else {
                     throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantSendMessage);
                 }
             } else {
                 if ($oSmtpClient->IsConnected()) {
                     if (!empty($sFrom)) {
                         $oSmtpClient->MailFrom($sFrom, '', $bDsn);
                     }
                     $aRcpt =& $oRcpt->GetAsArray();
                     foreach ($aRcpt as $oEmail) {
                         $oSmtpClient->Rcpt($oEmail->GetEmail(), $bDsn);
                     }
                     if ($bAddHiddenRcpt && \is_array($aHiddenRcpt) && 0 < \count($aHiddenRcpt)) {
                         foreach ($aHiddenRcpt as $sEmail) {
                             if (\preg_match('/^[^@\\s]+@[^@\\s]+$/', $sEmail)) {
                                 $oSmtpClient->Rcpt($sEmail);
                             }
                         }
                     }
                     $oSmtpClient->DataWithStream($rMessageStream);
                     if ($bLoggined) {
                         $oSmtpClient->Logout();
                     }
                     $oSmtpClient->Disconnect();
                 }
             }
         } catch (\MailSo\Net\Exceptions\ConnectionException $oException) {
             if ($this->Config()->Get('labs', 'smtp_show_server_errors')) {
                 throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::ClientViewError, $oException);
             } else {
                 throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::ConnectionError, $oException);
             }
         } catch (\MailSo\Smtp\Exceptions\LoginException $oException) {
             throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError, $oException);
         } catch (\Exception $oException) {
             if ($this->Config()->Get('labs', 'smtp_show_server_errors')) {
                 throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::ClientViewError, $oException);
             } else {
                 throw $oException;
             }
         }
     } else {
         throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::InvalidRecipients);
     }
 }
示例#7
0
                return include RAINLOOP_APP_LIBRARIES_PATH . \strtr($sClassName, '\\', '/') . '.php';
            }
        }
        return false;
    }
    \spl_autoload_register('rainLoopSplAutoloadRegisterFunction', false);
}
if (\class_exists('RainLoop\\Api')) {
    if (!\class_exists('MailSo\\Version', false)) {
        include APP_VERSION_ROOT_PATH . 'app/libraries/MailSo/MailSo.php';
    }
    if (\class_exists('MailSo\\Version')) {
        if (RAINLOOP_INCLUDE_AS_API_DEF) {
            if (!\defined('APP_API_STARTED')) {
                \define('APP_API_STARTED', true);
                \RainLoop\Api::Handle();
            }
        } else {
            if (!\defined('APP_STARTED')) {
                \define('APP_STARTED', true);
                \RainLoop\Api::Handle();
                \RainLoop\Service::Handle();
                \RainLoop\Api::ExitOnEnd();
            }
        }
    }
} else {
    if (\function_exists('rainLoopSplAutoloadRegisterFunction')) {
        \spl_autoload_unregister('rainLoopSplAutoloadRegisterFunction');
    }
}
示例#8
0
 /**
  * @param string $sEmail
  *
  * @return bool
  */
 public static function ClearUserData($sEmail)
 {
     if (0 < \strlen($sEmail)) {
         $sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail);
         $oStorageProvider = \RainLoop\Api::Actions()->StorageProvider();
         if ($oStorageProvider && $oStorageProvider->IsActive()) {
             $oStorageProvider->DeleteStorage($sEmail);
         }
         if (\RainLoop\Api::Actions()->AddressBookProvider() && \RainLoop\Api::Actions()->AddressBookProvider()->IsActive()) {
             \RainLoop\Api::Actions()->AddressBookProvider()->DeleteAllContacts($sEmail);
         }
         return true;
     }
     return false;
 }
示例#9
0
 /**
  * @param bool $bAdmin
  * @param string $sAuthAccountHash = ''
  *
  * @return array
  */
 public function AppData($bAdmin, $sAuthAccountHash = '')
 {
     if (0 < \strlen($sAuthAccountHash) && \preg_match('/[^_\\-\\.a-zA-Z0-9]/', $sAuthAccountHash)) {
         $sAuthAccountHash = '';
     }
     $oAccount = null;
     $oConfig = $this->Config();
     $oPremProvider = $this->PremProvider();
     $aResult = array('Version' => APP_VERSION, 'Auth' => false, 'AccountHash' => '', 'WebPath' => \RainLoop\Utils::WebPath(), 'WebVersionPath' => \RainLoop\Utils::WebVersionPath(), 'AccountSignMe' => false, 'AuthAccountHash' => '', 'MailToEmail' => '', 'Email' => '', 'DevEmail' => '', 'DevPassword' => '', 'Title' => 'RainLoop Webmail', 'LoadingDescription' => 'RainLoop', 'LoadingDescriptionEsc' => 'RainLoop', 'FaviconUrl' => '', 'LoginDescription' => '', 'LoginPowered' => true, 'LoginLogo' => '', 'LoginBackground' => '', 'LoginCss' => '', 'UserLogo' => '', 'UserLogoTitle' => '', 'UserLogoMessage' => '', 'UserCss' => '', 'WelcomePageUrl' => '', 'WelcomePageDisplay' => 'none', 'IncludeCss' => '', 'IncludeBackground' => '', 'Token' => $oConfig->Get('security', 'csrf_protection', false) ? \RainLoop\Utils::GetCsrfToken() : '', 'InIframe' => (bool) $oConfig->Get('labs', 'in_iframe', false), 'AllowAdminPanel' => (bool) $oConfig->Get('security', 'allow_admin_panel', true), 'AllowHtmlEditorSourceButton' => (bool) $oConfig->Get('labs', 'allow_html_editor_source_button', false), 'AllowHtmlEditorBitiButtons' => (bool) $oConfig->Get('labs', 'allow_html_editor_biti_buttons', false), 'AllowCtrlEnterOnCompose' => (bool) $oConfig->Get('labs', 'allow_ctrl_enter_on_compose', false), 'UseRsaEncryption' => (bool) $oConfig->Get('security', 'use_rsa_encryption', false), 'RsaPublicKey' => '', 'CustomLoginLink' => $oConfig->Get('labs', 'custom_login_link', ''), 'CustomLogoutLink' => $oConfig->Get('labs', 'custom_logout_link', ''), 'LoginDefaultDomain' => $oConfig->Get('login', 'default_domain', ''), 'DetermineUserLanguage' => (bool) $oConfig->Get('login', 'determine_user_language', true), 'DetermineUserDomain' => (bool) $oConfig->Get('login', 'determine_user_domain', false), 'UseLoginWelcomePage' => (bool) $oConfig->Get('login', 'welcome_page', false), 'ForgotPasswordLinkUrl' => \trim($oConfig->Get('login', 'forgot_password_link_url', '')), 'RegistrationLinkUrl' => \trim($oConfig->Get('login', 'registration_link_url', '')), 'ContactsIsAllowed' => false, 'ChangePasswordIsAllowed' => false, 'RequireTwoFactor' => false, 'JsHash' => \md5(\RainLoop\Utils::GetConnectionToken()), 'UseImapThread' => (bool) $oConfig->Get('labs', 'use_imap_thread', false), 'UseImapSubscribe' => (bool) $oConfig->Get('labs', 'use_imap_list_subscribe', true), 'AllowAppendMessage' => (bool) $oConfig->Get('labs', 'allow_message_append', false), 'MaterialDesign' => (bool) $oConfig->Get('labs', 'use_material_design', true), 'FolderSpecLimit' => (int) $oConfig->Get('labs', 'folders_spec_limit', 50), 'StartupUrl' => \trim(\ltrim(\trim($oConfig->Get('labs', 'startup_url', '')), '#/')), 'FaviconStatus' => (bool) $oConfig->Get('labs', 'favicon_status', true), 'Filtered' => '' !== \trim(\RainLoop\Api::Config()->Get('labs', 'imap_message_list_permanent_filter', '')), 'Community' => true, 'PremType' => false, 'Admin' => array(), 'Capa' => array(), 'AttachmentsActions' => array(), 'Plugins' => array());
     if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::ATTACHMENTS_ACTIONS)) {
         if (!!\class_exists('ZipArchive')) {
             $aResult['AttachmentsActions'][] = 'zip';
         }
         if (\RainLoop\Utils::IsOwnCloudLoggedIn() && \class_exists('OCP\\Files')) {
             $aResult['AttachmentsActions'][] = 'owncloud';
         }
         if ($oConfig->Get('social', 'dropbox_enable', false) && 0 < \strlen(\trim($oConfig->Get('social', 'dropbox_api_key', '')))) {
             $aResult['AttachmentsActions'][] = 'dropbox';
         }
     }
     $aResult['AllowDropboxSocial'] = (bool) $oConfig->Get('social', 'dropbox_enable', false);
     $aResult['DropboxApiKey'] = \trim($oConfig->Get('social', 'dropbox_api_key', ''));
     if ($aResult['UseRsaEncryption'] && \file_exists(APP_PRIVATE_DATA . 'rsa/public') && \file_exists(APP_PRIVATE_DATA . 'rsa/private')) {
         $aResult['RsaPublicKey'] = \file_get_contents(APP_PRIVATE_DATA . 'rsa/public');
         $aResult['RsaPublicKey'] = $aResult['RsaPublicKey'] ? $aResult['RsaPublicKey'] : '';
         if (false === \strpos($aResult['RsaPublicKey'], 'PUBLIC KEY')) {
             $aResult['RsaPublicKey'] = '';
         }
     }
     if (0 === \strlen($aResult['RsaPublicKey'])) {
         $aResult['UseRsaEncryption'] = false;
     }
     if (0 < \strlen($sAuthAccountHash)) {
         $aResult['AuthAccountHash'] = $sAuthAccountHash;
     }
     $aResult['Title'] = $oConfig->Get('webmail', 'title', '');
     $aResult['LoadingDescription'] = $oConfig->Get('webmail', 'loading_description', '');
     $aResult['FaviconUrl'] = $oConfig->Get('webmail', 'favicon_url', '');
     if ($oPremProvider) {
         $oPremProvider->PopulateAppData($aResult);
     }
     if ('' !== $aResult['LoadingDescription'] && 'RainLoop' !== $aResult['LoadingDescription']) {
         $aResult['LoadingDescriptionEsc'] = @\htmlspecialchars($aResult['LoadingDescription'], ENT_QUOTES | ENT_IGNORE, 'UTF-8');
     }
     $oSettings = null;
     if (!$bAdmin) {
         $oAccount = $this->getAccountFromToken(false);
         if ($oAccount instanceof \RainLoop\Model\Account) {
             $aResult['IncludeCss'] = $aResult['UserCss'];
             $oAddressBookProvider = $this->AddressBookProvider($oAccount);
             $aResult['Auth'] = true;
             $aResult['Email'] = $oAccount->Email();
             $aResult['IncLogin'] = $oAccount->IncLogin();
             $aResult['OutLogin'] = $oAccount->OutLogin();
             $aResult['AccountHash'] = $oAccount->Hash();
             $aResult['AccountSignMe'] = $oAccount->SignMe();
             $aResult['ChangePasswordIsAllowed'] = $this->ChangePasswordProvider()->PasswordChangePossibility($oAccount);
             $aResult['ContactsIsAllowed'] = $oAddressBookProvider->IsActive();
             $aResult['ContactsSharingIsAllowed'] = $oAddressBookProvider->IsSharingAllowed();
             $aResult['ContactsSyncIsAllowed'] = (bool) $oConfig->Get('contacts', 'allow_sync', false);
             $aResult['ContactsSyncInterval'] = (int) $oConfig->Get('contacts', 'sync_interval', 20);
             $aResult['EnableContactsSync'] = false;
             $aResult['ContactsSyncUrl'] = '';
             $aResult['ContactsSyncUser'] = '';
             $aResult['ContactsSyncPassword'] = '';
             if ($aResult['ContactsIsAllowed'] && $aResult['ContactsSyncIsAllowed']) {
                 $mData = $this->getContactsSyncData($oAccount);
                 if (\is_array($mData)) {
                     $aResult['EnableContactsSync'] = isset($mData['Enable']) ? !!$mData['Enable'] : false;
                     $aResult['ContactsSyncUrl'] = isset($mData['Url']) ? \trim($mData['Url']) : '';
                     $aResult['ContactsSyncUser'] = isset($mData['User']) ? \trim($mData['User']) : '';
                     $aResult['ContactsSyncPassword'] = APP_DUMMY;
                 }
             }
             if ($aResult['AccountSignMe']) {
                 $sToken = \RainLoop\Utils::GetCookie(self::AUTH_MAILTO_TOKEN_KEY, null);
                 if (null !== $sToken) {
                     \RainLoop\Utils::ClearCookie(self::AUTH_MAILTO_TOKEN_KEY);
                     $mMailToData = \RainLoop\Utils::DecodeKeyValuesQ($sToken);
                     if (\is_array($mMailToData) && !empty($mMailToData['MailTo']) && 'MailTo' === $mMailToData['MailTo'] && !empty($mMailToData['To'])) {
                         $aResult['MailToEmail'] = $mMailToData['To'];
                     }
                 }
             }
             $oSettings = $this->SettingsProvider()->Load($oAccount);
             if (!$oAccount->IsAdditionalAccount() && !empty($aResult['WelcomePageUrl']) && ('once' === $aResult['WelcomePageDisplay'] || 'always' === $aResult['WelcomePageDisplay'])) {
                 if ('once' === $aResult['WelcomePageDisplay']) {
                     if ($aResult['WelcomePageUrl'] === $oSettings->GetConf('LastWelcomePage', '')) {
                         $aResult['WelcomePageUrl'] = '';
                         $aResult['WelcomePageDisplay'] = '';
                     }
                 }
             } else {
                 $aResult['WelcomePageUrl'] = '';
                 $aResult['WelcomePageDisplay'] = '';
             }
             if (!empty($aResult['StartupUrl'])) {
                 $aResult['StartupUrl'] = $this->compileLogParams($aResult['StartupUrl'], $oAccount, true);
             }
             if (!empty($aResult['UserIframeMessage'])) {
                 $aResult['UserIframeMessage'] = $this->compileLogParams($aResult['UserIframeMessage'], $oAccount, true);
             }
         } else {
             $oAccount = null;
             $aResult['IncludeBackground'] = $aResult['LoginBackground'];
             $aResult['IncludeCss'] = $aResult['LoginCss'];
             $aResult['DevEmail'] = $oConfig->Get('labs', 'dev_email', '');
             $aResult['DevPassword'] = $oConfig->Get('labs', 'dev_password', '');
             $aResult['WelcomePageUrl'] = '';
             $aResult['WelcomePageDisplay'] = '';
             $aResult['StartupUrl'] = '';
         }
         $aResult['AllowGoogleSocial'] = (bool) $oConfig->Get('social', 'google_enable', false);
         $aResult['AllowGoogleSocialAuth'] = (bool) $oConfig->Get('social', 'google_enable_auth', true);
         $aResult['AllowGoogleSocialAuthFast'] = (bool) $oConfig->Get('social', 'google_enable_auth_fast', true);
         $aResult['AllowGoogleSocialDrive'] = (bool) $oConfig->Get('social', 'google_enable_drive', true);
         $aResult['AllowGoogleSocialPreview'] = (bool) $oConfig->Get('social', 'google_enable_preview', true);
         $aResult['GoogleClientID'] = \trim($oConfig->Get('social', 'google_client_id', ''));
         $aResult['GoogleApiKey'] = \trim($oConfig->Get('social', 'google_api_key', ''));
         if (!$aResult['AllowGoogleSocial'] || $aResult['AllowGoogleSocial'] && ('' === \trim($oConfig->Get('social', 'google_client_id', '')) || '' === \trim($oConfig->Get('social', 'google_client_secret', '')))) {
             $aResult['AllowGoogleSocialAuth'] = false;
             $aResult['AllowGoogleSocialAuthFast'] = false;
             $aResult['AllowGoogleSocialDrive'] = false;
             $aResult['GoogleClientID'] = '';
             $aResult['GoogleApiKey'] = '';
         }
         if (!$aResult['AllowGoogleSocial']) {
             $aResult['AllowGoogleSocialPreview'] = false;
         }
         if ($aResult['AllowGoogleSocial'] && !$aResult['AllowGoogleSocialAuth'] && !$aResult['AllowGoogleSocialAuthFast'] && !$aResult['AllowGoogleSocialDrive'] && !$aResult['AllowGoogleSocialPreview']) {
             $aResult['AllowGoogleSocial'] = false;
         }
         $aResult['AllowFacebookSocial'] = (bool) $oConfig->Get('social', 'fb_enable', false);
         if ($aResult['AllowFacebookSocial'] && ('' === \trim($oConfig->Get('social', 'fb_app_id', '')) || '' === \trim($oConfig->Get('social', 'fb_app_secret', '')))) {
             $aResult['AllowFacebookSocial'] = false;
         }
         $aResult['AllowTwitterSocial'] = (bool) $oConfig->Get('social', 'twitter_enable', false);
         if ($aResult['AllowTwitterSocial'] && ('' === \trim($oConfig->Get('social', 'twitter_consumer_key', '')) || '' === \trim($oConfig->Get('social', 'twitter_consumer_secret', '')))) {
             $aResult['AllowTwitterSocial'] = false;
         }
         $aResult['AllowDropboxSocial'] = (bool) $oConfig->Get('social', 'dropbox_enable', false);
         $aResult['DropboxApiKey'] = \trim($oConfig->Get('social', 'dropbox_api_key', ''));
         if (!$aResult['AllowDropboxSocial']) {
             $aResult['DropboxApiKey'] = '';
         } else {
             if (0 === strlen($aResult['DropboxApiKey'])) {
                 $aResult['AllowDropboxSocial'] = false;
             }
         }
         $aResult['Capa'] = $this->Capa(false, $oAccount);
         if ($aResult['Auth'] && !$aResult['RequireTwoFactor']) {
             if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::TWO_FACTOR, $oAccount) && $this->GetCapa(false, \RainLoop\Enumerations\Capa::TWO_FACTOR_FORCE, $oAccount) && $this->TwoFactorAuthProvider()->IsActive()) {
                 $aData = $this->getTwoFactorInfo($oAccount, true);
                 $aResult['RequireTwoFactor'] = !$aData || !isset($aData['User'], $aData['IsSet'], $aData['Enable']) || !($aData['IsSet'] && $aData['Enable']);
             }
         }
     } else {
         $aResult['Auth'] = $this->IsAdminLoggined(false);
         if ($aResult['Auth']) {
             $aResult['AdminDomain'] = APP_SITE;
             $aResult['AdminLogin'] = (string) $oConfig->Get('security', 'admin_login', '');
             $aResult['UseTokenProtection'] = (bool) $oConfig->Get('security', 'csrf_protection', true);
             $aResult['EnabledPlugins'] = (bool) $oConfig->Get('plugins', 'enable', false);
             $aResult['VerifySslCertificate'] = (bool) $oConfig->Get('ssl', 'verify_certificate', false);
             $aResult['AllowSelfSigned'] = (bool) $oConfig->Get('ssl', 'allow_self_signed', true);
             $aDrivers = \class_exists('PDO') ? \PDO::getAvailableDrivers() : null;
             $aResult['MySqlIsSupported'] = \is_array($aDrivers) ? \in_array('mysql', $aDrivers) : false;
             $aResult['SQLiteIsSupported'] = \is_array($aDrivers) ? \in_array('sqlite', $aDrivers) : false;
             $aResult['PostgreSqlIsSupported'] = \is_array($aDrivers) ? \in_array('pgsql', $aDrivers) : false;
             $aResult['ContactsEnable'] = (bool) $oConfig->Get('contacts', 'enable', false);
             $aResult['ContactsSharing'] = (bool) $oConfig->Get('contacts', 'allow_sharing', false);
             $aResult['ContactsSync'] = (bool) $oConfig->Get('contacts', 'allow_sync', false);
             $aResult['ContactsPdoType'] = (string) $this->ValidateContactPdoType(\trim($this->Config()->Get('contacts', 'type', 'sqlite')));
             $aResult['ContactsPdoDsn'] = (string) $oConfig->Get('contacts', 'pdo_dsn', '');
             $aResult['ContactsPdoType'] = (string) $oConfig->Get('contacts', 'type', '');
             $aResult['ContactsPdoUser'] = (string) $oConfig->Get('contacts', 'pdo_user', '');
             $aResult['ContactsPdoPassword'] = (string) APP_DUMMY;
             $aResult['AllowGoogleSocial'] = (bool) $oConfig->Get('social', 'google_enable', false);
             $aResult['AllowGoogleSocialAuth'] = (bool) $oConfig->Get('social', 'google_enable_auth', true);
             $aResult['AllowGoogleSocialAuthFast'] = (bool) $oConfig->Get('social', 'google_enable_auth_fast', true);
             $aResult['AllowGoogleSocialDrive'] = (bool) $oConfig->Get('social', 'google_enable_drive', true);
             $aResult['AllowGoogleSocialPreview'] = (bool) $oConfig->Get('social', 'google_enable_preview', true);
             $aResult['GoogleClientID'] = (string) $oConfig->Get('social', 'google_client_id', '');
             $aResult['GoogleClientSecret'] = (string) $oConfig->Get('social', 'google_client_secret', '');
             $aResult['GoogleApiKey'] = (string) $oConfig->Get('social', 'google_api_key', '');
             $aResult['AllowFacebookSocial'] = (bool) $oConfig->Get('social', 'fb_enable', false);
             $aResult['FacebookAppID'] = (string) $oConfig->Get('social', 'fb_app_id', '');
             $aResult['FacebookAppSecret'] = (string) $oConfig->Get('social', 'fb_app_secret', '');
             $aResult['AllowTwitterSocial'] = (bool) $oConfig->Get('social', 'twitter_enable', false);
             $aResult['TwitterConsumerKey'] = (string) $oConfig->Get('social', 'twitter_consumer_key', '');
             $aResult['TwitterConsumerSecret'] = (string) $oConfig->Get('social', 'twitter_consumer_secret', '');
             $aResult['AllowDropboxSocial'] = (bool) $oConfig->Get('social', 'dropbox_enable', false);
             $aResult['DropboxApiKey'] = (string) $oConfig->Get('social', 'dropbox_api_key', '');
             $aResult['SubscriptionEnabled'] = (bool) \MailSo\Base\Utils::ValidateDomain($aResult['AdminDomain']);
             //					|| \MailSo\Base\Utils::ValidateIP($aResult['AdminDomain']);
             $aResult['WeakPassword'] = (bool) $oConfig->ValidatePassword('12345');
             $aResult['CoreAccess'] = (bool) $this->rainLoopCoreAccess();
             $aResult['PhpUploadSizes'] = array('upload_max_filesize' => \ini_get('upload_max_filesize'), 'post_max_size' => \ini_get('post_max_size'));
         }
         $aResult['Capa'] = $this->Capa(true);
     }
     $aResult['SupportedFacebookSocial'] = (bool) \version_compare(PHP_VERSION, '5.4.0', '>=');
     if (!$aResult['SupportedFacebookSocial']) {
         $aResult['AllowFacebookSocial'] = false;
         $aResult['FacebookAppID'] = '';
         $aResult['FacebookAppSecret'] = '';
     }
     $aResult['ProjectHash'] = \md5($aResult['AccountHash'] . APP_VERSION . $this->Plugins()->Hash());
     $sLanguage = $oConfig->Get('webmail', 'language', 'en');
     $sLanguageAdmin = $oConfig->Get('webmail', 'language_admin', 'en');
     $sTheme = $oConfig->Get('webmail', 'theme', 'Default');
     $aResult['Themes'] = $this->GetThemes();
     $aResult['Languages'] = $this->GetLanguages(false);
     $aResult['LanguagesAdmin'] = $this->GetLanguages(true);
     $aResult['AllowLanguagesOnSettings'] = (bool) $oConfig->Get('webmail', 'allow_languages_on_settings', true);
     $aResult['AllowLanguagesOnLogin'] = (bool) $oConfig->Get('login', 'allow_languages_on_login', true);
     $aResult['AttachmentLimit'] = (int) $oConfig->Get('webmail', 'attachment_size_limit', 10) * 1024 * 1024;
     $aResult['SignMe'] = (string) $oConfig->Get('login', 'sign_me_auto', \RainLoop\Enumerations\SignMeType::DEFAILT_OFF);
     $aResult['UseLocalProxyForExternalImages'] = (bool) $oConfig->Get('labs', 'use_local_proxy_for_external_images', false);
     // user
     $aResult['ShowImages'] = (bool) $oConfig->Get('defaults', 'show_images', false);
     $aResult['MPP'] = (int) $oConfig->Get('webmail', 'messages_per_page', 25);
     $aResult['SoundNotification'] = false;
     $aResult['DesktopNotifications'] = false;
     $aResult['Layout'] = (int) $oConfig->Get('defaults', 'view_layout', \RainLoop\Enumerations\Layout::SIDE_PREVIEW);
     $aResult['EditorDefaultType'] = (string) $oConfig->Get('defaults', 'view_editor_type', '');
     $aResult['UseCheckboxesInList'] = (bool) $oConfig->Get('defaults', 'view_use_checkboxes', true);
     $aResult['AutoLogout'] = (int) $oConfig->Get('defaults', 'autologout', 30);
     $aResult['UseThreads'] = (bool) $oConfig->Get('defaults', 'mail_use_threads', false);
     $aResult['ReplySameFolder'] = (bool) $oConfig->Get('defaults', 'mail_reply_same_folder', false);
     $aResult['ContactsAutosave'] = (bool) $oConfig->Get('defaults', 'contacts_autosave', true);
     $aResult['EnableTwoFactor'] = false;
     $aResult['ParentEmail'] = '';
     $aResult['InterfaceAnimation'] = true;
     $aResult['UserBackgroundName'] = '';
     $aResult['UserBackgroundHash'] = '';
     if (!$bAdmin && $oAccount instanceof \RainLoop\Model\Account) {
         $aResult['ParentEmail'] = $oAccount->ParentEmail();
         $oSettingsLocal = $this->SettingsProvider(true)->Load($oAccount);
         if ($oSettingsLocal instanceof \RainLoop\Settings) {
             // if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::FOLDERS, $oAccount))
             $aResult['SentFolder'] = (string) $oSettingsLocal->GetConf('SentFolder', '');
             $aResult['DraftFolder'] = (string) $oSettingsLocal->GetConf('DraftFolder', '');
             $aResult['SpamFolder'] = (string) $oSettingsLocal->GetConf('SpamFolder', '');
             $aResult['TrashFolder'] = (string) $oSettingsLocal->GetConf('TrashFolder', '');
             $aResult['ArchiveFolder'] = (string) $oSettingsLocal->GetConf('ArchiveFolder', '');
             $aResult['NullFolder'] = (string) $oSettingsLocal->GetConf('NullFolder', '');
         }
         if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::SETTINGS, $oAccount)) {
             if ($oSettings instanceof \RainLoop\Settings) {
                 if ($oConfig->Get('webmail', 'allow_languages_on_settings', true)) {
                     $sLanguage = (string) $oSettings->GetConf('Language', $sLanguage);
                 }
                 $aResult['EditorDefaultType'] = (string) $oSettings->GetConf('EditorDefaultType', $aResult['EditorDefaultType']);
                 $aResult['ShowImages'] = (bool) $oSettings->GetConf('ShowImages', $aResult['ShowImages']);
                 $aResult['ContactsAutosave'] = (bool) $oSettings->GetConf('ContactsAutosave', $aResult['ContactsAutosave']);
                 $aResult['MPP'] = (int) $oSettings->GetConf('MPP', $aResult['MPP']);
                 $aResult['SoundNotification'] = (bool) $oSettings->GetConf('SoundNotification', $aResult['SoundNotification']);
                 $aResult['DesktopNotifications'] = (bool) $oSettings->GetConf('DesktopNotifications', $aResult['DesktopNotifications']);
                 $aResult['UseCheckboxesInList'] = (bool) $oSettings->GetConf('UseCheckboxesInList', $aResult['UseCheckboxesInList']);
                 $aResult['AutoLogout'] = (int) $oSettings->GetConf('AutoLogout', $aResult['AutoLogout']);
                 $aResult['Layout'] = (int) $oSettings->GetConf('Layout', $aResult['Layout']);
                 if (!$this->GetCapa(false, \RainLoop\Enumerations\Capa::AUTOLOGOUT, $oAccount)) {
                     $aResult['AutoLogout'] = 0;
                 }
                 if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::USER_BACKGROUND, $oAccount)) {
                     $aResult['UserBackgroundName'] = (string) $oSettings->GetConf('UserBackgroundName', $aResult['UserBackgroundName']);
                     $aResult['UserBackgroundHash'] = (string) $oSettings->GetConf('UserBackgroundHash', $aResult['UserBackgroundHash']);
                     //					if (!empty($aResult['UserBackgroundName']) && !empty($aResult['UserBackgroundHash']))
                     //					{
                     //						$aResult['IncludeBackground'] = './?/Raw/&q[]=/{{USER}}/UserBackground/&q[]=/'.
                     //							$aResult['UserBackgroundHash'].'/';
                     //					}
                 }
                 $aResult['EnableTwoFactor'] = (bool) $oSettings->GetConf('EnableTwoFactor', $aResult['EnableTwoFactor']);
             }
             if ($oSettingsLocal instanceof \RainLoop\Settings) {
                 $aResult['UseThreads'] = (bool) $oSettingsLocal->GetConf('UseThreads', $aResult['UseThreads']);
                 $aResult['ReplySameFolder'] = (bool) $oSettingsLocal->GetConf('ReplySameFolder', $aResult['ReplySameFolder']);
                 if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::THEMES, $oAccount)) {
                     $sTheme = (string) $oSettingsLocal->GetConf('Theme', $sTheme);
                 }
             }
         }
     }
     $sStaticCache = \md5(APP_VERSION . $this->Plugins()->Hash());
     $sTheme = $this->ValidateTheme($sTheme);
     $sNewThemeLink = './?/Css/0/' . ($bAdmin ? 'Admin' : 'User') . '/-/' . $sTheme . '/-/' . $sStaticCache . '/Hash/-/';
     if (!$aResult['Auth']) {
         if (!$bAdmin) {
             if ($oConfig->Get('login', 'allow_languages_on_login', true) && $oConfig->Get('login', 'determine_user_language', true)) {
                 $sLanguage = $this->ValidateLanguage($this->detectUserLanguage(), $sLanguage, false);
             }
         }
     }
     $sPluginsLink = '';
     if (0 < $this->Plugins()->Count() && $this->Plugins()->HaveJs($bAdmin)) {
         $sPluginsLink = './?/Plugins/0/' . ($bAdmin ? 'Admin' : 'User') . '/' . $sStaticCache . '/';
     }
     $aResult['Theme'] = $sTheme;
     $aResult['NewThemeLink'] = $sNewThemeLink;
     $aResult['Language'] = $this->ValidateLanguage($sLanguage, '', false);
     $aResult['LanguageAdmin'] = $this->ValidateLanguage($sLanguageAdmin, '', true);
     $aResult['UserLanguageRaw'] = $this->detectUserLanguage();
     $aResult['UserLanguage'] = $this->ValidateLanguage($aResult['UserLanguageRaw'], '', false, true, true);
     $aResult['UserLanguageAdmin'] = $this->ValidateLanguage($aResult['UserLanguageRaw'], '', true, true, true);
     $aResult['LangLink'] = './?/Lang/0/' . ($bAdmin ? 'Admin' : 'App') . '/' . ($bAdmin ? $aResult['LanguageAdmin'] : $aResult['Language']) . '/' . $sStaticCache . '/';
     $aResult['TemplatesLink'] = './?/Templates/0/' . ($bAdmin ? 'Admin' : 'App') . '/' . $sStaticCache . '/';
     $aResult['PluginsLink'] = $sPluginsLink;
     $aResult['EditorDefaultType'] = \in_array($aResult['EditorDefaultType'], array('Plain', 'Html', 'HtmlForced', 'PlainForced')) ? $aResult['EditorDefaultType'] : 'Plain';
     // IDN
     $aResult['Email'] = \MailSo\Base\Utils::IdnToUtf8($aResult['Email']);
     $aResult['ParentEmail'] = \MailSo\Base\Utils::IdnToUtf8($aResult['ParentEmail']);
     $aResult['MailToEmail'] = \MailSo\Base\Utils::IdnToUtf8($aResult['MailToEmail']);
     $aResult['DevEmail'] = \MailSo\Base\Utils::IdnToUtf8($aResult['DevEmail']);
     $this->Plugins()->InitAppData($bAdmin, $aResult, $oAccount);
     return $aResult;
 }
示例#10
0
<?php

// Enable RainLoop Api and include index file
$_ENV['RAINLOOP_INCLUDE_AS_API'] = true;
include '/var/www/rainloop/app/index.php';
// Retrieve email and password
if (isset($_SERVER['HTTP_EMAIL']) && isset($_SERVER['PHP_AUTH_PW'])) {
    $email = $_SERVER['HTTP_EMAIL'];
    $password = $_SERVER['PHP_AUTH_PW'];
    $ssoHash = \RainLoop\Api::GetUserSsoHash($email, $password);
    // redirect to webmail sso url
    \header('Location: https://domain.tldPATHTOCHANGE/app/index.php?sso&hash=' . $ssoHash);
} else {
    \header('Location: https://domain.tldPATHTOCHANGE/app/index.php');
}
示例#11
0
 public static function logout()
 {
     OCP\Config::setUserValue(OCP\User::getUser(), 'rainloop', 'rainloop-autologin-password', '');
     $sApiPath = __DIR__ . '/../app/index.php';
     if (file_exists($sApiPath)) {
         self::regRainLoopDataFunction();
         $_ENV['RAINLOOP_INCLUDE_AS_API'] = true;
         include $sApiPath;
         if (class_exists('\\RainLoop\\Api')) {
             \RainLoop\Api::LogoutCurrentLogginedUser();
         }
     }
     return true;
 }
                            include_once RAINLOOP_APP_LIBRARIES_PATH . 'RainLoop/Common/MbStringFix.php';
                        }
                        return include RAINLOOP_APP_LIBRARIES_PATH . 'Sabre/' . \str_replace('\\', '/', \substr($sClassName, 6)) . '.php';
                    }
                }
            }
        }
        return false;
    });
}
if (\class_exists('RainLoop\\Service')) {
    $oException = null;
    if (!\class_exists('MailSo\\Version')) {
        try {
            include APP_VERSION_ROOT_PATH . 'app/libraries/MailSo/MailSo.php';
        } catch (\Exception $oException) {
        }
    }
    if (!$oException) {
        if (isset($_ENV['RAINLOOP_INCLUDE_AS_API']) && $_ENV['RAINLOOP_INCLUDE_AS_API']) {
            $_ENV['RAINLOOP_INCLUDE_AS_API'] = false;
            \RainLoop\Api::Handle();
        } else {
            if (!\defined('APP_STARTED')) {
                \define('APP_STARTED', true);
                \RainLoop\Service::NewInstance()->Handle();
            }
        }
    }
}
return '';
 /**
  * @param string $sEmail
  *
  * @return bool
  */
 public static function ClearUserData($sEmail)
 {
     if (0 < \strlen($sEmail)) {
         $sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail);
         $oStorageProvider = \RainLoop\Api::Actions()->StorageProvider();
         if ($oStorageProvider && $oStorageProvider->IsActive()) {
             // TwoFactor Auth User Data
             $oStorageProvider->Clear(null, \RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY, \RainLoop\KeyPathHelper::TwoFactorAuthUserData($sEmail));
             // Accounts list
             $oStorageProvider->Clear(null, \RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY, \RainLoop\KeyPathHelper::WebmailAccounts($sEmail));
             // Contact sync data
             $oStorageProvider->Clear($sEmail, \RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG, 'contacts_sync');
         }
         \RainLoop\Api::Actions()->SettingsProvider()->ClearByEmail($sEmail);
         if (\RainLoop\Api::Actions()->AddressBookProvider() && \RainLoop\Api::Actions()->AddressBookProvider()->IsActive()) {
             \RainLoop\Api::Actions()->AddressBookProvider()->DeleteAllContactsAndTags($sEmail);
         }
         return true;
     }
     return false;
 }