Revision 22c02125
Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt
SL/Auth.pm | ||
---|---|---|
13 | 13 |
use SL::Auth::LDAP; |
14 | 14 |
|
15 | 15 |
use SL::User; |
16 |
use SL::DBConnect; |
|
16 | 17 |
use SL::DBUpgrade2; |
17 | 18 |
use SL::DBUtils; |
18 | 19 |
|
... | ... | |
38 | 39 |
sub get_user_dbh { |
39 | 40 |
my ($self, $login) = @_; |
40 | 41 |
my %user = $self->read_user($login); |
41 |
my $dbh = DBI->connect(
|
|
42 |
my $dbh = SL::DBConnect->connect(
|
|
42 | 43 |
$user{dbconnect}, |
43 | 44 |
$user{dbuser}, |
44 | 45 |
$user{dbpasswd}, |
... | ... | |
166 | 167 |
|
167 | 168 |
$main::lxdebug->message(LXDebug->DEBUG1, "Auth::dbconnect DSN: $dsn"); |
168 | 169 |
|
169 |
$self->{dbh} = DBI->connect($dsn, $cfg->{user}, $cfg->{password}, { pg_enable_utf8 => $::locale->is_utf8, AutoCommit => 1 });
|
|
170 |
$self->{dbh} = SL::DBConnect->connect($dsn, $cfg->{user}, $cfg->{password}, { pg_enable_utf8 => $::locale->is_utf8, AutoCommit => 1 });
|
|
170 | 171 |
|
171 | 172 |
if (!$may_fail && !$self->{dbh}) { |
172 | 173 |
$main::form->error($main::locale->text('The connection to the authentication database failed:') . "\n" . $DBI::errstr); |
... | ... | |
246 | 247 |
my $encoding = $Common::charset_to_db_encoding{$charset}; |
247 | 248 |
$encoding ||= 'UNICODE'; |
248 | 249 |
|
249 |
my $dbh = DBI->connect($dsn, $params{superuser}, $params{superuser_password}, { pg_enable_utf8 => $charset =~ m/^utf-?8$/i });
|
|
250 |
my $dbh = SL::DBConnect->connect($dsn, $params{superuser}, $params{superuser_password}, { pg_enable_utf8 => $charset =~ m/^utf-?8$/i });
|
|
250 | 251 |
|
251 | 252 |
if (!$dbh) { |
252 | 253 |
$main::form->error($main::locale->text('The connection to the template database failed:') . "\n" . $DBI::errstr); |
SL/DB.pm | ||
---|---|---|
16 | 16 |
sub dbi_connect { |
17 | 17 |
shift; |
18 | 18 |
|
19 |
return DBI->connect(@_) unless $::lx_office_conf{debug} && $::lx_office_conf{debug}->{dbix_log4perl}; |
|
20 |
|
|
21 |
require Log::Log4perl; |
|
22 |
require DBIx::Log4perl; |
|
23 |
|
|
24 |
my $filename = $LXDebug::file_name; |
|
25 |
my $config = $::lx_office_conf{debug}->{dbix_log4perl_config}; |
|
26 |
$config =~ s/LXDEBUGFILE/${filename}/g; |
|
27 |
|
|
28 |
Log::Log4perl->init(\$config); |
|
29 |
return DBIx::Log4perl->connect(@_); |
|
19 |
return SL::DBConnect->connect(@_); |
|
30 | 20 |
} |
31 | 21 |
|
32 | 22 |
sub create { |
SL/DBConnect.pm | ||
---|---|---|
1 |
package SL::DBConnect; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use DBI; |
|
6 |
|
|
7 |
sub connect { |
|
8 |
shift; |
|
9 |
|
|
10 |
return DBI->connect(@_) unless $::lx_office_conf{debug} && $::lx_office_conf{debug}->{dbix_log4perl}; |
|
11 |
|
|
12 |
require Log::Log4perl; |
|
13 |
require DBIx::Log4perl; |
|
14 |
|
|
15 |
my $filename = $LXDebug::file_name; |
|
16 |
my $config = $::lx_office_conf{debug}->{dbix_log4perl_config}; |
|
17 |
$config =~ s/LXDEBUGFILE/${filename}/g; |
|
18 |
|
|
19 |
Log::Log4perl->init(\$config); |
|
20 |
return DBIx::Log4perl->connect(@_); |
|
21 |
} |
|
22 |
|
|
23 |
1; |
SL/Form.pm | ||
---|---|---|
52 | 52 |
use SL::Common; |
53 | 53 |
use SL::CVar; |
54 | 54 |
use SL::DB; |
55 |
use SL::DBConnect; |
|
55 | 56 |
use SL::DBUtils; |
56 | 57 |
use SL::DO; |
57 | 58 |
use SL::IC; |
... | ... | |
1582 | 1583 |
my ($self, $myconfig) = @_; |
1583 | 1584 |
|
1584 | 1585 |
# connect to database |
1585 |
my $dbh = DBI->connect($myconfig->{dbconnect}, $myconfig->{dbuser}, $myconfig->{dbpasswd}, $self->_dbconnect_options)
|
|
1586 |
my $dbh = SL::DBConnect->connect($myconfig->{dbconnect}, $myconfig->{dbuser}, $myconfig->{dbpasswd}, $self->_dbconnect_options)
|
|
1586 | 1587 |
or $self->dberror; |
1587 | 1588 |
|
1588 | 1589 |
# set db options |
... | ... | |
1601 | 1602 |
my ($self, $myconfig) = @_; |
1602 | 1603 |
|
1603 | 1604 |
# connect to database |
1604 |
my $dbh = DBI->connect($myconfig->{dbconnect}, $myconfig->{dbuser}, $myconfig->{dbpasswd}, $self->_dbconnect_options(AutoCommit => 0))
|
|
1605 |
my $dbh = SL::DBConnect->connect($myconfig->{dbconnect}, $myconfig->{dbuser}, $myconfig->{dbpasswd}, $self->_dbconnect_options(AutoCommit => 0))
|
|
1605 | 1606 |
or $self->dberror; |
1606 | 1607 |
|
1607 | 1608 |
# set db options |
SL/User.pm | ||
---|---|---|
38 | 38 |
use Fcntl qw(:seek); |
39 | 39 |
|
40 | 40 |
#use SL::Auth; |
41 |
use SL::DBConnect; |
|
41 | 42 |
use SL::DBUpgrade2; |
42 | 43 |
use SL::DBUtils; |
43 | 44 |
use SL::Iconv; |
... | ... | |
104 | 105 |
my %myconfig = $main::auth->read_user($self->{login}); |
105 | 106 |
|
106 | 107 |
# check if database is down |
107 |
my $dbh = |
|
108 |
DBI->connect($myconfig{dbconnect}, $myconfig{dbuser}, |
|
109 |
$myconfig{dbpasswd}) |
|
108 |
my $dbh = SL::DBConnect->connect($myconfig{dbconnect}, $myconfig{dbuser}, $myconfig{dbpasswd}) |
|
110 | 109 |
or $self->error($DBI::errstr); |
111 | 110 |
|
112 | 111 |
# we got a connection, check the version |
... | ... | |
252 | 251 |
$form->{sid} = $form->{dbdefault}; |
253 | 252 |
&dbconnect_vars($form, $form->{dbdefault}); |
254 | 253 |
|
255 |
my $dbh = |
|
256 |
DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) |
|
254 |
my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) |
|
257 | 255 |
or $form->dberror; |
258 | 256 |
|
259 | 257 |
if ($form->{dbdriver} eq 'Pg') { |
... | ... | |
270 | 268 |
next if ($db =~ /^template/); |
271 | 269 |
|
272 | 270 |
&dbconnect_vars($form, $db); |
273 |
my $dbh = |
|
274 |
DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) |
|
271 |
my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) |
|
275 | 272 |
or $form->dberror; |
276 | 273 |
|
277 | 274 |
$query = |
... | ... | |
326 | 323 |
|
327 | 324 |
dbconnect_vars($form, $form->{dbdefault}); |
328 | 325 |
|
329 |
my $dbh = DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) || $form->dberror();
|
|
326 |
my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) || $form->dberror();
|
|
330 | 327 |
my $query = qq|SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE datname = 'template0'|; |
331 | 328 |
my ($cluster_encoding) = $dbh->selectrow_array($query); |
332 | 329 |
$dbh->disconnect(); |
... | ... | |
344 | 341 |
$form->{sid} = $form->{dbdefault}; |
345 | 342 |
&dbconnect_vars($form, $form->{dbdefault}); |
346 | 343 |
my $dbh = |
347 |
DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
|
|
344 |
SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
|
|
348 | 345 |
or $form->dberror; |
349 | 346 |
$form->{db} =~ s/\"//g; |
350 | 347 |
my %dbcreate = ( |
... | ... | |
386 | 383 |
|
387 | 384 |
&dbconnect_vars($form, $form->{db}); |
388 | 385 |
|
389 |
$dbh = DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
|
|
386 |
$dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
|
|
390 | 387 |
or $form->dberror; |
391 | 388 |
|
392 | 389 |
my $db_charset = $Common::db_encoding_to_charset{$form->{encoding}}; |
... | ... | |
417 | 414 |
|
418 | 415 |
$form->{sid} = $form->{dbdefault}; |
419 | 416 |
&dbconnect_vars($form, $form->{dbdefault}); |
420 |
my $dbh = |
|
421 |
DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) |
|
417 |
my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) |
|
422 | 418 |
or $form->dberror; |
423 | 419 |
my $query = $dbdelete{$form->{dbdriver}}; |
424 | 420 |
do_query($form, $dbh, $query); |
... | ... | |
464 | 460 |
map { $form->{$_} = $member->{$_} } qw(dbname dbuser dbpasswd dbhost dbport); |
465 | 461 |
dbconnect_vars($form, $form->{dbname}); |
466 | 462 |
|
467 |
my $dbh = DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd});
|
|
463 |
my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd});
|
|
468 | 464 |
|
469 | 465 |
next unless $dbh; |
470 | 466 |
|
... | ... | |
594 | 590 |
$db =~ s/^db//; |
595 | 591 |
&dbconnect_vars($form, $db); |
596 | 592 |
|
597 |
my $dbh = |
|
598 |
DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) |
|
593 |
my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) |
|
599 | 594 |
or $form->dberror; |
600 | 595 |
|
601 | 596 |
$dbh->do($form->{dboptions}) if ($form->{dboptions}); |
... | ... | |
659 | 654 |
$db =~ s/^db//; |
660 | 655 |
&dbconnect_vars($form, $db); |
661 | 656 |
|
662 |
my $dbh = DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) or $form->dberror;
|
|
657 |
my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) or $form->dberror;
|
|
663 | 658 |
|
664 | 659 |
$dbh->do($form->{dboptions}) if ($form->{dboptions}); |
665 | 660 |
|
... | ... | |
700 | 695 |
|
701 | 696 |
$main::auth->save_user($self->{login}, map { $_, $self->{$_} } config_vars()); |
702 | 697 |
|
703 |
my $dbh = DBI->connect($self->{dbconnect}, $self->{dbuser}, $self->{dbpasswd});
|
|
698 |
my $dbh = SL::DBConnect->connect($self->{dbconnect}, $self->{dbuser}, $self->{dbpasswd});
|
|
704 | 699 |
if ($dbh) { |
705 | 700 |
$self->create_employee_entry($form, $dbh, $self, 1); |
706 | 701 |
$dbh->disconnect(); |
Auch abrufbar als: Unified diff
Alle Datenbankverbindungen über DBIx::Log4perl laufen lassen, sofern dies in der Konfiguration aktiviert ist