*/ use wishthis\{Page, Database}; if ($options && $options->getOption('isInstalled')) { header('Location: /?page=home'); die(); } $page = new page(__FILE__, 'Install'); $page->header(); $step = isset($_POST['step']) ? $_POST['step'] : 1; switch ($step) { case 1: session_destroy(); ?>

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); ?>

Install

Step

Click Continue to test the database connection.

query('CREATE TABLE `users` ( `id` int PRIMARY KEY AUTO_INCREMENT, `email` varchar(64) NOT NULL UNIQUE, `password` varchar(128) NOT NULL, `last_login` datetime NOT NULL DEFAULT NOW(), `power` int NOT NULL DEFAULT 0 );'); $database->query('CREATE INDEX `idx_password` ON `users` (`password`);'); /** * Wishlists */ $database->query('CREATE TABLE `wishlists` ( `id` int PRIMARY KEY AUTO_INCREMENT, `user` int NOT NULL, `name` varchar(128) NOT NULL, `hash` varchar(128) NOT NULL, FOREIGN KEY (`user`) REFERENCES `users` (`id`) ON DELETE CASCADE );'); $database->query('CREATE INDEX `idx_hash` ON `wishlists` (`hash`);'); /** * Products */ $database->query('CREATE TABLE `products` ( `id` int NOT NULL PRIMARY KEY AUTO_INCREMENT, `wishlist` int NOT NULL, `url` VARCHAR(255) NOT NULL, FOREIGN KEY (`wishlist`) REFERENCES `wishlists` (`id`) ON DELETE CASCADE );'); /** * Options */ $database->query('CREATE TABLE `options` ( `id` int PRIMARY KEY AUTO_INCREMENT, `key` varchar(64) NOT NULL UNIQUE, `value` varchar(128) NOT NULL );'); $database->query('INSERT INTO `options` (`key`, `value`) VALUES ("isInstalled", true) ;'); ?>

Success

Register