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 #=====================================================================
41 $main::lxdebug->enter_sub();
43 my ($type, $memfile, $login) = @_;
47 &error("", "$memfile locked!") if (-f "${memfile}.LCK");
49 open(MEMBER, "$memfile") or &error("", "$memfile : $!");
60 # remove any trailing whitespace
63 ($key, $value) = split(/=/, $_, 2);
65 if (($key eq "stylesheet") && ($value eq "sql-ledger.css")) {
66 $value = "lx-office-erp.css";
69 $self->{$key} = $value;
72 $self->{login} = $login;
80 $main::lxdebug->leave_sub();
85 $main::lxdebug->enter_sub();
90 # scan the locale directory and read in the LANGUAGE files
91 opendir(DIR, "locale");
93 my @dir = grep(!/(^\.\.?$|\..*)/, readdir(DIR));
95 foreach my $dir (@dir) {
96 next unless open(FH, "locale/$dir/LANGUAGE");
100 $cc{$dir} = "@language";
105 $main::lxdebug->leave_sub();
111 $main::lxdebug->enter_sub();
113 my ($self, $form, $userspath) = @_;
117 if ($self->{login}) {
119 if ($self->{password}) {
120 if ($form->{hashed_password}) {
121 $form->{password} = $form->{hashed_password};
123 $form->{password} = crypt($form->{password},
124 substr($self->{login}, 0, 2));
126 if ($self->{password} ne $form->{password}) {
127 $main::lxdebug->leave_sub();
132 unless (-e "$userspath/$self->{login}.conf") {
133 $self->create_config("$userspath/$self->{login}.conf");
136 do "$userspath/$self->{login}.conf";
137 $myconfig{dbpasswd} = unpack('u', $myconfig{dbpasswd});
139 # check if database is down
141 DBI->connect($myconfig{dbconnect}, $myconfig{dbuser},
143 or $self->error(DBI::errstr);
145 # we got a connection, check the version
146 my $query = qq|SELECT version FROM defaults|;
147 my $sth = $dbh->prepare($query);
148 $sth->execute || $form->dberror($query);
150 my ($dbversion) = $sth->fetchrow_array;
153 # add login to employee table if it does not exist
154 # no error check for employee table, ignore if it does not exist
155 $query = qq|SELECT id FROM employee WHERE login = ?|;
156 my ($login) = selectrow_query($form, $dbh, $query, $self->{login});
159 $query = qq|INSERT INTO employee (login, name, workphone, role)| .
160 qq|VALUES (?, ?, ?, ?)|;
161 my @values = ($self->{login}, $myconfig{name}, $myconfig{tel}, "user");
162 do_query($form, $dbh, $query, @values);
165 $self->create_schema_info_table($form, $dbh);
172 parse_dbupdate_controls($form, $myconfig{"dbdriver"});
174 map({ $form->{$_} = $myconfig{$_} }
175 qw(dbname dbhost dbport dbdriver dbuser dbpasswd dbconnect));
177 if (update_available($myconfig{"dbdriver"}, $dbversion) ||
178 update2_available($form, $controls)) {
180 $form->{"stylesheet"} = "lx-office-erp.css";
181 $form->{"title"} = $main::locale->text("Dataset upgrade");
183 print($form->parse_html_template("dbupgrade/header"));
185 $form->{dbupdate} = "db$myconfig{dbname}";
186 $form->{ $form->{dbupdate} } = 1;
188 if ($form->{"show_dbupdate_warning"}) {
189 print($form->parse_html_template("dbupgrade/warning"));
194 open(FH, ">$userspath/nologin") or die("$!");
196 # required for Oracle
197 $form->{dbdefault} = $sid;
199 # ignore HUP, QUIT in case the webserver times out
200 $SIG{HUP} = 'IGNORE';
201 $SIG{QUIT} = 'IGNORE';
203 $self->dbupdate($form);
204 $self->dbupdate2($form, $controls);
207 unlink("$userspath/nologin");
210 $self->{"menustyle"} eq "v3" ? "menuv3.pl" :
211 $self->{"menustyle"} eq "neu" ? "menunew.pl" :
214 print($form->parse_html_template("dbupgrade/footer",
215 { "menufile" => $menufile }));
222 $main::lxdebug->leave_sub();
228 $main::lxdebug->enter_sub();
230 my ($form, $db) = @_;
233 'Pg' => { 'yy-mm-dd' => 'set DateStyle to \'ISO\'',
234 'yyyy-mm-dd' => 'set DateStyle to \'ISO\'',
235 'mm/dd/yy' => 'set DateStyle to \'SQL, US\'',
236 'mm-dd-yy' => 'set DateStyle to \'POSTGRES, US\'',
237 'dd/mm/yy' => 'set DateStyle to \'SQL, EUROPEAN\'',
238 'dd-mm-yy' => 'set DateStyle to \'POSTGRES, EUROPEAN\'',
239 'dd.mm.yy' => 'set DateStyle to \'GERMAN\''
242 'yy-mm-dd' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'YY-MM-DD\'',
243 'yyyy-mm-dd' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'YYYY-MM-DD\'',
244 'mm/dd/yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'MM/DD/YY\'',
245 'mm-dd-yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'MM-DD-YY\'',
246 'dd/mm/yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'DD/MM/YY\'',
247 'dd-mm-yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'DD-MM-YY\'',
248 'dd.mm.yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'DD.MM.YY\'',
251 $form->{dboptions} = $dboptions{ $form->{dbdriver} }{ $form->{dateformat} };
253 if ($form->{dbdriver} eq 'Pg') {
254 $form->{dbconnect} = "dbi:Pg:dbname=$db";
257 if ($form->{dbdriver} eq 'Oracle') {
258 $form->{dbconnect} = "dbi:Oracle:sid=$form->{sid}";
261 if ($form->{dbhost}) {
262 $form->{dbconnect} .= ";host=$form->{dbhost}";
264 if ($form->{dbport}) {
265 $form->{dbconnect} .= ";port=$form->{dbport}";
268 $main::lxdebug->leave_sub();
272 $main::lxdebug->enter_sub();
274 my @drivers = DBI->available_drivers();
276 $main::lxdebug->leave_sub();
278 return (grep { /(Pg|Oracle)/ } @drivers);
282 $main::lxdebug->enter_sub();
284 my ($self, $form) = @_;
289 $form->{dbdefault} = $form->{dbuser} unless $form->{dbdefault};
290 $form->{sid} = $form->{dbdefault};
291 &dbconnect_vars($form, $form->{dbdefault});
294 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
297 if ($form->{dbdriver} eq 'Pg') {
299 qq|SELECT datname FROM pg_database | .
300 qq|WHERE NOT datname IN ('template0', 'template1')|;
301 $sth = $dbh->prepare($query);
302 $sth->execute() || $form->dberror($query);
304 while (my ($db) = $sth->fetchrow_array) {
306 if ($form->{only_acc_db}) {
308 next if ($db =~ /^template/);
310 &dbconnect_vars($form, $db);
312 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
316 qq|SELECT tablename FROM pg_tables | .
317 qq|WHERE (tablename = 'defaults') AND (tableowner = ?)|;
318 my $sth = $dbh->prepare($query);
319 $sth->execute($form->{dbuser}) ||
320 $form->dberror($query . " ($form->{dbuser})");
322 if ($sth->fetchrow_array) {
323 push(@dbsources, $db);
329 push(@dbsources, $db);
333 if ($form->{dbdriver} eq 'Oracle') {
334 if ($form->{only_acc_db}) {
336 qq|SELECT owner FROM dba_objects | .
337 qq|WHERE object_name = 'DEFAULTS' AND object_type = 'TABLE'|;
339 $query = qq|SELECT username FROM dba_users|;
342 $sth = $dbh->prepare($query);
343 $sth->execute || $form->dberror($query);
345 while (my ($db) = $sth->fetchrow_array) {
346 push(@dbsources, $db);
353 $main::lxdebug->leave_sub();
359 $main::lxdebug->enter_sub();
361 my ($self, $form) = @_;
363 $form->{sid} = $form->{dbdefault};
364 &dbconnect_vars($form, $form->{dbdefault});
366 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
368 $form->{db} =~ s/\"//g;
370 'Pg' => qq|CREATE DATABASE "$form->{db}"|,
372 qq|CREATE USER "$form->{db}" DEFAULT TABLESPACE USERS | .
373 qq|TEMPORARY TABLESPACE TEMP IDENTIFIED BY "$form->{db}"|
380 push(@{$dboptions{"Pg"}}, "ENCODING = " . $dbh->quote($form->{"encoding"}))
381 if ($form->{"encoding"});
382 if ($form->{"dbdefault"}) {
383 my $dbdefault = $form->{"dbdefault"};
384 $dbdefault =~ s/[^a-zA-Z0-9_\-]//g;
385 push(@{$dboptions{"Pg"}}, "TEMPLATE = $dbdefault");
388 my $query = $dbcreate{$form->{dbdriver}};
389 $query .= " WITH " . join(" ", @{$dboptions{"Pg"}}) if (@{$dboptions{"Pg"}});
391 do_query($form, $dbh, $query);
393 if ($form->{dbdriver} eq 'Oracle') {
394 $query = qq|GRANT CONNECT, RESOURCE TO "$form->{db}"|;
395 do_query($form, $dbh, $query);
399 # setup variables for the new database
400 if ($form->{dbdriver} eq 'Oracle') {
401 $form->{dbuser} = $form->{db};
402 $form->{dbpasswd} = $form->{db};
405 &dbconnect_vars($form, $form->{db});
407 $dbh = DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
411 my $filename = qq|sql/lx-office.sql|;
412 $self->process_query($form, $dbh, $filename);
414 # load chart of accounts
415 $filename = qq|sql/$form->{chart}-chart.sql|;
416 $self->process_query($form, $dbh, $filename);
418 $query = "UPDATE defaults SET coa = ?";
419 do_query($form, $dbh, $query, $form->{chart});
423 $main::lxdebug->leave_sub();
426 # Process a Perl script which updates the database.
427 # If the script returns 1 then the update was successful.
428 # Return code "2" means "needs more interaction; remove
429 # users/nologin and exit".
430 # All other return codes are fatal errors.
431 sub process_perl_script {
432 $main::lxdebug->enter_sub();
434 my ($self, $form, $dbh, $filename, $version_or_control) = @_;
436 open(FH, "$filename") or $form->error("$filename : $!\n");
437 my $contents = join("", <FH>);
442 my %dbup_myconfig = ();
443 map({ $dbup_myconfig{$_} = $form->{$_}; }
444 qw(dbname dbuser dbpasswd dbhost dbport dbconnect));
446 my $nls_file = $filename;
447 $nls_file =~ s|.*/||;
448 $nls_file =~ s|.pl$||;
449 my $dbup_locale = Locale->new($main::language, $nls_file);
451 my $result = eval($contents);
458 if (!defined($result)) {
459 print($form->parse_html_template("dbupgrade/error",
460 { "file" => $filename,
463 } elsif (1 != $result) {
464 unlink("users/nologin") if (2 == $result);
468 if (ref($version_or_control) eq "HASH") {
469 $dbh->do("INSERT INTO schema_info (tag, login) VALUES (" .
470 $dbh->quote($version_or_control->{"tag"}) . ", " .
471 $dbh->quote($form->{"login"}) . ")");
472 } elsif ($version_or_control) {
473 $dbh->do("UPDATE defaults SET version = " .
474 $dbh->quote($version_or_control));
478 $main::lxdebug->leave_sub();
482 $main::lxdebug->enter_sub();
484 my ($self, $form, $dbh, $filename, $version_or_control) = @_;
486 open(FH, "$filename") or $form->error("$filename : $!\n");
495 # Remove DOS and Unix style line endings.
501 for (my $i = 0; $i < length($_); $i++) {
502 my $char = substr($_, $i, 1);
504 # Are we inside a string?
506 if ($char eq $quote_chars[-1]) {
512 if (($char eq "'") || ($char eq "\"")) {
513 push(@quote_chars, $char);
515 } elsif ($char eq ";") {
517 # Query is complete. Send it.
519 $sth = $dbh->prepare($query);
520 if (!$sth->execute()) {
521 my $errstr = $dbh->errstr;
524 $form->dberror("The database update/creation did not succeed. " .
525 "The file ${filename} containing the following " .
526 "query failed:<br>${query}<br>" .
527 "The error message was: ${errstr}<br>" .
528 "All changes in that file have been reverted.");
541 if (ref($version_or_control) eq "HASH") {
542 $dbh->do("INSERT INTO schema_info (tag, login) VALUES (" .
543 $dbh->quote($version_or_control->{"tag"}) . ", " .
544 $dbh->quote($form->{"login"}) . ")");
545 } elsif ($version_or_control) {
546 $dbh->do("UPDATE defaults SET version = " .
547 $dbh->quote($version_or_control));
553 $main::lxdebug->leave_sub();
557 $main::lxdebug->enter_sub();
559 my ($self, $form) = @_;
560 $form->{db} =~ s/\"//g;
561 my %dbdelete = ('Pg' => qq|DROP DATABASE "$form->{db}"|,
562 'Oracle' => qq|DROP USER "$form->{db}" CASCADE|);
564 $form->{sid} = $form->{dbdefault};
565 &dbconnect_vars($form, $form->{dbdefault});
567 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
569 my $query = $dbdelete{$form->{dbdriver}};
570 do_query($form, $dbh, $query);
574 $main::lxdebug->leave_sub();
577 sub dbsources_unused {
578 $main::lxdebug->enter_sub();
580 my ($self, $form, $memfile) = @_;
585 $form->error('File locked!') if (-f "${memfile}.LCK");
588 open(FH, "$memfile") or $form->error("$memfile : $!");
592 my ($null, $item) = split(/=/);
599 $form->{only_acc_db} = 1;
600 my @db = &dbsources("", $form);
602 push @dbexcl, $form->{dbdefault};
604 foreach $item (@db) {
605 unless (grep /$item$/, @dbexcl) {
606 push @dbsources, $item;
610 $main::lxdebug->leave_sub();
616 $main::lxdebug->enter_sub();
618 my ($self, $form) = @_;
623 $form->{sid} = $form->{dbdefault};
624 &dbconnect_vars($form, $form->{dbdefault});
627 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
630 if ($form->{dbdriver} eq 'Pg') {
633 qq|SELECT d.datname FROM pg_database d, pg_user u | .
634 qq|WHERE d.datdba = u.usesysid AND u.usename = ?|;
635 my $sth = prepare_execute_query($form, $dbh, $query, $form->{dbuser});
637 while (my ($db) = $sth->fetchrow_array) {
639 next if ($db =~ /^template/);
641 &dbconnect_vars($form, $db);
644 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
648 qq|SELECT tablename FROM pg_tables | .
649 qq|WHERE tablename = 'defaults'|;
650 my $sth2 = prepare_execute_query($form, $dbh, $query);
652 if ($sth2->fetchrow_array) {
653 $query = qq|SELECT version FROM defaults|;
654 my ($version) = selectrow_query($form, $dbh2, $query);
655 $dbsources{$db} = $version;
663 if ($form->{dbdriver} eq 'Oracle') {
665 qq|SELECT owner FROM dba_objects |.
666 qq|WHERE object_name = 'DEFAULTS' AND object_type = 'TABLE'|;
668 $sth = $dbh->prepare($query);
669 $sth->execute || $form->dberror($query);
671 while (my ($db) = $sth->fetchrow_array) {
673 $form->{dbuser} = $db;
674 &dbconnect_vars($form, $db);
677 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
680 $query = qq|SELECT version FROM defaults|;
681 my $sth = $dbh->prepare($query);
684 if (my ($version) = $sth->fetchrow_array) {
685 $dbsources{$db} = $version;
695 $main::lxdebug->leave_sub();
701 $main::lxdebug->enter_sub(2);
703 my (@v, $version, $i);
705 @v = split(/\./, $_[0]);
706 while (scalar(@v) < 4) {
710 for ($i = 0; $i < 4; $i++) {
715 $main::lxdebug->leave_sub(2);
719 sub cmp_script_version {
720 my ($a_from, $a_to, $b_from, $b_to);
721 my ($i, $res_a, $res_b);
722 my ($my_a, $my_b) = ($a, $b);
724 $my_a =~ s/.*-upgrade-//;
726 $my_b =~ s/.*-upgrade-//;
728 ($my_a_from, $my_a_to) = split(/-/, $my_a);
729 ($my_b_from, $my_b_to) = split(/-/, $my_b);
731 $res_a = calc_version($my_a_from);
732 $res_b = calc_version($my_b_from);
734 if ($res_a == $res_b) {
735 $res_a = calc_version($my_a_to);
736 $res_b = calc_version($my_b_to);
739 return $res_a <=> $res_b;
742 sub update_available {
743 my ($dbdriver, $cur_version) = @_;
745 opendir(SQLDIR, "sql/${dbdriver}-upgrade")
746 or &error("", "sql/${dbdriver}-upgrade: $!");
748 grep(/$form->{dbdriver}-upgrade-\Q$cur_version\E.*\.(sql|pl)$/,
752 return ($#upgradescripts > -1);
755 sub create_schema_info_table {
756 $main::lxdebug->enter_sub();
758 my ($self, $form, $dbh) = @_;
760 my $query = "SELECT tag FROM schema_info LIMIT 1";
761 if (!$dbh->do($query)) {
764 qq|CREATE TABLE schema_info (| .
767 qq| itime timestamp DEFAULT now(), | .
768 qq| PRIMARY KEY (tag))|;
769 $dbh->do($query) || $form->dberror($query);
772 $main::lxdebug->leave_sub();
776 $main::lxdebug->enter_sub();
778 my ($self, $form) = @_;
780 $form->{sid} = $form->{dbdefault};
782 my @upgradescripts = ();
786 if ($form->{dbupdate}) {
788 # read update scripts into memory
789 opendir(SQLDIR, "sql/" . $form->{dbdriver} . "-upgrade")
790 or &error("", "sql/" . $form->{dbdriver} . "-upgrade : $!");
792 sort(cmp_script_version
793 grep(/$form->{dbdriver}-upgrade-.*?\.(sql|pl)$/,
798 foreach my $db (split(/ /, $form->{dbupdate})) {
800 next unless $form->{$db};
802 # strip db from dataset
804 &dbconnect_vars($form, $db);
807 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
811 $query = qq|SELECT version FROM defaults|;
812 my ($version) = selectrow_query($form, $dbh, $query);
814 next unless $version;
816 $version = calc_version($version);
818 foreach my $upgradescript (@upgradescripts) {
819 my $a = $upgradescript;
820 $a =~ s/^$form->{dbdriver}-upgrade-|\.(sql|pl)$//g;
823 my ($mindb, $maxdb) = split /-/, $a;
824 my $str_maxdb = $maxdb;
825 $mindb = calc_version($mindb);
826 $maxdb = calc_version($maxdb);
828 next if ($version >= $maxdb);
830 # if there is no upgrade script exit
831 last if ($version < $mindb);
834 $main::lxdebug->message(DEBUG2, "Applying Update $upgradescript");
835 if ($file_type eq "sql") {
836 $self->process_query($form, $dbh, "sql/" . $form->{"dbdriver"} .
837 "-upgrade/$upgradescript", $str_maxdb);
839 $self->process_perl_script($form, $dbh, "sql/" . $form->{"dbdriver"} .
840 "-upgrade/$upgradescript", $str_maxdb);
852 $main::lxdebug->leave_sub();
858 $main::lxdebug->enter_sub();
860 my ($self, $form, $controls) = @_;
862 $form->{sid} = $form->{dbdefault};
864 my @upgradescripts = ();
865 my ($query, $sth, $tag);
868 @upgradescripts = sort_dbupdate_controls($controls);
870 foreach my $db (split / /, $form->{dbupdate}) {
872 next unless $form->{$db};
874 # strip db from dataset
876 &dbconnect_vars($form, $db);
879 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
882 map({ $_->{"applied"} = 0; } @upgradescripts);
884 $query = qq|SELECT tag FROM schema_info|;
885 $sth = $dbh->prepare($query);
886 $sth->execute() || $form->dberror($query);
887 while (($tag) = $sth->fetchrow_array()) {
888 $controls->{$tag}->{"applied"} = 1 if (defined($controls->{$tag}));
893 foreach (@upgradescripts) {
894 if (!$_->{"applied"}) {
900 next if ($all_applied);
902 foreach my $control (@upgradescripts) {
903 next if ($control->{"applied"});
905 $control->{"file"} =~ /\.(sql|pl)$/;
909 $main::lxdebug->message(DEBUG2, "Applying Update $control->{file}");
910 print($form->parse_html_template("dbupgrade/upgrade_message2",
913 if ($file_type eq "sql") {
914 $self->process_query($form, $dbh, "sql/" . $form->{"dbdriver"} .
915 "-upgrade2/$control->{file}", $control);
917 $self->process_perl_script($form, $dbh, "sql/" . $form->{"dbdriver"} .
918 "-upgrade2/$control->{file}", $control);
927 $main::lxdebug->leave_sub();
932 sub update2_available {
933 $main::lxdebug->enter_sub();
935 my ($form, $controls) = @_;
937 map({ $_->{"applied"} = 0; } values(%{$controls}));
939 dbconnect_vars($form, $form->{"dbname"});
942 DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) ||
945 my ($query, $tag, $sth);
947 $query = qq|SELECT tag FROM schema_info|;
948 $sth = $dbh->prepare($query);
949 $sth->execute() || $form->dberror($query);
950 while (($tag) = $sth->fetchrow_array()) {
951 $controls->{$tag}->{"applied"} = 1 if (defined($controls->{$tag}));
956 map({ $main::lxdebug->leave_sub() and return 1 if (!$_->{"applied"}) }
957 values(%{$controls}));
959 $main::lxdebug->leave_sub();
964 $main::lxdebug->enter_sub();
966 my ($self, $filename) = @_;
968 @config = &config_vars;
970 open(CONF, ">$filename") or $self->error("$filename : $!");
972 # create the config file
973 print CONF qq|# configuration file for $self->{login}
978 foreach $key (sort @config) {
979 $self->{$key} =~ s/\'/\\\'/g;
980 print CONF qq| $key => '$self->{$key}',\n|;
983 print CONF qq|);\n\n|;
987 $main::lxdebug->leave_sub();
991 $main::lxdebug->enter_sub();
993 my ($self, $memberfile, $userspath) = @_;
997 # format dbconnect and dboptions string
998 &dbconnect_vars($self, $self->{dbname});
1000 $self->error('File locked!') if (-f "${memberfile}.LCK");
1001 open(FH, ">${memberfile}.LCK") or $self->error("${memberfile}.LCK : $!");
1004 open(CONF, "+<$memberfile") or $self->error("$memberfile : $!");
1011 while ($line = shift @config) {
1012 if ($line =~ /^\[$self->{login}\]/) {
1019 # remove everything up to next login or EOF
1020 while ($line = shift @config) {
1021 last if ($line =~ /^\[/);
1024 # this one is either the next login or EOF
1027 while ($line = shift @config) {
1031 print CONF qq|[$self->{login}]\n|;
1033 if ((($self->{dbpasswd} ne $self->{old_dbpasswd}) || $newmember)
1035 $self->{dbpasswd} = pack 'u', $self->{dbpasswd};
1036 chop $self->{dbpasswd};
1038 if (defined($self->{new_password})) {
1039 if ($self->{new_password} ne $self->{old_password}) {
1040 $self->{password} = crypt $self->{new_password},
1041 substr($self->{login}, 0, 2)
1042 if $self->{new_password};
1045 if ($self->{password} ne $self->{old_password}) {
1046 $self->{password} = crypt $self->{password}, substr($self->{login}, 0, 2)
1047 if $self->{password};
1051 if ($self->{'root login'}) {
1052 @config = ("password");
1054 @config = &config_vars;
1057 # replace \r\n with \n
1058 map { $self->{$_} =~ s/\r\n/\\n/g } qw(address signature);
1059 foreach $key (sort @config) {
1060 print CONF qq|$key=$self->{$key}\n|;
1065 unlink "${memberfile}.LCK";
1068 $self->create_config("$userspath/$self->{login}.conf")
1069 unless $self->{'root login'};
1071 $main::lxdebug->leave_sub();
1075 $main::lxdebug->enter_sub();
1077 my @conf = qw(acs address admin businessnumber charset company countrycode
1078 currency dateformat dbconnect dbdriver dbhost dbport dboptions
1079 dbname dbuser dbpasswd email fax name numberformat password
1080 printer role sid signature stylesheet tel templates vclimit angebote
1081 bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen
1082 taxnumber co_ustid duns menustyle template_format default_media
1083 default_printer_id copies show_form_details);
1085 $main::lxdebug->leave_sub();
1091 $main::lxdebug->enter_sub();
1093 my ($self, $msg) = @_;
1095 if ($ENV{HTTP_USER_AGENT}) {
1096 print qq|Content-Type: text/html
1098 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
1100 <body bgcolor=ffffff>
1102 <h2><font color=red>Error!</font></h2>
1107 die "Error: $msg\n";
1109 $main::lxdebug->leave_sub();