1

我正在将客户从 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 密码类型。

4

2 回答 2

0

这并不重要,因为这只是检查密码:

passwordzc_legacy_passwords哪里选择email= \''.pSQL($email).'\' AND updated= 0');

然后这段代码检查表数据库 ZenCart/OScommerce 中的密码,您可以删除或评论(忽略)

$salt = substr($resultZC['password'], strrpos($resultZC['password'],':')+1, 2); $ZCpassword = md5($salt . $passwd) 。':' 。$盐;

if ($ZCpassword != $resultZC['password']) return false;

这很重要,因为将存储和修改 prestashop 的密码(此处不需要 modif)

Db::getInstance()->Execute(' UPDATE '._DB_PREFIX_ .'customerSET passwd= \''.md5(pSQL(_COOKIE_KEY_.$passwd)).'\' WHERE email= \''.pSQL($email).'\'');

忽略这个:

Db::getInstance()->Execute(' UPDATE zc_legacy_passwordsSET updated= 1 WHERE email= \''.pSQL($email).'\'');

忽略这个 :

$result = Db::getInstance()->getRow(' SELECT * FROM '._DB_PREFIX_ .'customerWHERE active= 1 AND email= \''.pSQL($email).'\' AND deleted= 0 AND is_guest= 0');

因此,代码将如下所示:

如果(!$结果){

Db::getInstance()->Execute(' 更新'._DB_PREFIX_ .'customer

passwd= \''.md5(pSQL(_COOKIE_KEY_.$passwd)).'\' WHERE email=

\''.pSQL($email).'\'');

}

于 2012-10-25T08:27:08.163 回答
0

迁移不同加密的密码非常困难,甚至不可能。因此,对于您的问题,可能为时已晚,我认为任何想要迁移密码的人都应该尝试自动移动它们。此工具不需要您任何技术技能,无需一些简单的点击。LitExtension是我的建议之一。当然,你必须付出一点,但也不会太多。

于 2016-09-13T07:50:33.150 回答