Click to See Complete Forum and Search --> : How can I get to a different folder tree from the main www directory?


Theremin
08-10-2007, 09:17 PM
I am trying to use a private directory that is outside the www directory on my server so I can keep some of my files seperate.

My code is working for the first include because it is a subfolder of the www folder, but the second two lines are not working because I don't know how to tell the server to start the path a couple of directories higher up the tree.

<?php include("htmlincludes/head.html"); ?>
<?php require_once("/home/https/private/include/head.php");
require_once("/home/https/private/include/login.php");
?>


I know you guys have the solution, so here I am again asking. :)

S!
Jason

NogDog
08-10-2007, 10:25 PM
Your syntax looks OK, but since I don't know the specifics of your directory structure and names, I can't comment on that.

Do you get any error messages? If so, copy-and-paste them here. If not, maybe you need to enable error message display:

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
// rest of code....

ghippleh
08-10-2007, 10:43 PM
perhaps the "/" in front of "home" is the problem

So perhaps use "home/...." instead of "/home/..."

hope this helps

felgall
08-10-2007, 11:36 PM
Another option is to try

require_once("../private/include/head.php");

Theremin
08-10-2007, 11:36 PM
hmm, seems like it is looking in the regular old httpdocs directory instead of going up the directory tree.

here are the errors:

<b>Warning</b>: main(home/private/include/headers.php): failed to open stream: No such file or directory in <b>/var/www/vhosts/recordingjunkie.com/httpdocs/testpage.php</b> on line <b>12</b><br />

<br />
<b>Fatal error</b>: main(): Failed opening required 'home/private/include/headers.php' (include_path='.:') in <b>/var/www/vhosts/recordingjunkie.com/httpdocs/testpage.php</b> on line <b>12</b><br />


thanks for the tip on error reporting nogdog :)

Jason

PS the folder structure is like this
httpdocs
-htmlincludes
private
-include

do if the indexfile that is making the call to the private folder actually resides in the httpdocs folder, it has to go up the directory tree and then back down the private folder branch. i know you all probably already understood me :P, but just in case what I am trying to do doesn't make sense, that is what I am attempting. :)

S!
Jason

Theremin
08-10-2007, 11:38 PM
here is an interesting error after trying Felgall's suggestion

main(): open_basedir restriction in effect



seems like maybe something might be disabled on my host? what do you all think?

Jason

NogDog
08-10-2007, 11:55 PM
here is an interesting error after trying Felgall's suggestion

main(): open_basedir restriction in effect



seems like maybe something might be disabled on my host? what do you all think?

Jason
Yep. That means that there is an open_basedir (http://us2.php.net/manual/en/features.safe-mode.php#ini.open-basedir) configuration in effect on your host, limiting which directories from which you are allowed to include files (or otherwise access them, such as via fopen()). Part of the error message should have told you what directories are allowed. Your include files will have to be in those directories or any sub-directories beneath them. The only way it can be changed is if the system admins will modify the open_basedir setting.

Theremin
08-11-2007, 12:02 AM
thanks all :) I have sent an email to see if I can get myself an allowed directory at the same level as my http directory.

S!
Jason

afigueroa
08-11-2007, 01:02 AM
$_SERVER['DOCUMENT_ROOT'] starts you off at the root of the web folder