fixing up commandLine.inc so it will work anywhere
[lhc/web/wiklou.git] / maintenance / commandLine.inc
1 <?php
2 if ( strpos( `hostname -a`, "wikimedia.org" ) !== false ) {
3 require_once( "liveCmdLine.inc" );
4 } else {
5 # Turn off output buffering if it's on
6 @ob_end_flush();
7
8 if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) {
9 print "This script must be run from the command line\n";
10 exit();
11 }
12
13 $wgCommandLineMode = true;
14
15 $sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":";
16 if ( @$argv[1] && @$argv[1] != "-" ) {
17 $self = array_shift( $argv );
18 $lang = array_shift( $argv );
19 putenv( "wikilang=$lang");
20 $settingsFile = "/apache/htdocs/{$argv[1]}/w/LocalSettings.php";
21 $newpath = "/apache/common/php$sep";
22 } else {
23 $settingsFile = "../LocalSettings.php";
24 $newpath = "";
25 }
26
27 if ( ! is_readable( $settingsFile ) ) {
28 print "A copy of your installation's LocalSettings.php\n" .
29 "must exist in the source directory.\n";
30 exit();
31 }
32
33
34 $wgCommandLineMode = true;
35 $DP = "../includes";
36 include_once( $settingsFile );
37 ini_set( "include_path", "../includes$sep../languages$sep$newpath$IP$sep$include_path" );
38
39 $wgUsePHPTal = false;
40 define("MEDIAWIKI",true);
41 include_once( "Setup.php" );
42 include_once( "../install-utils.inc" );
43 $wgTitle = Title::newFromText( "Command line script" );
44 $wgCommandLineMode = true;
45 set_time_limit(0);
46 }
47 ?>