Import der aktuellen Version des YAML-Moduls 0.62 in Lx-Office. Unsere eigene Version...
[kivitendo-erp.git] / am.pl
1 #!/usr/bin/perl
2 #
3 ######################################################################
4 # SQL-Ledger Accounting
5 # Copyright (C) 2001
6 #
7 #  Author: Dieter Simader
8 #   Email: dsimader@sql-ledger.org
9 #     Web: http://www.sql-ledger.org
10 #
11 #  Contributors:
12 #
13 # This program is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2 of the License, or
16 # (at your option) any later version.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #######################################################################
26 #
27 # this script is the frontend called from bin/$terminal/$script
28 # all the accounting modules are linked to this script which in
29 # turn execute the same script in bin/$terminal/
30 #
31 #######################################################################
32
33 BEGIN {
34   unshift @INC, "modules/YAML"; # Use our own version of YAML.
35   push @INC, "modules";         # Only use our own versions of modules if there's no system version.
36 }
37
38 # setup defaults, DO NOT CHANGE
39 $userspath  = "users";
40 $templates  = "templates";
41 $memberfile = "users/members";
42 $sendmail   = "| /usr/sbin/sendmail -t";
43 ########## end ###########################################
44
45 $| = 1;
46
47 use SL::LXDebug;
48 $lxdebug = LXDebug->new();
49
50 use CGI;
51 use SL::Form;
52 use SL::Locale;
53
54 eval { require "lx-erp.conf"; };
55 eval { require "lx-erp-local.conf"; } if -f "lx-erp-local.conf";
56
57 require "bin/mozilla/common.pl";
58
59 if (defined($latex) && !defined($latex_templates)) {
60   $latex_templates = $latex;
61   undef($latex);
62 }
63
64 $form = new Form;
65 $cgi = new CGI('');
66
67 # name of this script
68 $0 =~ tr/\\/\//;
69 $pos = rindex $0, '/';
70 $script = substr($0, $pos + 1);
71
72 # we use $script for the language module
73 $form->{script} = $script;
74
75 # strip .pl for translation files
76 $script =~ s/\.pl//;
77
78 # pull in DBI
79 use DBI;
80
81 $form->{login} =~ s|.*/||;
82
83 # check for user config file, could be missing or ???
84 eval { require("$userspath/$form->{login}.conf"); };
85 if ($@) {
86   $locale = new Locale "$language", "$script";
87
88   $form->{callback} = "";
89   $msg1             = $locale->text('You are logged out!');
90   $msg2             = $locale->text('Login');
91   $form->redirect("$msg1 <p><a href=login.pl target=_top>$msg2</a>");
92 }
93
94 $myconfig{dbpasswd} = unpack 'u', $myconfig{dbpasswd};
95 map { $form->{$_} = $myconfig{$_} } qw(stylesheet charset)
96   unless (($form->{action} eq 'save') && ($form->{type} eq 'preferences'));
97
98 # locale messages
99 $locale = new Locale "$myconfig{countrycode}", "$script";
100
101 # check password
102 $form->error($locale->text('Incorrect Password!'))
103   if ($form->{password} ne $myconfig{password});
104
105 # did sysadmin lock us out
106 if (-e "$userspath/nologin") {
107   $form->error($locale->text('System currently down for maintenance!'));
108 }
109
110 # pull in the main code
111 require "bin/mozilla/$form->{script}";
112
113 # customized scripts
114 if (-f "bin/mozilla/custom_$form->{script}") {
115   eval { require "bin/mozilla/custom_$form->{script}"; };
116   $form->error($@) if ($@);
117 }
118
119 # customized scripts for login
120 if (-f "bin/mozilla/$form->{login}_$form->{script}") {
121   eval { require "bin/mozilla/$form->{login}_$form->{script}"; };
122   $form->error($@) if ($@);
123 }
124
125 if ($form->{action}) {
126
127   # window title bar, user info
128   $form->{titlebar} =
129       "Lx-Office "
130     . $locale->text('Version')
131     . " $form->{version} - $myconfig{name} - $myconfig{dbname}";
132
133   call_sub($locale->findsub($form->{action}));
134 } else {
135   $form->error($locale->text('action= not defined!'));
136 }
137
138 # end
139