From 454c47247efba71b0d1c57bf4f4c3a3ff932b86e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 8 Sep 2004 20:20:10 +0000 Subject: [PATCH] Use handy-dandy __FILE__ constant to get the pathname instead of more cumbersome means. Would be nice if PHP documented these things better; things that aren't functions are very hard to find in their online docs. --- config/index.php | 4 +--- maintenance/mwdocgen.php | 14 ++------------ 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/config/index.php b/config/index.php index c14930da77..aa7a2a1a62 100644 --- a/config/index.php +++ b/config/index.php @@ -301,9 +301,7 @@ if( $conf->HaveGD ) { $conf->UseImageResize = $conf->HaveGD || $conf->ImageMagick; # $conf->IP = "/Users/brion/Sites/inplace"; -chdir( ".." ); -$conf->IP = getcwd(); -chdir( "config" ); +$conf->IP = dirname( dirname( __FILE__ ) ); print "
  • Installation directory: " . htmlspecialchars( $conf->IP ) . "
  • \n"; # $conf->ScriptPath = "/~brion/inplace"; diff --git a/maintenance/mwdocgen.php b/maintenance/mwdocgen.php index e5e8dd2dd6..464012f2dd 100755 --- a/maintenance/mwdocgen.php +++ b/maintenance/mwdocgen.php @@ -30,19 +30,9 @@ if( php_sapi_name() != 'cli' ) { #$pdExec = '/usr/bin/phpdoc'; $pdExec = 'phpdoc'; -/** Figure out the base directory. This is harder than it should be. */ -/** Since we're on the command line, don't trust the PWD! */ -$here = null; -$self = $_SERVER['SCRIPT_FILENAME']; +/** Figure out the base directory. */ $sep = DIRECTORY_SEPARATOR; -foreach( get_included_files() as $f ) { - if( preg_match( "!^(.*)maintenance$sep$self\$!", $f, $matches ) ) { - $here = $matches[1]; - } -} -if( is_null( $here ) ) { - die( "Couldn't determine current directory.\n" ); -} +$here = dirname( dirname( __FILE__ ) ) . $sep; /** where Phpdoc should output documentation */ #$pdOutput = '/var/www/mwdoc/'; -- 2.20.1