/** * @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); } } }
/** * @staticvar CLdapConnector|null $oLdap * @param CAccount $oAccount * @return CLdapConnector|bool */ private function Ldap($oAccount) { // if ($oAccount) // { // // TODO // $aCustomFields = $oAccount->CustomFields; // $aCustomFields['LdapPabUrl'] = 'ldap://192.168.0.197:389/ou=TestUser2,ou=PAB,dc=example,dc=com'; // $aCustomFields['LdapPabUrl'] = 'ldap://jes7dir.netvision.net.il:389/ou=24606995,ou=People,o=netvision.net.il,o=NVxSP,o=pab'; // $oAccount->CustomFields = $aCustomFields; // } static $aLdap = array(); if (!$oAccount || !isset($oAccount->CustomFields) || empty($oAccount->CustomFields['LdapPabUrl'])) { return false; } $sPabUrl = $oAccount->CustomFields['LdapPabUrl']; $aPabUrl = api_Utils::LdapUriParse($sPabUrl); if (isset($aLdap[$sPabUrl]) && $aLdap[$sPabUrl]) { return $aLdap[$sPabUrl]; } if (!extension_loaded('ldap')) { CApi::Log('LDAP: Can\'t load LDAP extension.', ELogLevel::Error); return false; } if (!class_exists('CLdapConnector')) { CApi::Inc('common.ldap'); } $oLdap = new CLdapConnector($aPabUrl['search_dn']); $oLdap = $oLdap->Connect((string) $aPabUrl['host'], (int) $aPabUrl['port'], (string) CApi::GetConf('contacts.ldap.bind-dn', ''), (string) CApi::GetConf('contacts.ldap.bind-password', '')) ? $oLdap : false; if ($oLdap) { if (!$oLdap->Search('(objectClass=*)')) { CApi::Log('LDAP: Init PabUrl Entry'); $sNewDn = $oLdap->GetSearchDN(); $aDnExplode = ldap_explode_dn($sNewDn, 1); $sOu = isset($aDnExplode[0]) ? trim($aDnExplode[0]) : ''; $aPabUrlEntry = CApi::GetConf('contacts.ldap.pab-url-entry', array('objectClass' => array('top', 'organizationalUnit'))); if (isset($aPabUrlEntry['objectClass'])) { $aPabUrlEntry['ou'] = $sOu; if (0 < strlen($sOu)) { if (!$oLdap->Add('', $aPabUrlEntry)) { $oLdap = false; } } else { CApi::Log('LDAP: empty Ou in SearchDn = ' . $sNewDn); $oLdap = false; } } else { CApi::Log('LDAP: pab-url-entry format error'); CApi::Log(print_r($aPabUrlEntry, true)); $oLdap = false; } } } $aLdap[$sPabUrl] = $oLdap; return $oLdap; }
/** * @param int $iDbType = EDbType::MySQL * @return IDbHelper */ public static function CommandCreatorHelperFabric($iDbType = EDbType::MySQL) { $oHelper = null; if (EDbType::PostgreSQL === $iDbType) { CApi::Inc('common.db.pdo.postgres_helper'); $oHelper = new CPdoPostgresHelper(); } else { CApi::Inc('common.db.pdo.mysql_helper'); $oHelper = new CPdoMySqlHelper(); } return $oHelper; }
/** * @param CApiGlobalManager &$oManager */ public function __construct(CApiGlobalManager &$oManager, $sForcedStorage = '') { parent::__construct('sieve', $oManager); CApi::Inc('common.net.protocols.sieve'); $this->inc('classes.enum'); $this->inc('classes.filter'); $this->aSieves = array(); $this->sGeneralPassword = ''; $this->sSieveFileName = CApi::GetConf('sieve.config.file', 'sieve'); $this->sSieveFolderCharset = CApi::GetConf('sieve.config.filters-folder-charset', 'utf-8'); $this->bSectionsParsed = false; $this->aSectionsData = array(); $this->aSectionsOrders = array('forward', 'autoresponder', 'filters'); }
/** * @param CApiGlobalManager &$oManager */ public function __construct(CApiGlobalManager &$oManager) { parent::__construct('carddav', $oManager); CApi::Inc('common.dav.client'); $this->Dav = null; $this->Settings = CApi::GetSettings(); $this->Pdo = CApi::GetPDO(); $this->User = null; $this->Account = null; $this->Connected = false; $this->aAddressBooksCache = array(); $this->aGroupItemsCache = array(); $this->ContactsCache = array(); $this->GroupsCache = array(); $this->DbPrefix = $this->Settings->GetConf('Common/DBPrefix'); $this->ApiUsersManager = CApi::Manager('users'); $this->ApiDavManager = CApi::Manager('dav'); }
<?php /* * Copyright 2004-2015, AfterLogic Corp. * Licensed under AGPLv3 license or AfterLogic license * if commercial version of the product was purchased. * See the LICENSE file for a full license statement. */ CApi::Inc('common.db.table'); /** * @package Db * @subpackage Classes */ class CDbSchemaHelper { /** * @staticvar string $sPrefix * * @return string */ public static function prefix() { static $sPrefix = null; if (null === $sPrefix) { $oSettings = null; $oSettings =& CApi::GetSettings(); $sPrefix = $oSettings->GetConf('Common/DBPrefix'); } return $sPrefix; } /**
<?php /* * Copyright 2004-2015, AfterLogic Corp. * Licensed under AGPLv3 license or AfterLogic license * if commercial version of the product was purchased. * See the LICENSE file for a full license statement. */ CApi::Inc('common.db.sql'); /** * @package Api * @subpackage Db */ class CDbPdoPostgres extends CDbSql { /** * @var bool */ protected $bUseExplain; /** * @var bool */ protected $bUseExplainExtended; /** * @var PDO database object */ protected $oPDO; /** * @var PDO resource */ protected $rResultId;
<?php /* * Copyright 2004-2015, AfterLogic Corp. * Licensed under AGPLv3 license or AfterLogic license * if commercial version of the product was purchased. * See the LICENSE file for a full license statement. */ CApi::Inc('common.db.helper'); /** * @package Api * @subpackage Db */ class CPdoPostgresHelper implements IDbHelper { /** * @param string $sValue * @param bool $bWithOutQuote = false * @param bool $bSearch = false * @return string */ public function EscapeString($sValue, $bWithOutQuote = false, $bSearch = false) { $sResult = ''; if ($bWithOutQuote) { $sResult = str_replace('\'', '\'\'', $sValue); } else { $sResult = 0 === strlen($sValue) ? '\'\'' : '\'' . str_replace('\'', '\'\'', $sValue) . '\''; } if ($bSearch) { $sResult = str_replace(array("%", "_"), array("\\%", "\\_"), $sResult);
* @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License, version 3, * along with this program. If not, see <http://www.gnu.org/licenses/> * */ CApi::Inc('db.helper'); /** * @package Api * @subpackage Db */ class CPdoMySqlHelper implements IDbHelper { /** * @param string $sValue * @param bool $bWithOutQuote = false * @param bool $bSearch = false * @return string */ public function EscapeString($sValue, $bWithOutQuote = false, $bSearch = false) { $sResult = '';
* @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License, version 3, * along with this program. If not, see <http://www.gnu.org/licenses/> * */ CApi::Inc('db.sql'); /** * @package Api * @subpackage Db */ class CDbPdoPostgres extends CDbSql { /** * @var bool */ protected $bUseExplain; /** * @var bool */ protected $bUseExplainExtended; /**
<?php class_exists('CApi') or die; CApi::Inc('common.plugins.change-password'); class CCustomChangePasswordPlugin extends AApiChangePasswordPlugin { /** * @param CApiPluginManager $oPluginManager */ public function __construct(CApiPluginManager $oPluginManager) { parent::__construct('1.0', $oPluginManager); } private function crypt_password($cleartext_password) { $salt = "\$1\$"; $base64_alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; for ($n = 0; $n < 8; $n++) { $salt .= $base64_alphabet[mt_rand(0, 63)]; } $salt .= "\$"; return crypt($cleartext_password, $salt); } /** * @param CAccount $oAccount * @return bool */ public function validateIfAccountCanChangePassword($oAccount) { $bResult = false; if ($oAccount instanceof CAccount) {
/** * @return bool */ public static function StorageInc($sManagerName, $sStorageName, $sFileName) { $sManagerName = preg_replace('/[^a-z]/', '', strtolower($sManagerName)); $sStorageName = preg_replace('/[^a-z]/', '', strtolower($sStorageName)); return CApi::Inc('Managers.' . $sManagerName . '.storages.' . $sStorageName . '.' . $sFileName); }
/** * @param CApiGlobalManager &$oManager */ public function __construct(CApiGlobalManager &$oManager, $sForcedStorage = '') { parent::__construct('dav', $oManager); CApi::Inc('common.dav.client'); $this->aDavClients = array(); }
* @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License, version 3, * along with this program. If not, see <http://www.gnu.org/licenses/> * */ CApi::Inc('db.table'); /** * @package Db * @subpackage Classes */ class CDbSchemaHelper { /** * @staticvar string $sPrefix * * @return string */ public static function prefix() { static $sPrefix = null; if (null === $sPrefix) {
<?php /* * Copyright 2004-2015, AfterLogic Corp. * Licensed under AGPLv3 license or AfterLogic license * if commercial version of the product was purchased. * See the LICENSE file for a full license statement. */ class_exists('CApi') or die; CApi::Inc('common.plugins.two-factor-auth'); include_once CApi::LibrariesPath() . 'PHPGangsta/GoogleAuthenticator.php'; class TwoFactorAuthenticationPlugin extends AApiTwoFactorAuthPlugin { protected $logs = false; protected $discrepancy = 2; public static $setAccountIsLoggedIn = false; /** * @param string $sText */ private function _writeLogs($sText) { if ($this->logs === true) { $this->Log($sText); } } /** * @param CApiPluginManager $oPluginManager */ public function __construct(CApiPluginManager $oPluginManager) { parent::__construct('1.0', $oPluginManager);
* @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License, version 3, * along with this program. If not, see <http://www.gnu.org/licenses/> * */ CApi::Inc('net.abstract'); /** * @package Api * @subpackage Net */ class CApiSieveProtocol extends CApiNetAbstract { /** * @var array */ protected $aData; public function __construct($sHost, $iPort, $bUseSsl = false, $iConnectTimeOut = null, $iSocketTimeOut = null) { parent::__construct($sHost, $iPort, $bUseSsl, $iConnectTimeOut, $iSocketTimeOut); $this->aData = array(); }
/** * @param string $sManagerName * @param CApiGlobalManager &$oManager * @param string $sForcedStorage = '' * @return AApiManager */ public function __construct($sManagerName, CApiGlobalManager &$oManager, $sForcedStorage = '') { parent::__construct($sManagerName, $oManager); $this->oStorage = null; $this->sStorageName = !empty($sForcedStorage) ? strtolower(trim($sForcedStorage)) : strtolower($oManager->GetStorageByType($sManagerName)); CApi::Inc('common.managers.' . $this->GetManagerName() . '.storages.default'); if (CApi::Inc('common.managers.' . $this->GetManagerName() . '.storages.' . $this->GetStorageName() . '.storage', false)) { $sClassName = 'CApi' . ucfirst($this->GetManagerName()) . ucfirst($this->GetStorageName()) . 'Storage'; $this->oStorage = new $sClassName($oManager); } else { $sClassName = 'CApi' . ucfirst($this->GetManagerName()) . 'Storage'; $this->oStorage = new $sClassName($this->sStorageName, $oManager); } }
<?php /* * Copyright 2004-2015, AfterLogic Corp. * Licensed under AGPLv3 license or AfterLogic license * if commercial version of the product was purchased. * See the LICENSE file for a full license statement. */ CApi::Inc('common.net.abstract'); /** * @package Api * @subpackage Net */ class CApiImap4MailProtocol extends CApiNetAbstract { /** * @var array */ protected $aCapa; public function __construct($sHost, $iPort, $bUseSsl = false, $iConnectTimeOut = null, $iSocketTimeOut = null) { parent::__construct($sHost, $iPort, $bUseSsl, $iConnectTimeOut, $iSocketTimeOut); $this->aCapa = null; } /** * @return bool */ public function Connect() { $bResult = false; if (parent::Connect()) {
/** * @param string $sManagerName * @param CApiGlobalManager &$oManager * @param string $sForcedStorage * @return AApiManager */ public function __construct($sManagerName, CApiGlobalManager &$oManager, $sForcedStorage = '', AApiModule $oModule = null) { parent::__construct($sManagerName, $oManager, $oModule); $this->oStorage = null; $this->sStorageName = !empty($sForcedStorage) ? strtolower(trim($sForcedStorage)) : strtolower($oManager->GetStorageByType($sManagerName)); if (isset($this->oModule)) { $this->incDefaultStorage(); if ($this->incStorage($this->GetStorageName() . '.storage', false)) { $sClassName = 'CApi' . ucfirst($oModule->GetName()) . ucfirst($this->GetManagerName()) . ucfirst($this->GetStorageName()) . 'Storage'; $this->oStorage = new $sClassName($this); } else { $sClassName = 'CApi' . ucfirst($oModule->GetName()) . ucfirst($this->GetManagerName()) . 'Storage'; $this->oStorage = new $sClassName($this->sStorageName, $this); } } else { CApi::Inc('managers.' . $this->GetManagerName() . '.storages.default'); if (CApi::Inc('managers.' . $this->GetManagerName() . '.storages.' . $this->GetStorageName() . '.storage', false)) { $sClassName = 'CApi' . ucfirst($this->GetManagerName()) . ucfirst($this->GetStorageName()) . 'Storage'; $this->oStorage = new $sClassName($this); } else { $sClassName = 'CApi' . ucfirst($this->GetManagerName()) . 'Storage'; if (class_exists($sClassName)) { $this->oStorage = new $sClassName($this->sStorageName, $this); } } } }