[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 16:28:16 EDT 2004
Joel De Gan wrote:
>On Tue, 2004-05-18 at 15:43, Phillip Powell wrote:
>
>
>>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.
>>
>>
>
>just try it.
>
>if you want to know all your defined constants try the following in a
>script.
>
>echo "<pre>\n";
>print_r($GLOBALS);
>
>
I tried it, and here are the steps I would have to take to ensure that
it would work.
The admin guy will do this:
php -q ../install.php
Here is install.php:
<?php
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------
File: INSTALL.PHP
Created: 5/18/2004
Modified: 5/18/2004
Purpose: This file will be housed in the /docs document folder for
the IVC project documentation list and not kept inside the document
root. It will generate all necessary global scripts for
use within the IVC.
Dependencies:
Will be called via command-line PHP and can be set up as a
cron, if so, move to /cron/[client folder name]/[project folder name].
Takes two required parameters:
1) client folder name
2) project folder name
Cookies: NONE
Sessions: NONE
Privacy Scope: Command-line PHP and not meant to be viewable by web
server
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
if (!is_file('client_project_folder_info.csv')) {
$clientFolderName = $argv[1];
$projectFolderName = $argv[2];
$contents .=
"\"clientFolderName\",\"$clientFolderName\"\n\"projectFolderName\",\"$projectFolderName\"";
$fileID = @fopen('client_project_folder_info.csv', 'wb');
@fputs($fileID, $contents); @fflush($fileID); @fclose($fileID);
}
@chmod('client_project_folder_info.csv', 0644);
// BE SURE TO COPY IT MANUALLY INTO /[document root]/[client folder
name]/[project folder name] DIRECTORY TO BE READ BY index.php
define('CLIENT_FOLDER_NAME', $clientFolderName);
define('PROJECT_FOLDER_NAME', $projectFolderName);
?>
And again, I'm not at all following your train of logic. In
"index.php", on the docroot, I have this line:
[PHP]
list($clientFolderName, $projectFolderName) = array(CLIENT_FOLDER_NAME,
PROJECT_FOLDER_NAME);
require(realpath($_SERVER['DOCUMENT_ROOT'] .
"/$clientFolderName/${clientFolderName}_globals/client_globals.inc.php"));
[/PHP]
You go to your browser, open up "index.php" and this is what you see:
[Quote]
*Fatal error*: main(): Failed opening required ''
(include_path='.:/usr/share/pear') in */www/html/index.php* on line *64
[/Quote]
Phil
*
>
>joeldg - developer, Intercosmos media group.
>http://lucifer.intercosmos.net
>
>_______________________________________________
>talk mailing list
>talk at lists.nyphp.org
>http://lists.nyphp.org/mailman/listinfo/talk
>
>
>
--
---------------------------------------------------------------------------------
Phil Powell
Multimedia Programmer
BPX Technologies, Inc.
#: (703) 709-7218 x107
Fax: (703) 709-7219
More information about the talk
mailing list