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 ) ); try { $database = new PDO ( "mysql:dbname=" . $config [ 'db' ] [ 'name' ] . ";host=" . $config [ 'db' ] [ 'host' ] . ":" . $config [ 'db' ] [ 'port' ], $config [ 'db' ] [ 'username' ], $config [ 'db' ] [ 'password' ] ); } catch ( PDOException $exception ) { unlink ( "config.json" ); http_response_code ( 400 ); header ( 'Content-Type: application/json' ); echo ( json_encode ( [ 'status' => 400, 'message' => $exception->getMessage ( ) ] ) ); exit; } $query = "CREATE TABLE IF NOT EXISTS `users` ( `ID` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `username` VARCHAR(50) NOT NULL COLLATE 'utf8mb4_bin', `password` VARCHAR(128) NOT NULL COLLATE 'utf8mb4_bin', PRIMARY KEY (`ID`) ) COLLATE='utf8mb4_bin' ENGINE=InnoDB; CREATE TABLE IF NOT EXISTS `links` ( `ID` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `URL` VARCHAR(50) NOT NULL COLLATE 'utf8mb4_bin', `created_by` BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (`ID`), INDEX `links.created_by` (`created_by`), CONSTRAINT `links.created_by` FOREIGN KEY (`created_by`) REFERENCES `users` (`ID`) ON UPDATE CASCADE ON DELETE CASCADE ) COLLATE='utf8mb4_bin' ENGINE=InnoDB;"; $database->query ( $query ); 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: