It's not pretty, but I'm sure it can be easily tied into the existing conversion script (or hopefully one that works with 1.3 in the future).
Convert avatars (run this in the /img/avatars/ directory):
<?php
/* db info & connect */
$db_name = 'vbulletin_db';
$db_username = 'username';
$db_password = 'password';
$conn = mysql_connect(localhost, $db_username, $db_password);
mysql_select_db($db_name);
/* query */
$sql = "select userid, filedata, filename from customavatar where filename != ''";
$result = mysql_query($sql);
/* parse the rows for avatar information, default to jpg
/* and output in format "userid.format" - run this
/* script from within the img/avatars directory */
while($row = mysql_fetch_assoc($result)){
$file_type = explode(".", strtolower($row['filename']));
if($file_type[1] == null){ $file_type[1] = 'jpg'; }
if($file_type[1] == "jpeg"){ $file_type[1] = 'jpg'; }
$filename = $row['userid'].".".$file_type[1];
echo "Saving: ".$filename."...<br>";
$fp = fopen("./".$filename,"w");
fwrite($fp, $row['filedata']);
fclose($fp);
}
?>
I regret to say the code for the PM conversion is lost it seems, I probably overwrote the file when writing the avatar converter; however it was not difficult and I can probably throw it together in a few minutes when I have some time.
Here are the bits I modified in the login script to allow for vBulletin passwords:
First, I added a new column to the users table; called vb_salt. I then did a query of:
UPDATE punbb.users SET vb_salt = (select userid, salt from vb.user where users.id = user.userid), punbb.password = (select user.password from vb.user where users.id = user.userid)
This pulls the old password and the salt from vBulletin's database over to the punBB database on a per-userid basis. Once this was done, I first modified the login code in login.php
// Get user info matching login attempt
$query = array(
'SELECT' => 'u.id, u.group_id, u.password, u.salt, u.vb_salt',
'FROM' => 'users AS u'
);
..to include the new column vb_salt that was added. The only other change I made was to the actual login logic:
$authorized = false;
if (!empty($db_password_hash))
{
$sha1_in_db = (strlen($db_password_hash) == 40) ? true : false;
/** include vb salt stuff here - eventually everyone should
/* migrate to the sha1/salted password that punbb supports natively */
$form_password_hash = forum_hash($form_password, $salt);
if ($sha1_in_db && $db_password_hash == $form_password_hash)
$authorized = true;
else if ((!$sha1_in_db && $db_password_hash == md5(md5($form_password).$vb_salt)) || ($sha1_in_db && $db_password_hash == sha1($form_password)))
{
$authorized = true;
$salt = random_key(12);
$form_password_hash = forum_hash($form_password, $salt);
// There's an old MD5 hash or an unsalted SHA1 hash in the database, so we replace it
// with a randomly generated salt and a new, salted SHA1 hash
$query = array(
'UPDATE' => 'users',
'SET' => 'password=\''.$form_password_hash.'\', salt=\''.$forum_db->escape($salt).'\'',
'WHERE' => 'id='.$user_id
);
($hook = get_hook('li_login_qr_update_user_hash')) ? eval($hook) : null;
$forum_db->query_build($query) or error(__FILE__, __LINE__);
}
}
Basically the old algorithm used in punBB is replaced with vBulletin's hashing algorithm. Once a user logs in the logic detects that an MD5 hash is used and generates the SHA1 hash.
I almost didn't switch to punBB because the existing (outdated!) migration script did not support migration of passwords, had I not found this method of utilizing them I would never have switched (too much of a hassle to ask users to 'reset' their password).
Edit: Upon checking the conversion script it looks like there is a 'removed' function to migrate PMs and polls. Wish I'd have known that existed!