/**
  * @param \RainLoop\Account $oAccount
  * @param string $sPrevPassword
  * @param string $sNewPassword
  *
  * @return bool
  */
 public function ChangePassword(\RainLoop\Account $oAccount, $sPrevPassword, $sNewPassword)
 {
     if ($this->oLogger) {
         $this->oLogger->Write('ISP: Try to change password for ' . $oAccount->Email());
     }
     $bResult = false;
     if (!empty($this->sDsn) && 0 < \strlen($this->sUser) && 0 < \strlen($this->sPassword) && $oAccount) {
         try {
             $oPdo = new \PDO($this->sDsn, $this->sUser, $this->sPassword);
             $oPdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
             $oStmt = $oPdo->prepare('SELECT password, mailuser_id FROM mail_user WHERE login = ? LIMIT 1');
             if ($oStmt->execute(array($oAccount->IncLogin()))) {
                 $aFetchResult = $oStmt->fetchAll(\PDO::FETCH_ASSOC);
                 if (\is_array($aFetchResult) && isset($aFetchResult[0]['password'], $aFetchResult[0]['mailuser_id'])) {
                     $sDbPassword = \stripslashes($aFetchResult[0]['password']);
                     $sDbSalt = '$1$' . \substr($sDbPassword, 3, 8) . '$';
                     if (\crypt(\stripslashes($sPrevPassword), $sDbSalt) === $sDbPassword) {
                         $oStmt = $oPdo->prepare('UPDATE mail_user SET password = ? WHERE mailuser_id = ?');
                         $bResult = (bool) $oStmt->execute(array($this->cryptPassword($sNewPassword), $aFetchResult[0]['mailuser_id']));
                     }
                 }
             }
         } catch (\Exception $oException) {
             if ($this->oLogger) {
                 $this->oLogger->WriteException($oException);
             }
         }
     }
     return $bResult;
 }
Beispiel #2
0
 /**
  * @param \RainLoop\Account $oAccount
  *
  * @throws \RainLoop\Exceptions\ClientException
  */
 public function CheckMailConnection($oAccount)
 {
     try {
         $this->MailClient()->Connect($oAccount->Domain()->IncHost(\MailSo\Base\Utils::GetDomainFromEmail($oAccount->Email())), $oAccount->Domain()->IncPort(), $oAccount->Domain()->IncSecure())->Login($oAccount->IncLogin(), $oAccount->Password());
     } catch (\RainLoop\Exceptions\ClientException $oException) {
         throw $oException;
     } catch (\MailSo\Net\Exceptions\ConnectionException $oException) {
         throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::ConnectionError, $oException);
     } catch (\Exception $oException) {
         throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError, $oException);
     }
 }