diff --git a/core/lib/Thelia/Install/CheckDatabaseConnection.php b/core/lib/Thelia/Install/CheckDatabaseConnection.php index a2a18853e..c9c2060f5 100644 --- a/core/lib/Thelia/Install/CheckDatabaseConnection.php +++ b/core/lib/Thelia/Install/CheckDatabaseConnection.php @@ -96,11 +96,11 @@ class CheckDatabaseConnection extends BaseInstall public function exec() { - $dsn = "mysql:host=%s"; + $dsn = "mysql:host=%s;port=%s"; try { $this->connection = new \PDO( - sprintf($dsn, $this->host), + sprintf($dsn, $this->host, $this->port), $this->user, $this->password ); diff --git a/web/install/bdd.php b/web/install/bdd.php index 059a25eb8..05fcfe762 100644 --- a/web/install/bdd.php +++ b/web/install/bdd.php @@ -51,7 +51,7 @@ $connection = $checkConnection->getConnection(); $databases = $connection->query('show databases'); ?>
-
+
Choose your database

@@ -107,6 +107,12 @@ $databases = $connection->query('show databases');

+
+
+ +
+ +
diff --git a/web/install/config.php b/web/install/config.php new file mode 100644 index 000000000..249f7c033 --- /dev/null +++ b/web/install/config.php @@ -0,0 +1,110 @@ +. */ +/* */ +/*************************************************************************************/ + +$step = 4; +include("header.php"); +global $thelia; +$err = isset($_GET['err']) && $_GET['err']; + +if (!$err) { + $checkConnection = new \Thelia\Install\CheckDatabaseConnection($_SESSION['install']['host'], $_SESSION['install']['username'], $_SESSION['install']['password'], $_SESSION['install']['port']); + $connection = $checkConnection->getConnection(); + $connection->exec("SET NAMES UTF8"); + $database = new \Thelia\Install\Database($connection); + + if (isset($_POST['database'])) { + $_SESSION['install']['database'] = $_POST['database']; + } + + if (isset($_POST['database_create']) && $_POST['database_create'] != "") { + $_SESSION['install']['database'] = $_POST['database_create']; + $database->createDatabase($_SESSION['install']['database']); + } + + if (!$connection->exec(sprintf('use %s', $_SESSION['install']['database']))) { + header('location: bdd.php?err=1'); + } + + $database->insertSql($_SESSION['install']['database']); + + if(!file_exists(THELIA_ROOT . "/local/config/database.yml")) { + $fs = new \Symfony\Component\Filesystem\Filesystem(); + + $sampleConfigFile = THELIA_ROOT . "/local/config/database.yml.sample"; + $configFile = THELIA_ROOT . "/local/config/database.yml"; + + $fs->copy($sampleConfigFile, $configFile, true); + + $configContent = file_get_contents($configFile); + + $configContent = str_replace("%DRIVER%", "mysql", $configContent); + $configContent = str_replace("%USERNAME%", $_SESSION['install']['username'], $configContent); + $configContent = str_replace("%PASSWORD%", $_SESSION['install']['password'], $configContent); + $configContent = str_replace( + "%DSN%", + sprintf("mysql:host=%s;dbname=%s;port=%s", $_SESSION['install']['host'], $_SESSION['install']['database'], $_SESSION['install']['port']), + $configContent + ); + + file_put_contents($configFile, $configContent); + + // FA - no, as no further install will be possible + // $fs->remove($sampleConfigFile); + + $fs->remove($thelia->getContainer()->getParameter("kernel.cache_dir")); + } +} + +?> +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + +
+ +
+ diff --git a/web/install/connection.php b/web/install/connection.php index 2d68c5cac..fdbddfafd 100644 --- a/web/install/connection.php +++ b/web/install/connection.php @@ -49,7 +49,7 @@ $_SESSION['install']['step'] = 3; -
+