Note ipb_expiry change
[lhc/web/wiklou.git] / maintenance / rebuildMessages.php
1 <?php
2 $wgCommandLineMode = true;
3
4 $sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":";
5 if ( $argv[1] ) {
6 $lang = $argv[1];
7 putenv( "wikilang=$lang");
8 $settingsFile = "/apache/htdocs/{$argv[1]}/w/LocalSettings.php";
9 $newpath = "/apache/common/php$sep";
10 } else {
11 $settingsFile = "../LocalSettings.php";
12 $newpath = "";
13 }
14
15 if ( $argv[2] == "update" ) {
16 $response = 1;
17 } elseif ( $argv[2] == "reinitialise" ) {
18 $response = 2;
19 } else {
20 $response = 0;
21 }
22
23 if ( ! is_readable( $settingsFile ) ) {
24 print "A copy of your installation's LocalSettings.php\n" .
25 "must exist in the source directory.\n";
26 exit();
27 }
28
29 ini_set( "include_path", "../includes$sep../languages$sep$newpath$IP$sep$include_path" );
30
31 $wgCommandLineMode = true;
32 $DP = "../includes";
33 include_once( $settingsFile );
34
35 include_once( "Setup.php" );
36 include_once( "./InitialiseMessages.inc" );
37 include_once( "../install-utils.inc" );
38 $wgTitle = Title::newFromText( "Rebuild messages script" );
39 $wgCommandLineMode = true;
40 set_time_limit(0);
41
42 if ( $response == 0 ) {
43 $row = wfGetArray( "cur", array("count(*) as c"), array("cur_namespace" => NS_MEDIAWIKI) );
44 print "Current namespace size: {$row->c}\n";
45
46 print "1. Update messages to include latest additions to Language.php\n" .
47 "2. Delete all messages and reinitialise namespace\n" .
48 "3. Quit\n\n".
49
50 "Please enter a number: ";
51
52 do {
53 $response = IntVal(readconsole());
54 if ( $response >= 1 && $response <= 3 ) {
55 $good = true;
56 } else {
57 $good = false;
58 print "Please type a number between 1 and 3: ";
59 }
60 } while ( !$good );
61 }
62
63 switch ( $response ) {
64 case 1:
65 initialiseMessages( false );
66 break;
67 case 2:
68 initialiseMessages( true );
69 break;
70 }
71
72 exit();
73
74 ?>