// get configuration
$dbHost = $dbUser = $dbPassword = $dbName = '';
$dbPort = 0;
- $dbClass = MySQLDatabase::class;
require(WCF_DIR.'config.inc.php');
// create database connection
- self::$dbObj = new $dbClass($dbHost, $dbUser, $dbPassword, $dbName, $dbPort);
+ self::$dbObj = new MySQLDatabase($dbHost, $dbUser, $dbPassword, $dbName, $dbPort);
}
/**
*/
protected static $developerMode = 0;
- /**
- * supported databases
- * @var string[][]
- */
- protected static $dbClasses = [
- 'MySQLDatabase' => ['class' => MySQLDatabase::class, 'minversion' => '5.1.17']//, // MySQL 5.1.17+
- //'PostgreSQLDatabase' => ['class' => 'wcf\system\database\PostgreSQLDatabase', 'minversion' => '8.2.0'] // PostgreSQL 8.2.0+
- ];
-
/** @noinspection PhpMissingParentConstructorInspection */
/**
* Calls all init functions of the WCFSetup class and starts the setup process.
}
}
- /**
- * Gets the available database classes.
- *
- * @return string[]
- */
- protected static function getAvailableDBClasses() {
- $availableDBClasses = [];
- foreach (self::$dbClasses as $class => $data) {
- if (call_user_func([$data['class'], 'isSupported'])) {
- $availableDBClasses[$class] = $data;
- }
- }
-
- return $availableDBClasses;
- }
-
/**
* Gets the selected wcf dir from request.
*
$system['phpVersion']['result'] = (version_compare($comparePhpVersion, '5.5.4') >= 0);
// sql
- $system['sql']['value'] = array_keys(self::getAvailableDBClasses());
- $system['sql']['result'] = !empty($system['sql']['value']);
+ $system['sql']['result'] = MySQLDatabase::isSupported();
// upload_max_filesize
$system['uploadMaxFilesize']['value'] = ini_get('upload_max_filesize');
* Shows the page for configurating the database connection.
*/
protected function configureDB() {
- $availableDBClasses = self::getAvailableDBClasses();
- $dbClass = '';
if (self::$developerMode && isset($_ENV['WCFSETUP_DBHOST'])) {
$dbHost = $_ENV['WCFSETUP_DBHOST'];
$dbUser = $_ENV['WCFSETUP_DBUSER'];
$dbNumber = 1;
}
- // set $dbClass to first item in $availableDBClasses
- foreach ($availableDBClasses as $dbClass) {
- $dbClass = $dbClass['class'];
- break;
- }
-
if (isset($_POST['send']) || (self::$developerMode && isset($_ENV['WCFSETUP_DBHOST']))) {
if (isset($_POST['dbHost'])) $dbHost = $_POST['dbHost'];
if (isset($_POST['dbUser'])) $dbUser = $_POST['dbUser'];
// ensure that $dbNumber is zero or a positive integer
if (isset($_POST['dbNumber'])) $dbNumber = max(0, intval($_POST['dbNumber']));
- if (isset($_POST['dbClass'])) $dbClass = $_POST['dbClass'];
// get port
$dbPort = 0;
// test connection
try {
- // check db class
- $validDB = false;
- foreach ($availableDBClasses as $dbData) {
- if ($dbData['class'] == $dbClass) {
- $validDB = true;
- break;
- }
- }
-
- if (!$validDB) {
- throw new SystemException("Database type '".$dbClass."'. is not available on this system.");
- }
-
// check connection data
/** @var \wcf\system\database\Database $db */
- $db = new $dbClass($dbHost, $dbUser, $dbPassword, $dbName, $dbPort, true);
+ $db = new MySQLDatabase($dbHost, $dbUser, $dbPassword, $dbName, $dbPort, true);
$db->connect();
// check sql version
- if (!empty($availableDBClasses[$dbClass]['minversion'])) {
- $compareSQLVersion = preg_replace('/^(\d+\.\d+\.\d+).*$/', '\\1', $db->getVersion());
- if (!(version_compare($compareSQLVersion, $availableDBClasses[$dbClass]['minversion']) >= 0)) {
- throw new SystemException("Insufficient SQL version '".$compareSQLVersion."'. Version '".$availableDBClasses[$dbClass]['minversion']."' or greater is needed.");
+ $sqlVersion = $db->getVersion();
+ $compareSQLVersion = preg_replace('/^(\d+\.\d+\.\d+).*$/', '\\1', $sqlVersion);
+ if (stripos($sqlVersion, 'MariaDB')) {
+ // MariaDB 10.0.22+
+ if (!(version_compare($compareSQLVersion, '10.0.22') >= 0)) {
+ throw new SystemException("Insufficient MariaDB version '".$compareSQLVersion."'. Version '10.0.22' or greater is needed.");
}
}
- // check innodb support
- if ($dbClass == MySQLDatabase::class) {
- $sql = "SHOW ENGINES";
- $statement = $db->prepareStatement($sql);
- $statement->execute();
- $hasInnoDB = false;
- while ($row = $statement->fetchArray()) {
- if ($row['Engine'] == 'InnoDB' && in_array($row['Support'], ['DEFAULT', 'YES'])) {
- $hasInnoDB = true;
- break;
- }
+ else {
+ // MySQL 5.5.35+
+ if (!(version_compare($compareSQLVersion, '5.5.35') >= 0)) {
+ throw new SystemException("Insufficient MySQL version '".$compareSQLVersion."'. Version '5.5.35' or greater is needed.");
}
-
- if (!$hasInnoDB) {
- throw new SystemException("Support for InnoDB is missing.");
+ }
+
+ // check innodb support
+ $sql = "SHOW ENGINES";
+ $statement = $db->prepareStatement($sql);
+ $statement->execute();
+ $hasInnoDB = false;
+ while ($row = $statement->fetchArray()) {
+ if ($row['Engine'] == 'InnoDB' && in_array($row['Support'], ['DEFAULT', 'YES'])) {
+ $hasInnoDB = true;
+ break;
}
}
+ if (!$hasInnoDB) {
+ throw new SystemException("Support for InnoDB is missing.");
+ }
+
// check for table conflicts
$conflictedTables = $this->getConflictedTables($db, $dbNumber);
$file->write("\$dbUser = '".str_replace("'", "\\'", $dbUser)."';\n");
$file->write("\$dbPassword = '".str_replace("'", "\\'", $dbPassword)."';\n");
$file->write("\$dbName = '".str_replace("'", "\\'", $dbName)."';\n");
- $file->write("\$dbClass = '".str_replace("'", "\\'", $dbClass)."';\n");
$file->write("if (!defined('WCF_N')) define('WCF_N', $dbNumber);\n");
$file->close();
'dbPassword' => $dbPassword,
'dbName' => $dbName,
'dbNumber' => $dbNumber,
- 'dbClass' => $dbClass,
- 'availableDBClasses' => $availableDBClasses,
'nextStep' => 'configureDB'
]);
WCF::getTPL()->display('stepConfigureDB');
<item name="wcf.global.languages.languages"><![CDATA[Sprachen]]></item>
<item name="wcf.global.languages.error.empty"><![CDATA[Bitte wählen Sie mindestens eine Sprache aus!]]></item>
<item name="wcf.global.configureDB"><![CDATA[Datenbankzugang konfigurieren]]></item>
- <item name="wcf.global.configureDB.description"><![CDATA[Die Daten der Software werden in einer SQL-Datenbank gespeichert. Bitte geben Sie die Zugangsdaten für diese Datenbank an! Falls Ihnen die Zugangsdaten nicht bekannt sind, wenden Sie sich bitte an Ihren Serveradministrator oder Webhoster.]]></item>
+ <item name="wcf.global.configureDB.description"><![CDATA[Die Daten der Software werden in einer MySQL oder MariaDB-Datenbank gespeichert. Bitte geben Sie die Zugangsdaten für diese Datenbank an! Falls Ihnen die Zugangsdaten nicht bekannt sind, wenden Sie sich bitte an Ihren Serveradministrator oder Webhoster.]]></item>
<item name="wcf.global.configureDB.host"><![CDATA[Server-Hostname]]></item>
<item name="wcf.global.configureDB.user"><![CDATA[Benutzername]]></item>
<item name="wcf.global.configureDB.password"><![CDATA[Kennwort]]></item>
<item name="wcf.global.configureDB.error"><![CDATA[Beim Verbindungsversuch mit der Datenbank ist folgender Fehler aufgetreten:
<br /><strong>{$exception->getMessage()}{if $exception->getPrevious()}<br />{$exception->getPrevious()->getMessage()}{/if}</strong>]]></item>
<item name="wcf.global.configureDB.conflictedTables"><![CDATA[Folgende Tabelle{if $conflictedTables|count > 1}n{/if} existier{if $conflictedTables|count > 1}en{else}t{/if} schon in der Datenbank „{$dbName}“:<br />{implode from=$conflictedTables item="table"}{$table}{/implode}.<br /><br />Um dieses Problem zu beheben, können Sie:<br />1. diese Tabelle{if $conflictedTables|count > 1}n{/if} manuell löschen und die „Weiter“ Schaltfläche betätigen, oder<br />2. Sie geben die Daten einer anderen Datenbank ein und betätigen die „Weiter“ Schaltfläche, oder<br />3. Sie geben eine von „{$dbNumber}“ unterschiedliche Installationsnummer an und betätigen die „Weiter“ Schaltfläche.]]></item>
- <item name="wcf.global.configureDB.class"><![CDATA[Datenbank-Typ]]></item>
- <item name="wcf.global.configureDB.class.MySQLDatabase"><![CDATA[MySQL 5.1+]]></item>
- <item name="wcf.global.configureDB.class.PostgreSQLDatabase"><![CDATA[PostgreSQL 8.2+]]></item>
<item name="wcf.global.createUser"><![CDATA[Administrator erstellen]]></item>
<item name="wcf.global.createUser.description"><![CDATA[Der Installationsassistent erstellt nun ein Administrator-Konto für Sie. Bitte geben Sie dazu einen Benutzernamen, eine E-Mail-Adresse und ein Kennwort ein.]]></item>
<item name="wcf.global.createUser.username"><![CDATA[Benutzername]]></item>
<item name="wcf.global.languages.languages"><![CDATA[Languages]]></item>
<item name="wcf.global.languages.error.empty"><![CDATA[Please choose at least one language!]]></item>
<item name="wcf.global.configureDB"><![CDATA[Configure Database Access]]></item>
- <item name="wcf.global.configureDB.description"><![CDATA[The data for this software needs to be stored in an SQL-database. Please enter your database access information!]]></item>
+ <item name="wcf.global.configureDB.description"><![CDATA[The data for this software needs to be stored in a MySQL or MariaDB-database. Please enter your database access information!]]></item>
<item name="wcf.global.configureDB.host"><![CDATA[Hostname]]></item>
<item name="wcf.global.configureDB.user"><![CDATA[Username]]></item>
<item name="wcf.global.configureDB.password"><![CDATA[Password]]></item>
<item name="wcf.global.configureDB.error"><![CDATA[An error has occurred while trying to connect to your database:
<br /><strong>{$exception->getMessage()}{if $exception->getPrevious()}<br />{$exception->getPrevious()->getMessage()}{/if}</strong>]]></item>
<item name="wcf.global.configureDB.conflictedTables"><![CDATA[The following table{if $conflictedTables|count > 1}s{/if} already exist{if $conflictedTables|count == 1}s{/if} within your “{$dbName}” Database:<br />{implode from=$conflictedTables item="table"}{$table}{/implode}.<br /><br />To solve this problem, please do one of the following:<br />1. Remove the table{if $conflictedTables|count > 1}s{/if} manually and continue the installation with the “Next” button or<br />2. You re-enter the database access information, but to a different database and continue the installation with the “Next” button or<br />3. Enter a new installation number, not forgetting to continue the installation with the “Next” Button.]]></item>
- <item name="wcf.global.configureDB.class"><![CDATA[Database Type]]></item>
- <item name="wcf.global.configureDB.class.MySQLDatabase"><![CDATA[MySQL 5.1+]]></item>
- <item name="wcf.global.configureDB.class.PostgreSQLDatabase"><![CDATA[PostgreSQL 8.2+]]></item>
<item name="wcf.global.createUser"><![CDATA[Create an Administrator]]></item>
<item name="wcf.global.createUser.description"><![CDATA[The installation will now generate an administrator account for you. Please provide username, email address and password.]]></item>
<item name="wcf.global.createUser.username"><![CDATA[Username]]></item>
<p class="sectionDescription">{lang}wcf.global.configureDB.description{/lang}</p>
</header>
- <dl>
- <dt><label for="dbClass">{lang}wcf.global.configureDB.class{/lang}</label></dt>
- <dd>
- <select id="dbClass" name="dbClass">
- {foreach from=$availableDBClasses key=dbClassName item=availableDBClass}
- <option value="{@$availableDBClass.class}"{if $availableDBClass.class == $dbClass} selected="selected"{/if}>{lang}wcf.global.configureDB.class.{@$dbClassName}{/lang}</option>
- {/foreach}
- </select>
- </dd>
- </dl>
-
<dl>
<dt><label for="dbHost">{lang}wcf.global.configureDB.host{/lang}</label></dt>
<dd><input type="text" id="dbHost" name="dbHost" value="{$dbHost}" required="required" class="long" /></dd>
{include file='header'}
-<section class="section">
- <h2 class="sectionTitle">{lang}wcf.global.systemRequirements.required{/lang}</h2>
-
+<form method="post" action="install.php">
<section class="section">
- <h2 class="sectionTitle">{lang}wcf.global.systemRequirements.php{/lang}</h2>
+ <h2 class="sectionTitle">{lang}wcf.global.systemRequirements.required{/lang}</h2>
- <div class="row rowColGap formGrid">
- <dl class="col-xs-12 col-md-6">
- <dt>{lang}wcf.global.systemRequirements.element.required{/lang}</dt>
- <dd>5.5.4</dd>
- </dl>
+ <section class="section">
+ <h2 class="sectionTitle">{lang}wcf.global.systemRequirements.php{/lang}</h2>
- <dl class="col-xs-12 col-md-6">
- <dt>{lang}wcf.global.systemRequirements.element.yours{/lang}</dt>
- <dd>
- <span class="badge {if !$system.phpVersion.result}red{else}green{/if}">{$system.phpVersion.value}</span>
- {if !$system.phpVersion.result}<small>{lang}wcf.global.systemRequirements.php.description{/lang}</small>{/if}
- </dd>
- </dl>
- </div>
- </section>
-
- <section class="section">
- <h2 class="sectionTitle">{lang}wcf.global.systemRequirements.memoryLimit{/lang}</h2>
-
- <div class="row rowColGap formGrid">
- <dl class="col-xs-12 col-md-6">
- <dt>{lang}wcf.global.systemRequirements.element.required{/lang}</dt>
- <dd>128M</dd>
- </dl>
+ <div class="row rowColGap formGrid">
+ <dl class="col-xs-12 col-md-6">
+ <dt>{lang}wcf.global.systemRequirements.element.required{/lang}</dt>
+ <dd>5.5.4</dd>
+ </dl>
+
+ <dl class="col-xs-12 col-md-6">
+ <dt>{lang}wcf.global.systemRequirements.element.yours{/lang}</dt>
+ <dd>
+ <span class="badge {if !$system.phpVersion.result}red{else}green{/if}">{$system.phpVersion.value}</span>
+ {if !$system.phpVersion.result}<small>{lang}wcf.global.systemRequirements.php.description{/lang}</small>{/if}
+ </dd>
+ </dl>
+ </div>
+ </section>
- <dl class="col-xs-12 col-md-6">
- <dt>{lang}wcf.global.systemRequirements.element.yours{/lang}</dt>
- <dd>
- <span class="badge {if !$system.memoryLimit.result}red{else}green{/if}">{$system.memoryLimit.value}</span>
- {if !$system.memoryLimit.result}<small>{lang}wcf.global.systemRequirements.memoryLimit.description{/lang}</small>{/if}
- </dd>
- </dl>
- </div>
- </section>
-
- <section class="section">
- <h2 class="sectionTitle">{lang}wcf.global.systemRequirements.sql{/lang}</h2>
+ <section class="section">
+ <h2 class="sectionTitle">{lang}wcf.global.systemRequirements.memoryLimit{/lang}</h2>
+
+ <div class="row rowColGap formGrid">
+ <dl class="col-xs-12 col-md-6">
+ <dt>{lang}wcf.global.systemRequirements.element.required{/lang}</dt>
+ <dd>128M</dd>
+ </dl>
+
+ <dl class="col-xs-12 col-md-6">
+ <dt>{lang}wcf.global.systemRequirements.element.yours{/lang}</dt>
+ <dd>
+ <span class="badge {if !$system.memoryLimit.result}red{else}green{/if}">{$system.memoryLimit.value}</span>
+ {if !$system.memoryLimit.result}<small>{lang}wcf.global.systemRequirements.memoryLimit.description{/lang}</small>{/if}
+ </dd>
+ </dl>
+ </div>
+ </section>
- <div class="row rowColGap formGrid">
- <dl class="col-xs-12 col-md-6">
- <dt>{lang}wcf.global.systemRequirements.element.required{/lang}</dt>
- <dd>{lang}wcf.global.systemRequirements.active{/lang}</dd>
- </dl>
+ <section class="section">
+ <h2 class="sectionTitle">{lang}wcf.global.systemRequirements.sql{/lang}</h2>
- <dl class="col-xs-12 col-md-6">
- <dt>{lang}wcf.global.systemRequirements.element.yours{/lang}</dt>
- <dd>
- <span class="badge {if !$system.sql.result}red{else}green{/if}">
- {if !$system.sql.result}{lang}wcf.global.systemRequirements.sql.notFound{/lang}{else}
- {implode from=$system.sql.value item=$sqlType glue=', '}{lang}wcf.global.configureDB.class.{@$sqlType}{/lang}{/implode}
- {/if}</span>
- {if !$system.sql.result}<small>{lang}wcf.global.systemRequirements.sql.description{/lang}</small>{/if}
- </dd>
- </dl>
- </div>
+ <div class="row rowColGap formGrid">
+ <dl class="col-xs-12 col-md-6">
+ <dt>{lang}wcf.global.systemRequirements.element.required{/lang}</dt>
+ <dd>{lang}wcf.global.systemRequirements.active{/lang}</dd>
+ </dl>
+
+ <dl class="col-xs-12 col-md-6">
+ <dt>{lang}wcf.global.systemRequirements.element.yours{/lang}</dt>
+ <dd>
+ <span class="badge {if !$system.sql.result}red{else}green{/if}">
+ {if !$system.sql.result}{lang}wcf.global.systemRequirements.sql.notFound{/lang}{else}
+ MySQL 5.5.35+ / MariaDB 10.0.22+
+ {/if}</span>
+ {if !$system.sql.result}<small>{lang}wcf.global.systemRequirements.sql.description{/lang}</small>{/if}
+ </dd>
+ </dl>
+ </div>
+ </section>
</section>
-</section>
-
-<section class="section">
- <h2 class="sectionTitle">{lang}wcf.global.systemRequirements.recommended{/lang}</h2>
<section class="section">
- <h2 class="sectionTitle">{lang}wcf.global.systemRequirements.uploadMaxFilesize{/lang}</h2>
+ <h2 class="sectionTitle">{lang}wcf.global.systemRequirements.recommended{/lang}</h2>
- <div class="row rowColGap formGrid">
- <dl class="col-xs-12 col-md-6">
- <dt>{lang}wcf.global.systemRequirements.element.recommended{/lang}</dt>
- <dd>> 0</dd>
- </dl>
+ <section class="section">
+ <h2 class="sectionTitle">{lang}wcf.global.systemRequirements.uploadMaxFilesize{/lang}</h2>
- <dl class="col-xs-12 col-md-6">
- <dt>{lang}wcf.global.systemRequirements.element.yours{/lang}</dt>
- <dd>
- <span class="badge {if !$system.uploadMaxFilesize.result}yellow{else}green{/if}">{$system.uploadMaxFilesize.value}</span>
- {if !$system.uploadMaxFilesize.result}<small>{lang}wcf.global.systemRequirements.uploadMaxFilesize.description{/lang}</small>{/if}
- </dd>
- </dl>
- </div>
- </section>
-
- <section class="section">
- <h2 class="sectionTitle">{lang}wcf.global.systemRequirements.gdLib{/lang}</h2>
+ <div class="row rowColGap formGrid">
+ <dl class="col-xs-12 col-md-6">
+ <dt>{lang}wcf.global.systemRequirements.element.recommended{/lang}</dt>
+ <dd>> 0</dd>
+ </dl>
+
+ <dl class="col-xs-12 col-md-6">
+ <dt>{lang}wcf.global.systemRequirements.element.yours{/lang}</dt>
+ <dd>
+ <span class="badge {if !$system.uploadMaxFilesize.result}yellow{else}green{/if}">{$system.uploadMaxFilesize.value}</span>
+ {if !$system.uploadMaxFilesize.result}<small>{lang}wcf.global.systemRequirements.uploadMaxFilesize.description{/lang}</small>{/if}
+ </dd>
+ </dl>
+ </div>
+ </section>
- <div class="row rowColGap formGrid">
- <dl class="col-xs-12 col-md-6">
- <dt>{lang}wcf.global.systemRequirements.element.recommended{/lang}</dt>
- <dd>2.0.0</dd>
- </dl>
+ <section class="section">
+ <h2 class="sectionTitle">{lang}wcf.global.systemRequirements.gdLib{/lang}</h2>
- <dl class="col-xs-12 col-md-6">
- <dt>{lang}wcf.global.systemRequirements.element.yours{/lang}</dt>
- <dd>
- <span class="badge {if !$system.gdLib.result}yellow{else}green{/if}">{$system.gdLib.value}</span>
- {if !$system.gdLib.result}<small>{lang}wcf.global.systemRequirements.gdLib.description{/lang}</small>{/if}
- </dd>
- </dl>
- </div>
+ <div class="row rowColGap formGrid">
+ <dl class="col-xs-12 col-md-6">
+ <dt>{lang}wcf.global.systemRequirements.element.recommended{/lang}</dt>
+ <dd>2.0.0</dd>
+ </dl>
+
+ <dl class="col-xs-12 col-md-6">
+ <dt>{lang}wcf.global.systemRequirements.element.yours{/lang}</dt>
+ <dd>
+ <span class="badge {if !$system.gdLib.result}yellow{else}green{/if}">{$system.gdLib.value}</span>
+ {if !$system.gdLib.result}<small>{lang}wcf.global.systemRequirements.gdLib.description{/lang}</small>{/if}
+ </dd>
+ </dl>
+ </div>
+ </section>
</section>
-</section>
-<form method="post" action="install.php">
<div class="formSubmit">
<input type="submit" value="{lang}wcf.global.button.next{/lang}"{if !$system.phpVersion.result || !$system.sql.result || !$system.memoryLimit.result} disabled="disabled"{/if} accesskey="s"/>
<input type="hidden" name="step" value="{@$nextStep}" />