Are you just looking to have the logouthash in the Links pages? It's easy enough to get this using a global like so, call it vb_logouthash:
my $user = 'yourDBusername';
my $pass = 'yourDBpassword';
my $host = 'localhost';
my $db = 'yourBname';
my $vb_id = $USER->{vbID};
my $query = qq{SELECT salt FROM user WHERE userid='$vb_id'};
my $dbh = DBI->connect ("DBI:mysql:host=$host;database=$db",$user, $pass,{ PrintError => 1, RaiseError => 1 } )
|| die "ERROR: Can't connect";
my $sth = $dbh->prepare($query) || die("$DBI::errstr");
$sth->execute();
my $usersalt = $sth->fetchrow;
use Digest::SHA1 qw(sha1_hex);
my $logouthash = sha1_hex($vb_id . sha1_hex($usersalt) . sha1_hex('Your VB license number'));
$logouthash ? return $logouthash : return '0';
}
You need to add a column to the User table to store the user ID from vBulletin - you can find it dynamically by looking up the username but we use the vbID in Links a lot so we added that field. It's a simple modification to the Auth_vBulletin plugin to insert this value when the user is created (let me know if you need the code).
To construct a logout link, do something like the following:
Code:
sub { my $user = 'yourDBusername';
my $pass = 'yourDBpassword';
my $host = 'localhost';
my $db = 'yourBname';
my $vb_id = $USER->{vbID};
my $query = qq{SELECT salt FROM user WHERE userid='$vb_id'};
my $dbh = DBI->connect ("DBI:mysql:host=$host;database=$db",$user, $pass,{ PrintError => 1, RaiseError => 1 } )
|| die "ERROR: Can't connect";
my $sth = $dbh->prepare($query) || die("$DBI::errstr");
$sth->execute();
my $usersalt = $sth->fetchrow;
use Digest::SHA1 qw(sha1_hex);
my $logouthash = sha1_hex($vb_id . sha1_hex($usersalt) . sha1_hex('Your VB license number'));
$logouthash ? return $logouthash : return '0';
}
You need to add a column to the User table to store the user ID from vBulletin - you can find it dynamically by looking up the username but we use the vbID in Links a lot so we added that field. It's a simple modification to the Auth_vBulletin plugin to insert this value when the user is created (let me know if you need the code).
To construct a logout link, do something like the following:
Code:
<a href="/forums/login.php?do=logout&logouthash=<%vb_logouthash%>">Logout</a>