Log in

View Full Version : using global.php from non-vb page


rsjpp
07-16-2005, 11:45 PM
I have a custom application in which I want to make use of VB's user authentication.

I tried including global.php and checking for bbusrinfo[userid] variable etc..

But since vBulletin is using includes like below
("./includes/xxx.php")
the scripts in nonVb folders are failing in includes...
Had vBulletin used ("includes/xxx.php") without the preceding "." for current directory, it would have worked.

Can you help me how I can check if a user is already logged in from my custom script?

Thanks

Adrian Schneider
07-16-2005, 11:52 PM
Use chdir('./path/to/your/forums'); so from then on all the paths are from vbulletins directory

rsjpp
07-17-2005, 02:29 PM
Thankyou Specialist, it resolved the include issue.

One more question..I have my code snippet like this..
<?
chdir("../Forums/");
include('global.php');
if($bbuserinfo[userid]) {
//my application
}
else {
print_please_login();
}
?>

Is this a good way to do? Or any other better ways exist?

Also, how can I select a specific style from the code here?
I want my Login page/error Page to display from a custom Style. not from the default style. Can I do that by setting some variable here ?

Thank you

Adrian Schneider
07-18-2005, 01:45 AM
Make a plugin in the hook "style_fetch" and put the following in it:
if (somecondition == true)
{
$styleid = x;
}
Where X is the style you want to use for the error message.

So maybe in your else{

define('iwantanotherstyle', true);
print_no_permission();

Then you can use the condition if (iwantanotherstyle == true) above.