diff --git a/fsdump/fsdump-lib.pl b/fsdump/fsdump-lib.pl index 1f7d8c206..09956f5dc 100644 --- a/fsdump/fsdump-lib.pl +++ b/fsdump/fsdump-lib.pl @@ -107,7 +107,10 @@ if ($config{'date_subs'}) { eval "use POSIX"; eval "use posix" if ($@); local @tm = localtime(time()); - return strftime($_[0], @tm); + &clear_time_locale(); + local $rv = strftime($_[0], @tm); + &reset_time_locale(); + return $rv; } else { return $_[0]; diff --git a/mysql/mysql-lib.pl b/mysql/mysql-lib.pl index 72ace8913..36f2773a4 100644 --- a/mysql/mysql-lib.pl +++ b/mysql/mysql-lib.pl @@ -727,7 +727,10 @@ if ($config{'date_subs'}) { eval "use POSIX"; eval "use posix" if ($@); local @tm = localtime(time()); - return strftime($_[0], @tm); + &clear_time_locale(); + local $rv = strftime($_[0], @tm); + &reset_time_locale(); + return $rv; } else { return $_[0]; diff --git a/postgresql/postgresql-lib.pl b/postgresql/postgresql-lib.pl index c83571759..43ee3a2c1 100644 --- a/postgresql/postgresql-lib.pl +++ b/postgresql/postgresql-lib.pl @@ -707,7 +707,10 @@ if ($config{'date_subs'}) { eval "use POSIX"; eval "use posix" if ($@); local @tm = localtime(time()); - return strftime($_[0], @tm); + &clear_time_locale(); + local $rv = strftime($_[0], @tm); + &reset_time_locale(); + return $rv; } else { return $_[0]; diff --git a/web-lib-funcs.pl b/web-lib-funcs.pl index 95b248670..35642d582 100755 --- a/web-lib-funcs.pl +++ b/web-lib-funcs.pl @@ -8400,16 +8400,16 @@ return &get_module_variable('$module_name'); sub get_module_variable { my ($v, $wantref) = @_; +my $slash = $wantref ? "\\" : ""; if (__PACKAGE__ eq 'WebminCore') { my ($vt, $vn) = split('', $v, 2); my $callpkg; for(my $i=0; ($callpkg) = caller($i); $i++) { last if ($callpkg ne __PACKAGE__); } - my $slash = $wantref ? "\\" : ""; return eval "${slash}${vt}${callpkg}::${vn}"; } -return eval "$v"; +return eval "${slash}${v}"; } # set_module_variable(name, value) @@ -8420,6 +8420,32 @@ my ($v, $value) = @_; # XXX } +# clear_time_locale() +# Temporarily force the locale to C, until reset_time_locale is called +sub clear_time_locale +{ +if ($main::clear_time_locale_count == 0) { + eval { + $main::clear_time_locale_old = POSIX::setlocale(POSIX::LC_TIME); + POSIX::setlocale(POSIX::LC_TIME, "C"); + }; + } +$main::clear_time_locale_count++; +} + +# reset_time_locale() +# Revert the locale to whatever it was before clear_time_locale was called +sub reset_time_locale +{ +if ($main::clear_time_locale_count == 1) { + eval { + POSIX::setlocale(POSIX::LC_TIME, $main::clear_time_locale_old); + $main::clear_time_locale_old = undef; + }; + } +$main::clear_time_locale_count--; +} + $done_web_lib_funcs = 1; 1;