Example #1
0
 public function SystemLogging()
 {
     if (isset($_POST['btnClearLog']) || isset($_POST['btnUserActivityClearLog'])) {
         /* @var $oApiLoggerManager CApiLoggerManager */
         $oApiLoggerManager = CApi::Manager('logger');
         $bResult = false;
         if (isset($_POST['btnClearLog'])) {
             $bResult = $oApiLoggerManager->deleteCurrentLog();
         } else {
             $bResult = $oApiLoggerManager->deleteCurrentUserActivityLog();
         }
         if ($bResult) {
             $this->LastMessage = WM_INFO_LOGCLEARSUCCESSFUL;
         } else {
             $this->LastError = AP_LANG_ERROR;
         }
     } else {
         if ($this->isStandartSubmit()) {
             $this->oSettings->SetConf('Common/EnableLogging', CPost::GetCheckBox('ch_EnableDebugLogging'));
             $this->oSettings->SetConf('Common/EnableEventLogging', CPost::GetCheckBox('ch_EnableUserActivityLogging'));
             $this->oSettings->SetConf('Common/LoggingLevel', EnumConvert::FromPost(CPost::get('selVerbosity', ''), 'ELogLevel'));
             $this->checkBolleanWithMessage($this->oSettings->SaveToXml());
         }
     }
 }
Example #2
0
 public function DoPost()
 {
     if (isset($_POST['next_btn'])) {
         if (5 > strlen(trim(CPost::get('txtPassword1', '')))) {
             CSession::Set('wm_install_pass_error', 'Minimum password length is 5 characters.');
         } else {
             if (CPost::get('txtPassword1', '') !== CPost::get('txtPassword2', '')) {
                 CSession::Set('wm_install_pass_error', 'The password and its confirmation don\'t match.');
             } else {
                 $this->oSettings->SetConf('Common/AdminPassword', md5(CPost::get('txtPassword1', '')));
                 return $this->oSettings->SaveToXml();
             }
         }
     }
     return false;
 }
