avoid jumping through install steps by url-manipulating; fix pre-selections of select-multiple-settings values;
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -94,6 +94,13 @@ class Install
|
|||||||
if (isset($_SESSION['installation']) && $this->currentStep == 0) {
|
if (isset($_SESSION['installation']) && $this->currentStep == 0) {
|
||||||
unset($_SESSION['installation']);
|
unset($_SESSION['installation']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check for url manipulation or wrong step
|
||||||
|
if ((isset($_SESSION['installation']['stepCompleted']) && ($this->currentStep + 1) > ($_SESSION['installation']['stepCompleted'] ?? 0))
|
||||||
|
|| (!isset($_SESSION['installation']['stepCompleted']) && $this->currentStep > 0)
|
||||||
|
) {
|
||||||
|
$this->currentStep = isset($_SESSION['installation']['stepCompleted']) ? $_SESSION['installation']['stepCompleted'] + 1 : 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,6 +122,7 @@ class Install
|
|||||||
UI::twigBuffer('/install/index.html.twig', [
|
UI::twigBuffer('/install/index.html.twig', [
|
||||||
'setup' => [
|
'setup' => [
|
||||||
'step' => $this->currentStep,
|
'step' => $this->currentStep,
|
||||||
|
'max_steps' => $this->maxSteps,
|
||||||
],
|
],
|
||||||
'preflight' => $this->checkRequirements(),
|
'preflight' => $this->checkRequirements(),
|
||||||
'page' => [
|
'page' => [
|
||||||
@@ -135,11 +143,10 @@ class Install
|
|||||||
*/
|
*/
|
||||||
private function handleFormData(array $formfield): void
|
private function handleFormData(array $formfield): void
|
||||||
{
|
{
|
||||||
// Validate user data
|
|
||||||
$validatedData = $this->validateRequest($formfield['sections']['step' . $this->currentStep]['fields']);
|
|
||||||
|
|
||||||
// handle current step
|
// handle current step
|
||||||
if ($this->currentStep <= $this->maxSteps) {
|
if ($this->currentStep <= $this->maxSteps) {
|
||||||
|
// Validate user data
|
||||||
|
$validatedData = $this->validateRequest($formfield['sections']['step' . $this->currentStep]['fields']);
|
||||||
// Check database connection (
|
// Check database connection (
|
||||||
if ($this->currentStep == 1) {
|
if ($this->currentStep == 1) {
|
||||||
$this->checkDatabase($validatedData);
|
$this->checkDatabase($validatedData);
|
||||||
@@ -152,6 +159,7 @@ class Install
|
|||||||
elseif ($this->currentStep == 3) {
|
elseif ($this->currentStep == 3) {
|
||||||
$this->checkSystem($validatedData);
|
$this->checkSystem($validatedData);
|
||||||
}
|
}
|
||||||
|
$validatedData['stepCompleted'] = ($this->currentStep < $this->maxSteps) ? $this->currentStep : ($this->maxSteps - 1);
|
||||||
// Store validated data for later use
|
// Store validated data for later use
|
||||||
$_SESSION['installation'] = array_merge($_SESSION['installation'] ?? [], $validatedData);
|
$_SESSION['installation'] = array_merge($_SESSION['installation'] ?? [], $validatedData);
|
||||||
}
|
}
|
||||||
@@ -160,7 +168,6 @@ class Install
|
|||||||
if ($this->currentStep == ($this->maxSteps - 1)) {
|
if ($this->currentStep == ($this->maxSteps - 1)) {
|
||||||
$core = new Core($_SESSION['installation']);
|
$core = new Core($_SESSION['installation']);
|
||||||
$core->doInstall();
|
$core->doInstall();
|
||||||
// @todo no going back after this point!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// redirect user to home if the installation is done
|
// redirect user to home if the installation is done
|
||||||
@@ -202,13 +209,13 @@ class Install
|
|||||||
private function checkRequirements(): array
|
private function checkRequirements(): array
|
||||||
{
|
{
|
||||||
// check whether we can read the userdata file
|
// check whether we can read the userdata file
|
||||||
if (!@touch(dirname(__DIR__, 2).'/.~writecheck' )) {
|
if (!@touch(dirname(__DIR__, 2) . '/.~writecheck')) {
|
||||||
// get possible owner
|
// get possible owner
|
||||||
$posixusername = posix_getpwuid(posix_getuid())['name'];
|
$posixusername = posix_getpwuid(posix_getuid())['name'];
|
||||||
$posixgroup = posix_getgrgid(posix_getgid())['name'];
|
$posixgroup = posix_getgrgid(posix_getgid())['name'];
|
||||||
$this->criticals['wrong_ownership'] = ['user' => $posixusername, 'group' => $posixgroup];
|
$this->criticals['wrong_ownership'] = ['user' => $posixusername, 'group' => $posixgroup];
|
||||||
} else {
|
} else {
|
||||||
@unlink(dirname(__DIR__, 2).'/.~writecheck');
|
@unlink(dirname(__DIR__, 2) . '/.~writecheck');
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for required extensions
|
// check for required extensions
|
||||||
|
|||||||
@@ -377,6 +377,7 @@ class Core
|
|||||||
if ($this->validatedData['use_ssl']) {
|
if ($this->validatedData['use_ssl']) {
|
||||||
$this->updateSetting($upd_stmt, 1, 'system', 'use_ssl');
|
$this->updateSetting($upd_stmt, 1, 'system', 'use_ssl');
|
||||||
$this->updateSetting($upd_stmt, 1, 'system', 'leenabled');
|
$this->updateSetting($upd_stmt, 1, 'system', 'leenabled');
|
||||||
|
$this->updateSetting($upd_stmt, 1, 'system', 'le_froxlor_enabled');
|
||||||
}
|
}
|
||||||
$this->updateSetting($upd_stmt, $this->validatedData['servername'], 'system', 'hostname');
|
$this->updateSetting($upd_stmt, $this->validatedData['servername'], 'system', 'hostname');
|
||||||
$this->updateSetting($upd_stmt, 'en', 'panel', 'standardlanguage'); // TODO: set language
|
$this->updateSetting($upd_stmt, 'en', 'panel', 'standardlanguage'); // TODO: set language
|
||||||
|
|||||||
@@ -148,6 +148,9 @@ class Form
|
|||||||
case 'select':
|
case 'select':
|
||||||
$fielddata['selected'] = $fielddata['value'];
|
$fielddata['selected'] = $fielddata['value'];
|
||||||
unset($fielddata['value']);
|
unset($fielddata['value']);
|
||||||
|
if (isset($fielddata['select_mode']) && $fielddata['select_mode'] == 'multiple') {
|
||||||
|
$fielddata['selected'] = array_flip(explode(",", $fielddata['selected']));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
$fielddata['checked'] = (bool)$fielddata['value'];
|
$fielddata['checked'] = (bool)$fielddata['value'];
|
||||||
|
|||||||
@@ -85,8 +85,6 @@ return [
|
|||||||
'visible_columns' => Listing::getVisibleColumnsForListing('ipsandports_list', [
|
'visible_columns' => Listing::getVisibleColumnsForListing('ipsandports_list', [
|
||||||
'ip',
|
'ip',
|
||||||
'port',
|
'port',
|
||||||
'listen',
|
|
||||||
'namevirtualhost',
|
|
||||||
'vhostcontainer',
|
'vhostcontainer',
|
||||||
'specialsettings',
|
'specialsettings',
|
||||||
'servername',
|
'servername',
|
||||||
|
|||||||
@@ -49,9 +49,13 @@
|
|||||||
{{ formfields.field(id, field) }}
|
{{ formfields.field(id, field) }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<div class="d-flex justify-content-between mt-4">
|
<div class="d-flex {% if setup.step < setup.max_steps %}justify-content-between{% else %}justify-content-end{% endif %} mt-4">
|
||||||
|
{% if setup.step < setup.max_steps %}
|
||||||
<a href="?step={{ setup.step - 1 }}" class="btn btn-secondary">« {{ lng('panel.back') }}</a>
|
<a href="?step={{ setup.step - 1 }}" class="btn btn-secondary">« {{ lng('panel.back') }}</a>
|
||||||
<button type="submit" name="submit" class="btn btn-primary">{{ lng('panel.next') }} »</button>
|
<button type="submit" name="submit" class="btn btn-primary">{{ lng('panel.next') }} »</button>
|
||||||
|
{% else %}
|
||||||
|
<button type="submit" name="submit" class="btn btn-success">{{ lng('install.install.top') }} »</button>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<h4 class="mb-3">{{ lng('install.dependency_check.title') }}</h4>
|
<h4 class="mb-3">{{ lng('install.dependency_check.title') }}</h4>
|
||||||
|
|||||||
Reference in New Issue
Block a user