Allow installing and running the wiki on a server where ini_set has been
authorBrion Vibber <brion@users.mediawiki.org>
Sun, 9 May 2004 10:37:00 +0000 (10:37 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sun, 9 May 2004 10:37:00 +0000 (10:37 +0000)
disabled via disable_functions in php.ini (bug #928168)

The PHPTal skin doesn't function unless the PEAR bits are in include_path,
so it's disabled if ini_set can't be used. If the files are manually placed
or a real PEAR installation is available with the right stuff, one can
use $wgUsePHPTal = true;

There are likely other things that need to be taken into account for
restricted environments. Maintenance scripts haven't been tweaked for
such an environment yet either.

config/index.php
includes/DefaultSettings.php
includes/Parser.php
includes/Setup.php
index.php
languages/LanguageUtf8.php

index 6382837..a883d49 100644 (file)
@@ -73,7 +73,7 @@ header( "Content-type: text/html; charset=utf-8" );
 <div id="credit">
  <center>
   <a href="http://www.mediawiki.org/"><img
-    src="../images/wiki.png" width="135" height="135" alt="" border="0" /></a>
+    src="../stylesheets/images/wiki.png" width="135" height="135" alt="" border="0" /></a>
  </center>
  
  <b><a href="http://www.mediawiki.org/">MediaWiki</a></b> is
@@ -106,7 +106,9 @@ header( "Content-type: text/html; charset=utf-8" );
 <?php
 
 $IP = ".."; # Just to suppress notices, not for anything useful
-include( "../includes/DefaultSettings.php" );
+define( "MEDIAWIKI", true );
+define( "MEDIAWIKI_INSTALL", true );
+require( "../includes/DefaultSettings.php" );
 ?>
 
 <h1>MediaWiki <?php print $wgVersion ?> installation</h1>
@@ -149,8 +151,8 @@ if( !is_writable( "." ) ) {
 }
 
 
-include( "../install-utils.inc" );
-include( "../maintenance/updaters.inc" );
+require( "../install-utils.inc" );
+require( "../maintenance/updaters.inc" );
 class ConfigData {
        function getEncoded( $data ) {
                # Hackish
@@ -235,6 +237,11 @@ $conf->IP = preg_replace( "/\\\\/","\\\\\\\\",$conf->IP );  // For Windows, \ ->
 chdir( "config" );
 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
 
+@$oldpath = ini_set( "include_path", ini_get( "include_path" ) );
+if( empty( $oldpath ) ) {
+       print "<li>Can't set <tt>include_path</tt>; new template layout will be disabled.</li>\n";
+}
+
 # $conf->ScriptPath = "/~brion/inplace";
 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["REQUEST_URI"] );
 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
@@ -296,13 +303,15 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                /* Load up the settings and get installin' */
                $local = writeLocalSettings( $conf );
                $wgCommandLineMode = false;
+               chdir( ".." );
                eval($local);
-
                $wgDBadminuser = $wgDBuser;
                $wgDBadminpassword = $wgDBpassword;
                $wgCommandLineMode = true;
                $wgUseDatabaseMessages = false; /* FIXME: For database failure */
-               require_once( "Setup.php" );
+               require_once( "includes/Setup.php" );
+               chdir( "config" );
+
                require_once( "../maintenance/InitialiseMessages.inc" );
 
                $wgTitle = Title::newFromText( "Installation script" );
@@ -691,8 +700,7 @@ function writeLocalSettings( $conf ) {
 # recreate them later.
 
 \$IP = \"{$conf->IP}\";
-ini_set( \"include_path\", \"\$IP/includes$sep\$IP/languages$sep\" . ini_get(\"include_path\") );
-require_once( \"DefaultSettings.php\" );
+require_once( \"includes/DefaultSettings.php\" );
 
 if ( \$wgCommandLineMode ) {
        if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
@@ -754,11 +762,6 @@ if ( \$wgCommandLineMode ) {
 \$wgMathDirectory    = \"{\$wgUploadDirectory}/math\";
 \$wgTmpDirectory     = \"{\$wgUploadDirectory}/tmp\";
 
-\$wgUsePHPTal = true;
-if ( \$wgUsePHPTal ) {
-      ini_set( \"include_path\", \"\$IP/PHPTAL-NP-0.7.0/libs$sep\" . ini_get(\"include_path\") );
-}
-
 \$wgLocalInterwiki   = \$wgSitename;
 
 \$wgLanguageCode = \"{$conf->LanguageCode}\";
@@ -836,7 +839,7 @@ function getLanguageList() {
                $wgLanguageCode = "xxx";
                function wfLocalUrl( $x ) { return $x; }
                function wfLocalUrlE( $x ) { return $x; }
-               include( "../languages/Language.php" );
+               require( "../languages/Language.php" );
        }
        
        $codes = array();
index 8c6f07c..ba13146 100644 (file)
@@ -318,8 +318,16 @@ $wgUseImageResize          = false;
 $wgUseImageMagick              = false;
 $wgImageMagickConvertCommand    = "/usr/bin/convert";
 
-# Make sure include_path is set correctly
+# PHPTal needs a PEAR directory in the include_path. If we can't change the
+# include_path (such as on free.fr and other hosts) we may have to disable it.
 $wgUsePHPTal = true;
+$pathchange = @ini_set( "include_path", "PHPTAL-NP-0.7.0/libs:" . ini_get("include_path") );
+if( empty( $pathchange ) ) {
+       # Can't fix path! User can manually enable it again if they put the files
+       # in an appropriate place.
+       $wgUsePHPTal = false;
+}
+
 
 if( !isset( $wgCommandLineMode ) ) {
        $wgCommandLineMode = false;
index 54a6528..9efab38 100644 (file)
@@ -3,7 +3,7 @@
 require_once('Tokenizer.php');
 
 if( $GLOBALS['wgUseWikiHiero'] ){
-       require_once('wikihiero.php');
+       require_once('extensions/wikihiero/wikihiero.php');
 }
 if( $GLOBALS['wgUseTimeline'] ){
        require_once('extensions/timeline/Timeline.php');
index 065f7d7..dabad2b 100644 (file)
@@ -61,6 +61,7 @@ require_once( "WebRequest.php" );
 $wgRequest = new WebRequest();
 
 
+
 wfProfileOut( "$fname-includes" );
 wfProfileIn( "$fname-memcached" );
 global $wgUser, $wgLang, $wgOut, $wgTitle;
@@ -141,13 +142,13 @@ if( $wgUseMemCached ) {
 wfProfileOut( "$fname-memcached" );
 wfProfileIn( "$fname-misc" );
 
-require_once( "Language.php" );
+require_once( "languages/Language.php" );
 
 $wgMessageCache = new MessageCache; 
 
 $wgLangClass = "Language" . ucfirst( $wgLanguageCode );
 if( ! class_exists( $wgLangClass ) || ($wgLanguageCode == "en" && strcasecmp( $wgInputEncoding, "utf-8" ) == 0 ) ) {
-       require_once( "LanguageUtf8.php" );
+       require_once( "languages/LanguageUtf8.php" );
        $wgLangClass = "LanguageUtf8";
 }
 
@@ -189,4 +190,5 @@ $wgOut->setParserOptions( ParserOptions::newFromUser( $wgUser ) );
 wfProfileOut( "$fname-misc" );
 wfProfileOut( $fname );
 
+
 ?>
index 916cb92..eb59c3d 100644 (file)
--- a/index.php
+++ b/index.php
@@ -5,21 +5,14 @@
 $wgRequestTime = microtime();
 
 unset( $IP );
-ini_set( "allow_url_fopen", 0 ); # For security...
+@ini_set( "allow_url_fopen", 0 ); # For security...
 if(!file_exists("LocalSettings.php")) {
        die( "You'll have to <a href='config/index.php'>set the wiki up</a> first!" );
 }
-require_once( "./LocalSettings.php" );
-
-if( $wgSitename == "MediaWiki" ) {
-       die( "You must set the site name in \$wgSitename before installation.\n\n" );
-}
 
-# PATH_SEPARATOR avaialble only from 4.3.0
-$sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
-ini_set( "include_path", $IP . $sep . ini_get( "include_path" ) );
-
-require_once( "Setup.php" );
+define( "MEDIAWIKI", true );
+require_once( "./LocalSettings.php" );
+require_once( "includes/Setup.php" );
 
 wfProfileIn( "main-misc-setup" );
 OutputPage::setEncodings(); # Not really used yet
@@ -94,7 +87,7 @@ if ( $search = $wgRequest->getText( 'search' ) ) {
 
        switch( $wgTitle->getNamespace() ) {
        case NS_IMAGE:
-               require_once( "ImagePage.php" );
+               require_once( "includes/ImagePage.php" );
                $wgArticle = new ImagePage( $wgTitle );
                break;
        default:
@@ -123,7 +116,7 @@ if ( $search = $wgRequest->getText( 'search' ) ) {
                        if( !$wgEnableDublinCoreRdf ) {
                                wfHttpError( 403, "Forbidden", wfMsg( "nodublincore" ) );
                        } else {
-                               require_once( "Metadata.php" );
+                               require_once( "includes/Metadata.php" );
                                wfDublinCoreRdf( $wgArticle );
                        }
                        break;
@@ -131,7 +124,7 @@ if ( $search = $wgRequest->getText( 'search' ) ) {
                        if( !$wgEnableCreativeCommonsRdf ) {
                                wfHttpError( 403, "Forbidden", wfMsg("nocreativecommons") );
                        } else {
-                               require_once( "Metadata.php" );
+                               require_once( "includes/Metadata.php" );
                                wfCreativeCommonsRdf( $wgArticle );
                        }
                        break;
@@ -140,7 +133,7 @@ if ( $search = $wgRequest->getText( 'search' ) ) {
                        if( !$wgCommandLineMode && !$wgRequest->checkSessionCookie() ) {
                                User::SetupSession();
                        }
-                       require_once( "EditPage.php" );
+                       require_once( "includes/EditPage.php" );
                        $editor = new EditPage( $wgArticle );
                        $editor->$action();
                        break;
@@ -148,12 +141,12 @@ if ( $search = $wgRequest->getText( 'search' ) ) {
                        if ($_SERVER["REQUEST_URI"] == $wgTitle->getInternalURL('action=history')) {
                                $wgOut->setSquidMaxage( $wgSquidMaxage );
                        }
-                       require_once( "PageHistory.php" );
+                       require_once( "includes/PageHistory.php" );
                        $history = new PageHistory( $wgArticle );
                        $history->history();
                        break;
                case "raw":
-                       require_once( "RawPage.php" );
+                       require_once( "includes/RawPage.php" );
                        $raw = new RawPage( $wgArticle );
                        $raw->view();
                        break;
index 06d613a..26d8fdd 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+if( defined( "MEDIAWIKI" ) ) {
 
 $wgInputEncoding    = "utf-8";
 $wgOutputEncoding      = "utf-8";
@@ -7,7 +8,7 @@ $wikiUpperChars = $wgMemc->get( $key1 = "$wgDBname:utf8:upper" );
 $wikiLowerChars = $wgMemc->get( $key2 = "$wgDBname:utf8:lower" );
 
 if(empty( $wikiUpperChars) || empty($wikiLowerChars )) {
-       require_once( "Utf8Case.php" );
+       require_once( "includes/Utf8Case.php" );
        $wgMemc->set( $key1, $wikiUpperChars );
        $wgMemc->set( $key2, $wikiLowerChars );
 }
@@ -65,4 +66,6 @@ class LanguageUtf8 extends Language {
        }
 }
 
+} # ifdef MEDIAWIKI
+
 ?>