PDA

View Full Version : Merging two vB3 forums - import avatars question - I have stuck


Scandal
06-23-2019, 11:56 AM
Hello all! :)

I'm building my own vB3 merge tool for personal use since Impex is not compatible with PHP 7.

I have stuck to the following code.

We have a vB3 forum which saving the avatars on the database (source forum) and the destination forum which is saving the avatars on the file system.

// make connection with source forum database
$es = new mysqli('localhost', 'root', '', 'es_db');

// fetching users for merge == it takes also the avatar data
$users = $es->query("
SELECT _vbuser.*, customavatar.filename AS afilename, customavatar.filedata AS afiledata, customavatar.filedata_thumb AS afiledata_thumb,
customprofilepic.filename AS pfilename, customprofilepic.filedata AS pfiledata,
sigpic.filename AS sfilename, sigpic.filedata AS sfiledata
FROM _vbuser
LEFT JOIN _vbcustomavatar AS customavatar ON (_vbuser.userid = customavatar.userid)
LEFT JOIN _vbcustomprofilepic AS customprofilepic ON (_vbuser.userid = customprofilepic.userid)
LEFT JOIN _vbsigpic AS sigpic ON (_vbuser.userid = sigpic.userid)
ORDER BY _vbuser.userid
LIMIT ". intval($vbulletin->GPC['perpage']) ."
");

while ($user = $db->fetch_array($users))
{
$userdm = datamanager_init('User', $vbulletin, ERRTYPE_CP);
// doing things [...]
$userdm->pre_save();
$userid = $userdm->save();

// $userid is the new account userid on the destination forum // I want to get the Avatar data ("afiledata") and upload it to destination file system

// Converting FROM mysql TO fs
# !!!
$vbulletin->options['usefileavatar'] = true;
if (!empty($user['afiledata']))
{
$userpic = datamanager_init('Userpic_Avatar', $vbulletin, ERRTYPE_CP, 'userpic');
$userpic->set_condition("userid = " . $userid);
$userpic->setr('filedata', $user['afiledata']);
$pictureid = $userpic->save();
}
}


# !!! code is not working :( Any idea?