PDA

View Full Version : vB functions in non vb pages.


Darkling
12-21-2003, 12:31 PM
I'm having trouble including vB files in pages outside the vB directory.
When those included pages themselves include other pages I get errors.

e.g.

A page on my site may need search functions so I add:

chdir('forums');
include('./global.php');
require_once('./includes/functions_search.php');
chdir('../');

I then get an error like:

Warning: fetch_search_forumids(./includes/functions_misc.php): failed to open stream: No such file or directory in /hsphere/local/home/neocivit/darkdelight.net/forums/includes/functions_search.php on line 561

Fatal error: fetch_search_forumids(): Failed opening required './includes/functions_misc.php' (include_path='.:/usr/local/lib/php') in /hsphere/local/home/neocivit/darkdelight.net/forums/includes/functions_search.php on line 561

Can you help me fix this?

Thanks.

MindTrix
12-26-2003, 05:17 PM
Im guessing your running vB3 GAMMA? If thats the case im not sure if we can help you here as vB3 hacking etc is not allowed until RC1

Darkling
12-26-2003, 07:24 PM
Im guessing your running vB3 GAMMA? If thats the case im not sure if we can help you here as vB3 hacking etc is not allowed until RC1
Hi MindTrix.

This is a bit of a grey area.
I would not call this vB hacking as I have not altered vB's files in the slightest.
All I have done is included them wholesale in other pages on my site.

Anyway, I found out what was going wrong
I used chdir('forums'); to change to the directory with all the vB files,
then require_once('./includes/functions_search.php'); or what ever other file had the
vB stuff I wanted,
and finally chdir('../'); to get back to the directory above.

What happened was that when functions in the included vB files later tried to include other vB files the chdir('../'); had already taken effect and vB's relative links were broken.

What I found works is to change to the vB directory and stay there, Only changing to other directories to include other scripts and returning to the vB directory.
Combined with setting the base tag to the vB directory and addressing files from the sites root with a preceding /


Never mind, I think I got this sorted now, but thanks anyway.

MindTrix
12-26-2003, 07:28 PM
Glad to hear you sorted it out ;)

I understand what you was saying though, its just that because it involved Editing and vB3 GAMMA im not sure whether it was allowed here etc :) Who knows i could be wrong. Bottom line is you got it all by youself, its more rewarding that way anyway ;)