Use handy-dandy __FILE__ constant to get the pathname instead of more
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 8 Sep 2004 20:20:10 +0000 (20:20 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 8 Sep 2004 20:20:10 +0000 (20:20 +0000)
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
maintenance/mwdocgen.php

index c14930d..aa7a2a1 100644 (file)
@@ -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 "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
 
 # $conf->ScriptPath = "/~brion/inplace";
index e5e8dd2..464012f 100755 (executable)
@@ -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/';