PDA

View Full Version : How to include vB3 into a file outside of vB3 folder?



Gary King
Mon 1st Sep '03, 2:01pm
How can I include vBulletin 3's functions, variables, etc. into a file outside of vB3?

In vB 2, I used to be able to just add require("./forum/global.php"); then that would work, but now, it's a totally different story. If I try including the global.php, then the other relative paths will have problems, such as the require_once('./includes/init.php'); in global.php or the require_once('./includes/config.php'); in includes/init.php

Any ideas?
Thanks in advance!

Scott MacVicar
Mon 1st Sep '03, 2:15pm
you'l need to use chdir to change the directory to the forums directory then
require_once('./global.php');

then chdir back to the one before if need be.

Gary King
Mon 1st Sep '03, 2:22pm
Ah yes, thanks Scott.

trackpads
Mon 1st Sep '03, 9:05pm
Gary,

Can you give me an example of how you do this? I have been trying to accomplish something like this aswell but am nowhere near as smart ;-)

squall14716
Tue 2nd Sep '03, 8:32am
Gary,

Can you give me an example of how you do this? I have been trying to accomplish something like this aswell but am nowhere near as smart ;-)

<?php
chdir('./forums');
require_once('./global.php');
chdir('./../');
?>

scri
Fri 5th Sep '03, 6:04am
forgive me if its obvious, but what kind of things can you do by accessing the vbulletin functions from external pages? I'm pretty interested in what that can do incase it would be off use for my site.

N9ne
Fri 5th Sep '03, 2:37pm
forgive me if its obvious, but what kind of things can you do by accessing the vbulletin functions from external pages? I'm pretty interested in what that can do incase it would be off use for my site.
There's many things, mainly for convenience, maybe they'd want to easily connect to the database, or use vBulletin's functions, etc. many options :). Sometimes it's to display statistics like # of members :).

Trigunflame
Wed 26th Nov '03, 8:12am
<?php
chdir('./forums');
require_once('./global.php');
chdir('./../');
?>
actually thats all right except last part

<?php
chdir("./location');
require_once("./global.php");
chdir("../");
?>

using ./../ is redundant only ../ is needed.

trackpads
Wed 26th Nov '03, 8:29am
actually thats all right except last part

<?php
chdir("./location');
require_once("./global.php");
chdir("../");
?>

using ./../ is redundant only ../ is needed.

I use it for requiring people to be logged in/registered before viewing other pages of my site. for example I have a fact sheets database (really a modded phpbb) and I used this code similar to make folks log into VB first-

http://www.trackpads.com/factsheets

You have to admit there is something funny about requiring a VB registration to see a phpBB :)

Gary King
Wed 26th Nov '03, 9:17am
actually thats all right except last part

<?php
chdir("./location');
require_once("./global.php");
chdir("../");
?>

using ./../ is redundant only ../ is needed.
Or you can use just
chdir(".."); :p

Trigunflame
Wed 26th Nov '03, 9:21am
true..but i prefer trailing slash :)