From d59eb79542fb6329933b334728c0d2e5c0ab4fb8 Mon Sep 17 00:00:00 2001 From: Ilia Rostovtsev Date: Sun, 26 Sep 2021 19:45:47 +0300 Subject: [PATCH] Fix ongoing issues with proxy prefixes in status collection, choosers 1/2 --- WebminCore.pm | 2 +- chooser.cgi | 8 ++++---- group_chooser.cgi | 10 +++++----- index.cgi | 10 +++++----- module_chooser.cgi | 6 +++--- postfix/postfix-lib.pl | 2 +- status/status-lib.pl | 2 +- status/system_info.pl | 2 +- ui-lib.pl | 36 ++++++++++++++++++------------------ user_chooser.cgi | 10 +++++----- web-lib-funcs.pl | 17 +++++++++-------- 11 files changed, 53 insertions(+), 52 deletions(-) diff --git a/WebminCore.pm b/WebminCore.pm index 76b5fdb5c..005b21e8a 100644 --- a/WebminCore.pm +++ b/WebminCore.pm @@ -24,7 +24,7 @@ require Exporter; # Add global variables in web-lib.pl push(@EXPORT, qw(&unique)); -push(@EXPORT, qw($config_directory $var_directory $remote_error_handler %month_to_number_map %number_to_month_map $webmin_feedback_address $default_lang $default_charset $module_index_name $module_index_link %in $in @in $progress_callback_prefix $progress_callback_url $wait_for_debug $wait_for_input @matches $theme_no_table $webmin_logfile $pragma_no_cache)); +push(@EXPORT, qw($config_directory $var_directory $remote_error_handler %month_to_number_map %number_to_month_map $webmin_feedback_address $default_lang $default_charset $module_index_name $module_index_link %in $in @in $progress_callback_prefix $progress_callback_url $wait_for_debug $wait_for_input @matches $theme_no_table $webmin_logfile $pragma_no_cache $gwebprefix)); # Functions defined in themes push(@EXPORT, qw(&theme_post_save_domain &theme_post_save_domains &theme_post_save_server &theme_select_server &theme_select_domain &theme_post_save_folder &theme_post_change_modules &theme_address_button &theme_virtualmin_ui_rating_selector &theme_virtualmin_ui_show_cron_time &theme_virtualmin_ui_parse_cron_time &theme_virtualmin_ui_html_editor_bodytags &theme_virtualmin_ui_show_html_editor &theme_post_change_theme &theme_pre_change_theme)); diff --git a/chooser.cgi b/chooser.cgi index a0ffdcd09..37e593bfc 100755 --- a/chooser.cgi +++ b/chooser.cgi @@ -123,10 +123,10 @@ if ($in{'frame'} == 0) { } print "\n"; print "\n"; print "\n"; print "\n"; } @@ -199,7 +199,7 @@ EOF $link = ""; } local @cols; - push(@cols, "$link"); + push(@cols, "$link"); push(@cols, "$link".&html_escape($f).""); push(@cols, &nice_size($st[7])); @tm = localtime($st[9]); @@ -212,7 +212,7 @@ EOF closedir(DIR); print &ui_columns_end(); if ( $cnt >= 10 ) { - print ""; + print ""; print ""; } &popup_footer(); diff --git a/group_chooser.cgi b/group_chooser.cgi index 17573499c..fcd6c2248 100755 --- a/group_chooser.cgi +++ b/group_chooser.cgi @@ -51,10 +51,10 @@ if ($in{'multi'}) { print "\n"; print "$text{'groups_title1'}\n"; print "\n"; - print "\n"; + print "\n"; print "\n"; - print " \n"; - print " \n"; + print " \n"; + print " \n"; print "\n"; print "\n"; } @@ -86,7 +86,7 @@ if ($in{'multi'}) { } print "\n"; if ( $cnt >= 10 ) { - print ""; + print ""; print ""; } &popup_footer(); @@ -178,7 +178,7 @@ else { } print "\n"; if ( $cnt >= 10 ) { - print ""; + print ""; print ""; } &popup_footer(); diff --git a/index.cgi b/index.cgi index 2ad4d70b3..b47a5c4cc 100755 --- a/index.cgi +++ b/index.cgi @@ -76,10 +76,10 @@ elsif ($gconfig{"notabs_${base_remote_user}"} == 2 || if ($pos % $cols == 0) { print "\n"; } print "\n"; local $idx = $m->{'index_link'}; - print "\n"; + print "{'dir'}/$idx>$m->{'desc'}\n"; if ($pos % $cols == $cols - 1) { print "\n"; } $pos++; } @@ -122,7 +122,7 @@ else { print "\n"; print "\n"; + "$t \n"; print "\n"; } @@ -142,10 +142,10 @@ else { if ($pos % $cols == 0) { print "\n"; } local $idx = $m->{'index_link'}; print "
{'dir'}/$idx>", + print "
{'dir'}/$idx>", "{'dir'}/images/icon.gif border=0 ", "width=48 height=48>
\n"; - print "
{'dir'}/$idx>$m->{'desc'}
", $usercol ? "
" : "\"\"","
 ", - "$t ", $usercol ? "