Example #3
0
 protected function initUpdateDomainByPost(CDomain &$oDomain)
 {
     $oDomain->OverrideSettings = CPost::GetCheckBox('chOverrideSettings');
     if (CPost::Has('txtIncomingMailHost') && CPost::Has('txtOutgoingMailHost') && CPost::Has('txtIncomingMailPort') && CPost::Has('txtOutgoingMailPort')) {
         $oDomain->IncomingMailServer = CPost::get('txtIncomingMailHost');
         $oDomain->IncomingMailPort = CPost::get('txtIncomingMailPort');
         $oDomain->IncomingMailUseSSL = CPost::GetCheckBox('chIncomingUseSSL');
         $oDomain->OutgoingMailServer = CPost::get('txtOutgoingMailHost');
         $oDomain->OutgoingMailPort = CPost::get('txtOutgoingMailPort');
         $oDomain->OutgoingMailUseSSL = CPost::GetCheckBox('chOutgoingUseSSL');
     }
     if (CPost::Has('radioAuthType')) {
         $oDomain->OutgoingMailAuth = EnumConvert::FromPost(CPost::get('radioAuthType'), 'ESMTPAuthType');
     }
     if (CPost::Has('txtOutgoingMailLogin') && CPost::Has('txtOutgoingMailPassword')) {
         $oDomain->OutgoingMailLogin = CPost::get('txtOutgoingMailLogin');
         if ((string) AP_DUMMYPASSWORD !== (string) CPost::get('txtOutgoingMailPassword')) {
             $oDomain->OutgoingMailPassword = CPost::get('txtOutgoingMailPassword', '');
         }
     }
     if (CPost::Has('selIncomingMailProtocol')) {
         $oDomain->IncomingMailProtocol = EnumConvert::FromPost(CPost::get('selIncomingMailProtocol'), 'EMailProtocol');
     }
     //		if ($oDomain->OverrideSettings || $oDomain->IsDefaultDomain)
     //		{
     //			$oDomain->ExternalHostNameOfDAVServer = CPost::Get('txtExternalHostNameOfDAVServer', $oDomain->ExternalHostNameOfDAVServer);
     //			$oDomain->ExternalHostNameOfLocalImap = CPost::Get('txtExternalHostNameOfLocalImap', $oDomain->ExternalHostNameOfLocalImap);
     //			$oDomain->ExternalHostNameOfLocalSmtp = CPost::Get('txtExternalHostNameOfLocalSmtp', $oDomain->ExternalHostNameOfLocalSmtp);
     //		}
     if ($oDomain->OverrideSettings) {
         // General
         $oDomain->Url = (string) CPost::get('txtWebDomain', $oDomain->Url);
         $oDomain->AllowUsersChangeEmailSettings = CPost::GetCheckBox('chAllowUsersAccessAccountsSettings');
         $oDomain->AllowNewUsersRegister = !CPost::GetCheckBox('chAllowNewUsersRegister');
         // Webmail
         $oDomain->AllowWebMail = CPost::GetCheckBox('chEnableWebmail');
         $oDomain->MailsPerPage = CPost::get('selMessagesPerPage', $oDomain->MailsPerPage);
         $oDomain->AutoCheckMailInterval = CPost::get('selAutocheckMail', $oDomain->AutoCheckMailInterval);
         if (CPost::Has('radioLayout')) {
             $oDomain->Layout = EnumConvert::FromPost(CPost::get('radioLayout'), 'ELayout');
         }
         // Address Book
         $oDomain->AllowContacts = CPost::GetCheckBox('chEnableAddressBook');
         $oDomain->ContactsPerPage = CPost::get('selContactsPerPage', $oDomain->ContactsPerPage);
     }
 }
 public function DoPost()
 {
     if (isset($_POST['test_btn'])) {
         $sMessage = '';
         $sHost = CPost::get('txtHost', '');
         $bCheckSMTP = (bool) CPost::get('chSMTP', false);
         $bCheckIMAP4 = (bool) CPost::get('chIMAP4', false);
         $_SESSION['wm_install_server_test_host'] = $sHost;
         $_SESSION['wm_install_server_test_ch_smtp'] = $bCheckSMTP;
         $_SESSION['wm_install_server_test_ch_imap4'] = $bCheckIMAP4;
         if (!empty($sHost)) {
             if ($bCheckSMTP) {
                 $iErrN = 0;
                 $sErrorS = '';
                 $sRes = @fsockopen($sHost, 25, $iErrN, $sErrorS, 5);
                 if (is_resource($sRes)) {
                     @fclose($sRes);
                     $sMessage .= '<div class="success">SMTP connection to port 25 successful, sending outgoing e-mail over SMTP should work.</div>';
                 } else {
                     $sMessage .= '<div class="error">SMTP connection to port 25 failed: ' . $sErrorS . ' (Error code: ' . $iErrN . ')</div>';
                 }
             }
             if ($bCheckIMAP4) {
                 $iErrN = 0;
                 $sErrorS = '';
                 $sRes = @fsockopen($sHost, 143, $iErrN, $sErrorS, 5);
                 if (is_resource($sRes)) {
                     @fclose($sRes);
                     $sMessage .= '<div class="success">IMAP connection to port 143 successful, checking and downloading incoming e-mail over IMAP should work.</div>';
                 } else {
                     $sMessage .= '<div class="error">IMAP connection to port 143 failed: ' . $sErrorS . ' (Error code: ' . $iErrN . ')</div>';
                 }
             }
         } else {
             $sMessage .= '<div class="error">Host is empty</div>';
         }
         if (!empty($sMessage)) {
             $_SESSION['wm_install_server_test_message'] = $sMessage;
         }
     } else {
         if (isset($_POST['next_btn'])) {
             return true;
         }
     }
     return false;
 }
Example #5
0
 protected function initDbSettings()
 {
     $this->oSettings->SetConf('Common/DBType', 'PostgreSQL' === CPost::get('chSqlType') ? EDbType::PostgreSQL : EDbType::MySQL);
     if (CPost::Has('txtSqlLogin')) {
         $this->oSettings->SetConf('Common/DBLogin', CPost::get('txtSqlLogin'));
     }
     if (CPost::Has('txtSqlPassword') && API_DUMMY !== (string) CPost::get('txtSqlPassword')) {
         $this->oSettings->SetConf('Common/DBPassword', CPost::get('txtSqlPassword'));
     }
     if (CPost::Has('txtSqlName')) {
         $this->oSettings->SetConf('Common/DBName', CPost::get('txtSqlName'));
     }
     if (CPost::Has('txtSqlSrc')) {
         $this->oSettings->SetConf('Common/DBHost', CPost::get('txtSqlSrc'));
     }
     if (CPost::Has('prefixString')) {
         $this->oSettings->SetConf('Common/DBPrefix', CPost::get('prefixString'));
     }
     $this->oSettings->SaveToXml();
 }
