Code Duplication    Length = 48-48 lines in 2 locations

plugins/ispmail-change-password/ChangePasswordISPmailDriver.php 1 location

@@ 203-250 (lines=48) @@
200
	 *
201
	 * @return bool
202
	 */
203
	public function ChangePassword(\RainLoop\Account $oAccount, $sPrevPassword, $sNewPassword)
204
	{
205
		if ($this->oLogger)
206
		{
207
			$this->oLogger->Write('ISPmail: Try to change password for '.$oAccount->Email());
208
		}
209
210
		unset($sPrevPassword);
211
212
		$bResult = false;
213
214
		if (0 < \strlen($sNewPassword))
215
		{
216
			try
217
			{
218
				$sDsn = 'mysql:host='.$this->sHost.';port='.$this->iPort.';dbname='.$this->sDatabase;
219
220
				$oPdo = new \PDO($sDsn, $this->sUser, $this->sPassword);
221
				$oPdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
222
223
				$sUpdatePassword = $this->cryptPassword($sNewPassword, $oPdo);
224
				if (0 < \strlen($sUpdatePassword))
225
				{
226
					$oStmt = $oPdo->prepare("UPDATE {$this->sTable} SET {$this->sPasscol} = ? WHERE {$this->sUsercol} = ?");
227
					$bResult = (bool) $oStmt->execute(array($sUpdatePassword, $oAccount->Email()));
228
				}
229
				else
230
				{
231
					if ($this->oLogger)
232
					{
233
						$this->oLogger->Write('ISPmail: Encrypted password is empty',
234
							\MailSo\Log\Enumerations\Type::ERROR);
235
					}
236
				}
237
238
				$oPdo = null;
239
			}
240
			catch (\Exception $oException)
241
			{
242
				if ($this->oLogger)
243
				{
244
					$this->oLogger->WriteException($oException);
245
				}
246
			}
247
		}
248
249
		return $bResult;
250
	}
251
252
	/**
253
	 * @param string $sPassword

plugins/postfixadmin-change-password/ChangePasswordPostfixAdminDriver.php 1 location

@@ 203-250 (lines=48) @@
200
	 *
201
	 * @return bool
202
	 */
203
	public function ChangePassword(\RainLoop\Account $oAccount, $sPrevPassword, $sNewPassword)
204
	{
205
		if ($this->oLogger)
206
		{
207
			$this->oLogger->Write('Postfix: Try to change password for '.$oAccount->Email());
208
		}
209
210
		unset($sPrevPassword);
211
212
		$bResult = false;
213
214
		if (0 < \strlen($sNewPassword))
215
		{
216
			try
217
			{
218
				$sDsn = 'mysql:host='.$this->sHost.';port='.$this->iPort.';dbname='.$this->sDatabase;
219
220
				$oPdo = new \PDO($sDsn, $this->sUser, $this->sPassword);
221
				$oPdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
222
223
				$sUpdatePassword = $this->cryptPassword($sNewPassword, $oPdo);
224
				if (0 < \strlen($sUpdatePassword))
225
				{
226
					$oStmt = $oPdo->prepare("UPDATE {$this->sTable} SET {$this->sPasscol} = ? WHERE {$this->sUsercol} = ?");
227
					$bResult = (bool) $oStmt->execute(array($sUpdatePassword, $oAccount->Email()));
228
				}
229
				else
230
				{
231
					if ($this->oLogger)
232
					{
233
						$this->oLogger->Write('Postfix: Encrypted password is empty',
234
							\MailSo\Log\Enumerations\Type::ERROR);
235
					}
236
				}
237
238
				$oPdo = null;
239
			}
240
			catch (\Exception $oException)
241
			{
242
				if ($this->oLogger)
243
				{
244
					$this->oLogger->WriteException($oException);
245
				}
246
			}
247
		}
248
249
		return $bResult;
250
	}
251
252
	/**
253
	 * @param string $sPassword