2012-01-04, 10:27 PM
Hi,
currently i'm writing a wbblite 1.0.2 to mybb 1.6.4 converter.
At the moment i'm able only to convert the users, but i'm having problems with their passwords.
As fas as i can tell the wbblite passwords are md5 coded (e.g. test123 -> cc03e747a6afbbcbf8be7668acfebee5).
How do i get mybb to accept or to update the old md5-passwords?
After i copied the userfields i tried to do something like that:
But i'm still unable to login.
Because i'm not using the mybb functions i got in the same file this code:
Got it working myself. A night of sleep does wonders
For anyone who is interested. This was the solution:
currently i'm writing a wbblite 1.0.2 to mybb 1.6.4 converter.
At the moment i'm able only to convert the users, but i'm having problems with their passwords.
As fas as i can tell the wbblite passwords are md5 coded (e.g. test123 -> cc03e747a6afbbcbf8be7668acfebee5).
How do i get mybb to accept or to update the old md5-passwords?
After i copied the userfields i tried to do something like that:
$sql = mysql_query("SELECT * FROM xxx_users");
while($passform = mysql_fetch_assoc($sql))
{
$password = "$passform[password]";
$salt = generate_salt();
$newpassword = md5(md5($salt).md5($password));
$insert = mysql_query("UPDATE xxx_users
SET
password = '$newpassword',
salt = '$salt'
WHERE
uid = ".$passform['uid']."
");
if(!$insert)
{
printf("Error: Cannot update password.");
echo "<br />";
}
}
But i'm still unable to login.
Because i'm not using the mybb functions i got in the same file this code:
function random_str( $length ) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$size = strlen( $chars );
for( $i = 0; $i < $length; $i++ ) {
$str .= $chars[ rand( 0, $size - 1 ) ];
}
return $str;
}
function generate_salt()
{
return random_str(8);
}
Got it working myself. A night of sleep does wonders
For anyone who is interested. This was the solution:
$password = "$passform[password]";
$salt = generate_salt();
$newpassword = md5(md5($salt).$password);