From bcaa1f2277a44f4ed96a610d04e40dbf8a743b9e Mon Sep 17 00:00:00 2001 From: grandeljay Date: Thu, 7 Sep 2023 15:04:52 +0200 Subject: [PATCH] feat(installer): add prerequisites check --- src/assets/css/default/dark.css | 40 ++++++++ src/pages/changelog.php | 6 ++ src/pages/install.php | 171 +++++++++++++++++++++++++++----- 3 files changed, 190 insertions(+), 27 deletions(-) diff --git a/src/assets/css/default/dark.css b/src/assets/css/default/dark.css index 37c6f8f8..f46fa15d 100644 --- a/src/assets/css/default/dark.css +++ b/src/assets/css/default/dark.css @@ -564,4 +564,44 @@ .ui.steps .step .description { color: rgba(255, 255, 255, .9); } + + /** + * Table + */ + .ui.table { + background-color: #333; + color: rgba(255, 255, 255, .9); + border: none; + } + + .ui.ui.table > tbody > tr > th, + .ui.ui.table > thead > tr > th, + .ui.ui.table > tr > th { + background-color: rgba(0, 0, 0, .15); + border-color: rgba(255, 255, 255, .1); + color: rgba(255, 255, 255, .9); + } + + .ui.ui.table td.positive, + .ui.ui.ui.ui.table tr.positive { + background-color: #a3c293; + color: #2c662d; + } + + .ui.ui.table td.negative, + .ui.ui.ui.ui.table tr.negative { + background-color: #e0b4b4; + color: #9f3a38; + } + + .ui.celled.table > tbody > tr > td, + .ui.celled.table > tr > td { + border-left: 1px solid rgba(255, 255, 255, .1); + } + + .ui.table > tbody > tr > td, + .ui.table > tfoot > tr > td, + .ui.table > tr > td { + border-color: rgba(255, 255, 255, .1); + } } diff --git a/src/pages/changelog.php b/src/pages/changelog.php index 0caa3dad..e23047d1 100644 --- a/src/pages/changelog.php +++ b/src/pages/changelog.php @@ -130,6 +130,12 @@ $page->navigation(); echo __('Amazon links are now automatically converted to affiliate links to help support wishthis financially.'); ?> +
  • + +
  • diff --git a/src/pages/install.php b/src/pages/install.php index cd4673a9..fa1be622 100644 --- a/src/pages/install.php +++ b/src/pages/install.php @@ -19,6 +19,9 @@ $page->bodyStart(); $step = isset($_POST['step']) ? $_POST['step'] : 1; switch ($step) { + /** + * Test the database credentials + */ case 1: session_destroy(); unset($_SESSION); @@ -87,9 +90,136 @@ switch ($step) { __('PHP Version >= 8.1'), + 'icon' => 'php', + 'condition' => \version_compare(\PHP_VERSION, '8.1', '>='), + 'label' => __('Compatible'), + ), + array( + 'filename' => __('PHP Version < 8.3'), + 'icon' => 'php', + 'condition' => \version_compare(\PHP_VERSION, '8.3', '<'), + 'label' => __('Compatible'), + ), + array( + 'filename' => 'PHP Extension: Intl', + 'icon' => 'php', + 'condition' => \extension_loaded('intl'), + 'label' => __('Activated'), + ), + + array( + 'filename' => '/src/cache', + 'icon' => 'folder', + 'condition' => \file_exists(ROOT . '/src/cache') && \is_dir(ROOT . '/src/cache'), + 'label' => __('Exists'), + ), + array( + 'filename' => '/src/cache', + 'icon' => 'folder', + 'condition' => \is_writeable(ROOT . '/src/cache'), + 'label' => __('Writeable'), + ), + + array( + 'filename' => '/src/config', + 'icon' => 'folder', + 'condition' => \file_exists(ROOT . '/src/config') && \is_dir(ROOT . '/src/config'), + 'label' => __('Exists'), + ), + array( + 'filename' => '/src/config', + 'icon' => 'folder', + 'condition' => \is_writeable(ROOT . '/src/config'), + 'label' => __('Writeable'), + ), + array( + 'filename' => '/src/config/config.php', + 'icon' => 'file', + 'condition' => !\file_exists('/src/config/config.php'), + 'label' => __('Doesn\'t exist (yet)'), + ), + ); + + foreach ($_POST as $key => $value) { + if ('DATABASE' === substr($key, 0, 8)) { + $_SESSION[$key] = $value; + } + } + ?> +
    + +
    + + +

    title ?>

    + +
    +

    + +

    +
    + +
    +

    + + + + + + + + + + + + + + + + +
    + + + + + + + + + +
    + +
    + + +
    + +
    + +
    +
    +
    +
    +
    + $value) { + foreach ($_SESSION as $key => $value) { if ('DATABASE' === substr($key, 0, 8)) { $configContents = preg_replace('/(' . $key . '.+?\').*?(\')/', '$1' . $value . '$2', $configContents); } } - file_put_contents($configPath, $configContents); - ?> -
    - -
    -
    -

    title ?>

    -

    -

    + \file_put_contents($configPath, $configContents); -
    - + /** + * Database + */ + $database = new Database( + $_SESSION['DATABASE_HOST'], + $_SESSION['DATABASE_NAME'], + $_SESSION['DATABASE_USER'], + $_SESSION['DATABASE_PASSWORD'] + ); + unset($_SESSION); - -
    -
    -
    -
    - query('SET foreign_key_checks = 0;'); /**