mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-08 17:07:03 +03:00
working version
This commit is contained in:
parent
b17e5dd11d
commit
353964e729
1 changed files with 20 additions and 11 deletions
|
|
@ -161,16 +161,13 @@ class ChangePasswordCustomSqlDriver implements \RainLoop\Providers\ChangePasswor
|
||||||
$sEmailDomain = \MailSo\Base\Utils::GetDomainFromEmail($sEmail);
|
$sEmailDomain = \MailSo\Base\Utils::GetDomainFromEmail($sEmail);
|
||||||
|
|
||||||
// some variables cannot be prepared
|
// some variables cannot be prepared
|
||||||
/*
|
|
||||||
$this->mSql = str_replace(array(
|
$this->mSql = str_replace(array(
|
||||||
':table'
|
':table'
|
||||||
), array(
|
), array(
|
||||||
$this->mTable
|
$this->mTable
|
||||||
), $this->mSql);
|
), $this->mSql);
|
||||||
*/
|
|
||||||
|
|
||||||
$placeholders = array(
|
$placeholders = array(
|
||||||
':table' => $this->mTable,
|
|
||||||
':email' => $sEmail,
|
':email' => $sEmail,
|
||||||
':oldpass' => $sPrevPassword,
|
':oldpass' => $sPrevPassword,
|
||||||
':newpass' => $sNewPassword,
|
':newpass' => $sNewPassword,
|
||||||
|
|
@ -178,24 +175,36 @@ class ChangePasswordCustomSqlDriver implements \RainLoop\Providers\ChangePasswor
|
||||||
':username' => $sEmailUser
|
':username' => $sEmailUser
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// we have to check that all placehoders are used in the query, passing any unused placeholders will generate an error
|
||||||
|
$used_placeholders = array();
|
||||||
|
|
||||||
|
foreach($placeholders as $placeholder => $value) {
|
||||||
|
if(preg_match_all('/'.$placeholder . '(?![a-zA-Z0-9\-])'.'/', $this->mSql) === 1) {
|
||||||
|
// backwards-compabitibility: remove single and double quotes around placeholders
|
||||||
|
$this->mSql = str_replace('`'.$placeholder.'`', $placeholder, $this->mSql);
|
||||||
|
$this->mSql = str_replace("'".$placeholder."'", $placeholder, $this->mSql);
|
||||||
|
$this->mSql = str_replace('"'.$placeholder.'"', $placeholder, $this->mSql);
|
||||||
|
$used_placeholders[$placeholder] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$statement = $conn->prepare($this->mSql);
|
$statement = $conn->prepare($this->mSql);
|
||||||
|
|
||||||
$this->oLogger->Write($this->mSql);
|
// everything is ready (hopefully), bind the values
|
||||||
|
foreach($used_placeholders as $placeholder => $value) {
|
||||||
$statement->bindValue(':table', 'accounts');
|
$statement->bindValue($placeholder, $value);
|
||||||
$statement->bindValue(':email', $sEmail);
|
}
|
||||||
$statement->bindValue(':oldpass', $sPrevPassword);
|
|
||||||
$statement->bindValue(':newpass', $sNewPassword);
|
|
||||||
$statement->bindValue(':domain', $sEmailDomain);
|
|
||||||
$statement->bindValue(':username', $sEmailUser);
|
|
||||||
|
|
||||||
|
// and execute
|
||||||
$mSqlReturn = $statement->execute();
|
$mSqlReturn = $statement->execute();
|
||||||
|
|
||||||
|
/* can be used for debugging
|
||||||
ob_start();
|
ob_start();
|
||||||
$statement->debugDumpParams();
|
$statement->debugDumpParams();
|
||||||
$r = ob_get_contents();
|
$r = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
$this->oLogger->Write($r);
|
$this->oLogger->Write($r);
|
||||||
|
*/
|
||||||
|
|
||||||
if ($mSqlReturn == true)
|
if ($mSqlReturn == true)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue