From: Brion Vibber Date: Sun, 9 May 2004 10:37:00 +0000 (+0000) Subject: Allow installing and running the wiki on a server where ini_set has been X-Git-Tag: 1.3.0beta1~113 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=762b8e9b47bc7b35e76cd854e79b13f941b47e88;p=lhc%2Fweb%2Fwiklou.git Allow installing and running the wiki on a server where ini_set has been 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. --- diff --git a/config/index.php b/config/index.php index 6382837547..a883d49db7 100644 --- a/config/index.php +++ b/config/index.php @@ -73,7 +73,7 @@ header( "Content-type: text/html; charset=utf-8" );
+ src="../stylesheets/images/wiki.png" width="135" height="135" alt="" border="0" />
MediaWiki is @@ -106,7 +106,9 @@ header( "Content-type: text/html; charset=utf-8" );

MediaWiki installation

@@ -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 "
  • Installation directory: " . htmlspecialchars( $conf->IP ) . "
  • \n"; +@$oldpath = ini_set( "include_path", ini_get( "include_path" ) ); +if( empty( $oldpath ) ) { + print "
  • Can't set include_path; new template layout will be disabled.
  • \n"; +} + # $conf->ScriptPath = "/~brion/inplace"; $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["REQUEST_URI"] ); print "
  • Script URI path: " . htmlspecialchars( $conf->ScriptPath ) . "
  • \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(); diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 8c6f07c0aa..ba13146618 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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; diff --git a/includes/Parser.php b/includes/Parser.php index 54a6528b3a..9efab38c05 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -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'); diff --git a/includes/Setup.php b/includes/Setup.php index 065f7d7938..dabad2b80a 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -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 ); + ?> diff --git a/index.php b/index.php index 916cb92bb6..eb59c3d5d2 100644 --- 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 set the wiki up 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; diff --git a/languages/LanguageUtf8.php b/languages/LanguageUtf8.php index 06d613a329..26d8fdd411 100644 --- a/languages/LanguageUtf8.php +++ b/languages/LanguageUtf8.php @@ -1,4 +1,5 @@ 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 + ?>