Add update button placeholder
This commit is contained in:
parent
0b7b775c4b
commit
3c55219c7e
4 changed files with 39 additions and 12 deletions
|
@ -23,11 +23,7 @@ class Database
|
|||
$dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->database . ';port=3306;charset=utf8';
|
||||
$options = array();
|
||||
|
||||
try {
|
||||
$this->pdo = new \PDO($dsn, $this->user, $this->password, $options);
|
||||
} catch (\PDOException $PDOE) {
|
||||
throw new \PDOException($PDOE->getMessage(), (int)$PDOE->getCode());
|
||||
}
|
||||
$this->pdo = new \PDO($dsn, $this->user, $this->password, $options);
|
||||
}
|
||||
|
||||
public function query(string $query)
|
||||
|
|
|
@ -12,6 +12,8 @@ namespace wishthis;
|
|||
|
||||
class Options
|
||||
{
|
||||
public bool $updateAvailable = false;
|
||||
|
||||
public function __construct(private Database $database)
|
||||
{
|
||||
}
|
||||
|
@ -23,6 +25,6 @@ class Options
|
|||
WHERE `key` = "' . $key . '";'
|
||||
)->fetch();
|
||||
|
||||
return $option['value'];
|
||||
return $option['value'] ?? '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,6 +146,12 @@ class Page
|
|||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php global $options; ?>
|
||||
<?php if ($options->updateAvailable) { ?>
|
||||
<a class="item" href="/?page=update">
|
||||
<i class="upload icon"></i> Update
|
||||
</a>
|
||||
<?php } ?>
|
||||
<div class="right item">
|
||||
<div class="ui input"><input type="text" placeholder="Search..."></div>
|
||||
</div>
|
||||
|
|
35
index.php
35
index.php
|
@ -6,6 +6,8 @@
|
|||
* @author Jay Trees <github.jay@grandel.anonaddy.me>
|
||||
*/
|
||||
|
||||
$version_new = '0.1.0';
|
||||
|
||||
/**
|
||||
* Include
|
||||
*/
|
||||
|
@ -27,6 +29,7 @@ if (file_exists($configPath)) {
|
|||
* Database
|
||||
*/
|
||||
$database = false;
|
||||
$options = false;
|
||||
|
||||
if (
|
||||
defined('DATABASE_HOST')
|
||||
|
@ -40,12 +43,12 @@ if (
|
|||
DATABASE_USER,
|
||||
DATABASE_PASSWORD
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Options
|
||||
*/
|
||||
$options = new wishthis\Options($database);
|
||||
/**
|
||||
* Options
|
||||
*/
|
||||
$options = new wishthis\Options($database);
|
||||
}
|
||||
|
||||
/**
|
||||
* Session
|
||||
|
@ -66,6 +69,17 @@ if (!$options) {
|
|||
$page = 'install';
|
||||
}
|
||||
|
||||
/**
|
||||
* Update
|
||||
*/
|
||||
if ($options) {
|
||||
$version_current = $options->getOption('version') ?? '0.0.0';
|
||||
|
||||
if (-1 === version_compare($version_current, $version_new)) {
|
||||
$options->updateAvailable = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Page
|
||||
*/
|
||||
|
@ -74,4 +88,13 @@ if (!isset($page)) {
|
|||
}
|
||||
$pagePath = 'includes/pages/' . $page . '.php';
|
||||
|
||||
require $pagePath;
|
||||
if (file_exists($pagePath)) {
|
||||
require $pagePath;
|
||||
} else {
|
||||
http_response_code(404);
|
||||
?>
|
||||
<h1>Not found</h1>
|
||||
<p>The requested URL was not found on this server.</p>
|
||||
<?php
|
||||
die();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue