MyBB Community Forums

Full Version: [Need help] wbblite 1.0.2 -> mybb 1.6.4
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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:
$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 Wink

For anyone who is interested. This was the solution:
$password = "$passform[password]";
$salt = generate_salt();
$newpassword = md5(md5($salt).$password);