/** * @param CAccount $oAccount */ public function ChangePasswordProcess($oAccount) { if (0 < strlen($oAccount->PreviousMailPassword) && $oAccount->PreviousMailPassword !== $oAccount->IncomingMailPassword) { $cpanel_hostname = CApi::GetConf('plugins.cpanel-change-password.config.hostname', 'localhost'); $cpanel_username = CApi::GetConf('plugins.cpanel-change-password.config.username', 'local'); $cpanel_password = CApi::GetConf('plugins.cpanel-change-password.config.password', ''); $email_user = urlencode($oAccount->Email); $email_password = urlencode($oAccount->IncomingMailPassword); $email_domain = urlencode($oAccount->Domain->Name); $query = "https://" . $cpanel_hostname . ":2083/execute/Email/passwd_pop?email=" . $email_user . "&password="******"&domain=" . $email_domain; $curl = curl_init(); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $header[0] = "Authorization: Basic " . base64_encode($cpanel_username . ":" . $cpanel_password) . "\n\r"; curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl, CURLOPT_URL, $query); $result = curl_exec($curl); if ($result == false) { CApi::Log("curl_exec threw error \"" . curl_error($curl) . "\" for {$query}"); curl_close($curl); throw new CApiManagerException(Errs::UserManager_AccountNewPasswordUpdateError); } else { curl_close($curl); $json_res = json_decode($result); if (!$json_res->status) { throw new CApiManagerException(Errs::UserManager_AccountNewPasswordUpdateError); } } } }
/** * Returns a list of calendars * * @return array */ public function getChildren() { $aCalendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']); $aObjs = array(); foreach ($aCalendars as $aCalendarInfo) { if ($this->caldavBackend instanceof \Sabre\CalDAV\Backend\SharingSupport) { if (isset($aCalendarInfo['{http://calendarserver.org/ns/}shared-url'])) { $aObjs[] = new SharedCalendar($this->caldavBackend, $aCalendarInfo, $this->principalInfo); } else { $aObjs[] = new ShareableCalendar($this->caldavBackend, $aCalendarInfo); } } else { $aObjs[] = new Calendar($this->caldavBackend, $aCalendarInfo); } } $aObjs[] = new \Sabre\CalDAV\Schedule\Outbox($this->principalInfo['uri']); if ($this->caldavBackend instanceof \Sabre\CalDAV\Backend\SchedulingSupport) { $aObjs[] = new \Sabre\CalDAV\Schedule\Inbox($this->caldavBackend, $this->principalInfo['uri']); $aObjs[] = new \Sabre\CalDAV\Schedule\Outbox($this->principalInfo['uri']); } // If the backend supports subscriptions, we'll add those as well, if ($this->caldavBackend instanceof \Sabre\CalDAV\Backend\SubscriptionSupport) { foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) { $aObjs[] = new \Sabre\CalDAV\Subscriptions\Subscription($this->caldavBackend, $subscription); } } // We're adding a notifications node, if it's supported by the backend. if ($this->caldavBackend instanceof \Sabre\CalDAV\Backend\NotificationSupport && \CApi::GetConf('labs.dav.caldav.notification', false)) { $aObjs[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); } return $aObjs; }
public static function getInstance() { if (null === self::$instance) { self::$instance = \CApi::GetConf('labs.dav.use-digest-auth', false) ? new Backend\Digest() : new Backend\Basic(); } return self::$instance; }
/** * @param CAdminPanel $oAdminPanel * @return ap_Login_Screen */ public function __construct(CAdminPanel &$oAdminPanel) { parent::__construct($oAdminPanel, 'login.php'); $sError = ''; if (isset($_GET['auth_error'])) { $sError = AP_LANG_LOGIN_AUTH_ERROR; } else { if (isset($_GET['sess_error'])) { $sError = AP_LANG_LOGIN_SESS_ERROR; } else { if (isset($_GET['access_error'])) { $sError = AP_LANG_LOGIN_ACCESS_ERROR; } } } if (0 < strlen($sError)) { $this->Data->SetValue('LoginErrorDesc', '<div class="wm_login_error"><div class="wm_login_error_icon"></div><div class="wm_login_error_message" id="login_error_message">' . $sError . '</div></div>'); } $this->JsAddInitText('$(\'#loginId\').focus();'); $this->CssAddFile('static/styles/screens/login.css'); $this->Data->SetValue('AdminLogin', CApi::GetConf('demo.adminpanel.login', '')); $this->Data->SetValue('AdminPassword', CApi::GetConf('demo.adminpanel.password', '')); if (CApi::GetConf('demo.adminpanel.enable', false)) { $this->Data->SetValue('LoginDemoFooter', '<div class="info" id="demo_info" dir="ltr"> <div class="demo_note"> This is a demo version of administrative interface. <br />For WebMail demo interface, click <a href="..">here</a>. </div> </div>'); } }
public function __construct(CApiGlobalManager $oApiGlobalManager) { $this->_aHooks = array(); $this->_aServiceHooks = array(); $this->_aJsFiles = array(); $this->_aJsonHooks = array(); $this->_aCssFiles = array(); $this->_aPlugins = array(); $this->_aTemplates = array(); $this->_aAddTemplates = array(); $this->_mState = null; $this->_oApiGlobalManager = $oApiGlobalManager; $this->_oActions = null; $this->bIsEnabled = (bool) CApi::GetConf('plugins', false); if ($this->bIsEnabled) { $sPluginsPath = CApi::DataPath() . '/plugins/'; if (@is_dir($sPluginsPath)) { if (false !== ($rDirHandle = @opendir($sPluginsPath))) { while (false !== ($sFile = @readdir($rDirHandle))) { if (0 < strlen($sFile) && '.' !== $sFile[0] && preg_match('/^[a-z0-9\\-]+$/', $sFile) && (CApi::GetConf('plugins.config.include-all', false) || CApi::GetConf('plugins.' . $sFile, false)) && @file_exists($sPluginsPath . $sFile . '/index.php')) { $oPlugin = (include $sPluginsPath . $sFile . '/index.php'); if ($oPlugin instanceof AApiPlugin) { $oPlugin->SetName($sFile); $oPlugin->SetPath($sPluginsPath . $sFile); $oPlugin->Init(); // $oPlugin->Log('INIT > '.get_class($oPlugin)); $this->_aPlugins[] = $oPlugin; } } } @closedir($rDirHandle); } } } }
/** * @param CAccount $oAccount */ public function ChangePasswordProcess($oAccount) { if (0 < strlen($oAccount->PreviousMailPassword) && $oAccount->PreviousMailPassword !== $oAccount->IncomingMailPassword) { if (null === $this->oPopPassD) { CApi::Inc('common.net.protocols.poppassd'); $this->oPopPassD = new CApiPoppassdProtocol(CApi::GetConf('plugins.poppassd-change-password.config.host', '127.0.0.1'), CApi::GetConf('plugins.poppassd-change-password.config.port', 106)); } if ($this->oPopPassD && $this->oPopPassD->Connect()) { try { // if ($this->oPopPassD->Login(api_Utils::GetAccountNameFromEmail($oAccount->IncomingMailLogin), $oAccount->PreviousMailPassword)) if ($this->oPopPassD->Login($oAccount->IncomingMailLogin, $oAccount->PreviousMailPassword)) { if (!$this->oPopPassD->NewPass($oAccount->IncomingMailPassword)) { throw new CApiManagerException(Errs::UserManager_AccountNewPasswordRejected); } } else { throw new CApiManagerException(Errs::UserManager_AccountOldPasswordNotCorrect); } } catch (Exception $oException) { $this->oPopPassD->Disconnect(); throw $oException; } } else { throw new CApiManagerException(Errs::UserManager_AccountNewPasswordUpdateError); } } }
public function __construct() { parent::__construct(get_class($this), 'IdContact'); $this->__USE_TRIM_IN_STRINGS__ = true; $this->SetDefaults(array('IdContact' => '', 'IdContactStr' => '', 'IdUser' => 0, 'IdDomain' => 0, 'IdTenant' => 0, 'GroupsIds' => array(), 'Type' => EContactType::Personal, 'IdTypeLink' => '', 'FullName' => '', 'UseFriendlyName' => true, 'ViewEmail' => '', 'PrimaryEmail' => CApi::GetConf('contacts.default-primary-email', EPrimaryEmailType::Home), 'DateCreated' => time(), 'DateModified' => time(), 'Title' => '', 'FirstName' => '', 'LastName' => '', 'NickName' => '', 'Skype' => '', 'Facebook' => '', 'HomeEmail' => '', 'HomeStreet' => '', 'HomeCity' => '', 'HomeState' => '', 'HomeZip' => '', 'HomeCountry' => '', 'HomePhone' => '', 'HomeFax' => '', 'HomeMobile' => '', 'HomeWeb' => '', 'BusinessEmail' => '', 'BusinessCompany' => '', 'BusinessStreet' => '', 'BusinessCity' => '', 'BusinessState' => '', 'BusinessZip' => '', 'BusinessCountry' => '', 'BusinessJobTitle' => '', 'BusinessDepartment' => '', 'BusinessOffice' => '', 'BusinessPhone' => '', 'BusinessMobile' => '', 'BusinessFax' => '', 'BusinessWeb' => '', 'OtherEmail' => '', 'Notes' => '', 'BirthdayDay' => 0, 'BirthdayMonth' => 0, 'BirthdayYear' => 0, 'ReadOnly' => false, 'Global' => false, 'ItsMe' => false, 'ETag' => '', 'SharedToAll' => false, 'HideInGAB' => false)); $this->__LOCK_DATE_MODIFIED__ = false; $this->__SKIP_VALIDATE__ = false; CApi::Plugin()->RunHook('api-contact-construct', array(&$this)); }
public function Init() { parent::Init(); $this->AddJsFile('js/iframeAppScreen.js'); $this->AddJsFile('js/include.js'); $this->AddTemplate('IframeAppScreen', 'templates/iframeAppScreen.html', 'Layout', 'Screens-Middle'); $this->AddJsonHook('AjaxAccountSettingsGet', 'AjaxAccountSettingsGet'); $this->mAllowOrigin = \CApi::GetConf('plugins.iframe-app.allow-origin', false); }
/** * @param CApiGlobalManager &$oManager */ public function __construct(CApiGlobalManager &$oManager, $sForcedStorage = '') { parent::__construct('logger', $oManager); $sS = CApi::GetConf('log.custom-full-path', ''); $sPrePath = empty($sS) ? CApi::DataPath() . '/logs/' : rtrim(trim($sS), '\\/') . '/'; $this->sLogFileName = CApi::GetConf('log.log-file', 'log.txt'); $this->sLogFile = $sPrePath . $this->sLogFileName; $this->sCurrentUserLogFileName = CApi::GetConf('log.event-file', 'event.txt'); $this->sCurrentUserLogFile = $sPrePath . $this->sCurrentUserLogFileName; }
/** * @param string $sHost * @param int $iPort * @param bool $bUseSsl = false * @param int $iConnectTimeOut = null * @param int $iSocketTimeOut = null */ public function __construct($sHost, $iPort, $bUseSsl = false, $iConnectTimeOut = null, $iSocketTimeOut = null) { $iConnectTimeOut = null === $iConnectTimeOut ? CApi::GetConf('socket.connect-timeout', 5) : $iConnectTimeOut; $iSocketTimeOut = null === $iSocketTimeOut ? CApi::GetConf('socket.get-timeout', 5) : $iSocketTimeOut; $this->sHost = $sHost; $this->iPort = $iPort; $this->bUseSsl = $bUseSsl; $this->iConnectTimeOut = $iConnectTimeOut; $this->iSocketTimeOut = $iSocketTimeOut; }
/** * @param string $sHost * @param string $sUser * @param string $sPassword * @param string $sDbName * @param string $sDbTablePrefix = '' */ public function __construct($sHost, $sUser, $sPassword, $sDbName, $sDbTablePrefix = '') { $this->sHost = trim($sHost); $this->sUser = trim($sUser); $this->sPassword = trim($sPassword); $this->sDbName = trim($sDbName); $this->sDbTablePrefix = trim($sDbTablePrefix); $this->oPDO = null; $this->rResultId = null; $this->iExecuteCount = 0; $this->bUseExplain = CApi::GetConf('labs.db.use-explain', false); $this->bUseExplainExtended = CApi::GetConf('labs.db.use-explain-extended', false); }
public function System() { $sType = isset($_GET['type']) ? $_GET['type'] : ''; $sAction = isset($_GET['action']) ? $_GET['action'] : ''; $iLimit = CApi::GetConf('log.max-view-size', 100) * 1024; if ('log' === $sType && 'view' === $sAction || 'useractivity' === $sType && 'view' === $sAction) { /* @var $oApiLoggerManager CApiLoggerManager */ $oApiLoggerManager = CApi::Manager('logger'); $iSize = 0; $rLog = 'log' === $sType ? $oApiLoggerManager->GetCurrentLogStream($iSize) : $oApiLoggerManager->GetCurrentUserActivityLogStream($iSize); @header('Content-type: text/plain; charset=utf-8'); if ($rLog && false !== $iSize) { if (0 === $iSize) { echo 'Log file empty'; } else { if ($iLimit < $iSize) { @fseek($rLog, $iSize - $iLimit); } @fpassthru($rLog); } } else { echo 'Log file can\'t be read'; } if ($rLog) { @fclose($rLog); } } else { if ('dllog' === $sType || 'dluseractivity' === $sType) { /* @var $oApiLoggerManager CApiLoggerManager */ $oApiLoggerManager = CApi::Manager('logger'); $iSize = 0; $rLog = 'dllog' === $sType ? $oApiLoggerManager->GetCurrentLogStream($iSize) : $oApiLoggerManager->GetCurrentUserActivityLogStream($iSize); // IE @header('Expires: 0', true); @header('Cache-Control: must-revalidate, post-check=0, pre-check=0', true); @header('Pragma: public', true); $sName = 'dllog' === $sType ? $oApiLoggerManager->LogName() : $oApiLoggerManager->CurrentUserActivityLogName(); @header('Accept-Ranges: bytes', true); @header('Content-Disposition: attachment; filename="' . urlencode($sName) . '"; charset=utf-8'); @header('Content-Transfer-Encoding: binary', true); @header('Content-Length: ' . $iSize); @header('Content-type: text/plain; charset=utf-8', true); if ($rLog && false !== $iSize) { @fpassthru($rLog); } if ($rLog) { @fclose($rLog); } } } }
public function __construct() { $this->oSettings = null; $this->oConnection = null; $this->oSqlHelper = null; $this->aManagers = array(); $this->aStorageMap = array('mailsuite' => 'db', 'min' => 'db', 'fetchers' => 'db', 'helpdesk' => 'db', 'subscriptions' => 'db', 'db' => 'db', 'domains' => 'db', 'tenants' => 'db', 'channels' => 'db', 'users' => 'db', 'webmail' => 'db', 'mail' => 'db', 'gcontacts' => 'db', 'contactsmain' => 'db', 'filecache' => 'file', 'calendar' => 'sabredav', 'filestorage' => 'sabredav', 'social' => 'db', 'twofactorauth' => 'db'); if (CApi::GetConf('gcontacts.ldap', false)) { $this->aStorageMap['gcontacts'] = 'ldap'; } if (CApi::GetConf('contacts.ldap', false)) { $this->aStorageMap['contactsmain'] = 'ldap'; } }
/** * This method is called before any HTTP method, but after authentication. * * @param string $sMethod * @param string $path * @throws \Sabre\DAV\Exception\NotAuthenticated * @return bool */ public function beforeMethod($sMethod, $path) { $aHeaders = $this->server->httpRequest->getHeaders(); \CApi::Log($sMethod . ' ' . $path, \ELogLevel::Full, 'sabredav-'); \CApi::LogObject($aHeaders, \ELogLevel::Full, 'sabredav-'); $bLogBody = (bool) \CApi::GetConf('labs.dav.log-body', false); if ($bLogBody) { $body = $this->server->httpRequest->getBodyAsString(); $this->server->httpRequest->setBody($body); \CApi::LogObject($body, \ELogLevel::Full, 'sabredav-'); } \CApi::Log('', \ELogLevel::Full, 'sabredav-'); return; }
public function __construct() { $this->oSettings = null; $this->oConnection = null; $this->oSqlHelper = null; $this->aManagers = array(); $this->aStorageMap = array('db' => 'db', 'filecache' => 'file'); if (CApi::GetConf('gcontacts.ldap', false)) { $this->aStorageMap['gcontacts'] = 'ldap'; } if (CApi::GetConf('contacts.ldap', false)) { $this->aStorageMap['contactsmain'] = 'ldap'; } }
/** * @return bool */ public function Connect() { $sLine = ''; $bResult = false; if (parent::Connect()) { $sLine = $this->GetNextLine(); $aTokens = $this->parseLine($sLine); if ($aTokens && isset($aTokens[0], $aTokens[1]) && 'IMPLEMENTATION' === $aTokens[0]) { while (true) { if (false === $sLine || !isset($aTokens[0]) || in_array(substr($sLine, 0, 2), array('OK', 'NO'))) { break; } $sLine = trim($sLine); if (in_array($aTokens[0], array('IMPLEMENTATION', 'VERSION'))) { $this->aData[$aTokens[0]] = $aTokens[1]; } else { if ('STARTTLS' === $aTokens[0]) { $this->aData['STARTTLS'] = true; } else { if (isset($aTokens[1]) && in_array($aTokens[0], array('SIEVE', 'SASL'))) { $this->aData['TYPE'] = 'SASL' === $aTokens[0] ? 'AUTH' : 'MODULES'; $this->aData[$this->aData['TYPE']] = explode(' ', $aTokens[1]); } else { $this->aData['UNDEFINED'] = isset($this->aData['UNDEFINED']) ? $this->aData['UNDEFINED'] : array(); $this->aData['UNDEFINED'][] = $sLine; } } } $sLine = $this->GetNextLine(); $aTokens = $this->parseLine($sLine); } } } if ('OK' === substr($sLine, 0, 2)) { $bResult = true; } if (CApi::GetConf('labs.sieve.use-starttls', false) && $bResult && isset($this->aData['STARTTLS']) && $this->aData['STARTTLS']) { $rConnect = $this->GetConnectResource(); if (is_resource($rConnect) && function_exists('stream_socket_enable_crypto')) { if ($this->SendLine('STARTTLS') && $this->CheckResponse($this->GetResponse())) { @stream_socket_enable_crypto($rConnect, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); $this->CheckResponse($this->GetResponse()); } } } return $bResult; }
public function SystemDb(ap_Standard_Screen &$oScreen) { if (CApi::GetConf('mailsuite', false)) { $oScreen->Data->SetValue('classSqlTypeVisibility', 'wm_hide'); $oScreen->Data->SetValue('radioSqlTypeMySQL', true); } else { $oScreen->Data->SetValue('radioSqlTypeMySQL', EDbType::MySQL === $this->oSettings->GetConf('Common/DBType')); $oScreen->Data->SetValue('radioSqlTypePostgreSQL', EDbType::PostgreSQL === $this->oSettings->GetConf('Common/DBType')); } $oScreen->Data->SetValue('txtSqlLogin', $this->oSettings->GetConf('Common/DBLogin')); if (0 < strlen($this->oSettings->GetConf('Common/DBLogin'))) { $oScreen->Data->SetValue('txtSqlPassword', AP_DUMMYPASSWORD); } $oScreen->Data->SetValue('txtSqlName', $this->oSettings->GetConf('Common/DBName')); $oScreen->Data->SetValue('txtSqlSrc', $this->oSettings->GetConf('Common/DBHost')); $this->oModule->JsAddFile('db.js'); }
public function SystemDb() { if (CApi::getCsrfToken('p7admToken') === CPost::get('txtToken')) { if (CApi::GetConf('mailsuite', false)) { $this->oSettings->SetConf('Common/DBType', EDbType::MySQL); } else { $this->oSettings->SetConf('Common/DBType', EnumConvert::FromPost(CPost::get('radioSqlType'), 'EDbType')); } if (CPost::Has('txtSqlLogin')) { $this->oSettings->SetConf('Common/DBLogin', CPost::get('txtSqlLogin')); } if (CPost::Has('txtSqlPassword') && AP_DUMMYPASSWORD !== (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::GetCheckBox('isTestConnection')) { CDbCreator::ClearStatic(); $aConnections =& CDbCreator::CreateConnector($this->oSettings); $oConnect = $aConnections[0]; if ($oConnect) { $this->LastError = AP_LANG_CONNECTUNSUCCESSFUL; try { if ($oConnect->Connect()) { $this->LastMessage = AP_LANG_CONNECTSUCCESSFUL; $this->LastError = ''; } } catch (CApiDbException $oException) { $this->LastError .= "\r\n" . $oException->getMessage() . ' (' . (int) $oException->getCode() . ')'; } } else { $this->LastError = AP_LANG_CONNECTUNSUCCESSFUL; } $this->oSettings->SaveToXml(); } else { $this->saveSettingsXmlWithMessage(); } } return ''; }
/** * @param CAccount $oAccount * @return bool */ public function ChangePasswordProcess($oAccount) { $bResult = false; if (0 < strlen($oAccount->PreviousMailPassword) && $oAccount->PreviousMailPassword !== $oAccount->IncomingMailPassword) { $aISPConfig = ["host" => CApi::GetConf('plugins.ispconfig-change-password.config.host', '127.0.0.1'), "dbuser" => CApi::GetConf('plugins.ispconfig-change-password.config.dbuser', 'root'), "dbpassword" => CApi::GetConf('plugins.ispconfig-change-password.config.dbpassword', ''), "dbname" => CApi::GetConf('plugins.ispconfig-change-password.config.dbname', 'dbispconfig')]; //connect to ispconfig database $mysqlcon = mysqli_connect($aISPConfig['host'], $aISPConfig['dbuser'], $aISPConfig['dbpassword'], $aISPConfig['dbname']); if ($mysqlcon) { //check old pass is correct $username = $oAccount->IncomingMailLogin; $password = $oAccount->PreviousMailPassword; $new_password = $oAccount->IncomingMailPassword; $sql = "SELECT * FROM mail_user WHERE login='******'"; $result = mysqli_query($mysqlcon, $sql); $mailuser = mysqli_fetch_array($result); //extract salt from password $saved_password = stripslashes($mailuser['password']); $salt = '$1$' . substr($saved_password, 3, 8) . '$'; //* Check if mailuser password is correct if (crypt(stripslashes($password), $salt) == $saved_password) { //passwords match so set new password $mailuser_id = $mailuser['mailuser_id']; $new_password = $this->crypt_password($new_password); $sql = "UPDATE mail_user SET password='******' WHERE mailuser_id='{$mailuser_id}'"; $result = mysqli_query($mysqlcon, $sql); if (!$result) { //password update error throw new CApiManagerException(Errs::UserManager_AccountNewPasswordUpdateError); } } else { //old and new passwords dont match throw new CApiManagerException(Errs::UserManager_AccountOldPasswordNotCorrect); } //disconnect from database mysqli_close($mysqlcon); } else { //could not connect to database throw new CApiManagerException(Errs::UserManager_AccountNewPasswordUpdateError); } } return $bResult; }
/** * @param string $sLogin * @param string $sPassword * @param string $sLoginAuthKey = '' * @param string $sProxyAuthUser = '' * @return bool */ public function Login($sLogin, $sPassword, $sLoginAuthKey = '', $sProxyAuthUser = '') { $bReturn = false; $bPlain = (bool) CApi::GetConf('login.enable-plain-auth', false) && $this->IsSupported('AUTH=PLAIN'); if ($bPlain) { $sAuth = base64_encode($sLoginAuthKey . "" . $sLogin . "" . $sPassword); $sTag = $this->getNextTag(); $this->WriteLine($sTag . ' AUTHENTICATE PLAIN'); if (strtok(trim($this->ReadLine()), ' ') == '+') { $this->WriteLine($sAuth); $bReturn = $this->CheckResponse($sTag, $this->GetResponse($sTag)); } } else { $bReturn = $this->SendCommand('LOGIN ' . $this->escapeString($sLogin, true) . ' ' . $this->escapeString($sPassword, true)); if ($bReturn && 0 < strlen($sProxyAuthUser)) { $bReturn = $this->SendCommand('LOGIN ' . $this->escapeString($sLogin, true) . ' ' . $this->escapeString($sPassword, true)); } } return $bReturn; }
/** * @param CDomain &$oDomain * @return bool */ public function CreateDomain(CDomain &$oDomain) { $bResult = false; try { if ($oDomain->Validate()) { if (!$this->DomainExists($oDomain->Name)) { $oTenant = null; $oTenantsApi = null; if (0 < $oDomain->IdTenant && CApi::GetConf('tenant', false)) { /* @var $oTenantsApi CApiTenantsManager */ $oTenantsApi = CApi::Manager('tenants'); if ($oTenantsApi) { /* @var $oTenant CTenant */ $oTenant = $oTenantsApi->GetTenantById($oDomain->IdTenant); if (!$oTenant) { throw new CApiManagerException(Errs::TenantsManager_TenantDoesNotExist); } else { if (0 < $oTenant->DomainCountLimit && $oTenant->DomainCountLimit <= $oTenant->GetDomainCount()) { throw new CApiManagerException(Errs::TenantsManager_DomainCreateUserLimitReached); } } } else { $oDomain->IdTenant = 0; } } else { $oDomain->IdTenant = 0; } if (!$this->oStorage->CreateDomain($oDomain)) { throw new CApiManagerException(Errs::DomainsManager_DomainCreateFailed); } } else { throw new CApiManagerException(Errs::DomainsManager_DomainAlreadyExists); } } $bResult = true; } catch (CApiBaseException $oException) { $bResult = false; $this->setLastException($oException); } return $bResult; }
public function __construct() { $bErrorCreateDir = false; /* Public files folder */ $publicDir = \CApi::DataPath() . Constants::FILESTORAGE_PATH_ROOT; if (!file_exists($publicDir)) { if (!@mkdir($publicDir)) { $bErrorCreateDir = true; } } $publicDir .= Constants::FILESTORAGE_PATH_CORPORATE; if (!file_exists($publicDir)) { if (!@mkdir($publicDir)) { $bErrorCreateDir = true; } } $personalDir = \CApi::DataPath() . Constants::FILESTORAGE_PATH_ROOT . Constants::FILESTORAGE_PATH_PERSONAL; if (!file_exists($personalDir)) { if (!@mkdir($personalDir)) { $bErrorCreateDir = true; } } $sharedDir = \CApi::DataPath() . Constants::FILESTORAGE_PATH_ROOT . Constants::FILESTORAGE_PATH_SHARED; if (!file_exists($sharedDir)) { if (!@mkdir($sharedDir)) { $bErrorCreateDir = true; } } if ($bErrorCreateDir) { throw new \Sabre\DAV\Exception('Can\'t create directory in ' . \CApi::DataPath() . Constants::FILESTORAGE_PATH_ROOT, 500); } $this->aTree = array(new RootPersonal($personalDir)); $oApiCapaManager = \CApi::GetSystemManager('capability'); if ($oApiCapaManager->isCollaborationSupported()) { array_push($this->aTree, new RootPublic($publicDir)); } if (\CApi::GetConf('labs.files-sharing', false)) { array_push($this->aTree, new RootShared($sharedDir)); } }
/** * Returns a list of calendars * * @return array */ public function getChildren() { $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']); $objs = array(); foreach ($calendars as $calendar) { if ($this->caldavBackend instanceof \Sabre\CalDAV\Backend\SharingSupport) { if (isset($calendar['{http://calendarserver.org/ns/}shared-url'])) { $objs[] = new SharedCalendar($this->caldavBackend, $calendar, $this->principalInfo); } else { $objs[] = new \Sabre\CalDAV\ShareableCalendar($this->caldavBackend, $calendar); } } else { $objs[] = new \Sabre\CalDAV\Calendar($this->caldavBackend, $calendar); } } $objs[] = new \Sabre\CalDAV\Schedule\Outbox($this->principalInfo['uri']); // We're adding a notifications node, if it's supported by the backend. if ($this->caldavBackend instanceof \Sabre\CalDAV\Backend\NotificationSupport && \CApi::GetConf('labs.dav.caldav.notification', false)) { $objs[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); } return $objs; }
public function Init() { parent::Init(); $this->SetI18N(true); $this->AddJsFile('js/include.js'); $this->AddCssFile('css/style.css'); $this->AddJsFile('js/VerifyTokenPopup.js'); $this->AddTemplate('VerifyTokenPopup', 'templates/VerifyTokenPopup.html', 'Layout', 'Screens-Middle', 'popup'); $this->AddJsFile('js/ValidatePasswordPopup.js'); $this->AddTemplate('ValidatePasswordPopup', 'templates/ValidatePasswordPopup.html', 'Layout', 'Screens-Middle', 'popup'); $this->AddJsonHook('AjaxValidatePassword', 'AjaxValidatePassword'); $this->AddJsFile('js/CAuthenticationViewModel.js'); $this->AddTemplate('AuthenticationTemplate', 'templates/AuthenticationTemplate.html'); $this->AddJsonHook('AjaxTwoFactorOnRouteAuthenticationSettings', 'AjaxTwoFactorOnRouteAuthenticationSettings'); $this->AddJsonHook('AjaxTwoFactorAuthenticationSave', 'AjaxTwoFactorAuthenticationSave'); $this->AddJsonHook('AjaxTwoFactorAuthenticationSettings', 'AjaxTwoFactorAuthenticationSettings'); $this->AddFontFile('afterlogic-two-factor-authentication.eot', 'css/fonts/afterlogic-two-factor-authentication.eot'); $mConfig = \CApi::GetConf('plugins.two-factor-authentication.config', false); if ($mConfig) { $this->logs = $mConfig['logs']; $this->discrepancy = $mConfig['discrepancy']; } }
/** * @param CAccount $oAccount * * @return \MailSo\Sieve\ManageSieveClient|false */ protected function _connectSieve($oAccount) { $bResult = false; $oSieve = $this->_getSieveDriver($oAccount); if ($oSieve) { if (!$oSieve->IsConnected()) { $sGeneralHost = CApi::GetConf('sieve.config.host', ''); $sGeneralPassword = CApi::GetConf('sieve.config.general-password', ''); $bResult = $oSieve->Connect($oAccount->IsInternal || 0 === strlen($sGeneralHost) ? $oAccount->IncomingMailServer : $sGeneralHost, (int) CApi::GetConf('sieve.config.port', 2000), \MailSo\Net\Enumerations\ConnectionSecurityType::NONE)->Login($oAccount->IncomingMailLogin, 0 === strlen($sGeneralPassword) ? $oAccount->IncomingMailPassword : $sGeneralPassword); } else { $bResult = true; } if ($oSieve) { return $oSieve; } } return $bResult; }
/** * @param object $oObject * @param object $oHelper * @return array */ public static function DbInsertArrays($oObject, $oHelper) { $aResult = array(false, false); $sQueryParams = ''; $bUseLogQueryParams = (bool) CApi::GetConf('labs.db.log-query-params', false); $oObject->initBeforeChange(); $aStaticMap = $oObject->getMap(); $aMap = api_AContainer::DbWriteKeys($aStaticMap, true); $aDbKeys = array_keys($aMap); $aResult[0] = array_map(array(&$oHelper, 'EscapeColumn'), $aDbKeys); $aDbValues = array_values($aMap); foreach ($aDbValues as $iIndex => $sKey) { $mValue = $oObject->{$sKey}; if (isset($aStaticMap[$sKey][0])) { if ('password' === $aStaticMap[$sKey][0]) { $mValue = api_Utils::EncodePassword($mValue); } else { if ('datetime' === $aStaticMap[$sKey][0]) { $mValue = $oHelper->TimeStampToDateFormat($mValue); } else { if ('serialize' === $aStaticMap[$sKey][0]) { $mValue = '' === $mValue ? '' : serialize($mValue); } } } } $aDbValues[$iIndex] = is_string($mValue) ? $oHelper->EscapeString($mValue) : (int) $mValue; if ($bUseLogQueryParams) { $sDbKey = isset($aDbKeys[$iIndex]) ? $aDbKeys[$iIndex] : '!unknown!'; $sQueryParams .= API_CRLF . API_TAB . $sDbKey . ' = ' . $aDbValues[$iIndex]; } } $aResult[1] = $aDbValues; if ($bUseLogQueryParams) { CApi::Log($sQueryParams); } return $aResult; }
/** * @return bool|int */ public function getNextHelpdeskIdForMonitoring() { $mResult = false; if (CApi::GetConf('helpdesk', false)) { if (CApi::GetConf('tenant', false)) { try { $mResult = $this->oStorage->getNextHelpdeskIdForMonitoring((int) CApi::GetConf('helpdesk.fetcher-time-limit-in-min', 5)); if (0 >= $mResult) { $mResult = false; } } catch (CApiBaseException $oException) { $this->setLastException($oException); } } else { $mResult = 0; } } return $mResult; }
/** * @return void */ protected function initModules() { $aLocalModules = array(); $this->aModules = array(); $sModulePath = self::RootPath() . 'modules/'; if (is_dir($sModulePath)) { if (false !== ($rDirHandle = opendir($sModulePath))) { $bIsMailSuite = (bool) CApi::GetConf('mailsuite', false); while (false !== ($sFile = readdir($rDirHandle))) { if ('.' !== $sFile[0] && @file_exists($sModulePath . $sFile . '/index.php')) { if (!$bIsMailSuite && 'bundle' === $sFile) { continue; } $bDisabled = false; $iSortIndex = null; $sCurrentModule = null; include $sModulePath . $sFile . '/index.php'; if (!$bDisabled && null !== $sCurrentModule && null !== $iSortIndex && class_exists($sCurrentModule)) { while (isset($aLocalModules[$iSortIndex])) { $iSortIndex++; } $aLocalModules[$iSortIndex] = new $sCurrentModule($this, $sModulePath . $sFile); } } } closedir($rDirHandle); } } ksort($aLocalModules); foreach ($aLocalModules as $oModule) { $this->aModules[get_class($oModule)] = $oModule; } }
/** * @return bool */ public function RawIframe() { $sEncodedUrl = $this->getParamValue('RawKey', ''); $sUrl = urldecode($sEncodedUrl); $sUrl = trim(trim($sUrl), '/\\?'); $aParts = null; if (!empty($sUrl)) { $aParts = explode('/', $sUrl); } if (is_array($aParts) && isset($aParts[0], $aParts[1], $aParts[2], $aParts[3])) { $aValues = \CApi::DecodeKeyValues($aParts[3]); if (isset($aValues['Iframed'], $aValues['Name'], $aValues['AccountID']) && (!isset($aValues['MimeType']) || !isset($aValues['FileName']))) { $aValues['FileName'] = $aValues['Name']; $aValues['MimeType'] = \api_Utils::MimeContentType($aValues['FileName']); } if (isset($aValues['Iframed'], $aValues['MimeType'], $aValues['FileName']) && $aValues['Iframed'] && \CApi::isIframedMimeTypeSupported($aValues['MimeType'], $aValues['FileName'])) { $oAccount = $this->getAccountFromParam(false); if ($oAccount) { $sNewUrl = ''; $sNewHash = ''; $sResultUrl = ''; $aSubParts = \CApi::DecodeKeyValues($aParts[3]); if (isset($aSubParts['Iframed']) && (int) $aParts[2] === (int) $oAccount->IdAccount && 0 < $oAccount->IdAccount) { $aSubParts['Time'] = \time(); $sNewHash = \CApi::EncodeKeyValues($aSubParts); } if (!empty($sNewHash)) { $aParts[3] = $sNewHash; $sNewUrl = rtrim(trim($this->oHttp->GetFullUrl()), '/') . '/?/' . implode('/', $aParts); \CApi::Plugin()->RunHook('webmail.filter.iframed-attachments-url', array(&$sResultUrl, $sNewUrl, $aValues['MimeType'], $aValues['FileName'])); if (empty($sResultUrl) && \CApi::GetConf('labs.allow-officeapps-viewer', true)) { $sResultUrl = 'https://view.officeapps.live.com/op/view.aspx?src=' . urlencode($sNewUrl); } } if (!empty($sResultUrl)) { header('Content-Type: text/html', true); echo '<html style="height: 100%; width: 100%; margin: 0; padding: 0"><head></head><body' . ' style="height: 100%; width: 100%; margin: 0; padding: 0">' . '<iframe style="height: 100%; width: 100%; margin: 0; padding: 0; border: 0" src="' . $sResultUrl . '"></iframe></body></html>'; return true; } } } } return false; }
/** * * @param type $oXmlDocument * @param string $sPayloadId * @param \CAccount $oAccount * @param bool $bIsDemo Default false * * @return DOMElement */ private function _generateCarddavDict($oXmlDocument, $sPayloadId, $oAccount, $bIsDemo = false) { $aCarddav = array('PayloadVersion' => 1, 'PayloadUUID' => \Sabre\DAV\UUIDUtil::getUUID(), 'PayloadType' => 'com.apple.carddav.account', 'PayloadIdentifier' => $sPayloadId . '.carddav', 'PayloadDisplayName' => 'CardDAV Account', 'PayloadOrganization' => $oAccount->Domain->SiteName, 'PayloadDescription' => 'Configures CardDAV Account', 'CardDAVAccountDescription' => $oAccount->Domain->SiteName . ' Contacts', 'CardDAVHostName' => $this->oApiDavManager ? $this->oApiDavManager->getServerHost($oAccount) : '', 'CardDAVUsername' => $oAccount->Email, 'CardDAVPassword' => $bIsDemo ? 'demo' : (CApi::GetConf('labs.ios-profile.include-password', true) ? $oAccount->IncomingMailPassword : ''), 'CardDAVUseSSL' => $this->oApiDavManager ? $this->oApiDavManager->isUseSsl($oAccount) : '', 'CardDAVPort' => $this->oApiDavManager ? $this->oApiDavManager->getServerPort($oAccount) : '', 'CardDAVPrincipalURL' => $this->oApiDavManager ? $this->oApiDavManager->getPrincipalUrl($oAccount) : ''); return $this->_generateDict($oXmlDocument, $aCarddav); }