From 36dbb3bdcc389df09e99893600896b23d3d515ba Mon Sep 17 00:00:00 2001 From: envoyr Date: Fri, 18 Feb 2022 18:50:45 +0100 Subject: [PATCH] set minimum php version to 7.4 and fix templates --- admin_autoupdate.php | 4 +- install/install.php | 4 +- install/lib/class.FroxlorInstall.php | 2 +- install/lng/english.lng.php | 2 +- install/lng/french.lng.php | 2 +- install/lng/german.lng.php | 2 +- lib/Froxlor/PhpHelper.php | 39 ++++------ lib/init.php | 4 +- lng/czech.lng.php | 2 +- lng/english.lng.php | 2 +- lng/german.lng.php | 2 +- scripts/froxlor_master_cronjob.php | 4 +- templates/Froxlor/assets/css/dark.css | 4 + templates/Froxlor/assets/css/main.css | 5 ++ templates/Froxlor/base.html.twig | 4 +- templates/Froxlor/form/form.html.twig | 75 +++++++++---------- .../Froxlor/misc/configurehint.html.twig | 2 +- templates/Froxlor/src/scss/_global.scss | 4 + .../Froxlor/src/scss/components/_card.scss | 1 + .../Froxlor/src/scss/components/_form.scss | 1 + templates/Froxlor/src/scss/main.scss | 1 + templates/Froxlor/user/change_theme.html.twig | 3 +- templates/Froxlor/user/index.html.twig | 2 +- tests/PhpAndFpm/FpmDaemonsTest.php | 10 +-- 24 files changed, 91 insertions(+), 90 deletions(-) create mode 100644 templates/Froxlor/src/scss/components/_form.scss diff --git a/admin_autoupdate.php b/admin_autoupdate.php index 8ef41962..b17dff9b 100644 --- a/admin_autoupdate.php +++ b/admin_autoupdate.php @@ -36,8 +36,8 @@ if (! extension_loaded('zip')) { )); } -// 0.10.x requires 7.0 at least -if (version_compare("7.0.0", PHP_VERSION, ">=")) { +// 0.11.x requires 7.4 at least +if (version_compare("7.4.0", PHP_VERSION, ">=")) { \Froxlor\UI\Response::redirectTo($filename, array( 's' => $s, 'page' => 'error', diff --git a/install/install.php b/install/install.php index a347e798..89b33615 100644 --- a/install/install.php +++ b/install/install.php @@ -25,11 +25,11 @@ function view($template, $attributes) { } // validate correct php version -if (version_compare("7.1.0", PHP_VERSION, ">=")) { +if (version_compare("7.4.0", PHP_VERSION, ">=")) { die( view($_deftheme . '/misc/phprequirementfailed.html.twig', [ '{{ basehref }}' => '../', - '{{ froxlor_min_version }}' => '7.1.0', + '{{ froxlor_min_version }}' => '7.4.0', '{{ current_version }}' => PHP_VERSION, '{{ current_year }}' => date('Y', time()), ]) diff --git a/install/lib/class.FroxlorInstall.php b/install/lib/class.FroxlorInstall.php index 2ac7162d..fb247d08 100644 --- a/install/lib/class.FroxlorInstall.php +++ b/install/lib/class.FroxlorInstall.php @@ -1138,7 +1138,7 @@ class FroxlorInstall 'result' => 0 ]; - if (version_compare("7.1.0", PHP_VERSION, ">=")) { + if (version_compare("7.4.0", PHP_VERSION, ">=")) { $check['result'] = 1; $check['result_txt'] = $this->_lng['requirements']['notfound'] . ' (' . PHP_VERSION . ')'; $_die = true; diff --git a/install/lng/english.lng.php b/install/lng/english.lng.php index 98629ad7..ad1d6484 100644 --- a/install/lng/english.lng.php +++ b/install/lng/english.lng.php @@ -22,7 +22,7 @@ $lng['requirements']['not_true'] = 'no'; $lng['requirements']['notfound'] = 'not found'; $lng['requirements']['notinstalled'] = 'not installed'; $lng['requirements']['activated'] = 'enabled'; -$lng['requirements']['phpversion'] = 'PHP version >= 7.1'; +$lng['requirements']['phpversion'] = 'PHP version >= 7.4 (8.x recommended)'; $lng['requirements']['newerphpprefered'] = 'Good, but php-7.4 is preferred.'; $lng['requirements']['phppdo'] = 'PHP PDO extension and PDO-MySQL driver...'; $lng['requirements']['phpsession'] = 'PHP session-extension...'; diff --git a/install/lng/french.lng.php b/install/lng/french.lng.php index 36a013a4..1464f654 100644 --- a/install/lng/french.lng.php +++ b/install/lng/french.lng.php @@ -22,7 +22,7 @@ $lng['requirements']['not_true'] = 'non'; $lng['requirements']['notfound'] = 'introuvable'; $lng['requirements']['notinstalled'] = 'non installé'; $lng['requirements']['activated'] = 'activé'; -$lng['requirements']['phpversion'] = 'PHP version >= 7.1'; +$lng['requirements']['phpversion'] = 'PHP version >= 7.4 (8.x recommandé)'; $lng['requirements']['phppdo'] = 'extension PHP PDO et pilote PDO-MySQL ...'; $lng['requirements']['phpxml'] = 'extension PHP XML...'; $lng['requirements']['phpfilter'] = 'extension PHP filter ...'; diff --git a/install/lng/german.lng.php b/install/lng/german.lng.php index 52455512..a08d10ca 100644 --- a/install/lng/german.lng.php +++ b/install/lng/german.lng.php @@ -22,7 +22,7 @@ $lng['requirements']['not_true'] = 'nein'; $lng['requirements']['notfound'] = 'nicht gefunden'; $lng['requirements']['notinstalled'] = 'nicht installiert'; $lng['requirements']['activated'] = 'ist aktiviert.'; -$lng['requirements']['phpversion'] = 'PHP Version >= 7.1'; +$lng['requirements']['phpversion'] = 'PHP Version >= 7.4 (8.x empfohlen)'; $lng['requirements']['newerphpprefered'] = 'Passt, aber php-7.4 wird bevorzugt.'; $lng['requirements']['phppdo'] = 'PHP PDO Erweiterung und PDO-MySQL Treiber...'; $lng['requirements']['phpsession'] = 'PHP session-Erweiterung...'; diff --git a/lib/Froxlor/PhpHelper.php b/lib/Froxlor/PhpHelper.php index a303f6b1..cd27bb5a 100644 --- a/lib/Froxlor/PhpHelper.php +++ b/lib/Froxlor/PhpHelper.php @@ -284,32 +284,21 @@ class PhpHelper } } - /** - * Function randomStr - * - * generate a pseudo-random string of bytes - * - * @param int $length - * - * @return string - */ + /** + * Function randomStr + * + * generate a pseudo-random string of bytes + * + * @param int $length + * @return string + * @throws \Exception + */ public static function randomStr($length) { - if (version_compare(PHP_VERSION, '7.0.0') >= 0) { - return random_bytes($length); - } elseif (function_exists('openssl_random_pseudo_bytes')) { - return openssl_random_pseudo_bytes($length); - } else { - $pr_bits = ''; - $fp = @fopen('/dev/urandom', 'rb'); - if ($fp !== false) { - $pr_bits .= @fread($fp, $length); - @fclose($fp); - } else { - $pr_bits = substr(rand(time(), getrandmax()) . rand(time(), getrandmax()), 0, $length); - } - return $pr_bits; - } + if (function_exists('openssl_random_pseudo_bytes')) { + return openssl_random_pseudo_bytes($length); + } + return random_bytes($length); } /** @@ -322,7 +311,7 @@ class PhpHelper * @param string $system * 'si' for SI, 'bi' for binary prefixes * - * @param + * @param string $retstring * string */ public static function sizeReadable($size, $max = null, $system = 'si', $retstring = '%01.2f %s') diff --git a/lib/init.php b/lib/init.php index 28acb427..5c1fbe8f 100644 --- a/lib/init.php +++ b/lib/init.php @@ -27,11 +27,11 @@ function view($template, $attributes) { } // validate correct php version -if (version_compare("7.1.0", PHP_VERSION, ">=")) { +if (version_compare("7.4.0", PHP_VERSION, ">=")) { die( view($_deftheme . '/misc/phprequirementfailed.html.twig', [ '{{ basehref }}' => '', - '{{ froxlor_min_version }}' => '7.1.0', + '{{ froxlor_min_version }}' => '7.4.0', '{{ current_version }}' => PHP_VERSION, '{{ current_year }}' => date('Y', time()), ]) diff --git a/lng/czech.lng.php b/lng/czech.lng.php index 8bfecbd7..729fb022 100644 --- a/lng/czech.lng.php +++ b/lng/czech.lng.php @@ -1866,7 +1866,7 @@ $lng['error']['autoupdate_6'] = 'Uf, nebyla nalezena (platná) verze ke stažen $lng['error']['autoupdate_7'] = 'Stažený archiv nebyl nalezen :('; $lng['error']['autoupdate_8'] = 'Archiv nemohl být extrahován :('; $lng['error']['autoupdate_9'] = 'Stažený soubor neprošel testem integrity. Zkus aktualizaci znovu.'; -$lng['error']['autoupdate_10'] = 'Minimální podporovaná verze PHP je 7.0'; +$lng['error']['autoupdate_10'] = 'Minimální podporovaná verze PHP je 7.4.0'; $lng['admin']['server_php'] = 'PHP'; $lng['domains']['termination_date'] = 'Datum zrušení'; diff --git a/lng/english.lng.php b/lng/english.lng.php index e04f1fe1..f280ea70 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -1872,7 +1872,7 @@ $lng['error']['autoupdate_6'] = 'Whoops, there was no (valid) version given to d $lng['error']['autoupdate_7'] = 'The downloaded archive could not be found :('; $lng['error']['autoupdate_8'] = 'The archive could not be extracted :('; $lng['error']['autoupdate_9'] = 'The downloaded file did not pass the integrity check. Please try to update again.'; -$lng['error']['autoupdate_10'] = 'Minimum supported version of PHP is 7.0'; +$lng['error']['autoupdate_10'] = 'Minimum supported version of PHP is 7.4.0'; $lng['admin']['server_php'] = 'PHP'; $lng['domains']['termination_date'] = 'Date of termination'; diff --git a/lng/german.lng.php b/lng/german.lng.php index cf9e1013..7ac4bd15 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -1523,7 +1523,7 @@ $lng['error']['autoupdate_6'] = 'Woops, keine (gültige) Version angegeben für $lng['error']['autoupdate_7'] = 'Das heruntergeladene Archiv konnte nicht gefunden werden :('; $lng['error']['autoupdate_8'] = 'Das Archiv konnte nicht entpackt werden :('; $lng['error']['autoupdate_9'] = 'Die heruntergeladene Datei konnte nicht verifiziert werden. Bitte erneut versuchen zu aktualisieren.'; -$lng['error']['autoupdate_10'] = 'Minimum unterstützte Version von PHP ist 7.0'; +$lng['error']['autoupdate_10'] = 'Minimum unterstützte Version von PHP ist 7.4.0'; $lng['domains']['termination_date'] = 'Kündigungsdatum'; $lng['domains']['termination_date_overview'] = 'gekündigt zum '; diff --git a/scripts/froxlor_master_cronjob.php b/scripts/froxlor_master_cronjob.php index d30fe4e8..8ceb547e 100644 --- a/scripts/froxlor_master_cronjob.php +++ b/scripts/froxlor_master_cronjob.php @@ -16,8 +16,8 @@ */ // validate correct php version -if (version_compare("7.0.0", PHP_VERSION, ">=")) { - die('Froxlor requires at least php-7.0. Please validate that your php-cli version and the cron execution command are correct.'); +if (version_compare("7.4.0", PHP_VERSION, ">=")) { + die('Froxlor requires at least php-7.4. Please validate that your php-cli version and the cron execution command are correct.'); } require dirname(__DIR__) . '/vendor/autoload.php'; diff --git a/templates/Froxlor/assets/css/dark.css b/templates/Froxlor/assets/css/dark.css index b29a0995..dde4a8e5 100644 --- a/templates/Froxlor/assets/css/dark.css +++ b/templates/Froxlor/assets/css/dark.css @@ -20527,3 +20527,7 @@ readers do not read off random characters that represent icons */ .max-h-before-header { max-height: calc(100vh - 4.375rem); } + +.rounded-tl-bl { + border-radius: 0.5rem 0 0.5rem 0; +} diff --git a/templates/Froxlor/assets/css/main.css b/templates/Froxlor/assets/css/main.css index 415deef1..cd6d3139 100644 --- a/templates/Froxlor/assets/css/main.css +++ b/templates/Froxlor/assets/css/main.css @@ -20528,6 +20528,10 @@ readers do not read off random characters that represent icons */ max-height: calc(100vh - 4.375rem); } +.rounded-tl-bl { + border-radius: 0.5rem 0 0.5rem 0; +} + .navbar { background: #f7f7f7; } @@ -20580,4 +20584,5 @@ readers do not read off random characters that represent icons */ } .card .card-header { border-bottom: #e5e5e5 solid 1px; + font-weight: bold; } diff --git a/templates/Froxlor/base.html.twig b/templates/Froxlor/base.html.twig index 6e185c5a..cdb7e312 100644 --- a/templates/Froxlor/base.html.twig +++ b/templates/Froxlor/base.html.twig @@ -9,7 +9,7 @@ {% if theme_css is empty %} - + {% else %} {{ theme_css|raw }} {% endif %} @@ -17,7 +17,7 @@ {% if theme_js is empty %} - + {% else %} {{ theme_js|raw }} {% endif %} diff --git a/templates/Froxlor/form/form.html.twig b/templates/Froxlor/form/form.html.twig index 88f56cb5..356aa224 100644 --- a/templates/Froxlor/form/form.html.twig +++ b/templates/Froxlor/form/form.html.twig @@ -3,48 +3,43 @@ {% import "Froxlor/form/formfields.html.twig" as formfields %}
-
- {% if title is not empty %} -
- {% if form_data.image is not empty %} - - {% endif %} - {{ title }} -
- {% endif %} -
- {% for section in form_data.sections %} -
- {% if section.title is not empty %} -
- {% if section.image is not empty %} - - {% endif %} - {{ section.title }} -
+ {% if title is not empty %} + + {% endif %} + + {% for section in form_data.sections %} +
+ {% if section.title is not empty %} +
+ {% if section.image is not empty %} + {% endif %} -
- {% for id,field in section.fields %} - {% if field.type == 'text' or field.type == 'password' %} - {{ formfields.input(id, field) }} - {% elseif field.type == 'textul' %} - {{ formfields.input_ul(id, field) }} - {% elseif field.type == 'checkbox' %} - {{ formfields.bool(id, field) }} - {% elseif field.type == 'select' %} - {{ formfields.select(id, field) }} - {% elseif field.type == 'textarea' %} - {{ formfields.textarea(id, field) }} - {% elseif field.type == 'label' %} - {{ formfields.plain(id, field) }} - {% endif %} - {% endfor %} -
+ {{ section.title }}
- {% endfor %} + {% endif %} +
+ {% for id,field in section.fields %} + {% if field.type == 'text' or field.type == 'password' %} + {{ formfields.input(id, field) }} + {% elseif field.type == 'textul' %} + {{ formfields.input_ul(id, field) }} + {% elseif field.type == 'checkbox' %} + {{ formfields.bool(id, field) }} + {% elseif field.type == 'select' %} + {{ formfields.select(id, field) }} + {% elseif field.type == 'textarea' %} + {{ formfields.textarea(id, field) }} + {% elseif field.type == 'label' %} + {{ formfields.plain(id, field) }} + {% endif %} + {% endfor %} +
- -
- + {% endfor %} {% endmacro %} diff --git a/templates/Froxlor/misc/configurehint.html.twig b/templates/Froxlor/misc/configurehint.html.twig index 31912974..0ddc7f8c 100644 --- a/templates/Froxlor/misc/configurehint.html.twig +++ b/templates/Froxlor/misc/configurehint.html.twig @@ -14,7 +14,7 @@
- +
diff --git a/templates/Froxlor/src/scss/_global.scss b/templates/Froxlor/src/scss/_global.scss index c61163d4..c4215f4a 100644 --- a/templates/Froxlor/src/scss/_global.scss +++ b/templates/Froxlor/src/scss/_global.scss @@ -50,6 +50,10 @@ max-height: calc(100vh - ($spacer * 3.5)); } +.rounded-tl-bl { + border-radius: $border-radius 0 $border-radius 0; +} + footer { @extend .text-muted; } diff --git a/templates/Froxlor/src/scss/components/_card.scss b/templates/Froxlor/src/scss/components/_card.scss index f95e72be..91e5eabc 100644 --- a/templates/Froxlor/src/scss/components/_card.scss +++ b/templates/Froxlor/src/scss/components/_card.scss @@ -3,6 +3,7 @@ .card-header { border-bottom: #e5e5e5 solid 1px; + font-weight: bold; } .card-body { p { diff --git a/templates/Froxlor/src/scss/components/_form.scss b/templates/Froxlor/src/scss/components/_form.scss new file mode 100644 index 00000000..cfdb62e5 --- /dev/null +++ b/templates/Froxlor/src/scss/components/_form.scss @@ -0,0 +1 @@ +// wip \ No newline at end of file diff --git a/templates/Froxlor/src/scss/main.scss b/templates/Froxlor/src/scss/main.scss index 2941d065..b8388dbf 100644 --- a/templates/Froxlor/src/scss/main.scss +++ b/templates/Froxlor/src/scss/main.scss @@ -9,3 +9,4 @@ @import "components/navbar"; @import "components/sidebar"; @import "components/card"; +@import "components/form"; diff --git a/templates/Froxlor/user/change_theme.html.twig b/templates/Froxlor/user/change_theme.html.twig index 8b6c124c..4887dbd4 100644 --- a/templates/Froxlor/user/change_theme.html.twig +++ b/templates/Froxlor/user/change_theme.html.twig @@ -24,7 +24,8 @@ + {{ lng('menue.main.changetheme') }} +
diff --git a/templates/Froxlor/user/index.html.twig b/templates/Froxlor/user/index.html.twig index aa345ab1..1d1fbbcd 100644 --- a/templates/Froxlor/user/index.html.twig +++ b/templates/Froxlor/user/index.html.twig @@ -1,7 +1,7 @@ {% extends "Froxlor/userarea.html.twig" %} {% block content %} - + {% if get_setting('panel.is_configured') == 0 and userinfo.adminsession == 1 and userinfo.change_serversettings == 1 %}
diff --git a/tests/PhpAndFpm/FpmDaemonsTest.php b/tests/PhpAndFpm/FpmDaemonsTest.php index 88a5647e..e36b4283 100644 --- a/tests/PhpAndFpm/FpmDaemonsTest.php +++ b/tests/PhpAndFpm/FpmDaemonsTest.php @@ -20,13 +20,13 @@ class FpmDaemonsTest extends TestCase global $admin_userdata; $data = [ 'description' => 'test2 fpm', - 'reload_cmd' => 'service php7.1-fpm reload', - 'config_dir' => '/etc/php/7.1/fpm/pool.d', + 'reload_cmd' => 'service php7.4-fpm reload', + 'config_dir' => '/etc/php/7.4/fpm/pool.d', 'limit_extensions' => '' ]; $json_result = FpmDaemons::getLocal($admin_userdata, $data)->add(); $result = json_decode($json_result, true)['data']; - $this->assertEquals('/etc/php/7.1/fpm/pool.d/', $result['config_dir']); + $this->assertEquals('/etc/php/7.4/fpm/pool.d/', $result['config_dir']); $this->assertEquals('dynamic', $result['pm']); $this->assertEquals(5, $result['max_children']); $this->assertEquals('.php', $result['limit_extensions']); @@ -77,7 +77,7 @@ class FpmDaemonsTest extends TestCase ]; $json_result = FpmDaemons::getLocal($admin_userdata, $data)->update(); $result = json_decode($json_result, true)['data']; - $this->assertEquals('/etc/php/7.1/fpm/pool.d/', $result['config_dir']); + $this->assertEquals('/etc/php/7.4/fpm/pool.d/', $result['config_dir']); $this->assertEquals(10, $result['max_children']); $this->assertEquals('.php .php.xml', $result['limit_extensions']); } @@ -239,7 +239,7 @@ class FpmDaemonsTest extends TestCase ]; $json_result = FpmDaemons::getLocal($admin_userdata, $data)->delete(); $result = json_decode($json_result, true)['data']; - $this->assertEquals('/etc/php/7.1/fpm/pool.d/', $result['config_dir']); + $this->assertEquals('/etc/php/7.4/fpm/pool.d/', $result['config_dir']); $this->assertEquals(10, $result['max_children']); $this->assertEquals('.php', $result['limit_extensions']); }