diff --git a/drupalvb.admin-pages.inc b/drupalvb.admin-pages.inc old mode 100644 new mode 100755 index 92a8453..6fcbe0d --- a/drupalvb.admin-pages.inc +++ b/drupalvb.admin-pages.inc @@ -20,12 +20,27 @@ function drupalvb_settings_integration() { $form = array(); + // In 3.8.4 PL2 vBulletin stopped using license number as salt for password + // and began using a constant named COOKIE_SALT. + $form['drupalvb_settings']['drupalvb_version'] = array( + '#type' => 'select', + '#title' => t('vBulletin version'), + '#default_value' => variable_get('drupalvb_version', 3), + '#description' => 'Select the version that most closely matches your vBulletin installation.', + '#options' => array( + '3.0' => t('3.0'), + '3.8' => t('3.8.4 PL2'), + '4.0' => t('4.0'), + ), + + ); + $form['drupalvb_license'] = array( '#type' => 'textfield', - '#title' => t('vBulletin license number'), + '#title' => t('vBulletin license number(up to version 3.8.4 PL2) or cookie salt (version 3.8.4 PL2 up)'), '#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' => t('For versions below 3.8.4 PL2 enter your vBulletin license number, which can be found at the top of any PHP file of vBulletin. For version 3.8.2 PL2 and above enter your vBulletin cookie salt, which can be found defined in the includes/functions.php 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_dual_login'] = array( diff --git a/drupalvb.inc b/drupalvb.inc old mode 100644 new mode 100755 diff --git a/drupalvb.inc.php b/drupalvb.inc.php old mode 100644 new mode 100755 index 349b759..49ce23f --- 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; @@ -394,4 +391,16 @@ function drupalvb_htmlspecialchars($text) { $text = preg_replace('/&(?!#[0-9]+|shy;)/si', '&', $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 (variable_get('drupalvb_version', 3) >= 4) { + $cookie_prefix .= '_'; + } + return $cookie_prefix; +} diff --git a/drupalvb.module b/drupalvb.module old mode 100644 new mode 100755 index e03c263..acc00ad --- a/drupalvb.module +++ b/drupalvb.module @@ -470,6 +470,12 @@ function drupalvb_user_delete($account) { */ function drupalvb_login() { global $user; + // If request is coming from vb4 then set values to vb3 values for auth + if (variable_get('drupalvb_version', 3) >= 4) { + $_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);