Re: problem of nesting includes...

From: 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:
Setting the include path is good because you end up including all files
from
"/" which you should be doing anyway. Then, whenever you include a file,
the
file's "file relative" placement in the directory structure is
irrelevant.
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 .htaccess
for
the reasons you mentioned plus ini_set should be quicker. If you can't or won't set your include path, include all files with the
path
starting 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...
At 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 lot
of
pseudo-solutions... and I've just implemented one of them which I think is the best...
but
while I was doing it I realised it is more 'pseudo' than I
tought...
it
worked finally.... but this is what I've figured: MAIN INCLUDE PROBLEM: - if a file "a" includes "b" and "b" includes "c"... "c" won't
have a
path relative to "b"... so it won't work... (unless of course they
are
all 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... that
it's
allways safe and you won't run into the MAIN INCLUDE PROBLEM....
Um, why not simply set PHP's include_path properly? I'm including
files
wildly 'round the place and never had any problems with it.
if I had: /vitrine /vitrine/adm /vitrine/include /vitrine/templates
php_value include_dir = .:/xyz/vitrine/adm:/xyz/vitrine/include:/xyz/vitrine/templates You then only have to take care that includes' names/paths relative
to
these include dirs don't overlap in a harmful way.
what if I don't have permissions to change any configs in PHP??? It
doesn't
sound like a great solution.... one should be able to include()
without
having to alter any server settings... in my case, I run the server, so there's no prob... but what if
someone
installs my script on a webhost that doesn't allow .htaccess, runs PHP
in
safe-mode and all that? how would we solve the 'nested include()'
problem?
It 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:
php-list-admin@lists.php.net
_____________________________ . Christian Dechery . . Gaita-L Owner / Web Developer . . http://www.webstyle.com.br . . http://www.tanamesa.com.br
_____________________________ . Christian Dechery . . Gaita-L Owner / Web Developer . . http://www.webstyle.com.br . . http://www.tanamesa.com.br

« previous php.general (#71038) next »