$form->{path} entfernt und hardcodiert auf bin/mozilla gesetzt.
[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   push(@INC, "modules");
35 }
36
37 # setup defaults, DO NOT CHANGE
38 $userspath  = "users";
39 $templates  = "templates";
40 $memberfile = "users/members";
41 $sendmail   = "| /usr/sbin/sendmail -t";
42 ########## end ###########################################
43
44 $| = 1;
45
46 use SL::LXDebug;
47 $lxdebug = LXDebug->new();
48
49 use CGI;
50 use SL::Form;
51 use SL::Locale;
52
53 eval { require "lx-erp.conf"; };
54
55 require "bin/mozilla/common.pl";
56
57 if (defined($latex) && !defined($latex_templates)) {
58   $latex_templates = $latex;
59   undef($latex);
60 }
61
62 $form = new Form;
63 $cgi = new CGI('');
64
65 # name of this script
66 $0 =~ tr/\\/\//;
67 $pos = rindex $0, '/';
68 $script = substr($0, $pos + 1);
69
70 # we use $script for the language module
71 $form->{script} = $script;
72
73 # strip .pl for translation files
74 $script =~ s/\.pl//;
75
76 # pull in DBI
77 use DBI;
78
79 # check for user config file, could be missing or ???
80 eval { require("$userspath/$form->{login}.conf"); };
81 if ($@) {
82   $locale = new Locale "$language", "$script";
83
84   $form->{callback} = "";
85   $msg1             = $locale->text('You are logged out!');
86   $msg2             = $locale->text('Login');
87   $form->redirect("$msg1 <p><a href=login.pl target=_top>$msg2</a>");
88 }
89
90 $myconfig{dbpasswd} = unpack 'u', $myconfig{dbpasswd};
91 map { $form->{$_} = $myconfig{$_} } qw(stylesheet charset)
92   unless (($form->{action} eq 'save') && ($form->{type} eq 'preferences'));
93
94 # locale messages
95 $locale = new Locale "$myconfig{countrycode}", "$script";
96
97 # check password
98 $form->error($locale->text('Incorrect Password!'))
99   if ($form->{password} ne $myconfig{password});
100
101 # did sysadmin lock us out
102 if (-e "$userspath/nologin") {
103   $form->error($locale->text('System currently down for maintenance!'));
104 }
105
106 # pull in the main code
107 require "bin/mozilla/$form->{script}";
108
109 # customized scripts
110 if (-f "bin/mozilla/custom_$form->{script}") {
111   eval { require "bin/mozilla/custom_$form->{script}"; };
112   $form->error($@) if ($@);
113 }
114
115 # customized scripts for login
116 if (-f "bin/mozilla/$form->{login}_$form->{script}") {
117   eval { require "bin/mozilla/$form->{login}_$form->{script}"; };
118   $form->error($@) if ($@);
119 }
120
121 if ($form->{action}) {
122
123   # window title bar, user info
124   $form->{titlebar} =
125       "Lx-Office "
126     . $locale->text('Version')
127     . " $form->{version} - $myconfig{name} - $myconfig{dbname}";
128
129   call_sub($locale->findsub($form->{action}));
130 } else {
131   $form->error($locale->text('action= not defined!'));
132 }
133
134 # end
135