Example #6
0
 protected function initUpdateDomainByPost(CDomain &$oDomain)
 {
     $oDomain->OverrideSettings = 0 < $oDomain->IdTenant ? true : CPost::GetCheckBox('chOverrideSettings');
     if ($oDomain->OverrideSettings) {
         // Regional settings and domain branding (moved from "webmail" module)
         $oDomain->SiteName = CPost::get('txtSiteName', $oDomain->SiteName);
         $oDomain->AllowUsersChangeInterfaceSettings = CPost::GetCheckBox('chAllowUsersAccessInterfaveSettings');
         $sSelSkin = CPost::get('selSkin', '');
         if (!empty($sSelSkin)) {
             $aSkins = $this->oModule->GetSkinList();
             if (is_array($aSkins) && in_array($sSelSkin, $aSkins)) {
                 $oDomain->DefaultSkin = $sSelSkin;
             }
         }
         $sSelTab = CPost::get('selTab', '');
         if (!empty($sSelTab)) {
             $aTabs = $this->oModule->getTabList($oDomain);
             if (is_array($aTabs) && in_array($sSelTab, array_keys($aTabs))) {
                 $oDomain->DefaultTab = $sSelTab;
             }
         }
         $sSelLanguage = CPost::get('selLanguage', '');
         if (!empty($sSelLanguage)) {
             $aLangs = $this->oModule->GetLangsList();
             if (is_array($aLangs) && in_array($sSelLanguage, $aLangs)) {
                 $oDomain->DefaultLanguage = $sSelLanguage;
             }
         }
         $sSelTimeZone = CPost::get('selTimeZone', null);
         if (null !== $sSelTimeZone) {
             $aTimeZones = $this->oModule->GetTimeZoneList();
             if (is_array($aTimeZones) && isset($aTimeZones[(int) $sSelTimeZone])) {
                 $oDomain->DefaultTimeZone = $sSelTimeZone;
             }
         }
         if (CPost::Has('radioTimeFormat')) {
             $oDomain->DefaultTimeFormat = EnumConvert::FromPost(CPost::get('radioTimeFormat'), 'ETimeFormat');
         }
         if (CPost::Has('selDateformat')) {
             $oDomain->DefaultDateFormat = CPost::get('selDateformat');
         }
     }
 }
Example #7
0
 /**
  * @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;
         }
     }
 }
Example #8
0
 public function CommonSocial()
 {
     $oApiCapa = CApi::Manager('capability');
     /* @var $oApiCapa CApiCapabilityManager */
     if ($oApiCapa) {
         $oTenant = $this->oModule->GetTenantAdminObject();
         if ($oTenant) {
             $aTenentSocials = array();
             foreach ($oTenant->getSocials() as $sKey => $oSocial) {
                 $oTenentSocial = new CTenantSocials();
                 $oTenentSocial->IdTenant = $oTenant->IdTenant;
                 $oTenentSocial->SocialAllow = CPost::GetCheckBox($sKey . '_chSocialAllow');
                 $oTenentSocial->SocialName = ucfirst($sKey);
                 $oTenentSocial->SocialId = CPost::get($sKey . '_txtSocialId');
                 $oTenentSocial->SocialSecret = CPost::get($sKey . '_txtSocialSecret');
                 $oTenentSocial->SocialApiKey = CPost::get($sKey . '_txtSocialApiKey');
                 $aScopes = CPost::get($sKey . '_chSocialScopes', array());
                 $oTenentSocial->SocialScopes = implode(' ', array_keys($aScopes));
                 $aTenentSocials[$sKey] = $oTenentSocial;
             }
             $oTenant->setSocials($aTenentSocials);
         }
         if ($oTenant && $this->oModule->UpdateTenantAdminObject($oTenant)) {
             $this->LastMessage = AP_LANG_SAVESUCCESSFUL;
             $this->LastError = '';
         } else {
             $this->LastMessage = '';
             $this->LastError = AP_LANG_SAVEUNSUCCESSFUL;
         }
     }
 }
