我正在将客户从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密码类型。
答案 0 :(得分:0)
这不重要,因为这只是检查密码:
SELECT
password
FROMzc_legacy_passwords
WHEREupdated
= 0');
然后这段代码检查表数据库中的密码ZenCart / OScommerce你可以删除或评论(只是忽略)
$ salt = substr($ resultZC ['password'],strrpos($ resultZC ['password'],':')+ 1,2); $ ZCpassword = md5($ salt。$ passwd)。 ':'。 $盐;
if($ ZCpassword!= $ resultZC ['password'])return false;
这很重要,因为它会存储和修改prestashop的密码(这里不需要修改)
DB ::的getInstance() - &GT;执行(” 更新
'._DB_PREFIX_ .'customer
SETpasswd
= \''。md5(pSQL(_COOKIE_KEY _。$ passwd))。'\'WHERE
忽略这一点:
Db :: getInstance() - &gt;执行('UPDATE
zc_legacy_passwords
SETupdated
= 1 WHERE
忽略这一点:
$ result = Db :: getInstance() - &gt; getRow('SELECT * FROM
'._DB_PREFIX_ .'customer
WHEREactive
= 1 ANDdeleted
= 0 ANDis_guest
= 0');
所以,代码看起来像:
if(!$ result){
Db :: getInstance() - &gt;执行('UPDATE
'._DB_PREFIX_ .'customer
SET
passwd
= \''。md5(pSQL(_COOKIE_KEY _。$ passwd))。'\'WHERE\ '' PSQL($电子邮件)。 '\'');
}
答案 1 :(得分:0)
使用不同的加密方式迁移密码非常困难,甚至无法实现。所以,对于你的问题可能为时已晚,我想任何想要迁移密码的人都应该尝试自动移动密码。没有一些简单的点击,这个工具不需要你任何技术技能。 LitExtension是我的一个建议。当然你需要支付一点,但不是太多。