ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Importing users from vbulletin..

January 18, 2011 12:40pm

Subscribe [4]
  • #1 / Jan 18, 2011 12:40pm

    BilldaCat

    6 posts

    I have several thousand users I want to import from vbulletin, but am not sure how to go about it given vbulletin’s password encryption (salted md5s) and getting them into EE2, which uses SHA1.

    Can anyone offer any advice on how to best get the user records over?

    Thanks!

  • #2 / Jan 19, 2011 1:14am

    John Henry Donovan

    12339 posts

    Have a look at vBee which may help. I have never used it but it looks promising

  • #3 / Jan 19, 2011 10:37am

    BilldaCat

    6 posts

    I’m actually looking to scrap VB, I just want to import the users over. 

    I’m thinking I’ll have to dump the data out of VB into an XML format and import into EE, specify the pw type as md5, and hack the EE login code with the right hash for it to calculate correctly—once a user logs in that way, I’ve read that EE converts their password to a SHA1 password, and stores that.

    My question is, where is this code at in EE?  Can someone point me to the right file?

  • #4 / Jan 19, 2011 11:22am

    BilldaCat

    6 posts

    Nevermind, I found it, worked perfectly.

    For those who stumble upon this in the future, here’s what I did:

    Created a custom member field to store the vbulletin salt, each user has a different salt (column is ‘salt’ in the vb_user table).

    Imported users via XML, make sure to set the password types to md5.

    Edit: /system/expressionengine/modules/member/mod.member_auth.php

    find the member_login function.. added/changed these lines.  not the best code, I just wanted to hammer it out fast.  could be cleaned up.

    $mid = $query->row('member_id');
    
    // grab vbulletin hash
                    $lookup_vb = mysql_query("SELECT m_field_id_3 from exp_member_data where member_id = $mid");
                    if ($vbr = mysql_fetch_array($lookup_vb)) {
                            $vb_salt = $vbr['m_field_id_3'];
                    } else {
                            echo mysql_error();
                    }
    
                    $vb_password = md5(md5($this->EE->input->post('password')).$vb_salt);
    
                    if ($query->row('password') != $password)
                    {
                            // To enable backward compatibility with pMachine we'll test to see
                            // if the password was encrypted with MD5.  If so, we will encrypt the
                            // password using SHA1 and update the member's info.
    
                            $password = do_hash($this->EE->input->post('password'), 'md5');
    
                            if ($query->row('password')  == $password)
                            {
                                    $password = do_hash($this->EE->input->post('password'));
    
                                    $sql = "UPDATE exp_members
                                                    SET     password = '".$password."'
                                                    WHERE  member_id = '".$query->row('member_id') ."' ";
    
                                    $this->EE->db->query($sql);
                            } elseif ($vb_password == $query->row('password')) {
    // check for vbulletin hash
                                    $password = do_hash($this->EE->input->post('password'));
    
                                    $sql = "UPDATE exp_members
                                                    SET     password = '".$password."'
                                                    WHERE  member_id = '".$query->row('member_id') ."' ";
    
                                    $this->EE->db->query($sql);
                            }
                            else
                            {
                                    /** ----------------------------------------
                                    /**  Invalid password
                                    /** ----------------------------------------*/


    Hope this helps someone else down the road.

  • #5 / Jan 19, 2011 3:41pm

    Ingmar

    29245 posts

    Thanks, I’m just moving this to the CodeShare Corner.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases