merge branch '0.11-dev' of github.com:Froxlor/Froxlor into 0.11-dev

This commit is contained in:
envoyr
2022-05-11 16:27:04 +02:00
7 changed files with 46 additions and 17 deletions

View File

@@ -26,6 +26,8 @@
use Froxlor\UI\Panel\UI; use Froxlor\UI\Panel\UI;
use Froxlor\Install\Install; use Froxlor\Install\Install;
require dirname(__DIR__) . '/lib/functions.php';
// define default theme for configurehint, etc. // define default theme for configurehint, etc.
$_deftheme = 'Froxlor'; $_deftheme = 'Froxlor';
@@ -62,7 +64,5 @@ require dirname(__DIR__) . '/lib/tables.inc.php';
UI::initTwig(true); UI::initTwig(true);
UI::sendHeaders(); UI::sendHeaders();
require dirname(__DIR__) . '/lib/functions.php';
$installer = new Install(); $installer = new Install();
$installer->handle(); $installer->handle();

View File

@@ -35,6 +35,7 @@ use Froxlor\Validate\Validate;
class Install class Install
{ {
public $currentStep; public $currentStep;
public $extendedView;
public $maxSteps; public $maxSteps;
public $phpVersion; public $phpVersion;
public $formfield; public $formfield;
@@ -76,6 +77,7 @@ class Install
// set actual step // set actual step
$this->currentStep = Request::get('step', 0); $this->currentStep = Request::get('step', 0);
$this->extendedView = Request::get('extended', 0);
$this->maxSteps = count($this->formfield['install']['sections']); $this->maxSteps = count($this->formfield['install']['sections']);
// set actual php version and extensions // set actual php version and extensions
@@ -112,13 +114,14 @@ class Install
'setup' => [ 'setup' => [
'step' => $this->currentStep, 'step' => $this->currentStep,
], ],
'preflight' => $this->checkExtensions(), 'preflight' => $this->checkRequirements(),
'page' => [ 'page' => [
'title' => 'Database', 'title' => 'Database',
'description' => 'Test', 'description' => 'Test',
], ],
'section' => $this->formfield['install']['sections']['step' . $this->currentStep] ?? [], 'section' => $this->formfield['install']['sections']['step' . $this->currentStep] ?? [],
'error' => $error ?? null, 'error' => $error ?? null,
'extended' => $this->extendedView,
]); ]);
// output view // output view
@@ -171,8 +174,18 @@ class Install
/** /**
* @return array * @return array
*/ */
private function checkExtensions(): array private function checkRequirements(): array
{ {
// check whether we can read the userdata file
if (!@touch(dirname(__DIR__, 2).'/.~writecheck' )) {
// get possible owner
$posixusername = posix_getpwuid(posix_getuid())['name'];
$posixgroup = posix_getgrgid(posix_getgid())['name'];
$this->criticals['wrong_ownership'] = ['user' => $posixusername, 'group' => $posixgroup];
} else {
@unlink(dirname(__DIR__, 2).'/.~writecheck');
}
// check for required extensions // check for required extensions
foreach ($this->requiredExtensions as $requiredExtension) { foreach ($this->requiredExtensions as $requiredExtension) {
if (in_array($requiredExtension, $this->loadedExtensions)) { if (in_array($requiredExtension, $this->loadedExtensions)) {

View File

@@ -149,12 +149,18 @@ return [
'select_var' => $this->supportedOS, 'select_var' => $this->supportedOS,
'selected' => $guessedDistribution 'selected' => $guessedDistribution
], ],
'serverip' => [ 'serveripv4' => [
'label' => lng('serversettings.ipaddress.title'), 'label' => lng('install.system.ipv4'),
'placeholder' => lng('serversettings.ipaddress.title'), 'placeholder' => lng('install.system.ipv4'),
'type' => 'text', 'type' => 'text',
'mandatory' => true, 'value' => old('serveripv4', filter_var($_SERVER['SERVER_ADDR'] ?? "", FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? ($_SERVER['SERVER_ADDR'] ?? "") : "", 'installation'),
'value' => old('serverip', $_SERVER['SERVER_ADDR'] ?? null, 'installation'),
],
'serveripv6' => [
'label' => lng('install.system.ipv6'),
'placeholder' => lng('install.system.ipv6'),
'type' => 'text',
'value' => old('serveripv6', filter_var($_SERVER['SERVER_ADDR'] ?? "", FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ? ($_SERVER['SERVER_ADDR'] ?? "") : "", 'installation'),
], ],
'servername' => [ 'servername' => [
'label' => lng('install.system.servername'), 'label' => lng('install.system.servername'),
@@ -189,6 +195,7 @@ return [
'type' => 'text', 'type' => 'text',
'mandatory' => true, 'mandatory' => true,
'value' => old('httpuser', posix_getpwuid(posix_getuid())['name'] ?? '', 'installation'), 'value' => old('httpuser', posix_getpwuid(posix_getuid())['name'] ?? '', 'installation'),
'advanced' => true,
], ],
'httpgroup' => [ 'httpgroup' => [
'label' => lng('admin.webserver_group'), 'label' => lng('admin.webserver_group'),
@@ -196,6 +203,7 @@ return [
'type' => 'text', 'type' => 'text',
'mandatory' => true, 'mandatory' => true,
'value' => old('httpgroup', posix_getgrgid(posix_getgid())['name'] ?? '', 'installation'), 'value' => old('httpgroup', posix_getgrgid(posix_getgid())['name'] ?? '', 'installation'),
'advanced' => true,
], ],
'activate_newsfeed' => [ 'activate_newsfeed' => [
'label' => lng('install.system.activate_newsfeed'), 'label' => lng('install.system.activate_newsfeed'),

View File

@@ -31,7 +31,7 @@ return [
'title' => lng('admin.cron.cronsettings'), 'title' => lng('admin.cron.cronsettings'),
'icon' => 'fa-solid fa-clock-rotate-left', 'icon' => 'fa-solid fa-clock-rotate-left',
'columns' => [ 'columns' => [
'c.description' => [ 'c.desc_lng_key' => [
'label' => lng('cron.description'), 'label' => lng('cron.description'),
'field' => 'desc_lng_key', 'field' => 'desc_lng_key',
'callback' => [Text::class, 'crondesc'] 'callback' => [Text::class, 'crondesc']
@@ -52,7 +52,7 @@ return [
], ],
], ],
'visible_columns' => Listing::getVisibleColumnsForListing('cron_list', [ 'visible_columns' => Listing::getVisibleColumnsForListing('cron_list', [
'c.description', 'c.desc_lng_key',
'c.lastrun', 'c.lastrun',
'c.interval', 'c.interval',
'c.isactive', 'c.isactive',

View File

@@ -2489,6 +2489,8 @@ Yours sincerely, your administrator',
'top' => 'System setup', 'top' => 'System setup',
'title' => 'Details about your server', 'title' => 'Details about your server',
'description' => 'Set your environment as well as server relevant data and options here to let froxlor know about your system. These values are crucial for the system configuration and operating.', 'description' => 'Set your environment as well as server relevant data and options here to let froxlor know about your system. These values are crucial for the system configuration and operating.',
'ipv4' => 'Primary IPv4 address (if applicable)',
'ipv6' => 'Primary IPv6 address (if applicable)',
'servername' => 'Server name (FQDN, no ip-address)', 'servername' => 'Server name (FQDN, no ip-address)',
'phpbackend' => 'PHP backend', 'phpbackend' => 'PHP backend',
'activate_newsfeed' => 'Enable the official newsfeed<br><small>(https://inside.froxlor.org/news/)</small>', 'activate_newsfeed' => 'Enable the official newsfeed<br><small>(https://inside.froxlor.org/news/)</small>',

View File

@@ -63,17 +63,19 @@
{# installation specific format #} {# installation specific format #}
{% macro field(id, field, norow = true, nohide = false, em = false) %} {% macro field(id, field, norow = true, nohide = false, em = false) %}
{% if field.type != 'checkbox' %} {% if field.type == 'checkbox' %}
<div class="form-floating mb-3">
{{ _self.fieldrow(id, field, norow, nohide, em) }}
<label for="{{ id }}" class="form-label">{{ field.label|raw }}</label>
</div>
{% else %}
<div class="form-check form-switch mb-3"> <div class="form-check form-switch mb-3">
<input type="hidden" value="0" name="{{ id }}" /> <input type="hidden" value="0" name="{{ id }}" />
<input type="checkbox" {% if (field.visible is defined and field.visible == false) or (field.disabled is defined and field.disabled == true) %} disabled {% endif %} value="{{ field.value }}" id="{{ id }}" name="{{ id }}" class="form-check-input {% if field.valid is defined and field.valid == false %}is-invalid{% endif %}" {% if field.checked is defined and field.checked == 1 %} checked="checked" {% endif %}> <input type="checkbox" {% if (field.visible is defined and field.visible == false) or (field.disabled is defined and field.disabled == true) %} disabled {% endif %} value="{{ field.value }}" id="{{ id }}" name="{{ id }}" class="form-check-input {% if field.valid is defined and field.valid == false %}is-invalid{% endif %}" {% if field.checked is defined and field.checked == 1 %} checked="checked" {% endif %}>
<label for="{{ id }}" class="form-check-label">{{ field.label|raw }}</label> <label for="{{ id }}" class="form-check-label">{{ field.label|raw }}</label>
</div> </div>
{% elseif field.type == 'hidden' %}
{{ _self.fieldrow(id, field, norow, nohide, em) }}
{% else %}
<div class="form-floating mb-3">
{{ _self.fieldrow(id, field, norow, nohide, em) }}
<label for="{{ id }}" class="form-label">{{ field.label|raw }}</label>
</div>
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}

View File

@@ -42,6 +42,10 @@
{% import "Froxlor/form/formfields.html.twig" as formfields %} {% import "Froxlor/form/formfields.html.twig" as formfields %}
{% for id, field in section.fields %} {% for id, field in section.fields %}
{% if field.advanced is defined and field.advanced == true and extended == false %}
{# hide advanced fields #}
{% set field = field|merge({'type': 'hidden'}) %}
{% endif %}
{{ formfields.field(id, field) }} {{ formfields.field(id, field) }}
{% endfor %} {% endfor %}