Joomla3二次开发 要合并discuz的会员账户信息到Joomla3系统中,这时候要修改一下Joomla3的PlgAuthentication的Joomla插件来添加一个discuz的验证方式
这个与密码验证相关的文件的位置是 (注意是Joomla3.x 其它版本暂时没研究) :
JOOMLA/plugins/authentication/joomla/joomla.php
首先要把discuz的ucenter_members表的数据 导入到 Joomla的users表 具体的自己做吧
关于密码的格式 我的处理方式是把 discuz的拼凑成 Joomla那种字符串的 :
$uc$/password/salt
这种样式 其中password跟salt都是discuz的数据
Joomla关于会员信息的表只有两张 一个users 还有一个user_usergroup_map(暂时不管)
所以导入时候 只要把ucenter_members改造一下就好了 自行导入到joomla的users表吧
要修改的部分是
// Get a database object
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('id, password')
->from('#__users')
->where('username=' . $db->quote($credentials['username']));
$db->setQuery($query);
$result = $db->loadObject();
后面开始
//导出discuz会员表 ucenter 关于discuz的password跟salt处理方式是
//组合成为 $uc$/password/salt 后面通过'/'切割 方便使用discuz的公式验证密码
if( substr( $result->password, 0 , 4) == '$uc$')
{
// discuz具体的验证方法是 $saltpassword = md5( md5( $plaintext_password ) . $salt);
$str = explode( '/', $result->password);
$match = md5( md5( $credentials['password']) . $str[2]) === $str[1] ? true : false;
}
else if (substr($result->password, 0, 4) == '$2y$')
{
// BCrypt passwords are always 60 characters, but it is possible that salt is appended although non standard.
$password60 = substr($result->password, 0, 60);
if (JCrypt::hasStrongPasswordSupport())
{
$match = password_verify($credentials['password'], $password60);
}
}
elseif (substr($result->password, 0, 8) == '{SHA256}')
{
// Check the password
$parts = explode(':', $result->password);
var_dump( $parts);
$crypt = $parts[0];
$salt = @$parts[1];
$testcrypt = JUserHelper::getCryptedPassword($credentials['password'], $salt, 'sha256', false);
if ($result->password == $testcrypt)
{
$match = true;
}
}
else
{
// Check the password
$parts = explode(':', $result->password);
var_dump( $parts);
$crypt = $parts[0];
$salt = @$parts[1];
$testcrypt = JUserHelper::getCryptedPassword($credentials['password'], $salt, 'md5-hex', false);
if ($crypt == $testcrypt)
{
$match = true;
}
}
这样应该差不多了,我继续研究看看还有什么要做的。初次学习joomla ,多多指教。
补充 还有创建分组的数据 表名叫 user_usergroup_map
在这里创建 user 跟 group 关联的数据 否则是无法登陆的。