Projekt

Allgemein

Profil

Herunterladen (4,44 KB) Statistiken
| Zweig: | Markierung: | Revision:
d319704a Moritz Bunkus
#!/usr/bin/perl
#
######################################################################
# SQL-Ledger Accounting
# Copyright (C) 2001
#
# Author: Dieter Simader
# Email: dsimader@sql-ledger.org
# Web: http://www.sql-ledger.org
#
# Contributors:
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#######################################################################
#
# this script is the frontend called from bin/$terminal/$script
# all the accounting modules are linked to this script which in
# turn execute the same script in bin/$terminal/
#
#######################################################################

3f65b4fb Moritz Bunkus
BEGIN {
b179b8df Moritz Bunkus
unshift @INC, "modules/override"; # Use our own versions of various modules (e.g. YAML).
push @INC, "modules/fallback"; # Only use our own versions of modules if there's no system version.
3f65b4fb Moritz Bunkus
}

d319704a Moritz Bunkus
# setup defaults, DO NOT CHANGE
$userspath = "users";
$templates = "templates";
$memberfile = "users/members";
$sendmail = "| /usr/sbin/sendmail -t";
########## end ###########################################

$| = 1;

use SL::LXDebug;
$lxdebug = LXDebug->new();

b6dc5623 Sven Schöling
use CGI qw( -no_xhtml);
8c7e4493 Moritz Bunkus
use SL::Auth;
d319704a Moritz Bunkus
use SL::Form;
541272c5 Moritz Bunkus
use SL::Locale;
d319704a Moritz Bunkus
8c7e4493 Moritz Bunkus
eval { require "config/lx-erp.conf"; };
eval { require "config/lx-erp-local.conf"; } if -f "config/lx-erp-local.conf";

our $cgi = new CGI('');
our $form = new Form;

our $auth = SL::Auth->new();
if (!$auth->session_tables_present()) {
_show_error('login/auth_db_unreachable');
}
$auth->expire_sessions();
$auth->restore_session();
d319704a Moritz Bunkus
40782548 Moritz Bunkus
require "bin/mozilla/common.pl";

3ce6fe64 Moritz Bunkus
if (defined($latex) && !defined($latex_templates)) {
$latex_templates = $latex;
undef($latex);
}

b6dc5623 Sven Schöling
# this prevents most of the tabindexes being created by CGI.
# note: most. popup menus and selecttables will still have tabindexes
# use common.pl's NTI function to get rid of those
local $CGI::TABINDEX = 0;

d319704a Moritz Bunkus
# name of this script
$0 =~ tr/\\/\//;
$pos = rindex $0, '/';
$script = substr($0, $pos + 1);

# we use $script for the language module
$form->{script} = $script;

# strip .pl for translation files
$script =~ s/\.pl//;

# pull in DBI
use DBI;

8c7e4493 Moritz Bunkus
# locale messages
$locale = new Locale($language, "$script");

# did sysadmin lock us out
if (-e "$userspath/nologin") {
$form->error($locale->text('System currently down for maintenance!'));
}

d5b09512 Moritz Bunkus
$form->{login} =~ s|.*/||;

8c7e4493 Moritz Bunkus
%myconfig = $auth->read_user($form->{login});
d319704a Moritz Bunkus
8c7e4493 Moritz Bunkus
if (!$myconfig{login}) {
_show_error('login/password_error');
d319704a Moritz Bunkus
}

# locale messages
$locale = new Locale "$myconfig{countrycode}", "$script";

8c7e4493 Moritz Bunkus
if (SL::Auth::OK != $auth->authenticate($form->{login}, $form->{password}, 0)) {
_show_error('login/password_error');
d319704a Moritz Bunkus
}

8c7e4493 Moritz Bunkus
$auth->set_session_value('login', $form->{login}, 'password', $form->{password});
$auth->create_or_refresh_session();

delete $form->{password};

map { $form->{$_} = $myconfig{$_} } qw(stylesheet charset)
unless (($form->{action} eq 'save') && ($form->{type} eq 'preferences'));

d319704a Moritz Bunkus
# pull in the main code
d629acd8 Sven Schöling
require "bin/mozilla/$form->{script}";
d319704a Moritz Bunkus
# customized scripts
d629acd8 Sven Schöling
if (-f "bin/mozilla/custom_$form->{script}") {
eval { require "bin/mozilla/custom_$form->{script}"; };
d319704a Moritz Bunkus
$form->error($@) if ($@);
}

# customized scripts for login
d629acd8 Sven Schöling
if (-f "bin/mozilla/$form->{login}_$form->{script}") {
eval { require "bin/mozilla/$form->{login}_$form->{script}"; };
d319704a Moritz Bunkus
$form->error($@) if ($@);
}

if ($form->{action}) {

# window title bar, user info
$form->{titlebar} =
"Lx-Office "
. $locale->text('Version')
. " $form->{version} - $myconfig{name} - $myconfig{dbname}";

40782548 Moritz Bunkus
call_sub($locale->findsub($form->{action}));
d319704a Moritz Bunkus
} else {
$form->error($locale->text('action= not defined!'));
}

8c7e4493 Moritz Bunkus
sub _show_error {
my $template = shift;
$locale = Locale->new($language, 'all');
$myconfig{countrycode} = $language;
$form->{stylesheet} = 'css/lx-office-erp.css';

$form->header();
print $form->parse_html_template($template);
exit;
}

d319704a Moritz Bunkus
# end