NYCPHP Meetup

NYPHP.org

[nycphp-talk] How do you do the equivalent of $PHP_SELF for PHP scripts not in docroot?

Phillip Powell phillip.powell at adnet-sys.com
Tue May 18 15:43:17 EDT 2004


Joel De Gan wrote:

>On Tue, 2004-05-18 at 15:23, Phillip Powell wrote:
>  
>
>>Yes and no.  Perhaps my understanding of "config" and "define" are a bit 
>>overcomplicated in my head for me to come up with a simplified version, 
>>so I came up with the complex one, as usual.
>>
>>I created a binary 0644 text CSV file that reads the required globals 
>>and sets them into $_SESSION variables one time shot only.  Problem is 
>>that the CSV file is 0644, a huge security HOLE!  It needs to be 0600, 
>>but then Apache can't read it and the application breaks.  The CSV file 
>>is created via a command-line PHP scripts "install.php" which creates it 
>>in /home/me/scripts/cron and then you have to physically move it to the 
>>docroot, in the same place as index.php
>>    
>>
>
>like so.. why are you messing around with csv files?
>  
>

The client wants the easiest means possible of inputting necessary data 
(I didn't say the most secure, the easiest), and CSV files can be opened 
up in Excel and edited.

>file config.php
><?
>	define("APPPATH", "/var/www/html/project");
>?>
>
>file app.php
><?
>	include 'config.php';
>	echo APPPATH ."\n";
>?>
>
>bash-2.05b$ php app.php
>/var/www/html/project
>
>
>  
>

I can easily write config.php, however, my knowledge of "define" comes 
from the PHP manual, and I see nowhere where it states that anything in 
define() is in a persistent state.  If I run "config.php", I lose all of 
my defined constants, don't I?  And when I go to "index.php" via 
browser, how would it know how to go to config.php if config.php would 
have to reside outside of the docroot?

Again I'm probably overcomplicating this but I can't honestly follow 
your train of logic, though I want to.

Phil

-- 
---------------------------------------------------------------------------------
Phil Powell
Multimedia Programmer
BPX Technologies, Inc.
#: (703) 709-7218 x107 
Fax: (703) 709-7219

	




More information about the talk mailing list