Fix php errors during install

This commit is contained in:
Jay Trees 2022-01-14 16:18:54 +01:00
parent 05a8549566
commit 43a6d67909
2 changed files with 17 additions and 8 deletions

View file

@ -20,11 +20,19 @@ class Options
public function getOption(string $key): string
{
$option = $this->database->query(
'SELECT * FROM `options`
WHERE `key` = "' . $key . '";'
)->fetch();
$value = '';
return $option['value'] ?? '';
try {
$option = $this->database->query(
'SELECT * FROM `options`
WHERE `key` = "' . $key . '";'
)->fetch();
$value = $option['value'] ?? '';
} catch (\Throwable $th) {
//throw $th;
}
return $value;
}
}

View file

@ -27,6 +27,7 @@ class Page
*/
$disableRedirect = array(
'login',
'register',
'install'
);
if (!isset($_SESSION['user']) && isset($_GET['page']) && !in_array($_GET['page'], $disableRedirect)) {
@ -126,9 +127,9 @@ class Page
<i class="dropdown icon"></i>
<div class="menu">
<?php
$user = new User();
$user = isset($_SESSION['user']) ? new User() : null;
if ($user->isLoggedIn()) {
if ($user && $user->isLoggedIn()) {
?>
<a class="item" href="/?page=logout">
<i class="sign out alternate icon"></i>
@ -151,7 +152,7 @@ class Page
</div>
</div>
<?php global $options; ?>
<?php if ($options->updateAvailable) { ?>
<?php if ($options->updateAvailable && $user && $user->isLoggedIn()) { ?>
<a class="item" href="/?page=update">
<i class="upload icon"></i> Update
</a>