Skip to content

Commit

Permalink
Fix to return only allowed type for system info
Browse files Browse the repository at this point in the history
  • Loading branch information
iliajie committed Aug 26, 2024
1 parent 3b0f751 commit e4ef4b1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 19 deletions.
50 changes: 34 additions & 16 deletions mailbox/system_info.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion mailbox/ulang/de
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion mailbox/ulang/en
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion mailbox/ulang/ms.auto
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e4ef4b1

Please sign in to comment.