ryan.od Posted November 14, 2006 Share Posted November 14, 2006 OK, I have searched and searched for an answer to this problem and have never come up with a solution (although I've seen many posts and pages about it). PLEASE, PLEASE, PLEASE HELP!!1. I cannot use absolute paths as this needs to be a generic solution. As such, this is not an option.2. I have tried to use ../ to move up a level, but I get the following error: open_basedir restriction in effect. I would change this setting on the server, but I understand this is a security no-no. Not an option.3. I have tried using $_SERVER['DOCUMENT_ROOT'] to determine the root and concatenate the file location onto it, but again, I understand this is a bad approach (treated differently by Windows based and Linux based servers). Again, not an option.4. I tried to use ./ as I read somewhere this goes to the root folder? Doesn't work for me. Not an option.I am out of ideas and possibilities. I know this is not a difficult issue. Seems to me every CMS out there does this. How the heck do they do it?? Thanks to whoever has the magic answer!!RyanOD Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 14, 2006 Share Posted November 14, 2006 [quote]4. I tried to use ./ as I read somewhere this goes to the root folder? Doesn't work for me. Not an option.[/quote]That is incorrect (At least I think it is):Try this:/ (no period before it.) Quote Link to comment Share on other sites More sharing options...
btherl Posted November 14, 2006 Share Posted November 14, 2006 I suggest you remove the open_basedir restriction, and do your own checks to ensure that the files you include are "ok". Programming always involves a tradeoff between security and flexibility, and in this case you need a little more flexibility."./" goes to the current directory, not the root directory. "/" is the root directory.You can find your current directory with getcwd(), if that helps. Quote Link to comment Share on other sites More sharing options...
ryan.od Posted November 14, 2006 Author Share Posted November 14, 2006 Hmmm, well, I decided I should check and see if my problem might be with how I included the files rather than a problem with the server. So I created a file that I put in its own folder that was at the same level as several other folders. I then had to use include('../folder/file') to include a file out of a folder on the same level (hope that makes sense).It worked fine.As such, I think my problem might be with how I am including things. However, I have tried all of the following:menu/menu.php/menu/menu.php../menu/men.php./menu/menu.php (?)menu.php/menu.php../menu.php. . .and none of them work! Uggh!!When you are including several files and some of those files include other files, where does your path reference from? Is it the initial file that starts the trail of includes or is it the file location where the include is actually written?Also, is there a general rule for this type of including? i.e. embedded include statements = YOU FEEL SHAME!! ??Thanks to all.Ryan OD Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 14, 2006 Share Posted November 14, 2006 I would recommend starting all your files with the / and working from the root directory to the file. I have never had a problem when I do that. Quote Link to comment Share on other sites More sharing options...
btherl Posted November 14, 2006 Share Posted November 14, 2006 It's referenced from the current file. Which makes sense, since you may include a file from many other files in many other locations, particularly shared libraries. Quote Link to comment Share on other sites More sharing options...
ryan.od Posted November 14, 2006 Author Share Posted November 14, 2006 OK, problem solved (for now).Thanks to all for your help.For anyone who cares (or has a similar issue), the solution I settled on was to declare $root at the beginning of every main file (index, blog, products, etc.) that way, all the included files would have access to the pathway to the root directory. Then, each include became, include ("$root"."folder/file.php"); and all you have to do is change the $root from "" to ".." for all files that are one level down and so on and soforth. It might not be an elegant solution, but it does work.I think this is what The Little Guy was recommending. I saw it somewhere else that escapes me now as well.Thanks again to everyone.Ryan OD Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.