Re: problem of nesting includes...
| From: | Christian Dechery | Date: | Sun, 14 Oct 2001 18:04:05 +0000 |
| Subject: | Re: problem of nesting includes... | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-71038@lists.php.net to get a copy of this message | ||
I'm using a solution that uses the dir in the drive... I use something called "include.conf.php" that is a file that contains only something like:
define("INCLUDE_DIR","C:/Apache/htdocs/vitrine");
and in all my files I require("include.conf.php") or require("../../include.conf.php"); or whatever... depending on the dir the file is in...
so this file (include.conf..) cannot be ANYWHERE but the root of-the-script... as long as it stays there and no file in the script moves its directory everthing works fine...
I know it's not a perfect solution... but at least it has the one property I'm looking for: it's 100% generic... and web-server-configuration-free...
:)
At 13:25 14/10/2001 -0500, you wrote:
Yes, I was talking root of the drive, not the web-server. This is the way I do it. If you are worried about security check out the safe-mode and safe-dir settings detailed at the php site somewhere. for instance, I can't include files outside of my virtual directory, even though I include them from the drive root. Matt. ----- Original Message ----- From: "Christian Dechery" <cdechery@easynet.com.br> To: "Matt Friedman" <matt@sprynewmedia.com> Sent: Sunday, October 14, 2001 12:19 PM Subject: Re: [PHP] problem of nesting includes... from what I've understand... you cannot do include("/dir/include/somefile.inc"); unless /dir is really the root of your drive... and not the root of your WEBServer... which is the real problem... if you could include using absolute path with webserver there would be no trouble at all... At 13:10 14/10/2001 -0500, Matt Friedman wrote:_____________________________ . Christian Dechery . . Gaita-L Owner / Web Developer . . http://www.webstyle.com.br . . http://www.tanamesa.com.brSetting the include path is good because you end up including all filesfrom"/" which you should be doing anyway. Then, whenever you include a file,thefile's "file relative" placement in the directory structure isirrelevant.All files are referenced from "/". (Or C:\ on windows or whatever) It's the same with using SSI's. You should always use virtual= instead of file= You'll save yourself a lot of trouble by doing this properly in the first place. Not a fan of nested includes anyway. You should be able to change this config by using ini_set. http://www.php.net/manual/en/function.ini-set.php Try to avoid .htaccessforthe reasons you mentioned plus ini_set should be quicker. If you can't or won't set your include path, include all files with thepathstarting from "/" and you won't have problems. Matt. ----- Original Message ----- From: "Christian Dechery" <cdechery@easynet.com.br> To: "Christian Reiniger" <creinig@mayn.de>; <php-general@lists.php.net> Sent: Sunday, October 14, 2001 10:53 AM Subject: Re: [PHP] problem of nesting includes...ofAt 13:20 13/10/2001 +0200, Christian Reiniger wrote:On Thursday 11 October 2001 04:15, Christian Dechery wrote:We ran a serious thread about "nested includes()" and I saw a lotbutpseudo-solutions... and I've just implemented one of them which I think is the best...tought...while I was doing it I realised it is more 'pseudo' than Iithave aworked finally.... but this is what I've figured: MAIN INCLUDE PROBLEM: - if a file "a" includes "b" and "b" includes "c"... "c" won'tarepath relative to "b"... so it won't work... (unless of course theyfilesit'sall in the same dir) there's no 100% safe solution to work around nested includes with PHP... right? there's no way you can assure in every file, that includes another and another (and so on) in different dirs... thatallways safe and you won't run into the MAIN INCLUDE PROBLEM....Um, why not simply set PHP's include_path properly? I'm includingtowildly 'round the place and never had any problems with it.if I had: /vitrine /vitrine/adm /vitrine/include /vitrine/templatesphp_value include_dir = .:/xyz/vitrine/adm:/xyz/vitrine/include:/xyz/vitrine/templates You then only have to take care that includes' names/paths relativewithoutdoesn'tthese include dirs don't overlap in a harmful way.what if I don't have permissions to change any configs in PHP??? Itsound like a great solution.... one should be able to include()someonehaving to alter any server settings... in my case, I run the server, so there's no prob... but what ifininstalls my script on a webhost that doesn't allow .htaccess, runs PHPproblem?safe-mode and all that? how would we solve the 'nested include()'php-list-admin@lists.php.netIt has to be 100% generic, or it's not a solution... _____________________________ . Christian Dechery . . Gaita-L Owner / Web Developer . . http://www.webstyle.com.br . . http://www.tanamesa.com.br -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail:_____________________________ . Christian Dechery . . Gaita-L Owner / Web Developer . . http://www.webstyle.com.br . . http://www.tanamesa.com.br