2022-01-18 09:51:40 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* home.php
|
|
|
|
*
|
|
|
|
* @author Jay Trees <github.jay@grandel.anonaddy.me>
|
|
|
|
*/
|
|
|
|
|
|
|
|
use wishthis\{Page, User};
|
|
|
|
|
|
|
|
$page = new page(__FILE__, 'Update');
|
|
|
|
$page->header();
|
|
|
|
$page->navigation();
|
2022-01-18 10:40:43 +00:00
|
|
|
|
|
|
|
$user = new User();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update
|
|
|
|
*/
|
|
|
|
if ('POST' === $_SERVER['REQUEST_METHOD']) {
|
|
|
|
/** Current version is below 0.1.0 */
|
|
|
|
if (-1 === version_compare($options->version, '0.2.0')) {
|
|
|
|
$database->query('ALTER TABLE `users`
|
|
|
|
ADD `last_login` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `password`,
|
|
|
|
ADD `isAdministrator` BOOLEAN NOT NULL AFTER `last_login`
|
|
|
|
;');
|
|
|
|
|
|
|
|
$database->query('ALTER TABLE `wishlists`
|
|
|
|
ADD `url` VARCHAR(128) NOT NULL AFTER `name`
|
|
|
|
;');
|
2022-01-18 10:49:37 +00:00
|
|
|
|
|
|
|
$database->query('INSERT INTO `options` (`key`, `value`) VALUES ("version", "' . VERSION . '");');
|
|
|
|
|
|
|
|
// Use this for future versions since it didn't existsin 0.1.0
|
|
|
|
// $options->setOption('version', VERSION);
|
2022-01-18 10:40:43 +00:00
|
|
|
}
|
2022-01-18 10:49:37 +00:00
|
|
|
|
|
|
|
header('Location: /?page=home');
|
|
|
|
die();
|
2022-01-18 10:40:43 +00:00
|
|
|
}
|
2022-01-18 09:51:40 +00:00
|
|
|
?>
|
|
|
|
|
|
|
|
<main>
|
|
|
|
<div class="ui container">
|
|
|
|
<h1 class="ui header"><?= $page->title ?></h1>
|
|
|
|
|
|
|
|
<?php if ($user->isLoggedIn()) { ?>
|
2022-01-18 10:40:43 +00:00
|
|
|
<div class="ui segment">
|
|
|
|
<h2 class="ui header">New version detected</h2>
|
|
|
|
<p>Thank you for updating to <strong>v<?= VERSION ?></strong>!</p>
|
|
|
|
<p>There have been some changes in the database, please run the updater.</p>
|
|
|
|
<div class="ui icon warning message">
|
|
|
|
<i class="exclamation triangle icon"></i>
|
|
|
|
<div class="content">
|
|
|
|
<div class="header">
|
|
|
|
Use at own risk
|
|
|
|
</div>
|
|
|
|
<p>Be sure to make backups before proceeding.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<form class="ui form" method="post">
|
|
|
|
<button class="ui orange button" type="submit">
|
|
|
|
<i class="upload icon"></i>
|
|
|
|
Run the updater
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
2022-01-18 09:51:40 +00:00
|
|
|
<?php } else { ?>
|
|
|
|
<div class="ui segment">
|
|
|
|
<h2 class="ui header">Maintenance</h2>
|
|
|
|
<p>
|
|
|
|
The administrator of this site is currently running an update.
|
|
|
|
This usually just takes a couple of seconds.
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
Trying again in <span id="retryIn">5</span> seconds...
|
|
|
|
</p>
|
2022-01-18 10:40:43 +00:00
|
|
|
<div class="ui primary progress nolabel">
|
2022-01-18 09:51:40 +00:00
|
|
|
<div class="bar"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?php } ?>
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
$page->footer();
|
|
|
|
?>
|