" : "\"\"","
\n"; - print "\n"; + print "{'dir'}/$idx>$m->{'desc'}\n"; if ($pos++ % $cols == $cols - 1) { print "\n"; } } while($pos++ % $cols) { diff --git a/module_chooser.cgi b/module_chooser.cgi index a932cdc15..667a9ace2 100755 --- a/module_chooser.cgi +++ b/module_chooser.cgi @@ -28,10 +28,10 @@ if ($in{'multi'}) { print "\n"; print "$text{'modules_title1'}\n"; print "\n"; - print "\n"; + print "\n"; print "\n"; - print " \n"; - print " \n"; + print " \n"; + print " \n"; print "\n"; print "\n"; } diff --git a/postfix/postfix-lib.pl b/postfix/postfix-lib.pl index fc4a2de7d..e1fb0d692 100755 --- a/postfix/postfix-lib.pl +++ b/postfix/postfix-lib.pl @@ -956,7 +956,7 @@ sub generate_map_edit elsif ($config{'max_maps'} && @{$mappings} > $config{'max_maps'} && !$in{'search'}) { # If there are too many, show a search form - print &ui_form_start($gconfig{'webprefix'}.$ENV{'SCRIPT_NAME'}); + print &ui_form_start($gwebprefix.$ENV{'SCRIPT_NAME'}); foreach my $i (keys %in) { next if ($i eq 'search'); print &ui_hidden($i, $in{$i}); diff --git a/status/status-lib.pl b/status/status-lib.pl index e828cee06..0a6da10cc 100755 --- a/status/status-lib.pl +++ b/status/status-lib.pl @@ -637,7 +637,7 @@ if ($first && $first->{'time'} < $cutoff-(24*60*60)) { sub get_status_icon { my ($up) = @_; -return $gconfig{'webprefix'}. +return $gwebprefix. "/".$module_name."/images/".($up == 1 ? "up.gif" : $up == -1 ? "not.gif" : $up == -2 ? "webmin.gif" : diff --git a/status/system_info.pl b/status/system_info.pl index 8d9be8806..b98d01d0f 100644 --- a/status/system_info.pl +++ b/status/system_info.pl @@ -39,7 +39,7 @@ foreach my $s (@serv) { $down += scalar(grep { $_ == 0 } @ups); my $desc = &html_escape($s->{'desc'}); if ($can) { - $desc = &ui_link("/$module_name/edit_mon.cgi?id=". + $desc = &ui_link("$gwebprefix/$module_name/edit_mon.cgi?id=". &urlize($s->{'id'}), $desc); } $table .= &ui_columns_row([ diff --git a/ui-lib.pl b/ui-lib.pl index d4351c48e..d44b59c4b 100755 --- a/ui-lib.pl +++ b/ui-lib.pl @@ -1762,7 +1762,7 @@ sub ui_hidden_javascript return &theme_ui_hidden_javascript(@_) if (defined(&theme_ui_hidden_javascript)); my $rv; -my $imgdir = "$gconfig{'webprefix'}/images"; +my $imgdir = "$gwebprefix/images"; my ($jscb, $jstb) = ($cb, $tb); $jscb =~ s/'/\\'/g; $jstb =~ s/'/\\'/g; @@ -1859,7 +1859,7 @@ my $divid = "hiddendiv_$name"; my $openerid = "hiddenopener_$name"; my $defimg = $status ? "open.gif" : "closed.gif"; my $defclass = $status ? 'opener_shown' : 'opener_hidden'; -$rv .= "*\n"; +$rv .= "*\n"; $rv .= "$title
\n"; $rv .= "
\n"; return $rv; @@ -1898,7 +1898,7 @@ my $openerid = "hiddenopener_$name"; my $defimg = $status ? "open.gif" : "closed.gif"; my $defclass = $status ? 'opener_shown' : 'opener_hidden'; if ($title) { - $rrv .= "\n"; + $rrv .= "\n"; $rrv .= "$title
\n"; $rv .= &ui_table_row(undef, $rrv, $main::ui_table_cols); } @@ -1964,7 +1964,7 @@ my $colspan = 1; if (defined($heading) || defined($rightheading)) { $rv .= "
"; + $rv .= "$heading"; } if (defined($rightheading)) { $rv .= ""; @@ -2040,7 +2040,7 @@ $rv .= "document.${name}_tabtitles = $tabtitles;\n"; $rv .= "\n"; # Output the tabs -my $imgdir = "$gconfig{'webprefix'}/images"; +my $imgdir = "$gwebprefix/images"; $rv .= &ui_hidden($name, $sel)."\n"; $rv .= "
{'dir'}/$idx>", + print "
{'dir'}/$idx>", "{'dir'}/images/icon.gif alt=\"\" border=0>", "
\n"; - print "
{'dir'}/$idx>$m->{'desc'}
"; if (defined($heading)) { - $rv .= " $heading $rightheading
\n"; $rv .= "\n"; $rv .= "\n"; @@ -2370,7 +2370,7 @@ sub ui_up_down_arrows return &theme_ui_up_down_arrows(@_) if (defined(&theme_ui_up_down_arrows)); my ($uplink, $downlink, $upshow, $downshow, $upicon, $downicon) = @_; my $mover; -my $imgdir = "$gconfig{'webprefix'}/images"; +my $imgdir = "$gwebprefix/images"; $upicon ||= "$imgdir/moveup.gif"; $downicon ||= "$imgdir/movedown.gif"; if ($downshow) { @@ -2416,11 +2416,11 @@ my ($direction, $url, $disabled) = @_; my $alt = $direction eq "left" ? '<-' : '->'; if ($disabled) { return "\"$alt\"\n"; + . "src=\"$gwebprefix/images/$direction-grey.gif\">\n"; } else { return "\"$alt\"\n"; + . "src=\"$gwebprefix/images/$direction.gif\">\n"; } } @@ -2593,11 +2593,11 @@ $rv .= &ui_form_start($cgi) if ($cgi); if (@_ > 5) { if ($farleft) { $rv .= "". - "\n"; } else { - $rv .= "\n"; } } @@ -2605,11 +2605,11 @@ if (@_ > 5) { # Left link if ($left) { $rv .= "". - "\n"; } else { - $rv .= "\n"; } @@ -2620,11 +2620,11 @@ $rv .= " ".$inputs if ($inputs); # Right link if ($right) { $rv .= "". - "\n"; } else { - $rv .= "\n"; } @@ -2632,11 +2632,11 @@ else { if (@_ > 5) { if ($farright) { $rv .= "". - "\n"; } else { - $rv .= "\n"; } } @@ -2679,7 +2679,7 @@ if (defined(&theme_js_redirect)) { $window ||= "window"; if ($url =~ /^\//) { # If the URL is like /foo , add webprefix - $url = $gconfig{'webprefix'}.$url; + $url = $gwebprefix.$url; } return "\n"; } diff --git a/user_chooser.cgi b/user_chooser.cgi index 0a20eeef5..f38b1b4af 100755 --- a/user_chooser.cgi +++ b/user_chooser.cgi @@ -42,10 +42,10 @@ if ($in{'multi'}) { print "\n"; print "$text{'users_title1'}\n"; print "\n"; - print "\n"; + print "\n"; print "\n"; - print " \n"; - print " \n"; + print " \n"; + print " \n"; print "\n"; print "\n"; } @@ -78,7 +78,7 @@ if ($in{'multi'}) { } print "
"; @@ -2112,7 +2112,7 @@ sub ui_tabs_end return &theme_ui_tabs_end(@_) if (defined(&theme_ui_tabs_end)); my ($border) = @_; my $rv; -my $imgdir = "$gconfig{'webprefix'}/images"; +my $imgdir = "$gwebprefix/images"; if ($border) { $rv .= "
\n"; if ( $cnt >= 10 ) { - print ""; + print ""; print ""; } &popup_footer(); @@ -169,7 +169,7 @@ else { } print "
\n"; if ( $cnt >= 10 ) { - print ""; + print ""; print ""; } &popup_footer(); diff --git a/web-lib-funcs.pl b/web-lib-funcs.pl index 8ec45e9ea..bbd7b23c6 100755 --- a/web-lib-funcs.pl +++ b/web-lib-funcs.pl @@ -922,7 +922,7 @@ sub read_parse_mime_javascript { my ($id, $fields) = @_; return "" if ($gconfig{'no_upload_tracker'}); -my $opener = "window.open(\"$gconfig{'webprefix'}/uptracker.cgi?id=$id&uid=$<\", \"uptracker\", \"toolbar=no,menubar=no,scrollbars=no,width=500,height=128\");"; +my $opener = "window.open(\"$gwebprefix/uptracker.cgi?id=$id&uid=$<\", \"uptracker\", \"toolbar=no,menubar=no,scrollbars=no,width=500,height=128\");"; if ($fields) { my $if = join(" || ", map { "typeof($_) != \"undefined\" && $_.value != \"\"" } @$fields); return "onSubmit='if ($if) { $opener }'"; @@ -2019,7 +2019,7 @@ my ($w, $h) = (400, 300); if ($gconfig{'db_sizefile'}) { ($w, $h) = split(/x/, $gconfig{'db_sizefile'}); } -return "\n"; +return "\n"; } =head2 popup_window_button(url, width, height, scrollbars?, &field-mappings) @@ -3656,7 +3656,7 @@ if (defined(&theme_hlink)) { my $mod = $_[2] ? $_[2] : &get_module_name(); my $width = $_[3] || $tconfig{'help_width'} || $gconfig{'help_width'} || 600; my $height = $_[4] || $tconfig{'help_height'} || $gconfig{'help_height'} || 400; -return "$_[0]"; +return "$_[0]"; } =head2 user_chooser_button(field, multiple, [form]) @@ -3685,7 +3685,7 @@ if ($_[1] && $gconfig{'db_sizeusers'}) { elsif (!$_[1] && $gconfig{'db_sizeuser'}) { ($w, $h) = split(/x/, $gconfig{'db_sizeuser'}); } -return "\n"; +return "\n"; } =head2 group_chooser_button(field, multiple, [form]) @@ -3714,7 +3714,7 @@ if ($_[1] && $gconfig{'db_sizeusers'}) { elsif (!$_[1] && $gconfig{'db_sizeuser'}) { ($w, $h) = split(/x/, $gconfig{'db_sizeuser'}); } -return "\n"; +return "\n"; } =head2 foreign_check(module, [api-only]) @@ -4779,6 +4779,7 @@ $config_file = "$config_directory/config"; %gconfig = ( ); &read_file_cached($config_file, \%gconfig); $gconfig{'webprefix'} = '' if (!exists($gconfig{'webprefix'})); +$gwebprefix = &get_webprefix(); $null_file = $gconfig{'os_type'} eq 'windows' ? "NUL" : "/dev/null"; $path_separator = $gconfig{'os_type'} eq 'windows' ? ';' : ':'; @@ -7749,7 +7750,7 @@ my ($w, $h) = (250, 225); if ($gconfig{'db_sizedate'}) { ($w, $h) = split(/x/, $gconfig{'db_sizedate'}); } -return "\n"; +return "\n"; } =head2 help_file(module, file) @@ -7862,7 +7863,7 @@ sub help_search_link { if (&foreign_available("man") && !$tconfig{'nosearch'}) { my $for = &urlize(shift(@_)); - return "". $text{'helpsearch'}."\n"; @@ -10120,7 +10121,7 @@ if ($_[1] && $gconfig{'db_sizemodules'}) { elsif (!$_[1] && $gconfig{'db_sizemodule'}) { ($w, $h) = split(/x/, $gconfig{'db_sizemodule'}); } -return "\n"; +return "\n"; } =head2 substitute_template(text, &hash)