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: +
+ +
+
+ +
+
+
+
+
+
+ + + + +