mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-31 00:59:58 +09:00
Ensure full compatibility with previous versions of XE and migration tools
This commit is contained in:
parent
7c6b82a522
commit
8fd32d09be
1 changed files with 17 additions and 6 deletions
|
|
@ -132,22 +132,25 @@ class Password
|
||||||
*/
|
*/
|
||||||
public function checkPassword($password, $hash, $algorithm = null)
|
public function checkPassword($password, $hash, $algorithm = null)
|
||||||
{
|
{
|
||||||
$password = trim($password);
|
|
||||||
|
|
||||||
if($algorithm === null)
|
if($algorithm === null)
|
||||||
{
|
{
|
||||||
$algorithm = $this->checkAlgorithm($hash);
|
$algorithm = $this->checkAlgorithm($hash);
|
||||||
}
|
}
|
||||||
if(!array_key_exists($algorithm, $this->getSupportedAlgorithms()))
|
|
||||||
{
|
$password = trim($password);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch($algorithm)
|
switch($algorithm)
|
||||||
{
|
{
|
||||||
case 'md5':
|
case 'md5':
|
||||||
return md5($password) === $hash || md5(sha1(md5($password))) === $hash;
|
return md5($password) === $hash || md5(sha1(md5($password))) === $hash;
|
||||||
|
|
||||||
|
case 'mysql_old_password':
|
||||||
|
return (class_exists('Context') && substr(Context::getDBType(), 0, 5) === 'mysql') ?
|
||||||
|
DB::getInstance()->isValidOldPassword($password, $hash) : false;
|
||||||
|
|
||||||
|
case 'mysql_password':
|
||||||
|
return $hash[0] === '*' && substr($hash, 1) === strtoupper(sha1(sha1($password, true)));
|
||||||
|
|
||||||
case 'pbkdf2':
|
case 'pbkdf2':
|
||||||
$hash = explode(':', $hash);
|
$hash = explode(':', $hash);
|
||||||
$hash[3] = base64_decode($hash[3]);
|
$hash[3] = base64_decode($hash[3]);
|
||||||
|
|
@ -182,6 +185,14 @@ class Password
|
||||||
{
|
{
|
||||||
return 'md5';
|
return 'md5';
|
||||||
}
|
}
|
||||||
|
elseif(strlen($hash) === 16 && ctype_xdigit($hash))
|
||||||
|
{
|
||||||
|
return 'mysql_old_password';
|
||||||
|
}
|
||||||
|
elseif(strlen($hash) === 41 && $hash[0] === '*')
|
||||||
|
{
|
||||||
|
return 'mysql_password';
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue