From c2f55791c0e46b8beaaf0ead8844894ce6832c70 Mon Sep 17 00:00:00 2001 From: slawkens Date: Mon, 3 Mar 2025 20:07:54 +0100 Subject: [PATCH 1/9] Nothing important, just better code style --- system/functions.php | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/system/functions.php b/system/functions.php index 7aa43935..947dd5bd 100644 --- a/system/functions.php +++ b/system/functions.php @@ -982,31 +982,29 @@ function load_config_lua($filename) continue; } $tmp_exp = explode('=', $line, 2); - if(strpos($line, 'dofile') !== false) - { + if(str_contains($line, 'dofile')) { $delimiter = '"'; - if(strpos($line, $delimiter) === false) + if(!str_contains($line, $delimiter)) { $delimiter = "'"; + } $tmp = explode($delimiter, $line); $result = array_merge($result, load_config_lua($config['server_path'] . $tmp[1])); } - else if(count($tmp_exp) >= 2) - { + else if(count($tmp_exp) >= 2) { $key = trim($tmp_exp[0]); - if(0 !== strpos($key, '--')) - { + if(!str_starts_with($key, '--')) { $value = trim($tmp_exp[1]); - if(strpos($value, '--') !== false) {// found some deep comment + if(str_contains($value, '--')) {// found some deep comment $value = preg_replace('/--.*$/i', '', $value); } if(is_numeric($value)) $result[$key] = (float) $value; elseif(in_array(@$value[0], array("'", '"')) && in_array(@$value[strlen($value) - 1], array("'", '"'))) - $result[$key] = (string) substr(substr($value, 1), 0, -1); + $result[$key] = substr(substr($value, 1), 0, -1); elseif(in_array($value, array('true', 'false'))) - $result[$key] = ($value === 'true') ? true : false; + $result[$key] = $value === 'true'; elseif(@$value[0] === '{') { // arrays are not supported yet // just ignore the error @@ -1014,7 +1012,7 @@ function load_config_lua($filename) } else { - foreach($result as $tmp_key => $tmp_value) // load values definied by other keys, like: dailyFragsToBlackSkull = dailyFragsToRedSkull + foreach($result as $tmp_key => $tmp_value) // load values defined by other keys, like: dailyFragsToBlackSkull = dailyFragsToRedSkull $value = str_replace($tmp_key, $tmp_value, $value); $ret = @eval("return $value;"); if((string) $ret == '' && trim($value) !== '""') // = parser error @@ -1028,8 +1026,7 @@ function load_config_lua($filename) } } - $result = array_merge($result, isset($config['lua']) ? $config['lua'] : array()); - return $result; + return array_merge($result, $config['lua'] ?? []); } function str_replace_first($search,$replace, $subject) { From 00fe1adc15ea7646596d755f6e6e1f7854ffc1d5 Mon Sep 17 00:00:00 2001 From: slawkens Date: Mon, 10 Mar 2025 10:48:12 +0100 Subject: [PATCH 2/9] Fix: add possibility to remove all menu items --- admin/pages/menus.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/admin/pages/menus.php b/admin/pages/menus.php index e2608b0b..572be25e 100644 --- a/admin/pages/menus.php +++ b/admin/pages/menus.php @@ -27,11 +27,11 @@ $pluginThemes = Plugins::getThemes(); if (isset($_POST['template'])) { $template = $_POST['template']; - if (isset($_POST['menu'])) { - $post_menu = $_POST['menu']; - $post_menu_link = $_POST['menu_link']; - $post_menu_blank = $_POST['menu_blank']; - $post_menu_color = $_POST['menu_color']; + if (isset($_POST['save'])) { + $post_menu = $_POST['menu'] ?? []; + $post_menu_link = $_POST['menu_link'] ?? []; + $post_menu_blank = $_POST['menu_blank'] ?? []; + $post_menu_color = $_POST['menu_color'] ?? []; if (count($post_menu) != count($post_menu_link)) { echo 'Menu count is not equal menu links. Something went wrong when sending form.'; return; @@ -135,7 +135,7 @@ if (isset($_POST['template'])) {