Re: problem with using include files

From: Date: Tue, 27 Aug 2002 21:46:34 +0000
Subject: Re: problem with using include files
Groups: php.general 
Request: Send a blank email to php-general+get-114288@lists.php.net to get a copy of this message
>The problem I have when using include files is the path to different parts >of the web site. > >To Explain: > >I have a header.inc file in an inc directory: > >root > |___inc > | |___header.inc You may want to move your include files outside the web tree so that malicious users can't surf directly to them and wreak havoc. > | > |___images > | |___topbar_01.gif > | > |___faq > |___faq.php > >In the header.inc file there is: ><img name="topbar_01" src="images/topbar_01.gif" width=783 height=56> > >now when I include this into the faq.php file I do not display the >topbar_01.gif as the path to topbar_01.gif is now >/root/faq/images/topbar_01.gif > >I would like to be able to use a header.inc file so that I can update the >entire site simply. The include file and PHP are irrelevant here -- You'd have the same problem with this directory structure and pure HTML. You've buried faq.php and are trying to use 'images/topbar_01.gif' when you really want '/images/topbar_01.gif' While the "rule" of not using absolute pathnames is Good, it's not Absolute. :-) Another possiblity (under Un*x) would be to symlink your images directory under your faq directory: cd ~/faq ln -s ../images images Or maybe you don't want faq.php buried down inside faq anyway... I dunno what else you have, but it seems like you're getting a little silly burying faq.php inside '/faq/' when you're probably not going to have a whole lot of files inside '/faq/' If you start getting that many FAQs, you should throw them in a database and have faq.php be a single file that reads FAQs out of the database on demand. :-) -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#114288) next »