note 8771 deleted from function.include by vincent

From: Date: Mon, 08 Sep 2003 15:09:41 +0000
Subject: note 8771 deleted from function.include by vincent
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-55843@lists.php.net to get a copy of this message
Note Submitter: drtebi@yahoo.com ---- After reading through all these comments I think I should try to clarify a few things: 1. There is no particular reason why an include file should have the extension ".inc". An easy way to prevent users from seeing your PHP code is to use the extension ".php" for your include files. This way any code in PHP tags will be executed rather than visible in the source code. This will solve most people's problems. 2. To use an Apache directive, in most cases it does not have to be done in the httpd.conf file. Most servers will allow you to use your own .htaccess files, which will accept anything that was specified in the httpd.conf file, as for the servers I am using, this is "AllowOverwrite All". So this way, if you want to use the ".inc" extension for includes, you can use this in your .htaccess file: AddType application/x-httpd-php3 .inc (for PHP3) AddType application/x-httpd-php .inc (for PHP4) Now Apache will process any PHP tags before sending out the .inc file, which is basically the same result as mentioned in 1., only that you can use .inc instead of .php now. 3. It is not necessary to chmod .inc files to 755, but it is also not possible to include .inc files if they are not world readable, as in 740 or 700. 4. An elegant solution, as mentioned by digita1l@hotmail.com is using the following file container, which can also be placed in an .htaccess file: <Files ~ ".inc"> Order allow,deny Deny from all </Files> This will give the user a "permission denied" error when he/she would try to access the .inc file directly, but PHP will still be able to include the document. I have tested everything I said above on a RedHad Linux 6.1 with PHP Version 4.0.1pl2 and Apache 1.3.12. cheers

« previous php.notes (#55843) next »