我正在将客户从 CubeCart 转移到 Prestashop,并希望保留客户现有的客户密码。
我在 Prestashop 论坛上找到了一个似乎可以满足我需要的贡献,但是,它是 ZenCart/OScommerce 到 Prestashop 的。因此,我需要帮助的密码结构略有不同,请参见下文:
ZC/OSC
格式:1 列,32 个字母数字字符 + 冒号 + 2 个字母数字字符盐。
例如
e56d64755f66a86996b54114bb4102bf:08
CC
格式:2 列,32 个字母数字字符 + 一个单独的 6 位随机盐。
例如
密码:e56d64755f66a86996b54114bb4102bf
盐:7pZcAF
所以我想请一点帮助调整以下代码以使用 2 列 CC 密码/盐:
// == BEGIN ZEN-CART / OSCOMMERCE TO PRESTASHOP PASSWORD INTEGRATION ==
// == BY João Cunha - this.person@joaocunha.eti.br
// == @ 31/03/2012
// == USE AND MODIFY AT WILL
// == TESTED ON PRESTASHOP V1.4.7X
if (!$result) { //<- INVALID PRESTASHOP LOGIN, IT MAY BE A ZEN-CART / OSCOMMERCE PASSWORD
//CHECK IF THE GIVEN EMAIL MATCHES A ROW IN OUR LEGACY TABLE AND RETRIEVES THE LEGACY PASSWORD
$resultZC = Db::getInstance()->getRow('
SELECT `password`
FROM `zc_legacy_passwords`
WHERE `email` = \''.pSQL($email).'\'
AND `updated` = 0');
if (!$resultZC)
return false; //<- EMAIL NOT FOUND IN NONE OF THE TABLES, SO IT IS AN INVALID LOGIN
//ENCRYPTS THE GIVEN PASSWORD IN ZEN-CART / OSCOMMERCE FORMAT
$salt = substr($resultZC['password'], strrpos($resultZC['password'],':')+1, 2);
$ZCpassword = md5($salt . $passwd) . ':' . $salt;
if ($ZCpassword != $resultZC['password'])
return false; //<- WRONG ZEN-CART/OSCOMMERCE PASSWORD GIVEN
//WE'LL UPDATE THE CUSTOMER TABLE WITH ITS PRESTASHOP ENCRYPTED PASSWORD...
Db::getInstance()->Execute('
UPDATE `'._DB_PREFIX_ .'customer`
SET `passwd` = \''.md5(pSQL(_COOKIE_KEY_.$passwd)).'\'
WHERE `email` = \''.pSQL($email).'\'');
//...AND FLAG IT AS UPDATED, SO THE NEXT TIME HE LOGS IN, HE WON'T ENTER THIS ROUTINE.
Db::getInstance()->Execute('
UPDATE `zc_legacy_passwords`
SET `updated` = 1
WHERE `email` = \''.pSQL($email).'\'');
//USER IS AUTHENTICATED, OVERWRITE THE EMPTY $result VARIABLE
$result = Db::getInstance()->getRow('
SELECT *
FROM `'._DB_PREFIX_ .'customer`
WHERE `active` = 1
AND `email` = \''.pSQL($email).'\'
AND `deleted` = 0
AND `is_guest` = 0');
}
// == END ZEN-CART / OSCOMMERCE TO PRESTASHOP PASSWORD INTEGRATION
此代码还将旧的加盐密码更新为新的 Prestashop 密码类型。