<?php
require_once(DIR . '/includes/drupaltin_config.php');
require_once($drup_main_dir . '/includes/bootstrap.inc');
$connector = new DbConnector();
$drupaltin_logout_cwd = getcwd();
chdir($drup_main_dir);
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
chdir($drupaltin_logout_cwd);
/**
* Dump the MD5 of the password the user entered into the Drupal database since vB doesn't store the password in pure MD5
*/
$dvb_md5 = md5($vbulletin->GPC['vb_login_password']);
$UpdateQuery = sprintf("UPDATE users SET pass = '%s' WHERE name = '%s'",
mysql_real_escape_string($dvb_md5),
mysql_real_escape_string($vbulletin->GPC['vb_login_username']));
$connector->query($UpdateQuery);
/**
* Start the Drupal session and push a cookie
*/
$name = $vbulletin->GPC['vb_login_username'];
$pass = $vbulletin->GPC['vb_login_password'];
user_authenticate($name, $pass);
// Sha1 the created
$drupaltin_login_fetch = sprintf("SELECT created FROM users WHERE name = '%s'",
mysql_real_escape_string($vbulletin->GPC['vb_login_username']));
$drupaltin_login_connect = $connector->query($drupaltin_login_fetch);
$drupaltin_login_created = mysql_fetch_row($drupaltin_login_connect);
$drupaltin_login_hash = sha1($drupaltin_login_created['0']);
// Setup for external cookie
$_POST['drupaltin_username'] = $vbulletin->GPC['vb_login_username'];
$_POST['drupaltin_password'] = $vbulletin->GPC['vb_login_password'];
$_POST['drupaltin_login_hash'] = $drupaltin_login_hash;
$drupaltin_login = include $drup_main_http . '/drupaltin_login.php';
if ($drupaltin_login != '1') {
echo "erm, could not set correct Drupal cookies. Notify the Administrator please!";
exit;
}
?>