coding style tweaks
[lhc/web/wiklou.git] / config / Installer.php
index 191ca85..7ebc8bd 100644 (file)
@@ -1,23 +1,27 @@
 <?php
-
-# MediaWiki web-based config/installation
-# Copyright (C) 2004 Brion Vibber <brion@pobox.com>, 2006 Rob Church <robchur@gmail.com>
-# http://www.mediawiki.org/
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-# http://www.gnu.org/copyleft/gpl.html
+/**
+ * MediaWiki web-based config/installation
+ *
+ * Copyright © 2004 Brion Vibber <brion@pobox.com>, 2006 Rob Church <robchur@gmail.com>
+ * http://www.mediawiki.org/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
 
 if( !defined( 'MEDIAWIKI_INSTALL' ) ) {
        die( 'Not an entry point.' );
@@ -83,6 +87,15 @@ $ourdb['sqlite'] = array(
        'serverless' =>  true
 );
 
+$ourdb['mssql'] = array(
+       'fullname'   => 'Microsoft SQL Server',
+       'havedriver' => 0,
+       'compile'    => 'sqlsrv',
+       'bgcolor'    => '#cccccc',
+       'rootuser'   => 'root',
+       'serverless' => false
+);
+
 $ourdb['ibm_db2'] = array(
        'fullname'   => 'DB2',
        'havedriver' => 0,
@@ -333,7 +346,7 @@ error_reporting( 0 );
 $phpdatabases = array();
 foreach (array_keys($ourdb) as $db) {
        $compname = $ourdb[$db]['compile'];
-       if( extension_loaded( $compname ) || ( mw_have_dl() && dl( "{$compname}." . PHP_SHLIB_SUFFIX ) ) ) {
+       if( wfDl( $compname ) ) {
                array_push($phpdatabases, $db);
                $ourdb[$db]['havedriver'] = 1;
        }
@@ -906,6 +919,44 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
 
                        if( !$ok ) { continue; }
                }
+               else if ( $conf->DBtype == 'mssql' ) {
+                       error_reporting( E_ALL );
+                       $wgSuperUser = '';
+                       # # Possible connect as a superuser
+                       if ( $useRoot ) {
+                               $wgDBsuperuser = $conf->RootUser;
+                               echo( "<li>Attempting to connect to database \"{$conf->DBtype}\" as superuser \"{$wgDBsuperuser}\"" );
+                               $wgDatabase = $dbc->newFromParams(
+                                                                               $conf->DBserver,
+                                                                               $conf->RootUser,
+                                                                               $conf->RootPW,
+                                                                               false,
+                                                                               false,
+                                                                               1
+                                                                       );
+                               if ( !$wgDatabase->isOpen() ) {
+                                       echo( " error: {$wgDatabase->lastError()}</li>\n" );
+                                       $errs['DBserver'] = 'Could not connect to database as superuser';
+                                       $errs['RootUser'] = 'Check username';
+                                       $errs['RootPW'] = 'and password';
+                                       continue;
+                               }
+                               $wgDatabase->initial_setup( $conf->RootPW, $conf->DBtype );
+                       }
+                       echo( "<li>Attempting to connect to database \"{$wgDBname}\" as \"{$wgDBuser}\"..." );
+                       $wgDatabase = $dbc->newFromParams(
+                                                                       $conf->DBserver,
+                                                                       $conf->DBuser,
+                                                                       $conf->DBpassword,
+                                                                       $conf->DBname,
+                                                                       1
+                                                               );
+                       if ( !$wgDatabase->isOpen() ) {
+                               echo( " error: {$wgDatabase->lastError()} </li>\n" );
+                       } else {
+                               $myver = $wgDatabase->getServerVersion();
+                       }
+               }
                else if( $conf->DBtype == 'ibm_db2' ) {
                        if( $useRoot ) {
                                $db_user = $conf->RootUser;
@@ -1033,10 +1084,9 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                        ## Possible connect as a superuser
                        // Changed !mysql to postgres check since it seems to only apply to postgres
                        if( $useRoot && $conf->DBtype == 'postgres' ) {
-                               $wgDBsuperuser = $conf->RootUser;
                                echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" .
-                                       htmlspecialchars( $wgDBsuperuser ) . "\"..." );
-                               $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1);
+                                       htmlspecialchars( $conf->RootUser ) . "\"..." );
+                               $wgDatabase = $dbc->newFromParams($wgDBserver, $conf->RootUser, $conf->RootPW, "postgres", 1);
                                if (!$wgDatabase->isOpen()) {
                                        print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
                                        $errs["DBserver"] = "Could not connect to database as superuser";
@@ -1044,7 +1094,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                                        $errs["RootPW"] = "and password";
                                        continue;
                                }
-                               $wgDatabase->initial_setup($conf->RootPW, 'postgres');
+                               $wgDatabase->initial_setup($conf->RootUser, $conf->RootPW, 'postgres');
                        }
                        echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
                                "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." );
@@ -1206,7 +1256,6 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                                                break;
                                        }
                                }
-                               $wgDatabase->freeResult( $res );
                                if ( !$found && $conf->DBengine != 'MyISAM' ) {
                                        echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine ) .
                                                " storage engine not available, " .
@@ -1515,8 +1564,8 @@ if( count( $errs ) ) {
                <label class='column'>E-mail notification about changes:</label>
                <ul class="plain">
                <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
-               <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
-               <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages, and to pages on watchlists (not recommended for large wikis)", "radio", "enotif_allpages" ); ?></li>
+               <li><?php aField( $conf, "Enotif", "Changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
+               <li><?php aField( $conf, "Enotif", "Changes to user discussion pages, and to pages on watchlists (not recommended for large wikis)", "radio", "enotif_allpages" ); ?></li>
                </ul>
        </div>
        <div class="config-desc">
@@ -1656,6 +1705,13 @@ if( count( $errs ) ) {
        </div>
        </fieldset>
 
+       
+       <?php database_switcher( 'mssql' ); ?>
+       <div class="config-desc">
+               <p>No MS SQL Server specific options at this time.</p>
+       </div>
+       
+       
        <?php database_switcher('ibm_db2'); ?>
        <div class="config-input"><?php
                aField( $conf, "DBport_db2", "Database port:" );
@@ -1860,7 +1916,7 @@ function writeLocalSettings( $conf ) {
        } elseif( $conf->DBtype == 'ibm_db2' ) {
                $dbsettings =
 "# DB2 specific settings
-\$wgDBport_db2       = \"{$slconf['DBport_db2']}\";
+\$wgDBport       = \"{$slconf['DBport_db2']}\";
 \$wgDBmwschema       = \"{$slconf['DBdb2schema']}\";
 \$wgDBcataloged      = \"{$slconf['DBcataloged']}\";";
        } elseif( $conf->DBtype == 'oracle' ) {
@@ -2293,7 +2349,7 @@ function getShellLocale( $wikiLang ) {
                        <li><a href="http://www.mediawiki.org/wiki/Manual:Contents">Administrator's Guide</a></li>
                        <li><a href="http://www.mediawiki.org/wiki/Manual:FAQ">FAQ</a></li>
                </ul>
-               <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright © 2001-2009 by Magnus Manske, Brion Vibber,
+               <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright © 2001-2010 by Magnus Manske, Brion Vibber,
                 Lee Daniel Crocker, Tim Starling, Erik Möller, Gabriel Wicke, Ævar Arnfjörð Bjarmason, Niklas Laxström,
                 Domas Mituzas, Rob Church, Yuri Astrakhan, Aryeh Gregor, Aaron Schulz and others.</p>
        </div></div>