Improve installation

This commit is contained in:
Jay 2021-11-15 09:45:36 +01:00
parent 39b2ef2c03
commit 7d5f19c3b8
6 changed files with 76 additions and 14 deletions

View file

@ -69,6 +69,8 @@ fieldset {
border: none;
}
input[type="email"],
input[type="password"],
input[type="text"] {
width: 100%;
padding: 0.4em;

View file

@ -29,4 +29,9 @@ class Database
throw new \PDOException($PDOE->getMessage(), (int)$PDOE->getCode());
}
}
public function query(string $query): void
{
$this->pdo->query($query);
}
}

View file

@ -15,6 +15,7 @@ $page->header();
<main>
<section>
<h1>Welcome to wishthis</h1>
<a href="?page=register">Register</a>
</section>
</main>

View file

@ -19,12 +19,11 @@ switch ($step) {
<main>
<section>
<h1>Install</h1>
<h2>Step <? $step ?></h2>
<h2>Step <?= $step ?></h2>
<p>Welcome to the wishthis installer.</p>
<p>wishthis needs a database to function properly. Please enter your credentials.</p>
<form method="post">
<input type="hidden" name="action" value="install" />
<form action="?page=install" method="post">
<input type="hidden" name="step" value="<?= $step + 1; ?>" />
<fieldset>
@ -34,7 +33,7 @@ switch ($step) {
<fieldset>
<label>Name</label>
<input type="text" name="DATABASE_NAME" placeholder="withthis" value="withthis" />
<input type="text" name="DATABASE_NAME" placeholder="wishthis" value="wishthis" />
</fieldset>
<fieldset>
@ -47,7 +46,7 @@ switch ($step) {
<input type="text" name="DATABASE_PASSWORD" />
</fieldset>
<input type="submit" value="Install" />
<input type="submit" value="Continue" />
</form>
</section>
</main>
@ -67,14 +66,35 @@ switch ($step) {
}
file_put_contents($configPath, $configContents);
?>
<main>
<section>
<h1>Install</h1>
<h2>Step <?= $step ?></h2>
<p>Klick Continue to test the database connection.</p>
<form action="?page=install" method="post">
<input type="hidden" name="step" value="<?= $step + 1; ?>" />
<input type="submit" value="Continue" />
</form>
</section>
</main>
<?php
break;
case 3:
$database->query('CREATE TABLE IF NOT EXISTS `users` (
`id` int AUTO_INCREMENT,
`email` varchar(64),
`password` varchar(128),
PRIMARY KEY (id)
);');
?>
<main>
<section>
<h1>Success</h1>
<p>wishthis has been successfully installed.</p>
<a class="button primary" href="">Continue</a>
<a href="?page=login">Login</a>
</section>
</main>
<?php

View file

@ -0,0 +1,36 @@
<?php
/**
* register.php
*
* @author Jay Trees <github.jay@grandel.anonaddy.me>
*/
use wishthis\Page;
$page = new page(__FILE__, 'Home');
$page->header();
?>
<main>
<section>
<h1>Register</h1>
<form method="post">
<fieldset>
<label>Email</label>
<input type="email" name="email" placeholder="john.doe@domain.tld" />
</fieldset>
<fieldset>
<label>Password</label>
<input type="password" name="password" />
</fieldset>
<input type="submit" value="Register" />
</form>
</section>
</main>
<?php
$page->footer();

View file

@ -15,14 +15,12 @@ autoInclude(__DIR__ . '/includes/classes');
autoInclude(__DIR__ . '/includes/functions');
/**
* Config / Install
* Config
*/
$configPath = 'includes/config/config.php';
if (file_exists($configPath)) {
require $configPath;
} else {
$page = 'install';
}
/**
@ -40,6 +38,8 @@ if (
DATABASE_USER,
DATABASE_PASSWORD
);
} else {
$page = 'install';
}
/**
@ -50,6 +50,4 @@ if (!isset($page)) {
}
$pagePath = 'includes/pages/' . $page . '.php';
if (file_exists($pagePath)) {
require $pagePath;
}
require $pagePath;