include function and path question

Hi,

The code attached bellow is my file test.php. It works perfect if I use it inside /board/ folder.

If I move it to the root of my site (/public_html/ folder) then  get this error:


Warning: require(./includes/class_bootstrap.php) [function.require]: failed to open stream: No such file or directory in /home/eagle/public_html/board/global.php on line 15

This happens because global.php require other files that are located inside /board/includes/ ...

How can I manage this issue?
How can I make that all files required by global.php to be found inside /board/includes/ ? ...

Please help!
Thank you.
<?php
include('/home/user/public_html/board/global.php');
if($vbulletin->userinfo['userid'] > 0){
    echo '<a href="login.php?' . $session[sessionurl] . 'do=logout&amp;logouthash=' . $vbulletin->userinfo['logouthash'] . '">Logout</a>';
}
?>

Open in new window

FernanditosAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

OnALearningCurveCommented:
Hi Fernanditos,

Don't you just need to edit global.php to have the correct relevant paths to the files it is calling?

Mark.
FernanditosAuthor Commented:
I tried but there are hundreds of requires in vbulletin. Any other idea?
Beverley PortlockCommented:
Create a sub-folder in board called includes and make sure that the correct scripts are in there.

Another approach is to use ini_set and ini_get to change the include_path variable

ini_set( 'include_path', '.:/home/eagle/public_html/board/:/home/eagle/public_html/board/includes:' . ini_get('include_path') );

More at http://www.php.net/ini_set and http://www.php.net/ini_get
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

Beverley PortlockCommented:
FernanditosAuthor Commented:
I solved the problem with

chdir('/home/eagle/public_html/board'); before the include, it was magic, working like a charm.

Thank you.
ee_autoCommented:
Question PAQ'd and stored in the solution database.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.