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