From patchwork Wed Apr 20 13:32:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Leo-Andres Hofmann X-Patchwork-Id: 5523 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4Kk1nf5HHDz3x1y for ; Wed, 20 Apr 2022 13:32:54 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4Kk1nd24Zgz2Cr; Wed, 20 Apr 2022 13:32:53 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Kk1nd0rKtz2xlq; Wed, 20 Apr 2022 13:32:53 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4Kk1nb4W8xz2xGC for ; Wed, 20 Apr 2022 13:32:51 +0000 (UTC) Received: from arche.uberspace.de (arche.uberspace.de [185.26.156.147]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4Kk1nV1S22z2Cr for ; Wed, 20 Apr 2022 13:32:46 +0000 (UTC) Received: (qmail 11237 invoked by uid 990); 20 Apr 2022 13:32:44 -0000 From: Leo-Andres Hofmann To: development@lists.ipfire.org Subject: [PATCH] menu: Fix warnings, clean code Date: Wed, 20 Apr 2022 15:32:34 +0200 Message-Id: <20220420133234.1588-1-hofmann@leo-andres.de> X-Mailer: git-send-email 2.27.0.windows.1 MIME-Version: 1.0 X-Rspamd-Bar: - X-Rspamd-Report: MID_CONTAINS_FROM(1) MIME_HTML_ONLY(0.2) BAYES_HAM(-3) X-Rspamd-Score: -1.8 Received: from unknown (HELO unkown) (::1) by arche.uberspace.de (Haraka/2.8.28) with ESMTPSA; Wed, 20 Apr 2022 15:32:44 +0200 ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1650461566; a=rsa-sha256; cv=none; b=VZJn3GIdDFQYorh4YrWMNn96QDhqp11ZRKkO0WE4xsFQ0A6Kf77FnHizyhrEfO8f4lMo1Z jtR++LsWXgbpco9FqXOEyTqaAhHikqzSdVJszhsi16irIcy9+3t720Uc93bNooKoEe1GJ7 GwIeHqeL7FIDaZT9QLvSMipw+/TQD+1VeWiQQXxIaEH7dxFmvXGK1sLgbmppR52/41pOfz mHTNTZZMVDBbGUorBU3jKw02Xa7aaNBEaJzBM9cAjeERfSmpwAMR6JMVqo6sCg+jJWvWWq 4D8HS3nEdhsC0VJKJz0HKajxkR3qm0qZke43XxOLQbSu+HJT9ikMxQSivLi9pg== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=none; dmarc=pass (policy=quarantine) header.from=leo-andres.de; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1650461566; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vRTuIJWApteWzXXxyNLZLe8RyYZAgayqDBFnuLX+4BY=; b=IoRlIm5TpI9lbUbKIdcLsZho/GBWMWO6UmKnLnpKmop/TrL3Rzzxse8AMyO95QtL+rq5p3 Rb+dpoeDqTAIQYsdbLmpGANu9FRGcAM9FvPcF/I5MwbR6OeDI7YQtNZfg0oa0y06fHwypw o51Gcpjf4GX/9q4OAzSXkqS0DJV3ciMhLcNDWtpEy+PP7kTHDpz50z4ctRUT7KI7Y/kxeH BNX261DCf/F5DMKlqi7QnWqCyn94hGwln/n2kUBwFahWEEgYZJUxYPWQeY3//uD4QbjOrO dCDBe1ooJZJbluavmEzkOS2zAQ5Ta9d74LtDQMBT+QPorRG2OHsLoMND6MwQuw== X-Rspamd-Queue-Id: 4Kk1nV1S22z2Cr X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [-3.46 / 11.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; SPF_REPUTATION_HAM(-0.87)[-0.86662465127587]; NEURAL_HAM(-0.59)[-0.586]; DMARC_POLICY_ALLOW(-0.50)[leo-andres.de,quarantine]; MX_INVALID(0.50)[]; R_SPF_ALLOW(-0.20)[+mx]; MIME_HTML_ONLY(0.20)[]; IP_REPUTATION_HAM(-0.01)[asn: 205766(0.00), country: DE(-0.01), ip: 185.26.156.147(0.00)]; RCVD_IN_DNSWL_NONE(0.00)[185.26.156.147:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; TO_DN_NONE(0.00)[]; ARC_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:~]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:205766, ipnet:185.26.156.0/24, country:DE]; RCVD_TLS_ALL(0.00)[] Authentication-Results: mail01.ipfire.org; dkim=none; dmarc=pass (policy=quarantine) header.from=leo-andres.de; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" This patch adds default values and removes a missing translation to fix "uninitialized value" and "odd number of elements" warnings. Removes function calls from functions.pl that have already been handled by the header before it is loaded by eval(). Signed-off-by: Leo-Andres Hofmann Reviewed-by: Bernhard Bitsch --- config/cfgroot/header.pl | 4 +++- config/menu/20-status.menu | 4 ++-- config/menu/30-network.menu | 2 +- html/html/themes/ipfire/include/functions.pl | 16 +++++----------- langs/de/cgi-bin/de.pl | 1 - langs/fr/cgi-bin/fr.pl | 1 - 6 files changed, 11 insertions(+), 17 deletions(-) diff --git a/config/cfgroot/header.pl b/config/cfgroot/header.pl index 5ddea348e..65459cc92 100644 --- a/config/cfgroot/header.pl +++ b/config/cfgroot/header.pl @@ -46,7 +46,7 @@ my $menu = \%menuhash; %settings = (); %ethsettings = (); %pppsettings = (); -@URI = (); +my @URI = split('\?', $ENV{'REQUEST_URI'}); ### Make sure this is an SSL request if ($ENV{'SERVER_ADDR'} && $ENV{'HTTPS'} ne 'on') { @@ -573,3 +573,5 @@ sub get_manualpage_url() { # No manual page configured, return nothing return; } + +1; # End of package "Header" diff --git a/config/menu/20-status.menu b/config/menu/20-status.menu index 2bcf0d5e8..f969a3b0b 100644 --- a/config/menu/20-status.menu +++ b/config/menu/20-status.menu @@ -49,7 +49,7 @@ $substatus->{'54.networkovpnsrv'} = { 'caption' => "$Lang::tr{'vpn statistic n2n'}", 'uri' => '/cgi-bin/netovpnsrv.cgi', - 'title' => "$Lang::tr{'vpn statistics n2n'}", + 'title' => "$Lang::tr{'vpn statistic n2n'}", 'enabled' => 1, }; $substatus->{'60.hardwaregraphs'} = { @@ -90,7 +90,7 @@ $substatus->{'75.atm-status'} = {'caption' => 'Atm-status', 'uri' => '/cgi-bin/atm-status.cgi', 'title' => 'Atm-status', - 'enabled' => `find /sys/class/atm/*/device 2>/dev/null`, + 'enabled' => (`find /sys/class/atm/*/device 2>/dev/null` ? 1 : 0), }; $substatus->{'76.mdstat'} = {'caption' => 'Mdstat', 'uri' => '/cgi-bin/mdstat.cgi', diff --git a/config/menu/30-network.menu b/config/menu/30-network.menu index 19571a870..4ef537ed4 100644 --- a/config/menu/30-network.menu +++ b/config/menu/30-network.menu @@ -67,7 +67,7 @@ 'caption' => $Lang::tr{'aliases'}, 'uri' => '/cgi-bin/aliases.cgi', 'title' => "$Lang::tr{'aliases'}", - 'enabled' => `grep "RED_TYPE=STATIC" /var/ipfire/ethernet/settings`, + 'enabled' => (`grep "RED_TYPE=STATIC" /var/ipfire/ethernet/settings` ? 1 : 0), }; $subnetwork->{'80.macadressmenu'} = { 'caption' => $Lang::tr{'mac address menu'}, diff --git a/html/html/themes/ipfire/include/functions.pl b/html/html/themes/ipfire/include/functions.pl index d74c962e4..f2b8e9925 100644 --- a/html/html/themes/ipfire/include/functions.pl +++ b/html/html/themes/ipfire/include/functions.pl @@ -31,8 +31,6 @@ # IPFire default theme. # ############################################################################### -require "${General::swroot}/lang.pl"; - ############################################################################### # # print menu html elements for submenu entries @@ -101,20 +99,15 @@ sub openpage { my $title = shift; my $boh = shift; my $extrahead = shift; - my $suppressMenu = shift; + my $suppressMenu = shift // 0; my @tmp = split(/\./, basename($0)); my $scriptName = @tmp[0]; - @URI=split ('\?', $ENV{'REQUEST_URI'} ); - &General::readhash("${swroot}/main/settings", \%settings); - &genmenu(); - my $headline = "IPFire"; if (($settings{'WINDOWWITHHOSTNAME'} eq 'on') || ($settings{'WINDOWWITHHOSTNAME'} eq '')) { $headline = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}"; } - print < @@ -165,7 +158,10 @@ print < @@ -270,5 +266,3 @@ sub openbox { sub closebox { print ""; } - -1; diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index 6094c191a..1145745e0 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -2874,7 +2874,6 @@ 'vpn start action start' => 'Immer An', 'vpn statistic n2n' => 'OpenVPN: Netz-zu-Netz-Statistik', 'vpn statistic rw' => 'OpenVPN: Roadwarrior-Statistik', -'vpn statistics n2n' => 'OpenVPN: Netz-zu-Netz-Statistiken', 'vpn subjectaltname' => 'SubjectAlternativeName', 'vpn subjectaltname missing' => 'SubjectAlternativeName darf nicht leer bleiben.', 'vpn wait' => 'WARTE', diff --git a/langs/fr/cgi-bin/fr.pl b/langs/fr/cgi-bin/fr.pl index 03fc754df..23c01ddb8 100644 --- a/langs/fr/cgi-bin/fr.pl +++ b/langs/fr/cgi-bin/fr.pl @@ -2949,7 +2949,6 @@ 'vpn start action start' => 'Toujours démarré', 'vpn statistic n2n' => 'OpenVPN (site-à-site)', 'vpn statistic rw' => 'OpenVPN (client nomade)', -'vpn statistics n2n' => 'OpenVPN (site-à-site)', 'vpn subjectaltname' => 'Nom de l\'objet', 'vpn subjectaltname missing' => 'Le nom de l\'objet ne peut être vide.', 'vpn wait' => 'ATTENTE',