* (bug 10387) Detect and handle '.php5' extension environments at install time

Patch by Edward Z. Yang.
This commit is contained in:
Brion Vibber 2007-06-28 14:50:06 +00:00
parent 6156396440
commit 13b739ec46
11 changed files with 50 additions and 15 deletions

View file

@ -110,6 +110,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
* (bug 6711) Add $wgAddGroups and $wgRemoveGroups to allow finer control over
usergroup assignment.
* Introduce 'UserEffectiveGroups' hook; see docs/hooks.txt for more information
* (bug 10387) Detect and handle '.php5' extension environments at install time
Patch by Edward Z. Yang.
== Bugfixes since 1.10 ==

2
api.php5 Normal file
View file

@ -0,0 +1,2 @@
<?php require 'api.php'; ?>
<?php require 'api.php'; ?>

View file

@ -201,7 +201,8 @@ $ourdb['postgres']['rootuser'] = 'postgres';
/* Check for existing configurations and bug out! */
if( file_exists( "../LocalSettings.php" ) ) {
dieout( "<p><strong>Setup has completed, <a href='../index.php'>your wiki</a> is configured.</strong></p>
$script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
dieout( "<p><strong>Setup has completed, <a href='../$script'>your wiki</a> is configured.</strong></p>
<p>Please delete the /config directory for extra security.</p></div></div></div></div>" );
}
@ -393,10 +394,11 @@ if( ini_get( "safe_mode" ) ) {
$sapi = php_sapi_name();
print "<li>PHP server API is $sapi; ";
$script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
if( $wgUsePathInfo ) {
print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
print "ok, using pretty URLs (<tt>$script/Page_Title</tt>)";
} else {
print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
print "using ugly URLs (<tt>$script?title=Page_Title</tt>)";
}
print "</li>\n";
@ -549,6 +551,18 @@ $path = ($_SERVER["PHP_SELF"] === '')
$conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $path );
print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
// We may be installing from *.php5 extension file, if so, print message
$conf->ScriptExtension = '.php';
if (defined('MW_INSTALL_PHP5_EXT')) {
$conf->ScriptExtension = '.php5';
print "<li>Installing MediaWiki with <tt>php5</tt> file extensions</li>\n";
} else {
print "<li>Installing MediaWiki with <tt>php</tt> file extensions</li>\n";
}
print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
$conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
@ -631,7 +645,7 @@ $wgAuth = new AuthPlugin();
if( $conf->SysopName ) {
# Check that the user can be created
$u = User::newFromName( $conf->SysopName );
if( $u instanceof User ) {
if( is_a($u, 'User') ) { // please do not use instanceof, it breaks PHP4
# Various password checks
if( $conf->SysopPass != '' ) {
if( $conf->SysopPass == $conf->SysopPass2 ) {
@ -1097,7 +1111,7 @@ if( count( $errs ) ) {
}
?>
<form action="index.php" name="config" method="post">
<form action="<?php echo defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; ?>" name="config" method="post">
<h2>Site config</h2>
@ -1148,7 +1162,8 @@ if( count( $errs ) ) {
<li><?php
aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
$partner = "MediaWiki";
$exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
$script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
$exit = urlencode( "$wgServer{$conf->ScriptPath}/config/$script?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
$icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
$ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
print "<a href=\"$ccApp\" target='_blank'>choose</a>";
@ -1418,6 +1433,7 @@ window.onload = toggleDBarea('<?php echo $conf->DBtype; ?>',
/* -------------------------------------------------------------------------------------- */
function writeSuccessMessage() {
$script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
echo <<<EOT
<div class="success-box">
@ -1427,7 +1443,7 @@ function writeSuccessMessage() {
<li>Download config/LocalSettings.php with your FTP client or file manager</li>
<li>Upload it to the parent directory</li>
<li>Delete config/LocalSettings.php</li>
<li>Start using <a href='../index.php'>your wiki</a>!
<li>Start using <a href='../$script'>your wiki</a>!
</ol>
<p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
remotely. LocalSettings.php is currently owned by the user your webserver is running under,
@ -1441,7 +1457,7 @@ EOT;
<p>
<span class="success-message">Installation successful!</span>
Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
<a href="../index.php"> this link</a> to your wiki.</p>
<a href="../$script"> this link</a> to your wiki.</p>
<p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
prevent other users on the server reading passwords and altering configuration data.</p>
</div>
@ -1568,6 +1584,7 @@ if ( \$wgCommandLineMode ) {
## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
\$wgScriptPath = \"{$slconf['ScriptPath']}\";
\$wgScriptExtension = \"{$slconf['ScriptExtension']}\";
## For more information on customizing the URLs please see:
## http://www.mediawiki.org/wiki/Manual:Short_URL

6
config/index.php5 Normal file
View file

@ -0,0 +1,6 @@
<?php
define('MW_INSTALL_PHP5_EXT', 1);
require './index.php';
?>

1
img_auth.php5 Normal file
View file

@ -0,0 +1 @@
<?php require './img_auth.php'; ?>

View file

@ -125,8 +125,9 @@ $wgUsePathInfo =
* in LocalSettings.php. Generally you should not need to change this
* unless you don't like seeing "index.php".
*/
$wgScript = false; /// defaults to "{$wgScriptPath}/index.php"
$wgRedirectScript = false; /// defaults to "{$wgScriptPath}/redirect.php"
$wgScriptExtension = '.php'; /// extension to append to script names by default
$wgScript = false; /// defaults to "{$wgScriptPath}/index{$wgScriptExtension}"
$wgRedirectScript = false; /// defaults to "{$wgScriptPath}/redirect{$wgScriptExtension}"
/**#@-*/
@ -443,7 +444,7 @@ $wgUploadNavigationUrl = false;
* apache servers don't have read/write access to the thumbnail path.
*
* Example:
* $wgThumbnailScriptPath = "{$wgScriptPath}/thumb.php";
* $wgThumbnailScriptPath = "{$wgScriptPath}/thumb{$wgScriptExtension}";
*/
$wgThumbnailScriptPath = false;
$wgSharedThumbnailScriptPath = false;

View file

@ -28,8 +28,8 @@ if ( !isset( $wgVersion ) ) {
}
// Set various default paths sensibly...
if( $wgScript === false ) $wgScript = "$wgScriptPath/index.php";
if( $wgRedirectScript === false ) $wgRedirectScript = "$wgScriptPath/redirect.php";
if( $wgScript === false ) $wgScript = "$wgScriptPath/index$wgScriptExtension";
if( $wgRedirectScript === false ) $wgRedirectScript = "$wgScriptPath/redirect$wgScriptExtension";
if( $wgArticlePath === false ) {
if( $wgUsePathInfo ) {

1
index.php5 Normal file
View file

@ -0,0 +1 @@
<?php require './index.php'; ?>

View file

@ -11,7 +11,9 @@ function install_version_checks() {
die( -1 );
}
if( version_compare( phpversion(), '5.0.0' ) < 0 ) {
echo "PHP 5.0.0 or higher is required. ABORTING.\n";
echo "PHP 5.0.0 or higher is required. If PHP 5 is available only when \n".
"PHP files have a .php5 extension, please navigate to <a href=\"index.php5\">index.php5</a> \n".
"to continue installation. ABORTING.\n";
die( -1 );
}
@ -122,4 +124,4 @@ function mw_get_session_save_path() {
return $path;
}
?>
?>

1
redirect.php5 Normal file
View file

@ -0,0 +1 @@
<?php require './redirect.php'; ?>

1
thumb.php5 Normal file
View file

@ -0,0 +1 @@
<?php require './thumb.php'; ?>