X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FUser.pm;h=0fb72d9fa4abb0dadfc6b75ffde49756926d429d;hb=bd23cc3e64900f14317c147aa52a8b1a7633e2a4;hp=d7d138588dfe6351b213a4c02f64713c0810d512;hpb=faef45c2e723c9fbc80d1d84b8481367204719b7;p=kivitendo-erp.git diff --git a/SL/User.pm b/SL/User.pm index d7d138588..0fb72d9fa 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -36,10 +36,10 @@ package User; use IO::File; use Fcntl qw(:seek); -use Text::Iconv; use SL::DBUpgrade2; use SL::DBUtils; +use SL::Iconv; sub new { $main::lxdebug->enter_sub(); @@ -48,6 +48,10 @@ sub new { my $self = {}; if ($login ne "") { + local *MEMBER; + + $login =~ s|.*/||; + &error("", "$memfile locked!") if (-f "${memfile}.LCK"); open(MEMBER, "$memfile") or &error("", "$memfile : $!"); @@ -55,8 +59,8 @@ sub new { while () { if (/^\[$login\]/) { while () { - last if /^\[/; - next if /^(#|\s)/; + last if m/^\[/; + next if m/^(#|\s)/; # remove comments s/\s#.*//g; @@ -88,6 +92,8 @@ sub new { sub country_codes { $main::lxdebug->enter_sub(); + local *DIR; + my %cc = (); my @language = (); @@ -116,6 +122,8 @@ sub login { my ($self, $form, $userspath) = @_; + local *FH; + my $rc = -3; if ($self->{login}) { @@ -134,7 +142,7 @@ sub login { } unless (-e "$userspath/$self->{login}.conf") { - $self->create_config("$userspath/$self->{login}.conf"); + $self->create_config(); } do "$userspath/$self->{login}.conf"; @@ -207,6 +215,8 @@ sub login { $self->dbupdate($form); $self->dbupdate2($form, $controls); + close(FH); + # remove lock file unlink("$userspath/nologin"); @@ -460,7 +470,7 @@ sub process_perl_script { $db_charset ||= Common::DEFAULT_CHARSET; - my $iconv = Text::Iconv->new($file_charset, $db_charset); + my $iconv = SL::Iconv::get_converter($file_charset, $db_charset); $dbh->begin_work(); @@ -524,12 +534,10 @@ sub process_query { $db_charset ||= Common::DEFAULT_CHARSET; - my $iconv = Text::Iconv->new($file_charset, $db_charset); - $dbh->begin_work(); while (<$fh>) { - $_ = $iconv->convert($_); + $_ = SL::Iconv::convert($file_charset, $db_charset, $_); # Remove DOS and Unix style line endings. chomp; @@ -618,6 +626,8 @@ sub dbsources_unused { my ($self, $form, $memfile) = @_; + local *FH; + my @dbexcl = (); my @dbsources = (); @@ -781,6 +791,8 @@ sub cmp_script_version { sub update_available { my ($dbdriver, $cur_version) = @_; + local *SQLDIR; + opendir(SQLDIR, "sql/${dbdriver}-upgrade") or &error("", "sql/${dbdriver}-upgrade: $!"); my @upgradescripts = @@ -816,6 +828,8 @@ sub dbupdate { my ($self, $form) = @_; + local *SQLDIR; + $form->{sid} = $form->{dbdefault}; my @upgradescripts = (); @@ -912,8 +926,6 @@ sub dbupdate2 { my $db_charset = $main::dbcharset; $db_charset ||= Common::DEFAULT_CHARSET; - my %converters; - foreach my $db (split / /, $form->{dbupdate}) { next unless $form->{$db}; @@ -949,10 +961,7 @@ sub dbupdate2 { foreach my $control (@upgradescripts) { next if ($control->{"applied"}); - if (!$converters{$control->{charset}}) { - $converters{$control->{charset}} = Text::Iconv->new($control->{charset}, $db_charset); - } - $control->{description} = $converters{$control->{charset}}->convert($control->{description}); + $control->{description} = SL::Iconv::convert($control->{charset}, $db_charset, $control->{description}); $control->{"file"} =~ /\.(sql|pl)$/; my $file_type = $1; @@ -1015,11 +1024,15 @@ sub update2_available { sub create_config { $main::lxdebug->enter_sub(); - my ($self, $filename) = @_; + my ($self) = @_; + + local *CONF; - @config = &config_vars; + @config = config_vars(); - open(CONF, ">$filename") or $self->error("$filename : $!"); + my $userspath = $main::userspath; + + open(CONF, ">", "$userspath/$self->{login}.conf") || $self->error("$userspath/$self->{login}.conf : $!"); # create the config file print CONF qq|# configuration file for $self->{login} @@ -1027,7 +1040,7 @@ sub create_config { \%myconfig = ( |; - foreach $key (sort @config) { + foreach my $key (sort @config) { $self->{$key} =~ s/\'/\\\'/g; print CONF qq| $key => '$self->{$key}',\n|; } @@ -1044,6 +1057,8 @@ sub save_member { my ($self, $memberfile, $userspath) = @_; + local (*FH, *CONF); + my $newmember = 1; # format dbconnect and dboptions string @@ -1117,8 +1132,7 @@ sub save_member { unlink "${memberfile}.LCK"; # create conf file - $self->create_config("$userspath/$self->{login}.conf") - unless $self->{'root login'}; + $self->create_config() unless $self->{'root login'}; $main::lxdebug->leave_sub(); } @@ -1144,6 +1158,8 @@ sub error { my ($self, $msg) = @_; + $main::lxdebug->show_backtrace(); + if ($ENV{HTTP_USER_AGENT}) { print qq|Content-Type: text/html