diff --git a/bind8/bind8-lib.pl b/bind8/bind8-lib.pl index adf7a7fcb..4b2913d16 100755 --- a/bind8/bind8-lib.pl +++ b/bind8/bind8-lib.pl @@ -1960,7 +1960,7 @@ if ($changed || !$filecount || $znc{'version'} != $zone_names_version || } # Use in-memory cache -if (defined(@list_zone_names_cache)) { +if (length(@list_zone_names_cache)) { return @list_zone_names_cache; } diff --git a/cfengine/cfengine-lib.pl b/cfengine/cfengine-lib.pl index c78fe3b01..17b52eabd 100755 --- a/cfengine/cfengine-lib.pl +++ b/cfengine/cfengine-lib.pl @@ -29,7 +29,7 @@ $cfrun_hosts = $config{'cfrun_hosts'} ? $config{'cfrun_hosts'} : # a list of classes, each containing options for the section type. sub get_config { -if (!defined(@get_config_cache)) { +if (!length(@get_config_cache)) { @get_config_cache = &get_config_file($cfengine_conf); } return \@get_config_cache; @@ -39,7 +39,7 @@ return \@get_config_cache; # Parses the cfd.conf file sub get_cfd_config { -if (!defined(@get_cfd_config_cache)) { +if (!length(@get_cfd_config_cache)) { @get_cfd_config_cache = &get_config_file($cfd_conf); } return \@get_cfd_config_cache; diff --git a/cron/cron-lib.pl b/cron/cron-lib.pl index c8cc2ba64..11f1f3454 100755 --- a/cron/cron-lib.pl +++ b/cron/cron-lib.pl @@ -59,7 +59,7 @@ reference with the following keys : sub list_cron_jobs { local (@rv, $lnum, $f); -if (defined(@cron_jobs_cache)) { +if (length(@cron_jobs_cache)) { return @cron_jobs_cache; } diff --git a/dovecot/dovecot-lib.pl b/dovecot/dovecot-lib.pl index 27de8ca81..5e54fb55b 100755 --- a/dovecot/dovecot-lib.pl +++ b/dovecot/dovecot-lib.pl @@ -13,7 +13,7 @@ use WebminCore; # Returns a list of dovecot config entries sub get_config { -if (!defined(@get_config_cache)) { +if (!length(@get_config_cache)) { @get_config_cache = ( ); local $lnum = 0; local ($section, @sections); diff --git a/fdisk/fdisk-lib.pl b/fdisk/fdisk-lib.pl index a20de7212..5eed83afe 100755 --- a/fdisk/fdisk-lib.pl +++ b/fdisk/fdisk-lib.pl @@ -26,7 +26,7 @@ $| = 1; # Returns a structure containing the details of all disks and partitions sub list_disks_partitions { -if (defined(@list_disks_partitions_cache)) { +if (length(@list_disks_partitions_cache)) { return @list_disks_partitions_cache; } @@ -872,7 +872,7 @@ if ($raid_module) { } } if ($lvm_module) { - if (!defined(@physical_volumes)) { + if (!length(@physical_volumes)) { @physical_volumes = (); foreach $vg (&foreign_call("lvm", "list_volume_groups")) { push(@physical_volumes, diff --git a/frox/frox-lib.pl b/frox/frox-lib.pl index 9da47c59c..24e65c03b 100755 --- a/frox/frox-lib.pl +++ b/frox/frox-lib.pl @@ -9,7 +9,7 @@ use WebminCore; # Returns an array reference containing the contents of the Frox config file sub get_config { - if (!defined(@get_config_cache)) { + if (!length(@get_config_cache)) { local $lnum = 0; open(CONF, $config{'frox_conf'}); while() { diff --git a/htaccess-htpasswd/htaccess-lib.pl b/htaccess-htpasswd/htaccess-lib.pl index 96f871ea5..d5d33251b 100755 --- a/htaccess-htpasswd/htaccess-lib.pl +++ b/htaccess-htpasswd/htaccess-lib.pl @@ -30,7 +30,7 @@ else { if (&supports_users()) { # Include user home @uinfo = getpwnam($remote_user); - if ($access{'home'} && defined(@uinfo)) { + if ($access{'home'} && length(@uinfo)) { push(@accessdirs, &resolve_links($uinfo[7])); } } diff --git a/ipsec/ipsec-lib.pl b/ipsec/ipsec-lib.pl index c42e8df08..d92b05120 100755 --- a/ipsec/ipsec-lib.pl +++ b/ipsec/ipsec-lib.pl @@ -353,7 +353,7 @@ return undef; # Returns a list of IPsec secret keys sub list_secrets { -if (!defined(@list_secrets_cache)) { +if (!length(@list_secrets_cache)) { local (@lines); local $lnum = 0; open(SEC, $config{'secrets'}); diff --git a/ldap-client/ldap-client-lib.pl b/ldap-client/ldap-client-lib.pl index 43fb435e4..25f963885 100755 --- a/ldap-client/ldap-client-lib.pl +++ b/ldap-client/ldap-client-lib.pl @@ -12,7 +12,7 @@ use WebminCore; sub get_config { local $file = $_[0] || $config{'auth_ldap'}; -if (!defined(@get_config_cache)) { +if (!length(@get_config_cache)) { local $lnum = 0; @get_config_cache = ( ); &open_readfile(CONF, $file); diff --git a/ldap-client/switch-lib.pl b/ldap-client/switch-lib.pl index d756e0a71..f1ed65185 100755 --- a/ldap-client/switch-lib.pl +++ b/ldap-client/switch-lib.pl @@ -6,7 +6,7 @@ $nsswitch_config_file = $config{'nsswitch_conf'} || "/etc/nsswitch.conf"; # Returns an array ref of information from nsswitch.conf sub get_nsswitch_config { -if (!defined(@get_nsswitch_cache)) { +if (!length(@get_nsswitch_cache)) { @get_nsswitch_cache = ( ); local $lnum = 0; open(CONF, $nsswitch_config_file); diff --git a/ldap-server/ldap-server-lib.pl b/ldap-server/ldap-server-lib.pl index ec3eb4896..8887ec094 100755 --- a/ldap-server/ldap-server-lib.pl +++ b/ldap-server/ldap-server-lib.pl @@ -635,7 +635,7 @@ sub check_ldap_permissions { local @uinfo; if ($config{'data_dir'} && $config{'ldap_user'} && - defined(@uinfo = getpwnam($config{'ldap_user'}))) { + length(@uinfo = getpwnam($config{'ldap_user'}))) { opendir(DATADIR, $config{'data_dir'}); local @datafiles = grep { !/^\./ } readdir(DATADIR); closedir(DATADIR); diff --git a/ldap-useradmin/ldap-useradmin-lib.pl b/ldap-useradmin/ldap-useradmin-lib.pl index c1b993ad3..9a9a2a41c 100755 --- a/ldap-useradmin/ldap-useradmin-lib.pl +++ b/ldap-useradmin/ldap-useradmin-lib.pl @@ -169,7 +169,7 @@ else { # Returns a list of users, in the same format as the useradmin module sub list_users { -if (!defined(@list_users_cache)) { +if (!length(@list_users_cache)) { local $ldap = &ldap_connect(); local $base = &get_user_base(); local $rv = $ldap->search(base => $base, @@ -213,7 +213,7 @@ local $rv = $ldap->add($_[0]->{'dn'}, attr => \@attrs); if ($rv->code) { &error(&text('usave_eadd', $rv->error)); } -push(@list_users_cache, $_[0]) if (defined(@list_users_cache)); +push(@list_users_cache, $_[0]) if (length(@list_users_cache)); $ldap->unbind(); &useradmin::refresh_nscd() if (!$batch_mode); } @@ -230,7 +230,7 @@ if ($rv->code) { } $ldap->unbind(); @list_users_cache = grep { $_ ne $_[0] } @list_users_cache - if (defined(@list_users_cache)); + if (length(@list_users_cache)); &useradmin::refresh_nscd() if (!$batch_mode); } @@ -292,7 +292,7 @@ $ldap->unbind(); # Returns a list of groups, in the same format as the useradmin module sub list_groups { -if (!defined(@list_groups_cache)) { +if (!length(@list_groups_cache)) { local $ldap = &ldap_connect(); local $base = &get_group_base(); local $rv = $ldap->search(base => $base, @@ -325,7 +325,7 @@ local $rv = $ldap->add($_[0]->{'dn'}, attr => \@attrs); if ($rv->code) { &error(&text('gsave_eadd', $rv->error)); } -push(@list_groups_cache, $_[0]) if (defined(@list_groups_cache)); +push(@list_groups_cache, $_[0]) if (length(@list_groups_cache)); $ldap->unbind(); &useradmin::refresh_nscd() if (!$batch_mode); } @@ -342,7 +342,7 @@ if ($rv->code) { } $ldap->unbind(); @list_groups_cache = grep { $_ ne $_[0] } @list_groups_cache - if (defined(@list_groups_cache)); + if (length(@list_groups_cache)); &useradmin::refresh_nscd() if (!$batch_mode); } diff --git a/lilo/lilo-lib.pl b/lilo/lilo-lib.pl index 998645385..ae6d27e34 100755 --- a/lilo/lilo-lib.pl +++ b/lilo/lilo-lib.pl @@ -20,7 +20,7 @@ if (open(VERSION, "$module_config_directory/version")) { # Parses lilo.conf and returns a list of directives sub get_lilo_conf { -return @lilo_conf_cache if (defined(@lilo_conf_cache)); +return @lilo_conf_cache if (length(@lilo_conf_cache)); open(CONF, $config{'lilo_conf'}); local $lnum = -1; local ($image, $line); diff --git a/lpadmin/freebsd-lib.pl b/lpadmin/freebsd-lib.pl index e4a83b667..1038cc08f 100755 --- a/lpadmin/freebsd-lib.pl +++ b/lpadmin/freebsd-lib.pl @@ -177,7 +177,7 @@ return $rv; # Returns an array of associative arrays containing printcap fields sub list_printcap { -return @list_printcap_cache if (defined(@list_printcap_cache)); +return @list_printcap_cache if (length(@list_printcap_cache)); local(@rv, @line, $line, $cont, $lnum, $i, %done, $capfile); foreach $capfile ($config{'printcap_file'}, $config{'ro_printcap_file'}) { next if (!$capfile || $done{$capfile}++); diff --git a/lpadmin/linux-lib.pl b/lpadmin/linux-lib.pl index a2d4dd40b..709b9de0a 100755 --- a/lpadmin/linux-lib.pl +++ b/lpadmin/linux-lib.pl @@ -212,7 +212,7 @@ return $rv; # Returns an array of associative arrays containing printcap fields sub list_printcap { -return @list_printcap_cache if (defined(@list_printcap_cache)); +return @list_printcap_cache if (length(@list_printcap_cache)); local(@rv, @line, @comment, @eline, @sline, $line, $cont, $lnum, $i, %done, $capfile); foreach $capfile ($config{'printcap_file'}, $config{'ro_printcap_file'}) { diff --git a/lpadmin/lprng-lib.pl b/lpadmin/lprng-lib.pl index 6cdc82955..a230f0cfc 100755 --- a/lpadmin/lprng-lib.pl +++ b/lpadmin/lprng-lib.pl @@ -255,7 +255,7 @@ return $rv; # Returns an array of associative arrays containing printcap fields sub list_printcap { -return @list_printcap_cache if (defined(@list_printcap_cache)); +return @list_printcap_cache if (length(@list_printcap_cache)); local(@rv, @line, @comment, $line, $cont, $lnum, $i, %done, $capfile); foreach $capfile ($config{'printcap_file'}, $config{'ro_printcap_file'}) { next if (!$capfile || $done{$capfile}++); diff --git a/mailboxes/mailboxes-lib.pl b/mailboxes/mailboxes-lib.pl index 120498be2..2c54df388 100755 --- a/mailboxes/mailboxes-lib.pl +++ b/mailboxes/mailboxes-lib.pl @@ -201,7 +201,7 @@ return &list_user_folders(@_); # mail file in home dir, and maildir in home dir sub get_mail_style { -if (!defined(@mail_style_cache)) { +if (!length(@mail_style_cache)) { if ($config{'auto'}) { # Based on mail server if ($config{'mail_system'} == 1) { diff --git a/mailcap/mailcap-lib.pl b/mailcap/mailcap-lib.pl index 37d4eb1f9..d6cd2c50f 100755 --- a/mailcap/mailcap-lib.pl +++ b/mailcap/mailcap-lib.pl @@ -19,7 +19,7 @@ else { # Returns a list of /etc/mailcap entries sub list_mailcap { -if (!defined(@list_mailcap_cache)) { +if (!length(@list_mailcap_cache)) { @list_mailcap_cache = ( ); open(CAP, $mailcap_file); local $lnum = 0; diff --git a/miniserv.pl b/miniserv.pl index feef5a43f..2d69ec0bb 100755 --- a/miniserv.pl +++ b/miniserv.pl @@ -3508,12 +3508,12 @@ if (!$uinfo) { return ( undef, 0, 1, undef ) if (!@uinfo && !$pamany); if (@uinfo) { - if (defined(@allowusers)) { + if (length(@allowusers)) { # Only allow people on the allow list return ( undef, 0, 0, undef ) if (!&users_match(\@uinfo, @allowusers)); } - elsif (defined(@denyusers)) { + elsif (length(@denyusers)) { # Disallow people on the deny list return ( undef, 0, 0, undef ) if (&users_match(\@uinfo, @denyusers)); diff --git a/mscstyle3/theme.pl b/mscstyle3/theme.pl index b500cd51c..57efc820d 100755 --- a/mscstyle3/theme.pl +++ b/mscstyle3/theme.pl @@ -219,7 +219,7 @@ if (@_ > 0) { } @msc_modules = &get_visible_module_infos() - if (!defined(@msc_modules)); + if (!length(@msc_modules)); print "\n"; local $dir = $current_lang_info->{'dir'} ? "dir=\"$current_lang_info->{'dir'}\"" diff --git a/mscstyle_mini/theme.pl b/mscstyle_mini/theme.pl new file mode 100755 index 000000000..fb059c60a --- /dev/null +++ b/mscstyle_mini/theme.pl @@ -0,0 +1,385 @@ +#!/usr/local/bin/perl + +#theme_prebody - called just before the main body of every page, so it can print any HTML it likes. +#theme_postbody - called just after the main body of every page. +#theme_header - called instead of the normal header function, with the same parameters. You could use this to re-write the header function in your own style with help and index links whereever you want them. +#theme_footer - called instead of the footer function with the same parameters. +#theme_error - called instead of the error function, with the same parameters. + + +sub theme_header { + +local @available = ("webmin", "system", "servers", "cluster", "hardware", "", "net", "kororaweb"); + +local($ll, %access); +print "\n"; +print "\n"; +if ($charset) { + print "\n"; + } +local $os_type = $gconfig{'real_os_type'} ? $gconfig{'real_os_type'} + : $gconfig{'os_type'}; +local $os_version = $gconfig{'real_os_version'} ? $gconfig{'real_os_version'} + : $gconfig{'os_version'}; +print "\n"; +if (@_ > 0) { + if ($gconfig{'sysinfo'} == 1) { + printf "%s : %s on %s (%s %s)\n", + $_[0], $remote_user, &get_display_hostname(), + $os_type, $os_version; + } + elsif ($gconfig{'sysinfo'} == 4) { + printf "%s on %s (%s %s)\n", + $remote_user, &get_display_hostname(), + $os_type, $os_version; + } + else { + print "$_[0]\n"; + } + print $_[7] if ($_[7]); + if ($gconfig{'sysinfo'} == 0 && $remote_user) { + print "\n"; + } + } + +@msc_modules = &get_visible_module_infos() + if (!length(@msc_modules)); + +print ''; + +if ($remote_user && @_ > 1) { + # Show basic header with webmin.com link and logout button + local $logout = $main::session_id ? "/session_login.cgi?logout=1" + : "/switch_user.cgi"; + print qq~ + + + + +
Webmin home page$text{'main_logout'}
~; + } + +local $one = @msc_modules == 1 && $gconfig{'gotoone'}; +if (@_ > 1 && !$one && $remote_user) { + # Display module categories + print qq~ + + + +
~; + + &read_file("$config_directory/webmin.catnames", \%catnames); + foreach $m (@msc_modules) { + $c = $m->{'category'}; + next if ($cats{$c}); + if (defined($catnames{$c})) { + $cats{$c} = $catnames{$c}; + } + elsif ($text{"category_$c"}) { + $cats{$c} = $text{"category_$c"}; + } + else { + # try to get category name from module .. + local %mtext = &load_language($m->{'dir'}); + if ($mtext{"category_$c"}) { + $cats{$c} = $mtext{"category_$c"}; + } + else { + $c = $m->{'category'} = ""; + $cats{$c} = $text{"category_$c"}; + } + } + } + @cats = sort { $b cmp $a } keys %cats; + $cats = @cats; + $per = $cats ? 100.0 / $cats : 100; + + if (!defined($in{'cat'})) { + + # Use default category + if (defined($gconfig{'deftab'}) && + &indexof($gconfig{'deftab'}, @cats) >= 0) { + $in{'cat'} = $gconfig{'deftab'}; + } + else { + $in{'cat'} = $cats[0]; + } + } + elsif (!$cats{$in{'cat'}}) { + $in{'cat'} = ""; + } + +#####Navigation Bar START##### + print qq~ + + +
~; + + foreach $c (@cats) { + $t = $cats{$c}; + $inlist = "false"; + foreach $testet (@available) { + if ($testet eq $c) { + $inlist = "true"; + } + } + if ($in{'cat'} eq $c) { + if ($inlist eq "true") { + + if ($c eq "") { + print qq~~; + + } elsif ($c eq "webmin") { + if (@_ > 1) { + print qq~~; + } else { + print qq~~; + } + } else { + print qq~~; + + + } + + } else { + print qq~~; + + + } + } + else { + if ($inlist eq "true") { + if ($c eq "") { + print qq~$c~; + + + } else { + print qq~$c~; + + + } + } else { + print qq~$c~; + + + } + + } + } + + print qq~ +
~; + print qq~ + + + +
~; + + + } + +if (@_ > 1 && (!$_[5] || $ENV{'HTTP_WEBMIN_SERVERS'})) { + # Show tabs under module categories +print '
'; + + if ($ENV{'HTTP_WEBMIN_SERVERS'}) { + &tab_start(); + print "", + "$text{'header_servers'}
\n"; + &tab_end(); + } + if (!$_[4]) { &tab_start; print "", + "$text{'header_module'}"; &tab_end;} + if (ref($_[2]) eq "ARRAY") { + &tab_start; print &hlink($text{'header_help'}, $_[2]->[0], $_[2]->[1]); &tab_end; + } + elsif (defined($_[2])) { + &tab_start; +print &hlink($text{'header_help'}, $_[2]); +&tab_end; + } + if ($_[3]) { + local %access = &get_module_acl(); + if (!$access{'noconfig'}) { + &tab_start; print "", + $text{'header_config'},""; &tab_end; + } + } + + foreach $t (split(/
/, $_[6])) { + if ($t =~ /\S/) { + &tab_start; print $t; &tab_end; + } + } + +print "
"; + + if (!$_[5]) { + # Show page title in tab + local $title = $_[0]; + $title =~ s/ä/ä/g; + $title =~ s/ö/ö/g; + $title =~ s/ü/ü/g; + $title =~ s/ / /g; + +# print "

\n"; + $usercol = defined($gconfig{'cs_header'}) || + defined($gconfig{'cs_table'}) || + defined($gconfig{'cs_page'}); +# print "\n"; +# print "\n"; +# print "\n"; +# print "
", +# "\"\""," $title ", +# "\"\"","
"; + +print "

$title
"; +&make_sep; + &theme_prebody; + } + } +@header_arguments = @_; +} + +sub theme_prebody +{ +print "
\n"; +} + +sub theme_postbody +{ +print "
\n" if (@header_arguments > 1 && !$header_arguments[5]); +} + +sub theme_footer { +local $i; + +print "
\n" + if (@header_arguments > 1 && !$header_arguments[5]); + +print "
\n"; + +for($i=0; $i+1<@_; $i+=2) { + local $url = $_[$i]; + if ($url eq '/') { + $url = "/?cat=$module_info{'category'}"; + } + elsif ($url eq '' && $module_name) { + $url = "/$module_name/"; + } + elsif ($url =~ /^\?/ && $module_name) { + $url = "/$module_name/$url"; + } + if ($i == 0) { + print " \"<-\"\n"; + } + else { + print " |\n"; + } + print " ",&text('main_return', $_[$i+1]),"\n"; + } +print "
\n"; + +print "
\n"; +if (!$_[$i]) { + local $postbody = $tconfig{'postbody'}; + if ($postbody) { + local $hostname = &get_display_hostname(); + local $version = &get_webmin_version(); + local $os_type = $gconfig{'real_os_type'} ? + $gconfig{'real_os_type'} : $gconfig{'os_type'}; + local $os_version = $gconfig{'real_os_version'} ? + $gconfig{'real_os_version'} : $gconfig{'os_version'}; + $postbody =~ s/%HOSTNAME%/$hostname/g; + $postbody =~ s/%VERSION%/$version/g; + $postbody =~ s/%USER%/$remote_user/g; + $postbody =~ s/%OS%/$os_type $os_version/g; + print "$postbody\n"; + } + if ($tconfig{'postbodyinclude'}) { + open(INC, $module_name ? + "../$gconfig{'theme'}/$tconfig{'postbodyinclude'}" : + "$gconfig{'theme'}/$tconfig{'postbodyinclude'}"); + while() { + print; + } + close(INC); + } + if (defined(&theme_postbody)) { + &theme_postbody(@_); + } + print "\n"; + } + +} + +#sub theme_error { + +#print "error"; + +#} + + +sub chop_font { + +if (!$lang->{'titles'} || $gconfig{'texttitles'}) { + print $t; +} else { + foreach $l (split(//, $t)) { + $ll = ord($l); + if ($ll > 127 && $lang->{'charset'}) { + print "{'charset'}.gif alt=\"$l\" align=bottom border=0>"; + } + elsif ($l eq " ") { + print "\"\ \""; + } + else { + print "\"$l\""; + } + } + } +} + +sub tab_start { + print qq~ + + + + + + +
+ ~; +} + + +sub tab_end { + print qq~
+ + ~; +} + +1; + +sub make_sep { + +print qq~ + + + + + +
 +
+~; + +} diff --git a/msctheme-enhanced/theme.pl b/msctheme-enhanced/theme.pl new file mode 100644 index 000000000..1cae660fe --- /dev/null +++ b/msctheme-enhanced/theme.pl @@ -0,0 +1,821 @@ +#!/usr/local/bin/perl + +#theme_prebody - called just before the main body of every page, so it can print any HTML it likes. +#theme_postbody - called just after the main body of every page. +#theme_header - called instead of the normal header function, with the same parameters. You could use this to re-write the header function in your own style with help and index links whereever you want them. +#theme_footer - called instead of the footer function with the same parameters. +#theme_error - called instead of the error function, with the same parameters. + +%letter_sizes = ( + '100.gif', [ 10, 16 ], + '101.gif', [ 11, 16 ], + '102.gif', [ 6, 16 ], + '103.gif', [ 10, 16 ], + '104.gif', [ 9, 16 ], + '105.gif', [ 4, 16 ], + '106.gif', [ 5, 16 ], + '107.gif', [ 9, 16 ], + '108.gif', [ 4, 16 ], + '109.gif', [ 14, 16 ], + '110.gif', [ 9, 16 ], + '111.gif', [ 11, 16 ], + '112.gif', [ 10, 16 ], + '113.gif', [ 10, 16 ], + '114.gif', [ 6, 16 ], + '115.gif', [ 8, 16 ], + '116.gif', [ 6, 16 ], + '117.gif', [ 9, 16 ], + '118.gif', [ 10, 16 ], + '119.gif', [ 13, 16 ], + '120.gif', [ 10, 16 ], + '121.gif', [ 10, 16 ], + '122.gif', [ 8, 16 ], + '123.gif', [ 7, 16 ], + '124.gif', [ 4, 16 ], + '125.gif', [ 7, 16 ], + '126.gif', [ 9, 16 ], + '177.iso-8859-2.gif', [ 10, 16 ], + '179.iso-8859-2.gif', [ 7, 16 ], + '182.iso-8859-2.gif', [ 9, 16 ], + '188.iso-8859-2.gif', [ 9, 16 ], + '191.iso-8859-2.gif', [ 9, 16 ], + '192.gif', [ 12, 16 ], + '193.gif', [ 12, 16 ], + '194.gif', [ 11, 16 ], + '195.gif', [ 12, 16 ], + '196.gif', [ 12, 16 ], + '197.gif', [ 12, 16 ], + '198.gif', [ 13, 16 ], + '199.gif', [ 12, 16 ], + '200.gif', [ 7, 16 ], + '201.gif', [ 8, 16 ], + '202.gif', [ 8, 16 ], + '203.gif', [ 7, 16 ], + '204.gif', [ 6, 16 ], + '205.gif', [ 5, 16 ], + '206.gif', [ 7, 16 ], + '207.gif', [ 7, 16 ], + '208.gif', [ 11, 16 ], + '208.iso-8859-9.gif', [ 13, 16 ], + '209.gif', [ 10, 16 ], + '210.gif', [ 13, 16 ], + '211.gif', [ 13, 16 ], + '211.iso-8859-2.gif', [ 13, 16 ], + '212.gif', [ 12, 16 ], + '213.gif', [ 13, 16 ], + '214.gif', [ 13, 16 ], + '214.iso-8859-9.gif', [ 13, 16 ], + '215.gif', [ 9, 16 ], + '216.gif', [ 13, 16 ], + '217.gif', [ 9, 16 ], + '218.gif', [ 9, 16 ], + '219.gif', [ 9, 16 ], + '220.gif', [ 9, 16 ], + '220.iso-8859-9.gif', [ 9, 16 ], + '221.gif', [ 11, 16 ], + '221.iso-8859-9.gif', [ 5, 16 ], + '222.gif', [ 9, 16 ], + '222.iso-8859-9.gif', [ 11, 16 ], + '223.gif', [ 9, 16 ], + '224.gif', [ 10, 16 ], + '225.gif', [ 10, 16 ], + '226.gif', [ 11, 16 ], + '227.gif', [ 10, 16 ], + '228.gif', [ 10, 16 ], + '229.gif', [ 11, 16 ], + '230.gif', [ 16, 16 ], + '230.iso-8859-2.gif', [ 9, 16 ], + '231.gif', [ 10, 16 ], + '231.iso-8859-9.gif', [ 10, 16 ], + '231.iso.8859-9.gif', [ 10, 16 ], + '232.gif', [ 11, 16 ], + '233.gif', [ 11, 16 ], + '234.gif', [ 11, 16 ], + '234.iso-8859-2.gif', [ 9, 16 ], + '235.gif', [ 11, 16 ], + '236.gif', [ 6, 16 ], + '237.gif', [ 6, 16 ], + '238.gif', [ 6, 16 ], + '239.gif', [ 7, 16 ], + '240.gif', [ 10, 16 ], + '240.iso-8859-9.gif', [ 10, 16 ], + '241.gif', [ 9, 16 ], + '241.iso-8859-2.gif', [ 9, 16 ], + '242.gif', [ 11, 16 ], + '243.gif', [ 11, 16 ], + '243.iso-8859-2.gif', [ 11, 16 ], + '244.gif', [ 11, 16 ], + '245.gif', [ 11, 16 ], + '246.gif', [ 11, 16 ], + '246.iso-8859-9.gif', [ 11, 16 ], + '247.gif', [ 9, 16 ], + '248.gif', [ 10, 16 ], + '249.gif', [ 9, 16 ], + '250.gif', [ 9, 16 ], + '251.gif', [ 9, 16 ], + '252.gif', [ 9, 16 ], + '252.iso-8859-9.gif', [ 9, 16 ], + '253.gif', [ 10, 16 ], + '253.iso-8859-9.gif', [ 5, 16 ], + '254.gif', [ 10, 16 ], + '255.gif', [ 9, 16 ], + '32.gif', [ 6, 16 ], + '33.gif', [ 4, 16 ], + '34.gif', [ 7, 16 ], + '35.gif', [ 9, 16 ], + '36.gif', [ 8, 16 ], + '37.gif', [ 13, 16 ], + '38.gif', [ 11, 16 ], + '39.gif', [ 3, 16 ], + '40.gif', [ 6, 16 ], + '41.gif', [ 6, 16 ], + '42.gif', [ 7, 16 ], + '43.gif', [ 9, 16 ], + '44.gif', [ 4, 16 ], + '45.gif', [ 6, 16 ], + '46.gif', [ 4, 16 ], + '47.gif', [ 7, 16 ], + '48.gif', [ 9, 16 ], + '49.gif', [ 6, 16 ], + '50.gif', [ 9, 16 ], + '51.gif', [ 9, 16 ], + '52.gif', [ 10, 16 ], + '53.gif', [ 9, 16 ], + '54.gif', [ 10, 16 ], + '55.gif', [ 8, 16 ], + '56.gif', [ 9, 16 ], + '57.gif', [ 10, 16 ], + '58.gif', [ 5, 16 ], + '59.gif', [ 4, 16 ], + '60.gif', [ 9, 16 ], + '61.gif', [ 10, 16 ], + '62.gif', [ 10, 16 ], + '63.gif', [ 9, 16 ], + '64.gif', [ 12, 16 ], + '65.gif', [ 12, 16 ], + '66.gif', [ 9, 16 ], + '67.gif', [ 12, 16 ], + '68.gif', [ 10, 16 ], + '69.gif', [ 7, 16 ], + '70.gif', [ 7, 16 ], + '71.gif', [ 13, 16 ], + '72.gif', [ 9, 16 ], + '73.gif', [ 5, 16 ], + '74.gif', [ 8, 16 ], + '75.gif', [ 9, 16 ], + '76.gif', [ 8, 16 ], + '77.gif', [ 12, 16 ], + '78.gif', [ 10, 16 ], + '79.gif', [ 12, 16 ], + '80.gif', [ 9, 16 ], + '81.gif', [ 13, 16 ], + '82.gif', [ 9, 16 ], + '83.gif', [ 9, 16 ], + '84.gif', [ 8, 16 ], + '85.gif', [ 9, 16 ], + '86.gif', [ 11, 16 ], + '87.gif', [ 14, 16 ], + '88.gif', [ 11, 16 ], + '89.gif', [ 11, 16 ], + '90.gif', [ 9, 16 ], + '91.gif', [ 5, 16 ], + '93.gif', [ 6, 16 ], + '94.gif', [ 9, 16 ], + '95.gif', [ 9, 16 ], + '96.gif', [ 6, 16 ], + '97.gif', [ 11, 16 ], + '98.gif', [ 10, 16 ], + '99.gif', [ 10, 16 ] + ); + +sub theme_header { + +local @available = ("webmin", "system", "servers", "cluster", "hardware", "", "net", "kororaweb"); + +local $ll; +local %access = &get_module_acl(); +local %gaccess = &get_module_acl(undef, ""); +print "\n"; +print "\n"; +local $os_type = $gconfig{'real_os_type'} ? $gconfig{'real_os_type'} + : $gconfig{'os_type'}; +local $os_version = $gconfig{'real_os_version'} ? $gconfig{'real_os_version'} + : $gconfig{'os_version'}; +print "\n"; +if ($charset) { + print "\n"; + } +print "\n"; +if (@_ > 0) { + if ($gconfig{'sysinfo'} == 1) { + printf "%s : %s on %s (%s %s)\n", + $_[0], $remote_user, &get_system_hostname(), + $os_type, $os_version; + } + else { + print "$_[0]\n"; + } + print $_[7] if ($_[7]); + if ($gconfig{'sysinfo'} == 0 && $remote_user) { + print " + + +~; +#########JAVA & CSS FOR MENUS STOP########### + + } + } + +@msc_modules = &get_available_module_infos() + if (!length(@msc_modules)); + +print "\n"; +if ($theme_no_table) { + print ''; + } +else { + print ''; + } + +if ($remote_user && @_ > 1) { + # Show basic header with webmin.com link and logout button + local $logout = $main::session_id ? "/session_login.cgi?logout=1" + : "/switch_user.cgi"; + local $loicon = $main::session_id ? "logout.jpg" : "switch.jpg"; + local $lowidth = $main::session_id ? 84 : 27; + local $lotext = $main::session_id ? $text{'main_logout'} + : $text{'main_switch'}; + print qq~ + + + + ~; + if (!$ENV{'ANONYMOUS_USER'}) { + if ($gconfig{'nofeedbackcc'} != 2 && $gaccess{'feedback'}) { + print qq~~; + } + if (!$ENV{'SSL_USER'} && !$ENV{'LOCAL_USER'} && + !$ENV{'HTTP_WEBMIN_SERVERS'}) { + if ($gconfig{'nofeedbackcc'} != 2 && + $gaccess{'feedback'}) { + print qq~~; + } + print qq~~; + } + } + print qq~ + +
Webmin home page$text{'main_feedback'}$lotext +
+
~; + } + +local $one = @msc_modules == 1 && $gconfig{'gotoone'}; +local $notabs = $gconfig{"notabs_${base_remote_user}"} == 2 || + $gconfig{"notabs_${base_remote_user}"} == 0 && $gconfig{'notabs'}; +if (@_ > 1 && !$one && $remote_user && !$notabs) { + # Display module categories + print qq~ + + + +
~; + + local %catnames; + &read_file("$config_directory/webmin.catnames", \%catnames); + foreach $m (@msc_modules) { + local $c = $m->{'category'}; + next if ($cats{$c}); + if (defined($catnames{$c})) { + $cats{$c} = $catnames{$c}; + } + elsif ($text{"category_$c"}) { + $cats{$c} = $text{"category_$c"}; + } + else { + # try to get category name from module .. + local %mtext = &load_language($m->{'dir'}); + if ($mtext{"category_$c"}) { + $cats{$c} = $mtext{"category_$c"}; + } + else { + $c = $m->{'category'} = ""; + $cats{$c} = $text{"category_$c"}; + } + } + } + @cats = sort { $b cmp $a } keys %cats; + $cats = @cats; + $per = $cats ? 100.0 / $cats : 100; + + if ($theme_index_page) { + if (!defined($in{'cat'})) { + + # Use default category + if (defined($gconfig{'deftab'}) && + &indexof($gconfig{'deftab'}, @cats) >= 0) { + $in{'cat'} = $gconfig{'deftab'}; + } + else { + $in{'cat'} = $cats[0]; + } + } + elsif (!$cats{$in{'cat'}}) { + $in{'cat'} = ""; + } + } + +#####Navigation Bar START##### + print qq~ + + ~; + + foreach $c (@cats) { + local $t = $cats{$c}; + $inlist = "false"; + foreach $testet (@available) { + if ($testet eq $c) { + $inlist = "true"; + } + } + if ($in{'cat'} eq $c && $theme_index_page) { + if ($inlist eq "true") { + + if ($c eq "") { + +###OTHER MENU [ACTIVE] + + print qq~ + ~; + } elsif ($c eq "webmin") { + +###WEBMIN MENU [ACTIVE] + + if (@_ > 1) { + print qq~ + ~; + } else { + +###UNKNOWN MENU [ACTIVE] + + print qq~ + ~; + } + } else { + +###REST OF MENUS [ACTIVE] + + print qq~ + ~; + } + + } else { + +###UNKNOWN CATAGORY [ACTIVE] + + print qq~ + ~; + } + } + else { + if ($inlist eq "true") { + if ($c eq "") { + +###OTHER MENU [NON-ACTIVE] + + print qq~ + ~; + } else { + +###REST OF MENUS [NON-ACTIVE] + print qq~ + ~; + } + } else { + +###UNKNOWN CATAGORY [NON-ACTIVE] + + print qq~ + ~; + } + + } + } + + print qq~ + + +
$t
~; + + &chop_font; + + print "
"; +&create_menu(); + print qq~
$t
~; + + + &chop_font; + print "
"; +&create_menu(); + print qq~
$t
~; + &chop_font; + print "
"; +&create_menu(); + print qq~
$t
~; + + &chop_font; + + print "
"; +&create_menu(); + print qq~
$t
~; + + &chop_font; + + print "
"; +&create_menu(); + print qq~
$t
~; + + + &chop_font; + + print "
"; +&create_menu(); + print qq~
$t
~; + + + &chop_font; + + print "
"; +&create_menu(); + print qq~
$t
~; + + &chop_font; + + print "
"; +&create_menu(); + print qq~
 
 
~; + print qq~
+ + + +
~; + } + +if (@_ > 1 && (!$_[5] || $ENV{'HTTP_WEBMIN_SERVERS'})) { + # Show tabs under module categories + print qq~~; + + if ($gconfig{'sysinfo'} == 2 && $remote_user) { + &tab_start(); + printf "%s%s logged into %s %s on %s (%s%s)\n", + $ENV{'ANONYMOUS_USER'} ? "Anonymous user" : "$remote_user", + $ENV{'SSL_USER'} ? " (SSL certified)" : + $ENV{'LOCAL_USER'} ? " (Local user)" : "", + $text{'programname'}, + $version, "".&get_system_hostname()."", + $os_type, $os_version eq "*" ? "" : " $os_version"; + &tab_end(); + } + if ($ENV{'HTTP_WEBMIN_SERVERS'}) { + &tab_start(); + print "", + "$text{'header_servers'}
\n"; + &tab_end(); + } + if ($notabs && !$_[5]) { + &tab_start; + print "$text{'header_webmin'}
\n"; + &tab_end; + } + if (!$_[4]) { + local $mi = $module_index_link || + $module_name ? "/$module_name/" : "/"; + &tab_start; print "", + "$text{'header_module'}"; &tab_end; + } + if (ref($_[2]) eq "ARRAY" && !$ENV{'ANONYMOUS_USER'}) { + &tab_start; print &hlink($text{'header_help'}, $_[2]->[0], $_[2]->[1]); &tab_end; + } + elsif (defined($_[2]) && !$ENV{'ANONYMOUS_USER'}) { + &tab_start; print &hlink($text{'header_help'}, $_[2]); &tab_end; + } + if ($_[3]) { + if (!$access{'noconfig'}) { + &tab_start; print "", + $text{'header_config'},""; &tab_end; + } + } + + foreach $t (split(/
/, $_[6])) { + if ($t =~ /\S/) { + &tab_start; print $t; &tab_end; + } + } + +print qq~ + + +
+ + + + + +
+ + +
~; + + if (!$_[5]) { + # Show page title in tab + local $title = $_[0]; + $title =~ s/ä/ä/g; + $title =~ s/ö/ö/g; + $title =~ s/ü/ü/g; + $title =~ s/ / /g; + + print "

\n"; + print "\n"; + print "\n"; + print "\n"; + if ($_[9]) { + print "
", + ""," $title ", + "","
\n"; + print "\n"; + print "\n"; + print "\n"; + } + print "
", + ""," $_[9] ", + "\"\"","
"; + + &theme_prebody; + } + } elsif (@_ > 1) { + print qq~ + + + +

~; + } +@header_arguments = @_; +} + +sub theme_prebody +{ +if ($theme_no_table) { + print "

    \n"; + } +else { + #print "~; +} + +sub create_menu { + my $tmpid; + if ($c eq "") { $tmpid = "other"; } + else { $tmpid = $c; } + + my $tmpimg; + if ($c eq "") { $tmpimg = "other"; } + if ($inlist eq "true" && $c ne "") { $tmpimg = "$c"; } + if ($inlist ne "true" && $c ne "") { $tmpimg = "unknown"; } + + if ($in{'cat'} eq $c) { + print qq~ +
    \n"; + print "
    \n"; + print "
    \n"; + } +} + +sub theme_footer { +local $i; + +if ($theme_no_table) { + print "\n"; + } +elsif (@header_arguments > 1 && !$header_arguments[5]) { + print "

    \n"; + } + +print "
    \n"; + +for($i=0; $i+1<@_; $i+=2) { + local $url = $_[$i]; + if ($url eq '/') { + $url = "/?cat=$module_info{'category'}"; + } + elsif ($url eq '' && $module_name) { + $url = "/$module_name/"; + } + elsif ($url =~ /^\?/ && $module_name) { + $url = "/$module_name/$url"; + } + if ($i == 0) { + print " \"<-\"\n"; + } + else { + print " |\n"; + } + print " ",&text('main_return', $_[$i+1]),"\n"; + } +print "
    \n"; + +print "
    \n"; +if (!$_[$i]) { + local $postbody = $tconfig{'postbody'}; + if ($postbody) { + local $hostname = &get_system_hostname(); + local $version = &get_webmin_version(); + local $os_type = $gconfig{'real_os_type'} ? + $gconfig{'real_os_type'} : $gconfig{'os_type'}; + local $os_version = $gconfig{'real_os_version'} ? + $gconfig{'real_os_version'} : $gconfig{'os_version'}; + $postbody =~ s/%HOSTNAME%/$hostname/g; + $postbody =~ s/%VERSION%/$version/g; + $postbody =~ s/%USER%/$remote_user/g; + $postbody =~ s/%OS%/$os_type $os_version/g; + print "$postbody\n"; + } + if ($tconfig{'postbodyinclude'}) { + open(INC, $module_name ? + "../$gconfig{'theme'}/$tconfig{'postbodyinclude'}" : + "$gconfig{'theme'}/$tconfig{'postbodyinclude'}"); + while() { + print; + } + close(INC); + } + if (defined(&theme_postbody)) { + &theme_postbody(@_); + } + print "\n"; + } + +} + +#sub theme_error { + +#print "error"; + +#} + + +sub chop_font { + +if (!$current_lang_info->{'titles'} || $gconfig{'texttitles'}) { + print $t; +} else { + foreach $l (split(//, $t)) { + $ll = ord($l); + local $gif; + if ($ll > 127 && $current_lang_info->{'charset'}) { + $gif = "$ll.$current_lang_info->{'charset'}.gif"; + } + else { + $gif = "$ll.gif"; + } + local $sz = $letter_sizes{$gif}; + printf "\"%s\"", + $gif, $sz->[0], $sz->[1], $ll eq " " ? " " : $l; + } + } +} + +sub tab_start { + print qq~
    + + + + + + + + + + +
    + ~; +} + + +sub tab_end { + print qq~
    + +
    ", + "$_[9]
    \n"; + } + $started_osx_table++; + } +} + +sub theme_footer +{ +if ($started_osx_table) { + # Close table for main page + &end_osx_table(); + } + +# Show footer links + +print "\n"; +print "\n"; +} + +# start_osx_table(title, rightstuff, width) +sub start_osx_table +{ +local ($title, $right, $width) = @_; +$width ||= 100; +print < + + + + + + + + + +
      $title$right
    + + + + + + + + + + + + + + + +
    + + +
    +EOF +} + +sub end_osx_table +{ +print < +
    +
    +EOF +} + +sub theme_ui_post_header +{ +local ($text) = @_; +local $rv; +if (defined($text)) { + $rv .= "
    $text

    \n"; + } +return $rv; +} + +sub theme_ui_pre_footer +{ +return ""; +} + +# Hack to prevent the display of
    lines +#package miniserv; +#sub PRINT +#{ +#if ($_[1] !~ /^
    (

    |
    )?\s*$/) { +# $r = shift; +# $$r++; +# &write_to_sock(@_); +# } +#} + + + diff --git a/package-updates/package-updates-lib.pl b/package-updates/package-updates-lib.pl index 04c3d1df8..5a7147107 100644 --- a/package-updates/package-updates-lib.pl +++ b/package-updates/package-updates-lib.pl @@ -255,7 +255,7 @@ return defined(&software::update_system_updates); sub updates_available { my ($nocache) = @_; -if (!defined(@updates_available_cache)) { +if (!length(@updates_available_cache)) { if ($nocache || &cache_expired($updates_cache_file)) { # Get from original source @updates_available_cache = &software::update_system_updates(); diff --git a/postfix/postfix-lib.pl b/postfix/postfix-lib.pl index ca62ea5bc..e3263dc72 100755 --- a/postfix/postfix-lib.pl +++ b/postfix/postfix-lib.pl @@ -1283,7 +1283,7 @@ else { # 2 and the maildir name for ~/Maildir style sub postfix_mail_system { -if (!defined(@mail_system_cache)) { +if (!length(@mail_system_cache)) { local $home_mailbox = &get_current_value("home_mailbox"); if ($home_mailbox) { @mail_system_cache = $home_mailbox =~ /^(.*)\/$/ ? @@ -1535,7 +1535,7 @@ return &parse_value_header_checks(@_); # Returns an array reference of entries from the Postfix master.cf file sub get_master_config { -if (!defined(@master_config_cache)) { +if (!length(@master_config_cache)) { @master_config_cache = ( ); local $lnum = 0; local $prog; @@ -2080,7 +2080,7 @@ sub supports_map_type { local ($type) = @_; return 1 if ($type eq 'hash'); # Assume always supported -if (!defined(@supports_map_type_cache)) { +if (!length(@supports_map_type_cache)) { @supports_map_type = ( ); open(POSTCONF, "$config{'postfix_config_command'} -m |"); while() { diff --git a/qmailadmin/qmail-lib.pl b/qmailadmin/qmail-lib.pl index 410b59784..ffb915636 100755 --- a/qmailadmin/qmail-lib.pl +++ b/qmailadmin/qmail-lib.pl @@ -261,7 +261,7 @@ else { # Returns a list of all SMTP routes sub list_routes { -if (!defined(@list_routes_cache)) { +if (!length(@list_routes_cache)) { local $lnum = 0; local @rv; open(ROUTES, $qmail_routes_file); @@ -387,7 +387,7 @@ print "\n"; # Returns a list of all virtualdomains file entries sub list_virts { -if (!defined(@list_virts_cache)) { +if (!length(@list_virts_cache)) { local $lnum = 0; local @rv; open(VIRTS, $qmail_virts_file); @@ -592,7 +592,7 @@ return $r; # Returns a list of qmail user assignments sub list_assigns { -if (!defined(@list_assigns_cache)) { +if (!length(@list_assigns_cache)) { local @rv; local $lnum = 0; open(ASSIGNS, $qmail_assigns_file); diff --git a/quota/cgi_args.pl b/quota/cgi_args.pl index b23fa49a3..6f8bd4465 100755 --- a/quota/cgi_args.pl +++ b/quota/cgi_args.pl @@ -23,13 +23,13 @@ elsif ($cgi eq 'edit_group_quota.cgi') { '&group='.&urlize($group{0,'group'}) : 'none'; } elsif ($cgi eq 'user_filesys.cgi' || $cgi eq 'copy_user_form.cgi') { - return defined(@uinfo) ? + return length(@uinfo) ? 'user='.&urlize($remote_user) : 'user=root'; } elsif ($cgi eq 'group_filesys.cgi' || $cgi eq 'copy_group_form.cgi') { - if (defined(@uinfo)) { + if (length(@uinfo)) { my @ginfo = getgrgid($uinfo[3]); - return 'group='.&urlize($ginfo[0]) if (defined(@ginfo)); + return 'group='.&urlize($ginfo[0]) if (length(@ginfo)); } return 'group=bin'; } diff --git a/raid/raid-lib.pl b/raid/raid-lib.pl index ae8df84d9..bb89d81e2 100755 --- a/raid/raid-lib.pl +++ b/raid/raid-lib.pl @@ -65,7 +65,7 @@ return %mdstat; sub get_raidtab { local ($raiddev, $device, %mdstat); -return \@get_raidtab_cache if (defined(@get_raidtab_cache)); +return \@get_raidtab_cache if (length(@get_raidtab_cache)); %mdstat = &get_mdstat(); if ($raid_mode eq "raidtools") { @@ -601,7 +601,7 @@ if ($mounted) { return ($mounted->[0], $mounted->[2], 1, &indexof($mounted, @mounted)); } elsif ($mount) { return ($mount->[0], $mount->[2], 0, &indexof($mount, @mounts)); } -if (!defined(@physical_volumes)) { +if (!length(@physical_volumes)) { @physical_volumes = (); foreach $vg (&lvm::list_volume_groups()) { push(@physical_volumes, diff --git a/rbac/rbac-lib.pl b/rbac/rbac-lib.pl index b62f7bc0d..05f3f65c8 100755 --- a/rbac/rbac-lib.pl +++ b/rbac/rbac-lib.pl @@ -11,7 +11,7 @@ use WebminCore; # Returns a list of user attribute objects sub list_user_attrs { -if (!defined(@list_user_attrs_cache)) { +if (!length(@list_user_attrs_cache)) { @list_user_attrs_cache = ( ); local $lnum = 0; open(ATTR, $config{'user_attr'}); @@ -142,7 +142,7 @@ return @rv; # Returns a list of all profiles sub list_prof_attrs { -if (!defined(@list_prof_attrs_cache)) { +if (!length(@list_prof_attrs_cache)) { @list_prof_attrs_cache = ( ); local $lnum = 0; open(ATTR, $config{'prof_attr'}); @@ -285,7 +285,7 @@ return @rv; # Returns a user of all authorizations sub list_auth_attrs { -if (!defined(@list_auth_attrs_cache)) { +if (!length(@list_auth_attrs_cache)) { @list_auth_attrs_cache = ( ); local $lnum = 0; open(ATTR, $config{'auth_attr'}); @@ -406,7 +406,7 @@ return join(",", @auths); # Returns a user of all execorizations sub list_exec_attrs { -if (!defined(@list_exec_attrs_cache)) { +if (!length(@list_exec_attrs_cache)) { @list_exec_attrs_cache = ( ); local $lnum = 0; open(ATTR, $config{'exec_attr'}); @@ -496,7 +496,7 @@ return $rv; # Returns a list of policy config file directives sub get_policy_config { -if (!defined(@policy_conf_cache)) { +if (!length(@policy_conf_cache)) { @policy_conf_cache = ( ); local $lnum = 0; open(ATTR, $config{'policy_conf'}); @@ -571,7 +571,7 @@ elsif ($old && $old->{'enabled'} && !$value) { # Returns a list of project objects sub list_projects { -if (!defined(@list_projects_cache)) { +if (!length(@list_projects_cache)) { @list_projects_cache = ( ); local $lnum = 0; open(ATTR, $config{'project'}); @@ -808,7 +808,7 @@ foreach $c (&rbac_config_files()) { # Returns 1 list of all encryption algorithms, including the internal __unix__ sub list_crypt_algorithms { -if (!defined(@list_crypt_algorithms_cache)) { +if (!length(@list_crypt_algorithms_cache)) { push(@list_crypt_algorithms_cache, { 'name' => '__unix__' } ); local $lnum = 0; open(CRYPT, $config{'crypt_conf'}); diff --git a/sarg/sarg-lib.pl b/sarg/sarg-lib.pl index 3da6a80ff..a7e50737e 100755 --- a/sarg/sarg-lib.pl +++ b/sarg/sarg-lib.pl @@ -13,7 +13,7 @@ $cron_cmd = "$module_config_directory/generate.pl"; # Parses the sarg config file into directives sub get_config { -if (!defined(@get_config_cache)) { +if (!length(@get_config_cache)) { local $lnum = 0; open(CONF, $config{'sarg_conf'}); while() { diff --git a/sendmail/access-lib.pl b/sendmail/access-lib.pl index b8b860f76..bb7409e9d 100755 --- a/sendmail/access-lib.pl +++ b/sendmail/access-lib.pl @@ -23,7 +23,7 @@ return &find_textfile($config{'access_file'}, &access_dbm($_[0])); # list_access(textfile) sub list_access { -if (!defined(@list_access_cache)) { +if (!length(@list_access_cache)) { @list_access_cache = ( ); local $lnum = 0; open(ACC, $_[0]); diff --git a/sendmail/domain-lib.pl b/sendmail/domain-lib.pl index 71e4905a6..8139a82c0 100755 --- a/sendmail/domain-lib.pl +++ b/sendmail/domain-lib.pl @@ -23,7 +23,7 @@ return &find_textfile($config{'domains_file'}, &domains_dbm($_[0])); # list_domains(textfile) sub list_domains { -if (!defined(@list_domains_cache)) { +if (!length(@list_domains_cache)) { @list_domains_cache = ( ); local $lnum = 0; local $cmt; diff --git a/sendmail/generics-lib.pl b/sendmail/generics-lib.pl index dd91df184..1bc033616 100755 --- a/sendmail/generics-lib.pl +++ b/sendmail/generics-lib.pl @@ -23,7 +23,7 @@ return &find_textfile($config{'generics_file'}, &generics_dbm($_[0])); # list_generics(textfile) sub list_generics { -if (!defined(@list_generics_cache)) { +if (!length(@list_generics_cache)) { @list_generics_cache = ( ); local $lnum = 0; local $cmt; diff --git a/sendmail/mailers-lib.pl b/sendmail/mailers-lib.pl index 245ec68c1..731edd843 100755 --- a/sendmail/mailers-lib.pl +++ b/sendmail/mailers-lib.pl @@ -23,7 +23,7 @@ return &find_textfile($config{'mailers_file'}, &mailers_dbm($_[0])); # list_mailers(textfile) sub list_mailers { -if (!defined(@list_mailers_cache)) { +if (!length(@list_mailers_cache)) { local $lnum = 0; @list_mailers_cache = ( ); local $cmt; diff --git a/sendmail/virtusers-lib.pl b/sendmail/virtusers-lib.pl index 7ba3d39d7..8157bd9bd 100755 --- a/sendmail/virtusers-lib.pl +++ b/sendmail/virtusers-lib.pl @@ -23,7 +23,7 @@ return &find_textfile($config{'virtusers_file'}, &virtusers_dbm($_[0])); # list_virtusers(textfile) sub list_virtusers { -if (!defined(@list_virtusers_cache)) { +if (!length(@list_virtusers_cache)) { @list_virtusers_cache = ( ); local $lnum = 0; local $cmt; diff --git a/spam/spam-lib.pl b/spam/spam-lib.pl index 4c3f3e9e3..1a5088441 100755 --- a/spam/spam-lib.pl +++ b/spam/spam-lib.pl @@ -1044,9 +1044,9 @@ elsif ($access{'awl_groups'}) { # Check if the user is a member of any of the allowed groups local %ugroups; local @uinfo = getpwnam($user); - return 0 if (!defined(@uinfo)); + return 0 if (!length(@uinfo)); local @ginfo = getgrgid($uinfo[3]); - $ugroups{$ginfo[0]}++ if (defined(@ginfo)); + $ugroups{$ginfo[0]}++ if (length(@ginfo)); foreach my $o (&other_groups($user)) { $ugroups{$o}++; } diff --git a/status/nut-monitor.pl b/status/nut-monitor.pl index b2f2f3634..2f8bbcaf7 100755 --- a/status/nut-monitor.pl +++ b/status/nut-monitor.pl @@ -72,7 +72,7 @@ elsif ($in{'mode'} == 2) { # Returns a list of NUT attribute names and values for some UPS sub get_ups_values { -if (!defined(@get_ups_cache)) { +if (!length(@get_ups_cache)) { local @rv; open(SENS, "upsc ".quotemeta($_[0])." |"); while() { diff --git a/status/sensors-monitor.pl b/status/sensors-monitor.pl index ffa18fcb6..43a5fefa2 100755 --- a/status/sensors-monitor.pl +++ b/status/sensors-monitor.pl @@ -63,7 +63,7 @@ elsif ($in{'mode'} == 2) { # Returns a list of lm_sensors names, values and maxes sub get_sensors_values { -if (!defined(@get_sensors_cache)) { +if (!length(@get_sensors_cache)) { local @rv; open(SENS, "sensors 2>/dev/null |"); while() { diff --git a/syslog-ng/syslog-ng-lib.pl b/syslog-ng/syslog-ng-lib.pl index 5022f5ee3..c6ee83659 100755 --- a/syslog-ng/syslog-ng-lib.pl +++ b/syslog-ng/syslog-ng-lib.pl @@ -23,7 +23,7 @@ return $gconfig{'os_type'} eq 'solaris'; # Parses the syslog-ng config file into an array ref of objects sub get_config { -if (!defined(@get_config_cache)) { +if (!length(@get_config_cache)) { # First read file into tokens @get_config_cache = &read_config_file($config{'syslogng_conf'}); } diff --git a/useradmin/user-lib.pl b/useradmin/user-lib.pl index 554b779e3..2ad24ed43 100755 --- a/useradmin/user-lib.pl +++ b/useradmin/user-lib.pl @@ -97,7 +97,7 @@ Or if it supports FreeBSD master.passwd info, it will also have keys : =cut sub list_users { -return @list_users_cache if (defined(@list_users_cache)); +return @list_users_cache if (length(@list_users_cache)); # read the password file local (@rv, $_, %idx, $lnum, @pw, $p, $i, $j); @@ -306,7 +306,7 @@ if ($pft == 1) { "$_[0]->{'gid'}:$_[0]->{'class'}:$_[0]->{'change'}:". "$_[0]->{'expire'}:$_[0]->{'real'}:$_[0]->{'home'}:". "$_[0]->{'shell'}"); - if (defined(@list_users_cache)) { + if (length(@list_users_cache)) { map { $_->{'line'}++ if ($_->{'line'} >= $_[0]->{'line'}) } @list_users_cache; } @@ -337,7 +337,7 @@ else { # add to /etc/passwd $lref = &read_file_lines($config{'passwd_file'}); $_[0]->{'line'} = &nis_index($lref); - if (defined(@list_users_cache)) { + if (length(@list_users_cache)) { map { $_->{'line'}++ if ($_->{'line'} >= $_[0]->{'line'}) } @list_users_cache; } @@ -351,7 +351,7 @@ else { # Find correct place to insert in shadow file $lref = &read_file_lines($config{'shadow_file'}); $_[0]->{'sline'} = &nis_index($lref); - if (defined(@list_users_cache)) { + if (length(@list_users_cache)) { map { $_->{'sline'}++ if ($_->{'sline'} >= $_[0]->{'sline'}) } @list_users_cache; @@ -400,7 +400,7 @@ else { } } &flush_file_lines() if (!$batch_mode); -push(@list_users_cache, $_[0]) if (defined(@list_users_cache)); +push(@list_users_cache, $_[0]) if (length(@list_users_cache)); &refresh_nscd() if (!$batch_mode); } @@ -568,7 +568,7 @@ else { } } @list_users_cache = grep { $_->{'user'} ne $_[0]->{'user'} } @list_users_cache - if (defined(@list_users_cache)); + if (length(@list_users_cache)); if (!$batch_mode) { &flush_file_lines(); &refresh_nscd(); @@ -591,7 +591,7 @@ contain the keys : =cut sub list_groups { -return @list_groups_cache if (defined(@list_groups_cache)); +return @list_groups_cache if (length(@list_groups_cache)); local(@rv, $lnum, $_, %idx, $g, $i, $j, @gr); $lnum = 0; @@ -740,7 +740,7 @@ else { local $lref; $lref = &read_file_lines($config{'group_file'}); $_[0]->{'line'} = &nis_index($lref); - if (defined(@list_groups_cache)) { + if (length(@list_groups_cache)) { map { $_->{'line'}++ if ($_->{'line'} >= $_[0]->{'line'}) } @list_groups_cache; } @@ -751,7 +751,7 @@ else { if ($gft == 2) { $lref = &read_file_lines($config{'gshadow_file'}); $_[0]->{'sline'} = &nis_index($lref); - if (defined(@list_groups_cache)) { + if (length(@list_groups_cache)) { map { $_->{'sline'}++ if ($_->{'sline'} >= $_[0]->{'sline'}) } @list_groups_cache; @@ -767,7 +767,7 @@ else { &flush_file_lines(); } &refresh_nscd(); -push(@list_groups_cache, $_[0]) if (defined(@list_groups_cache)); +push(@list_groups_cache, $_[0]) if (length(@list_groups_cache)); } =head2 modify_group(&old, &details) @@ -860,7 +860,7 @@ else { } } @list_groups_cache = grep { $_ ne $_[0] } @list_groups_cache - if (defined(@list_groups_cache)); + if (length(@list_groups_cache)); &refresh_nscd(); } diff --git a/zones/zones-lib.pl b/zones/zones-lib.pl index f6847cf3c..f0fecdf3a 100755 --- a/zones/zones-lib.pl +++ b/zones/zones-lib.pl @@ -289,7 +289,7 @@ return &ui_opt_textbox($name, $value, 10, $text{'pool_none'}); sub get_active_interface { local ($zinfo, $net) = @_; -if (!defined(@active_interfaces_cache)) { +if (!length(@active_interfaces_cache)) { @active_interfaces_cache = &net::active_interfaces(); } local $address = $net->{'address'}; @@ -307,7 +307,7 @@ sub get_active_mount { local ($zinfo, $fs) = @_; local $dir = &get_zone_root($zinfo).$fs->{'dir'}; -if (!defined(@active_mounts_cache)) { +if (!length(@active_mounts_cache)) { @active_mounts_cache = &mount::list_mounted(); } local ($mount) = grep { $_->[0] eq $dir } @active_mounts_cache;