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 #######################################################################
 
  33 # setup defaults, DO NOT CHANGE
 
  35 $templates  = "templates";
 
  36 $memberfile = "users/members";
 
  37 $sendmail   = "| /usr/sbin/sendmail -t";
 
  38 ########## end ###########################################
 
  43 $lxdebug = LXDebug->new();
 
  49 eval { require "lx-erp.conf"; };
 
  51 if (defined($latex) && !defined($latex_templates)) {
 
  52   $latex_templates = $latex;
 
  61 $pos = rindex $0, '/';
 
  62 $script = substr($0, $pos + 1);
 
  64 # we use $script for the language module
 
  65 $form->{script} = $script;
 
  67 # strip .pl for translation files
 
  73 # check for user config file, could be missing or ???
 
  74 eval { require("$userspath/$form->{login}.conf"); };
 
  76   $locale = new Locale "$language", "$script";
 
  78   $form->{callback} = "";
 
  79   $msg1             = $locale->text('You are logged out!');
 
  80   $msg2             = $locale->text('Login');
 
  81   $form->redirect("$msg1 <p><a href=login.pl target=_top>$msg2</a>");
 
  84 $myconfig{dbpasswd} = unpack 'u', $myconfig{dbpasswd};
 
  85 map { $form->{$_} = $myconfig{$_} } qw(stylesheet charset)
 
  86   unless (($form->{action} eq 'save') && ($form->{type} eq 'preferences'));
 
  89 $locale = new Locale "$myconfig{countrycode}", "$script";
 
  92 $form->error($locale->text('Incorrect Password!'))
 
  93   if ($form->{password} ne $myconfig{password});
 
  95 $form->{path} =~ s/\.\.\///g;
 
  96 if ($form->{path} !~ /^bin\//) {
 
  97   $form->error($locale->text('Invalid path!') . "\n");
 
 100 # did sysadmin lock us out
 
 101 if (-e "$userspath/nologin") {
 
 102   $form->error($locale->text('System currently down for maintenance!'));
 
 105 # pull in the main code
 
 106 require "$form->{path}/$form->{script}";
 
 109 if (-f "$form->{path}/custom_$form->{script}") {
 
 110   eval { require "$form->{path}/custom_$form->{script}"; };
 
 111   $form->error($@) if ($@);
 
 114 # customized scripts for login
 
 115 if (-f "$form->{path}/$form->{login}_$form->{script}") {
 
 116   eval { require "$form->{path}/$form->{login}_$form->{script}"; };
 
 117   $form->error($@) if ($@);
 
 120 if ($form->{action}) {
 
 122   # window title bar, user info
 
 125     . $locale->text('Version')
 
 126     . " $form->{version} - $myconfig{name} - $myconfig{dbname}";
 
 128   &{ $locale->findsub($form->{action}) };
 
 130   $form->error($locale->text('action= not defined!'));