*/ use wishthis\{Page, User}; $page = new page(__FILE__, 'Update', 100); $page->header(); $page->navigation(); /** * Update */ if ('POST' === $_SERVER['REQUEST_METHOD']) { /** * Files */ $zip_filename = __DIR__ . '/' . $tag . '.zip'; /** Download */ file_put_contents( $zip_filename, file_get_contents('https://github.com/grandeljay/wishthis/archive/refs/tags/' . $tag . '.zip') ); /** Decompress */ $zip = new ZipArchive(); if ($zip->open($zip_filename)) { $zip->extractTo(__DIR__); $zip->close(); $directory_wishthis_github = __DIR__ . '/wishthis-' . $version; foreach (scandir($directory_wishthis_github) as $filename) { if (in_array($filename, array('.', '..', 'config'))) { continue; } $filepath = __DIR__ . '/' . $filename; $filepath_github = $directory_wishthis_github . '/' . $filename; if (is_dir($filepath) && is_dir($filepath_github)) { delete_directory($filepath); } rename($filepath_github, $filepath); } } /** Delete */ unlink($zip_filename); /** * Database */ /** Current version is below 0.2.0 */ if (-1 === version_compare($options->version, '0.2.0')) { $database->query('ALTER TABLE `users` ADD `last_login` DATETIME NOT NULL DEFAULT NOW() AFTER `password`, ADD `power` BOOLEAN NOT NULL DEFAULT 0 AFTER `last_login` ;'); $database->query('UPDATE `users` SET `power` = 100 WHERE `id` = ' . $user->id . ';'); $database->query('ALTER TABLE `users` ADD INDEX(`password`);'); $database->query('ALTER TABLE `wishlists` ADD `hash` VARCHAR(128) NOT NULL AFTER `name` ;'); $database->query('ALTER TABLE `wishlists` ADD INDEX(`hash`);'); $database->query('INSERT INTO `options` (`key`, `value`) VALUES ("version", "' . $version . '");'); } /** Current version is below 0.3.0 */ if (-1 === version_compare($options->version, '0.3.0')) { $database->query('ALTER TABLE `products` ADD `status` VARCHAR(32) NOT NULL AFTER `url` ;'); } /** Update version */ $options->setOption('version', $version); header('Location: /?page=home'); die(); } ?>

title ?>

New version detected

An update is available. If you are brave, please click the button to start the self updater.

Use at own risk

Be sure to make backups before proceeding.

Changes

', $release['body']) ?>
footer(); ?>