-$optionsWithArgs[] = 'conf'; # For specifying the location of LocalSettings.php
-$optionsWithArgs[] = 'aconf'; # As above for AdminSettings.php
-$optionsWithArgs[] = 'wiki'; # For specifying the wiki ID
-
-$self = array_shift( $argv );
-$IP = strval( getenv('MW_INSTALL_PATH') ) !== ''
- ? getenv('MW_INSTALL_PATH')
- : realpath( dirname( __FILE__ ) . '/..' );
-#chdir( $IP );
-if ( file_exists( "$IP/StartProfiler.php" ) ) {
- require_once( "$IP/StartProfiler.php" );
-} else {
- require_once( "$IP/includes/ProfilerStub.php" );
-}
-
-$options = array();
-$args = array();
-
-
-# Parse arguments
-for( $arg = reset( $argv ); $arg !== false; $arg = next( $argv ) ) {
- if ( $arg == '--' ) {
- # End of options, remainder should be considered arguments
- $arg = next( $argv );
- while( $arg !== false ) {
- $args[] = $arg;
- $arg = next( $argv );
- }
- break;
- } elseif ( substr( $arg, 0, 2 ) == '--' ) {
- # Long options
- $option = substr( $arg, 2 );
- if ( in_array( $option, $optionsWithArgs ) ) {
- $param = next( $argv );
- if ( $param === false ) {
- echo "$arg needs a value after it\n";
- die( -1 );
- }
- $options[$option] = $param;
- } else {
- $bits = explode( '=', $option, 2 );
- if( count( $bits ) > 1 ) {
- $option = $bits[0];
- $param = $bits[1];
- } else {
- $param = 1;
- }
- $options[$option] = $param;
- }
- } elseif ( substr( $arg, 0, 1 ) == '-' ) {
- # Short options
- for ( $p=1; $p<strlen( $arg ); $p++ ) {
- $option = $arg{$p};
- if ( in_array( $option, $optionsWithArgs ) ) {
- $param = next( $argv );
- if ( $param === false ) {
- echo "$arg needs a value after it\n";
- die( -1 );
- }
- $options[$option] = $param;
- } else {
- $options[$option] = 1;
- }
- }
- } else {
- $args[] = $arg;
- }
-}
-
-
-# General initialisation
-
-$wgCommandLineMode = true;
-# Turn off output buffering if it's on
-@ob_end_flush();
-$sep = PATH_SEPARATOR;
-
-if (!isset( $wgUseNormalUser ) ) {
- $wgUseNormalUser = false;
-}
-
-if ( file_exists( dirname(__FILE__).'/wikimedia-mode' ) ) {
- $wgWikiFarm = true;
- $cluster = 'pmtpa';
- require_once( "$IP/includes/AutoLoader.php" );
- require_once( "$IP/includes/SiteConfiguration.php" );
-
- # Get $wgConf
- require( "$IP/wgConf.php" );
-
- if ( empty( $wgNoDBParam ) ) {
- # Check if we were passed a db name
- if ( isset( $options['wiki'] ) ) {
- $db = $options['wiki'];
- } else {
- $db = array_shift( $args );
- }
- list( $site, $lang ) = $wgConf->siteFromDB( $db );
-
- # If not, work out the language and site the old way
- if ( is_null( $site ) || is_null( $lang ) ) {
- if ( !$db ) {
- $lang = 'aa';
- } else {
- $lang = $db;
- }
- if ( isset( $args[0] ) ) {
- $site = array_shift( $args );
- } else {
- $site = 'wikipedia';
- }
- }
- } else {
- $lang = 'aa';
- $site = 'wikipedia';
- }
-
- # This is for the IRC scripts, which now run as the apache user
- # The apache user doesn't have access to the wikiadmin_pass command
- if ( $_ENV['USER'] == 'apache' ) {
- #if ( posix_geteuid() == 48 ) {
- $wgUseNormalUser = true;
- }