From e4ef4b1bef413e87c31701baf895435e69d8f657 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Mon, 26 Aug 2024 14:46:13 +0300 Subject: [PATCH] Fix to return only allowed type for system info --- mailbox/system_info.pl | 50 ++++++++++++++++++++++++++++-------------- mailbox/ulang/de | 2 +- mailbox/ulang/en | 2 +- mailbox/ulang/ms.auto | 2 +- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/mailbox/system_info.pl b/mailbox/system_info.pl index 24301af3..0ab25c0b 100644 --- a/mailbox/system_info.pl +++ b/mailbox/system_info.pl @@ -13,32 +13,50 @@ sub list_system_info my @table; my $table = { 'type' => 'table', 'desc' => $text{'right_header'}, - 'priority' => 10, + 'priority' => 10, 'table' => \@table }; +my $can_type = sub { + my ($type) = @_; + return 1 if (!defined($gconfig{'ui_show'})); + return 1 if ($gconfig{'ui_show'} =~ /\b$type\b/); + return 0; + }; + # Hostname -push(@table, { 'desc' => $text{'right_host'}, - 'value' => &get_display_hostname() }); +if ($can_type->('host')) { + push(@table, { 'desc' => $text{'right_host'}, + 'value' => &get_display_hostname(), + 'type' => 'hostname' }); + } # Operating system -push(@table, { 'desc' => $text{'right_os'}, - 'value' => $gconfig{'os_version'} eq '*' ? - $gconfig{'real_os_type'} : - $gconfig{'real_os_type'}.' '.$gconfig{'real_os_version'} - }); +if ($can_type->('os')) { + push(@table, { 'desc' => $text{'right_os'}, + 'value' => $gconfig{'os_version'} eq '*' ? + $gconfig{'real_os_type'} : + $gconfig{'real_os_type'}.' '.$gconfig{'real_os_version'}, + 'type' => 'os' }); + } # Usermin version -push(@table, { 'desc' => $text{'right_usermin'}, - 'value' => &get_webmin_version() }); +if ($can_type->('ver')) { + push(@table, { 'desc' => $text{'right_usermin'}, + 'value' => &get_webmin_version(), + 'type' => 'version' }); + } # System time -my $tm = localtime(time()); -eval "use DateTime; use DateTime::Locale; use DateTime::TimeZone;"; -if (!$@) { - $tm = make_date(time(), {get => 'complete'}); +if ($can_type->('time')) { + my $tm = localtime(time()); + eval "use DateTime; use DateTime::Locale; use DateTime::TimeZone;"; + if (!$@) { + $tm = make_date(time(), { get => 'complete' }); + } + push(@table, { 'desc' => $text{'right_time'}, + 'value' => $tm, + 'type' => 'time' }); } -push(@table, { 'desc' => $text{'right_time'}, - 'value' => $tm }); return ($table); } diff --git a/mailbox/ulang/de b/mailbox/ulang/de index aca41ff9..71680681 100644 --- a/mailbox/ulang/de +++ b/mailbox/ulang/de @@ -259,5 +259,5 @@ allow_eaddr='$1' ist keine gültige Mail-Adresse right_header=System Information right_host=System Hostname right_os=Betriebssystem -right_usermin=Usermin Version +right_usermin=Usermin version right_time=Systemzeit diff --git a/mailbox/ulang/en b/mailbox/ulang/en index eb747f6d..48689627 100644 --- a/mailbox/ulang/en +++ b/mailbox/ulang/en @@ -287,5 +287,5 @@ allow_eaddr='$1' is not a valid email address right_header=System Information right_host=System hostname right_os=Operating system -right_usermin=Usermin Version +right_usermin=Usermin version right_time=Time on system diff --git a/mailbox/ulang/ms.auto b/mailbox/ulang/ms.auto index 78ff0edd..57a47ee8 100644 --- a/mailbox/ulang/ms.auto +++ b/mailbox/ulang/ms.auto @@ -260,5 +260,5 @@ allow_eaddr='$1' bukan alamat e-mel yang sah right_header=Maklumat sistem right_host=Nama hos sistem right_os=Sistem operasi -right_usermin=Usermin Version +right_usermin=Usermin version right_time=Masa pada sistem