3 ######################################################################
4 # SQL-Ledger Accounting
7 # Author: Dieter Simader
8 # Email: dsimader@sql-ledger.org
9 # Web: http://www.sql-ledger.org
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.
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 #######################################################################
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/
31 #######################################################################
34 unshift @INC, "modules/override"; # Use our own versions of various modules (e.g. YAML).
35 push @INC, "modules/fallback"; # Only use our own versions of modules if there's no system version.
38 # setup defaults, DO NOT CHANGE
40 $templates = "templates";
41 $memberfile = "users/members";
42 $sendmail = "| /usr/sbin/sendmail -t";
43 ########## end ###########################################
48 $lxdebug = LXDebug->new();
50 use CGI qw( -no_xhtml);
55 eval { require "config/lx-erp.conf"; };
56 eval { require "config/lx-erp-local.conf"; } if -f "config/lx-erp-local.conf";
58 our $cgi = new CGI('');
61 our $auth = SL::Auth->new();
62 if (!$auth->session_tables_present()) {
63 _show_error('login/auth_db_unreachable');
65 $auth->expire_sessions();
66 $auth->restore_session();
68 require "bin/mozilla/common.pl";
70 if (defined($latex) && !defined($latex_templates)) {
71 $latex_templates = $latex;
75 # this prevents most of the tabindexes being created by CGI.
76 # note: most. popup menus and selecttables will still have tabindexes
77 # use common.pl's NTI function to get rid of those
78 local $CGI::TABINDEX = 0;
82 $pos = rindex $0, '/';
83 $script = substr($0, $pos + 1);
85 # we use $script for the language module
86 $form->{script} = $script;
88 # strip .pl for translation files
95 $locale = new Locale($language, "$script");
97 # did sysadmin lock us out
98 if (-e "$userspath/nologin") {
99 $form->error($locale->text('System currently down for maintenance!'));
102 $form->{login} =~ s|.*/||;
104 %myconfig = $auth->read_user($form->{login});
106 if (!$myconfig{login}) {
107 _show_error('login/password_error');
111 $locale = new Locale "$myconfig{countrycode}", "$script";
113 if (SL::Auth::OK != $auth->authenticate($form->{login}, $form->{password}, 0)) {
114 _show_error('login/password_error');
117 $auth->set_session_value('login', $form->{login}, 'password', $form->{password});
118 $auth->create_or_refresh_session();
120 delete $form->{password};
122 map { $form->{$_} = $myconfig{$_} } qw(stylesheet charset)
123 unless (($form->{action} eq 'save') && ($form->{type} eq 'preferences'));
125 # pull in the main code
126 require "bin/mozilla/$form->{script}";
129 if (-f "bin/mozilla/custom_$form->{script}") {
130 eval { require "bin/mozilla/custom_$form->{script}"; };
131 $form->error($@) if ($@);
134 # customized scripts for login
135 if (-f "bin/mozilla/$form->{login}_$form->{script}") {
136 eval { require "bin/mozilla/$form->{login}_$form->{script}"; };
137 $form->error($@) if ($@);
140 if ($form->{action}) {
142 # window title bar, user info
145 . $locale->text('Version')
146 . " $form->{version} - $myconfig{name} - $myconfig{dbname}";
148 call_sub($locale->findsub($form->{action}));
150 $form->error($locale->text('action= not defined!'));
154 my $template = shift;
155 $locale = Locale->new($language, 'all');
156 $myconfig{countrycode} = $language;
157 $form->{stylesheet} = 'css/lx-office-erp.css';
160 print $form->parse_html_template($template);