Example #9
0
 /**
  * @param string $sLogin
  * @param string $sPassword
  * @return bool
  */
 public function AuthLogin($sLogin, $sPassword)
 {
     $oSettings = null;
     $oSettings =& CApi::GetSettings();
     $sDemoLogin = CApi::GetConf('demo.adminpanel.login', '');
     $sLogin = trim($sLogin);
     $sPassword = trim($sPassword);
     if (empty($sLogin) || empty($sPassword)) {
         return false;
     }
     if ($oSettings->GetConf('Common/AdminLogin') === $sLogin && $this->oWebmailApi->validateAdminPassword($sPassword)) {
         $this->setAdminAccessType(AP_SESS_AUTH_TYPE_SUPER_ADMIN);
         return true;
     } else {
         if (CApi::GetConf('demo.adminpanel.enable', false) && 0 < strlen($sDemoLogin) && $sDemoLogin === CPost::get('AdmloginInput')) {
             $this->setAdminAccessType(AP_SESS_AUTH_TYPE_SUPER_ADMIN_ONLYREAD);
             return true;
         } else {
             if ($this->oAdminPanel->PType() && $this->oAdminPanel->RType()) {
                 $iTenantId = $this->oAdminPanel->CallModuleFunction('CProModule', 'GetTenantIdByLoginPassword', array($sLogin, $sPassword));
                 if (0 < $iTenantId) {
                     $oTenant = $this->oAdminPanel->CallModuleFunction('CProModule', 'getTenantById', array($iTenantId));
                     if ($oTenant) {
                         /* @var $oTenant CTenant */
                         if (0 < $oTenant->Expared && $oTenant->Expared < \time()) {
                             $sDesc = '<div style="display: block; margin: 0px auto; font: 11pt Verdana,sans-serif; width: 340px; padding: 20px; color: #777;">';
                             $sDesc .= '<h2 style="color: #D35A5A; font-weight: normal; font-size: 16pt;">' . CAPi::I18N('ADMIN_PANEL/YOUR_SUBSCRIPTION_IS_EXPIRED') . '</h2>';
                             if (0 < strlen($oTenant->PayUrl)) {
                                 $sDesc .= '<p>' . CAPi::I18N('ADMIN_PANEL/TO_RENEW_FOLLOW_LINK') . ' <a target="_blank" href="' . ap_Utils::AttributeQuote($oTenant->PayUrl) . '">' . $oTenant->PayUrl . '</a></p>';
                             }
                             $sDesc .= '</div>';
                             CSession::Set('SESSION_LOGIN_WARNING', $sDesc);
                             return true;
                         }
                         $this->setAdminAccessType(AP_SESS_AUTH_TYPE_TENANT);
                         $this->setTenantAccessId($iTenantId);
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
Example #10
0
 /**
  * @return void
  */
 public function InitAjaxAction($sPostName, $sTab, &$sMessage, &$sError, &$sRef)
 {
     if ($this->oTableAjaxAction && $this->IsInTab($sTab)) {
         $sQueryAction = CPost::get('QueryAction', '');
         $sAjaxActionFunction = ucfirst($sTab) . ucfirst($sQueryAction) . (empty($sPostName) ? '' : '_' . $sPostName);
         if (method_exists($this->oTableAjaxAction, $sAjaxActionFunction)) {
             CApi::Log('call ' . get_class($this) . '->TableAjaxAction->' . $sAjaxActionFunction . '()');
             $this->oTableAjaxAction->{$sAjaxActionFunction}();
             if (!empty($this->oTableAjaxAction->LastError)) {
                 $sError = $this->oTableAjaxAction->LastError;
             } else {
                 if (!empty($this->oTableAjaxAction->LastMessage)) {
                     $sMessage = $this->oTableAjaxAction->LastMessage;
                 }
             }
             if (!empty($this->oTableAjaxAction->Ref)) {
                 $sRef = $this->oTableAjaxAction->Ref;
             }
             if (!empty($sError)) {
                 CApi::Log('function ' . $sAjaxActionFunction . '() return $sError = ' . $sError, ELogLevel::Error);
             }
         }
     }
 }