diff --git a/drupalvb.admin-pages.inc b/drupalvb.admin-pages.inc index 92a8453..75b65d4 100644 --- a/drupalvb.admin-pages.inc +++ b/drupalvb.admin-pages.inc @@ -19,13 +19,26 @@ function drupalvb_settings_integration() { } $form = array(); + $vb_config = drupalvb_get_config(); + + // In version 3.8.4 vBulletin stopped using license number as salt for + // password and began using a constant named COOKIE_SALT. + if (version_compare($vb_config['version'], '3.8.4', '>=')) { + $title = t('vBulletin cookie salt'); + $description = t('Enter your vBulletin cookie salt, which can be found in the file @file of vBulletin. This is required to generate proper session ID hashes for cookies.', array( + '@file' => 'includes/functions.php' + )); + } + else { + $title = t('vBulletin license number'); + $description = t('Enter your vBulletin license number, which can be found at the top of any PHP file of vBulletin. This is required to generate proper session ID hashes for cookies. Please note that this is not your customer number.'); + } $form['drupalvb_license'] = array( '#type' => 'textfield', - '#title' => t('vBulletin license number'), + '#title' => $title, '#default_value' => variable_get('drupalvb_license', ''), - '#size' => 20, - '#description' => t('Enter your vBulletin license number, which can be found at the top of any PHP file of vBulletin. This is required to generate proper session id hashes for cookies. Please note that this is not your customer number.'), + '#description' => $description, ); $form['drupalvb_dual_login'] = array( diff --git a/drupalvb.inc.php b/drupalvb.inc.php index 5f14494..84241b8 100644 --- a/drupalvb.inc.php +++ b/drupalvb.inc.php @@ -24,10 +24,8 @@ function drupalvb_set_login_cookies($userid) { return FALSE; } - $vb_config = drupalvb_get('config'); $vb_options = drupalvb_get('options'); - - $cookie_prefix = (isset($vb_config['Misc']['cookieprefix']) ? $vb_config['Misc']['cookieprefix'] : 'bb'); + $cookie_prefix = drupalvb_get_cookieprefix(); $cookie_path = $vb_options['cookiepath']; $now = time(); $expire = $now + (@ini_get('session.cookie_lifetime') ? ini_get('session.cookie_lifetime') : 60 * 60 * 24 * 365); @@ -67,10 +65,9 @@ function drupalvb_set_login_cookies($userid) { * @see drupalvb_logout(), drupalvb_user_logout() */ function drupalvb_clear_cookies($userid = NULL) { - $vb_config = drupalvb_get('config'); $vb_options = drupalvb_get('options'); - $cookie_prefix = (isset($vb_config['Misc']['cookieprefix']) ? $vb_config['Misc']['cookieprefix'] : 'bb'); + $cookie_prefix = drupalvb_get_cookieprefix(); $cookie_path = $vb_options['cookiepath']; $expire = time() - 86400; @@ -419,3 +416,17 @@ function drupalvb_htmlspecialchars($text) { return str_replace(array('<', '>', '"'), array('<', '>', '"'), $text); } +/** + * Get vB cookie prefix. + */ +function drupalvb_get_cookieprefix() { + $vb_config = drupalvb_get('config'); + $cookie_prefix = (isset($vb_config['Misc']['cookieprefix']) ? $vb_config['Misc']['cookieprefix'] : 'bb'); + + // Version 4 began using an underscore following the prefix. + if(version_compare($vb_config['version'], 4, '>=')) { + $cookie_prefix .= '_'; + } + + return $cookie_prefix; +} diff --git a/drupalvb.module b/drupalvb.module index e03c263..07293c1 100644 --- a/drupalvb.module +++ b/drupalvb.module @@ -471,6 +471,14 @@ function drupalvb_user_delete($account) { function drupalvb_login() { global $user; + // Starting from 4.x, vB uses 'vb_login_*' login form input names, whereas + // earlier versions used 'name' and 'pass'. + if (isset($_POST['vb_login_username']) && isset($_POST['vb_login_password'])) { + $_POST['name'] = $_POST['vb_login_username']; + $_POST['pass'] = $_POST['vb_login_password']; + unset($_POST['vb_login_username'], $_POST['vb_login_password']); + } + if ($_POST['name']) { $form_state = array('values' => $_POST); if ($user->uid) {