From 44c1d26d8945325a627a24c831780cbbcaa37800 Mon Sep 17 00:00:00 2001 From: grandeljay Date: Sun, 14 Nov 2021 09:12:49 +0100 Subject: [PATCH] Improve installer --- includes/pages/install.php | 118 ++++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 55 deletions(-) diff --git a/includes/pages/install.php b/includes/pages/install.php index 7308eabd..a683ad46 100644 --- a/includes/pages/install.php +++ b/includes/pages/install.php @@ -11,66 +11,74 @@ use wishthis\{Page, Database}; $page = new page(__FILE__, 'Home'); $page->header(); -if (isset($_POST['action']) && 'install' === $_POST['action']) { - $configDirectory = 'includes/config'; - $configPath = $configDirectory . '/config.php'; - $configSamplePath = $configDirectory . '/config-sample.php'; - $configContents = file_get_contents($configSamplePath); +$step = isset($_POST['step']) ? $_POST['step'] : 1; - foreach ($_POST as $key => $value) { - if ('DATABASE' === substr($key, 0, 8)) { - $configContents = preg_replace('/(' . $key . '.+?\').*?(\')/', '$1' . $value . '$2', $configContents); +switch ($step) { + case 1: + ?> +
+
+

Install

+

Step

+

Welcome to the wishthis installer.

+

wishthis needs a database to function properly. Please enter your credentials.

+ +
+ + + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+
+
+ $value) { + if ('DATABASE' === substr($key, 0, 8)) { + $configContents = preg_replace('/(' . $key . '.+?\').*?(\')/', '$1' . $value . '$2', $configContents); + } } - } - file_put_contents($configPath, $configContents); + file_put_contents($configPath, $configContents); - ?> -
-
-

Success

-

wishthis has been successfully installed.

+ ?> +
+
+

Success

+

wishthis has been successfully installed.

- Continue -
-
- -
-
-

Install

-

Welcome to the wishthis installer.

-

wishthis needs a database to function properly. Please enter your credentials.

- -
- - -
- - -
- -
- - -
- -
- - -
- -
- - -
- - -
-
-
- Continue +
+
+ footer();