From 8abf2c5e8aa7d4ce864b0e90e14f1b8c0b5b4522 Mon Sep 17 00:00:00 2001 From: Bryan Date: Sun, 2 Jun 2019 15:20:08 +0200 Subject: [PATCH] deleted config.json - no more need of it, added installer to create config.json --- config.json | 11 ---- functions.php | 1 - index.php | 13 +++- lib/php/install.php | 148 ++++++++++++++++++++++++++++++++++++++++++++ lib/php/login.php | 2 +- 5 files changed, 160 insertions(+), 15 deletions(-) delete mode 100644 config.json create mode 100644 lib/php/install.php diff --git a/config.json b/config.json deleted file mode 100644 index bac5848..0000000 --- a/config.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "installed": false, - "website_name": "OpenShorte", - "db": { - "host": "127.0.0.1", - "port": 3306, - "username": "", - "password": "", - "name": "" - } -} \ No newline at end of file diff --git a/functions.php b/functions.php index 2ff1edb..4f56039 100644 --- a/functions.php +++ b/functions.php @@ -3,6 +3,5 @@ function load_config ( ) : array { $config = file_get_contents ( 'config.json' ); $config = json_decode ( $config, true ); - $config [ 'installation_path' ] = substr ( $_SERVER [ 'SCRIPT_NAME' ], 0, -10 ); return $config; } diff --git a/index.php b/index.php index 4bfb292..69ad4e4 100644 --- a/index.php +++ b/index.php @@ -1,8 +1,17 @@ true, + 'website_name' => $_POST [ 'site_name' ], + 'db' => [ + 'host' => $_POST [ 'db_host' ], + 'port' => (integer) $_POST [ 'db_port' ], + 'username' => $_POST [ 'db_username' ], + 'password' => $_POST [ 'db_password' ], + 'name' => $_POST [ 'db_name' ], + ], + 'installation_path' => substr ( $_SERVER [ 'SCRIPT_NAME' ], 0, -10 ), + ]; + file_put_contents ( 'config.json', json_encode ( $config ) ); + header ( 'Content-Type: application/json' ); + echo ( json_encode ( [ 'status' => 200, 'message' => 'Installation completed!
You will be redirected to the home page in 5 seconds.', 'homelocation' => $config [ 'installation_path' ] ] ) ); + exit; + } + else { +?> + + + + + Installer | OpenShorte + + + + +
+
+
+

+ Welcome to the OpenShorte installer.
+ Since it seems that there are no installation found for this website, we'll proceed now with creating one.
+ Please click 'Next' and provide all the necessary informations for the database and the site name in order to let this website work correctly. +

+ +
+
+
+
+
+ Website Name: +
+ +
+
+ +
+
+
+
+
+ Host: +
+ +
+
+
+ Port: +
+ +
+
+
+
+
+ Username: +
+ +
+
+
+ Password: +
+ +
+
+
+ Repeat Password: +
+ +
+
+
+ Database Name: +
+ +
+
+ +
+
+
+
+
+
+ + + + +