1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger Accounting
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
17 # This program is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation; either version 2 of the License, or
20 # (at your option) any later version.
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the Free Software
28 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #=====================================================================
31 # user related functions
33 #=====================================================================
40 $main::lxdebug->enter_sub();
42 my ($type, $memfile, $login) = @_;
46 &error("", "$memfile locked!") if (-f "${memfile}.LCK");
48 open(MEMBER, "$memfile") or &error("", "$memfile : $!");
59 # remove any trailing whitespace
62 ($key, $value) = split(/=/, $_, 2);
64 if (($key eq "stylesheet") && ($value eq "sql-ledger.css")) {
65 $value = "lx-office-erp.css";
68 $self->{$key} = $value;
71 $self->{login} = $login;
79 $main::lxdebug->leave_sub();
84 $main::lxdebug->enter_sub();
89 # scan the locale directory and read in the LANGUAGE files
90 opendir DIR, "locale";
92 my @dir = grep !/(^\.\.?$|\..*)/, readdir DIR;
94 foreach my $dir (@dir) {
95 next unless open(FH, "locale/$dir/LANGUAGE");
99 $cc{$dir} = "@language";
104 $main::lxdebug->leave_sub();
110 $main::lxdebug->enter_sub();
112 my ($self, $form, $userspath) = @_;
116 if ($self->{login}) {
118 if ($self->{password}) {
119 if ($form->{hashed_password}) {
120 $form->{password} = $form->{hashed_password};
122 $form->{password} = crypt($form->{password},
123 substr($self->{login}, 0, 2));
125 if ($self->{password} ne $form->{password}) {
126 $main::lxdebug->leave_sub();
131 unless (-e "$userspath/$self->{login}.conf") {
132 $self->create_config("$userspath/$self->{login}.conf");
135 do "$userspath/$self->{login}.conf";
136 $myconfig{dbpasswd} = unpack 'u', $myconfig{dbpasswd};
138 # check if database is down
140 DBI->connect($myconfig{dbconnect}, $myconfig{dbuser},
142 or $self->error(DBI::errstr);
144 # we got a connection, check the version
145 my $query = qq|SELECT version FROM defaults|;
146 my $sth = $dbh->prepare($query);
147 $sth->execute || $form->dberror($query);
149 my ($dbversion) = $sth->fetchrow_array;
152 # add login to employee table if it does not exist
153 # no error check for employee table, ignore if it does not exist
154 $query = qq|SELECT e.id FROM employee e WHERE e.login = '$self->{login}'|;
155 $sth = $dbh->prepare($query);
158 my ($login) = $sth->fetchrow_array;
162 $query = qq|INSERT INTO employee (login, name, workphone, role)
163 VALUES ('$self->{login}', '$myconfig{name}',
164 '$myconfig{tel}', 'user')|;
168 $self->create_schema_info_table($form, $dbh);
175 parse_dbupdate_controls($form, $myconfig{"dbdriver"});
177 map({ $form->{$_} = $myconfig{$_} }
178 qw(dbname dbhost dbport dbdriver dbuser dbpasswd dbconnect));
180 if (update_available($myconfig{"dbdriver"}, $dbversion) ||
181 update2_available($form, $controls)) {
183 $form->{"stylesheet"} = "lx-office-erp.css";
184 $form->{"title"} = $main::locale->text("Dataset upgrade");
186 print($form->parse_html_template("dbupgrade/header"));
188 $form->{dbupdate} = "db$myconfig{dbname}";
189 $form->{ $form->{dbupdate} } = 1;
191 if ($form->{"show_dbupdate_warning"}) {
192 print($form->parse_html_template("dbupgrade/warning"));
197 open(FH, ">$userspath/nologin") or die("$!");
199 # required for Oracle
200 $form->{dbdefault} = $sid;
202 # ignore HUP, QUIT in case the webserver times out
203 $SIG{HUP} = 'IGNORE';
204 $SIG{QUIT} = 'IGNORE';
206 $self->dbupdate($form);
207 $self->dbupdate2($form, $controls);
210 unlink("$userspath/nologin");
212 print($form->parse_html_template("dbupgrade/footer"));
219 $main::lxdebug->leave_sub();
225 $main::lxdebug->enter_sub();
227 my ($form, $db) = @_;
230 'Pg' => { 'yy-mm-dd' => 'set DateStyle to \'ISO\'',
231 'yyyy-mm-dd' => 'set DateStyle to \'ISO\'',
232 'mm/dd/yy' => 'set DateStyle to \'SQL, US\'',
233 'mm-dd-yy' => 'set DateStyle to \'POSTGRES, US\'',
234 'dd/mm/yy' => 'set DateStyle to \'SQL, EUROPEAN\'',
235 'dd-mm-yy' => 'set DateStyle to \'POSTGRES, EUROPEAN\'',
236 'dd.mm.yy' => 'set DateStyle to \'GERMAN\''
239 'yy-mm-dd' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'YY-MM-DD\'',
240 'yyyy-mm-dd' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'YYYY-MM-DD\'',
241 'mm/dd/yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'MM/DD/YY\'',
242 'mm-dd-yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'MM-DD-YY\'',
243 'dd/mm/yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'DD/MM/YY\'',
244 'dd-mm-yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'DD-MM-YY\'',
245 'dd.mm.yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'DD.MM.YY\'',
248 $form->{dboptions} = $dboptions{ $form->{dbdriver} }{ $form->{dateformat} };
250 if ($form->{dbdriver} eq 'Pg') {
251 $form->{dbconnect} = "dbi:Pg:dbname=$db";
254 if ($form->{dbdriver} eq 'Oracle') {
255 $form->{dbconnect} = "dbi:Oracle:sid=$form->{sid}";
258 if ($form->{dbhost}) {
259 $form->{dbconnect} .= ";host=$form->{dbhost}";
261 if ($form->{dbport}) {
262 $form->{dbconnect} .= ";port=$form->{dbport}";
265 $main::lxdebug->leave_sub();
269 $main::lxdebug->enter_sub();
271 my @drivers = DBI->available_drivers();
273 $main::lxdebug->leave_sub();
275 return (grep { /(Pg|Oracle)/ } @drivers);
279 $main::lxdebug->enter_sub();
281 my ($self, $form) = @_;
286 $form->{dbdefault} = $form->{dbuser} unless $form->{dbdefault};
287 $form->{sid} = $form->{dbdefault};
288 &dbconnect_vars($form, $form->{dbdefault});
291 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
294 if ($form->{dbdriver} eq 'Pg') {
296 $query = qq|SELECT datname FROM pg_database WHERE NOT ((datname = 'template0') OR (datname = 'template1'))|;
297 $sth = $dbh->prepare($query);
298 $sth->execute || $form->dberror($query);
300 while (my ($db) = $sth->fetchrow_array) {
302 if ($form->{only_acc_db}) {
304 next if ($db =~ /^template/);
306 &dbconnect_vars($form, $db);
308 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
311 $query = qq|SELECT p.tablename FROM pg_tables p
312 WHERE p.tablename = 'defaults'
313 AND p.tableowner = '$form->{dbuser}'|;
314 my $sth = $dbh->prepare($query);
315 $sth->execute || $form->dberror($query);
317 if ($sth->fetchrow_array) {
318 push @dbsources, $db;
324 push @dbsources, $db;
328 if ($form->{dbdriver} eq 'Oracle') {
329 if ($form->{only_acc_db}) {
330 $query = qq|SELECT o.owner FROM dba_objects o
331 WHERE o.object_name = 'DEFAULTS'
332 AND o.object_type = 'TABLE'|;
334 $query = qq|SELECT username FROM dba_users|;
337 $sth = $dbh->prepare($query);
338 $sth->execute || $form->dberror($query);
340 while (my ($db) = $sth->fetchrow_array) {
341 push @dbsources, $db;
348 $main::lxdebug->leave_sub();
354 $main::lxdebug->enter_sub();
356 my ($self, $form) = @_;
359 'Pg' => qq|CREATE DATABASE "$form->{db}"|,
361 qq|CREATE USER "$form->{db}" DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP IDENTIFIED BY "$form->{db}"|
364 $dbcreate{Pg} .= " WITH ENCODING = '$form->{encoding}'" if $form->{encoding};
366 $form->{sid} = $form->{dbdefault};
367 &dbconnect_vars($form, $form->{dbdefault});
369 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
371 my $query = qq|$dbcreate{$form->{dbdriver}}|;
372 $dbh->do($query) || $form->dberror($query);
374 if ($form->{dbdriver} eq 'Oracle') {
375 $query = qq|GRANT CONNECT,RESOURCE TO "$form->{db}"|;
376 $dbh->do($query) || $form->dberror($query);
380 # setup variables for the new database
381 if ($form->{dbdriver} eq 'Oracle') {
382 $form->{dbuser} = $form->{db};
383 $form->{dbpasswd} = $form->{db};
386 &dbconnect_vars($form, $form->{db});
388 $dbh = DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
392 my $filename = qq|sql/lx-office.sql|;
393 $self->process_query($form, $dbh, $filename);
396 ($filename) = split /_/, $form->{chart};
398 $self->process_query($form, $dbh, "sql/${filename}-gifi.sql");
400 # load chart of accounts
401 $filename = qq|sql/$form->{chart}-chart.sql|;
402 $self->process_query($form, $dbh, $filename);
404 $query = "UPDATE defaults SET coa = " . $dbh->quote($form->{"chart"});
405 $dbh->do($query) || $form->dberror($query);
409 $main::lxdebug->leave_sub();
412 # Process a Perl script which updates the database.
413 # If the script returns 1 then the update was successful.
414 # Return code "2" means "needs more interaction; remove
415 # users/nologin and exit".
416 # All other return codes are fatal errors.
417 sub process_perl_script {
418 $main::lxdebug->enter_sub();
420 my ($self, $form, $dbh, $filename, $version) = @_;
422 open(FH, "$filename") or $form->error("$filename : $!\n");
423 my $contents = join("", <FH>);
428 my %dbup_myconfig = ();
429 map({ $dbup_myconfig{$_} = $form->{$_}; }
430 qw(dbname dbuser dbpasswd dbhost dbport dbconnect));
432 my $nls_file = $filename;
433 $nls_file =~ s|.*/||;
434 $nls_file =~ s|.pl$||;
435 my $dbup_locale = Locale->new($main::language, $nls_file);
437 my $result = eval($contents);
444 if (!defined($result)) {
445 print($form->parse_html_template("dbupgrade/error",
446 { "file" => $filename,
449 } elsif (1 != $result) {
450 unlink("users/nologin") if (2 == $result);
455 $dbh->do("UPDATE defaults SET version = " . $dbh->quote($version));
459 $main::lxdebug->leave_sub();
463 $main::lxdebug->enter_sub();
465 my ($self, $form, $dbh, $filename, $version_or_control) = @_;
467 # return unless (-f $filename);
469 open(FH, "$filename") or $form->error("$filename : $!\n");
478 # Remove DOS and Unix style line endings.
484 for (my $i = 0; $i < length($_); $i++) {
485 my $char = substr($_, $i, 1);
487 # Are we inside a string?
489 if ($char eq $quote_chars[-1]) {
495 if (($char eq "'") || ($char eq "\"")) {
496 push(@quote_chars, $char);
498 } elsif ($char eq ";") {
500 # Query is complete. Send it.
502 $sth = $dbh->prepare($query);
503 if (!$sth->execute()) {
504 my $errstr = $dbh->errstr;
507 $form->dberror("The database update/creation did not succeed. The file ${filename} containing the following query failed:<br>${query}<br>" .
508 "The error message was: ${errstr}<br>" .
509 "All changes in that file have been reverted.");
522 if (ref($version_or_control) eq "HASH") {
523 $dbh->do("INSERT INTO schema_info (tag, login) VALUES (" .
524 $dbh->quote($version_or_control->{"tag"}) . ", " .
525 $dbh->quote($form->{"login"}) . ")");
526 } elsif ($version_or_control) {
527 $dbh->do("UPDATE defaults SET version = " .
528 $dbh->quote($version_or_control));
534 $main::lxdebug->leave_sub();
538 $main::lxdebug->enter_sub();
540 my ($self, $form) = @_;
542 my %dbdelete = ('Pg' => qq|DROP DATABASE "$form->{db}"|,
543 'Oracle' => qq|DROP USER $form->{db} CASCADE|);
545 $form->{sid} = $form->{dbdefault};
546 &dbconnect_vars($form, $form->{dbdefault});
548 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
550 my $query = qq|$dbdelete{$form->{dbdriver}}|;
551 $dbh->do($query) || $form->dberror($query);
555 $main::lxdebug->leave_sub();
558 sub dbsources_unused {
559 $main::lxdebug->enter_sub();
561 my ($self, $form, $memfile) = @_;
566 $form->error('File locked!') if (-f "${memfile}.LCK");
569 open(FH, "$memfile") or $form->error("$memfile : $!");
573 my ($null, $item) = split(/=/);
580 $form->{only_acc_db} = 1;
581 my @db = &dbsources("", $form);
583 push @dbexcl, $form->{dbdefault};
585 foreach $item (@db) {
586 unless (grep /$item$/, @dbexcl) {
587 push @dbsources, $item;
591 $main::lxdebug->leave_sub();
597 $main::lxdebug->enter_sub();
599 my ($self, $form) = @_;
604 $form->{sid} = $form->{dbdefault};
605 &dbconnect_vars($form, $form->{dbdefault});
608 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
611 if ($form->{dbdriver} eq 'Pg') {
613 $query = qq|SELECT d.datname FROM pg_database d, pg_user u
614 WHERE d.datdba = u.usesysid
615 AND u.usename = '$form->{dbuser}'|;
616 my $sth = $dbh->prepare($query);
617 $sth->execute || $form->dberror($query);
619 while (my ($db) = $sth->fetchrow_array) {
621 next if ($db =~ /^template/);
623 &dbconnect_vars($form, $db);
626 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
629 $query = qq|SELECT t.tablename FROM pg_tables t
630 WHERE t.tablename = 'defaults'|;
631 my $sth = $dbh->prepare($query);
632 $sth->execute || $form->dberror($query);
634 if ($sth->fetchrow_array) {
635 $query = qq|SELECT version FROM defaults|;
636 my $sth = $dbh->prepare($query);
639 if (my ($version) = $sth->fetchrow_array) {
640 $dbsources{$db} = $version;
650 if ($form->{dbdriver} eq 'Oracle') {
651 $query = qq|SELECT o.owner FROM dba_objects o
652 WHERE o.object_name = 'DEFAULTS'
653 AND o.object_type = 'TABLE'|;
655 $sth = $dbh->prepare($query);
656 $sth->execute || $form->dberror($query);
658 while (my ($db) = $sth->fetchrow_array) {
660 $form->{dbuser} = $db;
661 &dbconnect_vars($form, $db);
664 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
667 $query = qq|SELECT version FROM defaults|;
668 my $sth = $dbh->prepare($query);
671 if (my ($version) = $sth->fetchrow_array) {
672 $dbsources{$db} = $version;
682 $main::lxdebug->leave_sub();
689 $main::lxdebug->enter_sub(2);
691 my (@v, $version, $i);
693 @v = split(/\./, $_[0]);
694 while (scalar(@v) < 4) {
698 for ($i = 0; $i < 4; $i++) {
703 $main::lxdebug->leave_sub(2);
707 sub cmp_script_version {
708 my ($a_from, $a_to, $b_from, $b_to);
709 my ($i, $res_a, $res_b);
710 my ($my_a, $my_b) = ($a, $b);
712 $my_a =~ s/.*-upgrade-//;
714 $my_b =~ s/.*-upgrade-//;
716 ($my_a_from, $my_a_to) = split(/-/, $my_a);
717 ($my_b_from, $my_b_to) = split(/-/, $my_b);
719 $res_a = calc_version($my_a_from);
720 $res_b = calc_version($my_b_from);
722 if ($res_a == $res_b) {
723 $res_a = calc_version($my_a_to);
724 $res_b = calc_version($my_b_to);
727 return $res_a <=> $res_b;
731 sub update_available {
732 my ($dbdriver, $cur_version) = @_;
734 opendir SQLDIR, "sql/${dbdriver}-upgrade" or &error("", "sql/${dbdriver}-upgrade: $!");
736 grep(/$form->{dbdriver}-upgrade-\Q$cur_version\E.*\.(sql|pl)$/, readdir(SQLDIR));
739 return ($#upgradescripts > -1);
742 sub create_schema_info_table {
743 $main::lxdebug->enter_sub();
745 my ($self, $form, $dbh) = @_;
747 my $query = "SELECT tag FROM schema_info LIMIT 1";
748 if (!$dbh->do($query)) {
750 "CREATE TABLE schema_info (" .
753 " itime timestamp DEFAULT now(), " .
754 " PRIMARY KEY (tag))";
755 $dbh->do($query) || $form->dberror($query);
758 $main::lxdebug->leave_sub();
762 $main::lxdebug->enter_sub();
764 my ($self, $form) = @_;
766 $form->{sid} = $form->{dbdefault};
768 my @upgradescripts = ();
772 if ($form->{dbupdate}) {
774 # read update scripts into memory
775 opendir SQLDIR, "sql/" . $form->{dbdriver} . "-upgrade" or &error("", "sql/" . $form->{dbdriver} . "-upgrade : $!");
778 sort(cmp_script_version
779 grep(/$form->{dbdriver}-upgrade-.*?\.(sql|pl)$/, readdir(SQLDIR)));
784 foreach my $db (split / /, $form->{dbupdate}) {
786 next unless $form->{$db};
788 # strip db from dataset
790 &dbconnect_vars($form, $db);
793 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
797 $query = qq|SELECT version FROM defaults|;
798 my $sth = $dbh->prepare($query);
800 # no error check, let it fall through
803 my $version = $sth->fetchrow_array;
806 next unless $version;
809 $version = calc_version($version);
812 foreach my $upgradescript (@upgradescripts) {
813 my $a = $upgradescript;
814 $a =~ s/^$form->{dbdriver}-upgrade-|\.(sql|pl)$//g;
817 my ($mindb, $maxdb) = split /-/, $a;
818 my $str_maxdb = $maxdb;
820 $mindb = calc_version($mindb);
821 $maxdb = calc_version($maxdb);
824 next if ($version >= $maxdb);
826 # if there is no upgrade script exit
827 last if ($version < $mindb);
830 $main::lxdebug->message(DEBUG2, "Applying Update $upgradescript");
831 if ($file_type eq "sql") {
832 $self->process_query($form, $dbh, "sql/" . $form->{"dbdriver"} . "-upgrade/$upgradescript", $str_maxdb);
834 $self->process_perl_script($form, $dbh, "sql/" . $form->{"dbdriver"} . "-upgrade/$upgradescript", $str_maxdb);
846 $main::lxdebug->leave_sub();
852 $main::lxdebug->enter_sub();
854 my ($self, $form, $controls) = @_;
856 $form->{sid} = $form->{dbdefault};
858 my @upgradescripts = ();
859 my ($query, $sth, $tag);
862 @upgradescripts = sort_dbupdate_controls($controls);
864 foreach my $db (split / /, $form->{dbupdate}) {
866 next unless $form->{$db};
868 # strip db from dataset
870 &dbconnect_vars($form, $db);
873 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
876 map({ $_->{"applied"} = 0; } @upgradescripts);
878 $query = "SELECT tag FROM schema_info";
879 $sth = $dbh->prepare($query);
880 $sth->execute() || $form->dberror($query);
881 while (($tag) = $sth->fetchrow_array()) {
882 $controls->{$tag}->{"applied"} = 1 if (defined($controls->{$tag}));
887 foreach (@upgradescripts) {
888 if (!$_->{"applied"}) {
894 next if ($all_applied);
896 foreach my $control (@upgradescripts) {
897 next if ($control->{"applied"});
899 $control->{"file"} =~ /\.(sql|pl)$/;
903 $main::lxdebug->message(DEBUG2, "Applying Update $control->{file}");
904 print($form->parse_html_template("dbupgrade/upgrade_message2",
907 if ($file_type eq "sql") {
908 $self->process_query($form, $dbh, "sql/" . $form->{"dbdriver"} .
909 "-upgrade2/$control->{file}", $control);
911 $self->process_perl_script($form, $dbh, "sql/" . $form->{"dbdriver"} .
912 "-upgrade2/$control->{file}", $control);
921 $main::lxdebug->leave_sub();
926 sub update2_available {
927 $main::lxdebug->enter_sub();
929 my ($form, $controls) = @_;
931 map({ $_->{"applied"} = 0; } values(%{$controls}));
933 dbconnect_vars($form, $form->{"dbname"});
936 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) ||
939 my ($query, $tag, $sth);
941 $query = "SELECT tag FROM schema_info";
942 $sth = $dbh->prepare($query);
943 $sth->execute() || $form->dberror($query);
944 while (($tag) = $sth->fetchrow_array()) {
945 $controls->{$tag}->{"applied"} = 1 if (defined($controls->{$tag}));
950 map({ $main::lxdebug->leave_sub() and return 1 if (!$_->{"applied"}) }
951 values(%{$controls}));
953 $main::lxdebug->leave_sub();
958 $main::lxdebug->enter_sub();
960 my ($self, $filename) = @_;
962 @config = &config_vars;
964 open(CONF, ">$filename") or $self->error("$filename : $!");
966 # create the config file
967 print CONF qq|# configuration file for $self->{login}
972 foreach $key (sort @config) {
973 $self->{$key} =~ s/\'/\\\'/g;
974 print CONF qq| $key => '$self->{$key}',\n|;
977 print CONF qq|);\n\n|;
981 $main::lxdebug->leave_sub();
985 $main::lxdebug->enter_sub();
987 my ($self, $memberfile, $userspath) = @_;
991 # format dbconnect and dboptions string
992 &dbconnect_vars($self, $self->{dbname});
994 $self->error('File locked!') if (-f "${memberfile}.LCK");
995 open(FH, ">${memberfile}.LCK") or $self->error("${memberfile}.LCK : $!");
998 open(CONF, "+<$memberfile") or $self->error("$memberfile : $!");
1005 while ($line = shift @config) {
1006 if ($line =~ /^\[$self->{login}\]/) {
1013 # remove everything up to next login or EOF
1014 while ($line = shift @config) {
1015 last if ($line =~ /^\[/);
1018 # this one is either the next login or EOF
1021 while ($line = shift @config) {
1025 print CONF qq|[$self->{login}]\n|;
1027 if ((($self->{dbpasswd} ne $self->{old_dbpasswd}) || $newmember)
1029 $self->{dbpasswd} = pack 'u', $self->{dbpasswd};
1030 chop $self->{dbpasswd};
1032 if (defined($self->{new_password})) {
1033 if ($self->{new_password} ne $self->{old_password}) {
1034 $self->{password} = crypt $self->{new_password},
1035 substr($self->{login}, 0, 2)
1036 if $self->{new_password};
1039 if ($self->{password} ne $self->{old_password}) {
1040 $self->{password} = crypt $self->{password}, substr($self->{login}, 0, 2)
1041 if $self->{password};
1045 if ($self->{'root login'}) {
1046 @config = ("password");
1048 @config = &config_vars;
1051 # replace \r\n with \n
1052 map { $self->{$_} =~ s/\r\n/\\n/g } qw(address signature);
1053 foreach $key (sort @config) {
1054 print CONF qq|$key=$self->{$key}\n|;
1059 unlink "${memberfile}.LCK";
1062 $self->create_config("$userspath/$self->{login}.conf")
1063 unless $self->{'root login'};
1065 $main::lxdebug->leave_sub();
1069 $main::lxdebug->enter_sub();
1071 my @conf = qw(acs address admin businessnumber charset company countrycode
1072 currency dateformat dbconnect dbdriver dbhost dbport dboptions
1073 dbname dbuser dbpasswd email fax name numberformat in_numberformat password
1074 printer role sid signature stylesheet tel templates vclimit angebote bestellungen rechnungen
1075 anfragen lieferantenbestellungen einkaufsrechnungen taxnumber co_ustid duns menustyle
1076 template_format copies);
1078 $main::lxdebug->leave_sub();
1084 $main::lxdebug->enter_sub();
1086 my ($self, $msg) = @_;
1088 if ($ENV{HTTP_USER_AGENT}) {
1089 print qq|Content-Type: text/html
1091 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
1093 <body bgcolor=ffffff>
1095 <h2><font color=red>Error!</font></h2>
1100 die "Error: $msg\n";
1102 $main::lxdebug->leave_sub();