vBulletin as login for entire website (edit: a cer

2019-07-18 12:01发布

问题:

I've come up against a bit of a brick wall in the vBul forums on how to do this, so I thought I'd ask the forum that's never let me down.

Does anyone know of a simple way, on an EXTERNAL page to the forum, to take in whether the user is logged in, and possibly extract their user ID while it's at it? I've seen a few plug ins with that intension but all seem to have fallen out of support, and vBul 4.1 seems to have "broken" them as a result.

Any and all help appreciated. Once I have those too things I can write scripts myself that work with the database. I just need those two variables :)

I've made SOME progress anyway. On the alternate pages the following code seems to link into vBuls user manager:

<? ini_set('display_errors', 1);
error_reporting(E_ALL); ?>
<? chdir("/home/sites/<sitename>/public_html/forum/");
require("./global.php"); ?>
<? echo "Your vBul user id is: ".$vbulletin->userinfo['userid']." and your username is ".$vbulletin->userinfo['username'].""; ?>
<? chdir("/home/sites/<sitename>/public_html/dev"); ?>

I say its connecting in ok because it returns "Your vBul user id is: 0 and your username is Unregistered" where as if it wasn't it would return to blank spaces. The problem is its returning 0 and unregistered despite my definitely being logged in on the forums.

Any suggestions?

回答1:

Just realised no one ever answer this, so here is my own solution:

#grab global.php to access vbuls user systems
chdir("../forum/");
require("./global.php");
require_once('includes/functions_login.php');

#sanatize all variables for easier use
$username = $vbulletin->userinfo['username'];
$userid = $vbulletin->userinfo['userid'];
$loggouthash = $vbulletin->userinfo['logouthash'];
chdir("../dev/");

This sorts it nicely, I know I dont NEED to sanatize the variables like that, but its a personal preference.