return $cgi->redirect($new_uri);
}
+sub set_standard_title {
+ $::lxdebug->enter_sub;
+ my $self = shift;
+
+ $self->{titlebar} = "Lx-Office " . $::locale->text('Version') . " $self->{version}";
+ $self->{titlebar} .= "- $::myconfig{name}" if $::myconfig{name};
+ $self->{titlebar} .= "- $::myconfig{dbname}" if $::myconfig{name};
+
+ $::lxdebug->leave_sub;
+}
+
sub _prepare_html_template {
$main::lxdebug->enter_sub();
my ($self, $msg) = @_;
- if ($self->{callback}) {
-
- my ($script, $argv) = split(/\?/, $self->{callback}, 2);
- $script =~ s|.*/||;
- $script =~ s|[^a-zA-Z0-9_\.]||g;
- exec("perl", "$script", $argv);
-
- } else {
+ if (!$self->{callback}) {
$self->info($msg);
exit;
}
+# my ($script, $argv) = split(/\?/, $self->{callback}, 2);
+# $script =~ s|.*/||;
+# $script =~ s|[^a-zA-Z0-9_\.]||g;
+# exec("perl", "$script", $argv);
+
+ print $::form->redirect_header($self->{callback});
+
$main::lxdebug->leave_sub();
}
+++ /dev/null
-login.pl
\ No newline at end of file
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+
+BEGIN {
+ 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.
+ push @INC, "SL"; # FCGI won't find modules that are not properly named. Help it by inclduging SL
+}
+
+use FCGI;
+use CGI qw( -no_xhtml);
+use SL::Auth;
+use SL::LXDebug;
+use SL::Locale;
+use SL::Common;
+use Form;
+use Moose;
+use Rose::DB;
+use Rose::DB::Object;
+use File::Basename;
+
+my ($script, $path, $suffix) = fileparse($0, ".pl");
+my $request = FCGI::Request();
+
+eval { require "config/lx-erp.conf"; };
+eval { require "config/lx-erp-local.conf"; } if -f "config/lx-erp-local.conf";
+require "bin/mozilla/common.pl";
+require "bin/mozilla/installationcheck.pl";
+require_main_code($script, $suffix);
+
+# dummy globals
+{
+ no warnings 'once';
+ $::userspath = "users";
+ $::templates = "templates";
+ $::memberfile = "users/members";
+ $::sendmail = "| /usr/sbin/sendmail -t";
+ $::lxdebug = LXDebug->new;
+ $::auth = SL::Auth->new;
+ %::myconfig = ();
+}
+
+_pre_startup_checks();
+
+if ($request->IsFastCGI) {
+ handle_request() while $request->Accept() >= 0;
+} else {
+ handle_request();
+}
+
+# end
+
+sub handle_request {
+ $::lxdebug->enter_sub;
+ $::lxdebug->begin_request;
+ $::cgi = CGI->new('');
+ $::locale = Locale->new($::language, $script);
+ $::form = Form->new;
+ $::form->{script} = $script . $suffix;
+
+ _pre_request_checks();
+
+ eval {
+ if ($script eq 'login' or $script eq 'admin' or $script eq 'kopf') {
+ $::form->{titlebar} = "Lx-Office " . $::locale->text('Version') . " $::form->{version}";
+ run($::auth->restore_session);
+ } elsif ($::form->{action}) {
+ # copy from am.pl routines
+ $::form->error($::locale->text('System currently down for maintenance!')) if -e "$main::userspath/nologin" && $script ne 'admin';
+
+ my $session_result = $::auth->restore_session;
+
+ _show_error('login/password_error', 'session') if SL::Auth::SESSION_EXPIRED == $session_result;
+ %::myconfig = $::auth->read_user($::form->{login});
+
+ _show_error('login/password_error', 'password') unless $::myconfig{login};
+
+ $::locale = Locale->new($::myconfig{countrycode}, $script);
+
+ _show_error('login/password_error', 'password') if SL::Auth::OK != $::auth->authenticate($::form->{login}, $::form->{password}, 0);
+
+ $::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';
+
+ $::form->set_standard_title;
+ call_sub($::locale->findsub($::form->{action}));
+ } else {
+ $::form->error($::locale->text('action= not defined!'));
+ }
+ };
+
+ # cleanup
+ $::locale = undef;
+ $::form = undef;
+ $::myconfig = ();
+
+ $::lxdebug->end_request;
+ $::lxdebug->leave_sub;
+}
+
+sub _pre_request_checks {
+ _show_error('login/auth_db_unreachable') unless $::auth->session_tables_present;
+ $::auth->expire_sessions;
+}
+
+sub _show_error {
+ $::lxdebug->enter_sub;
+ my $template = shift;
+ my $error_type = shift;
+ my $locale = Locale->new($::language, 'all');
+ $::form->{error} = $::locale->text('The session is invalid or has expired.') if ($error_type eq 'session');
+ $::form->{error} = $::locale->text('Incorrect password!.') if ($error_type eq 'password');
+ $::myconfig{countrycode} = $::language;
+ $::form->{stylesheet} = 'css/lx-office-erp.css';
+
+ $::form->header;
+ print $::form->parse_html_template($template);
+ $::lxdebug->leave_sub;
+
+ exit;
+}
+
+sub _pre_startup_checks {
+ verify_installation();
+}
+
+sub require_main_code {
+ my ($script, $suffix) = @_;
+
+ require "bin/mozilla/$script$suffix";
+
+ if (-f "bin/mozilla/custom_$script$suffix") {
+ eval { require "bin/mozilla/custom_$script$suffix"; };
+ $::form->error($@) if ($@);
+ }
+ if ($::form->{login} && -f "bin/mozilla/$::form->{login}_$::form->{script}") {
+ eval { require "bin/mozilla/$::form->{login}_$::form->{script}"; };
+ $::form->error($@) if ($@);
+ }
+}
+
+1;
+++ /dev/null
-#!/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/
-#
-#######################################################################
-
-use strict;
-
-BEGIN {
- 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.
-}
-
-# setup defaults, DO NOT CHANGE
-$main::userspath = "users";
-$main::templates = "templates";
-$main::memberfile = "users/members";
-$main::sendmail = "| /usr/sbin/sendmail -t";
-########## end ###########################################
-
-$| = 1;
-
-use SL::LXDebug;
-$main::lxdebug = LXDebug->new();
-
-use CGI qw( -no_xhtml);
-use SL::Auth;
-use SL::Form;
-use SL::Locale;
-
-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();
-my $session_result = $auth->restore_session();
-
-require "bin/mozilla/common.pl";
-
-if (defined($main::latex) && !defined($main::latex_templates)) {
- $main::latex_templates = $main::latex;
- undef($main::latex);
-}
-
-# 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;
-
-# name of this script
-$0 =~ tr/\\/\//;
-my $pos = rindex $0, '/';
-my $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;
-
-# locale messages
-$main::locale = new Locale($main::language, "$script");
-my $locale = $main::locale;
-
-# did sysadmin lock us out
-if (-e "$main::userspath/nologin") {
- $form->error($locale->text('System currently down for maintenance!'));
-}
-
-if (SL::Auth::SESSION_EXPIRED == $session_result) {
- _show_error('login/password_error', 'session');
-}
-
-$form->{login} =~ s|.*/||;
-
-%main::myconfig = $auth->read_user($form->{login});
-my %myconfig = %main::myconfig;
-
-if (!$myconfig{login}) {
- _show_error('login/password_error', 'password');
-}
-
-# locale messages
-$locale = new Locale "$myconfig{countrycode}", "$script";
-
-if (SL::Auth::OK != $auth->authenticate($form->{login}, $form->{password}, 0)) {
- _show_error('login/password_error', 'password');
-}
-
-$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'));
-
-# pull in the main code
-require "bin/mozilla/$form->{script}";
-
-# customized scripts
-if (-f "bin/mozilla/custom_$form->{script}") {
- eval { require "bin/mozilla/custom_$form->{script}"; };
- $form->error($@) if ($@);
-}
-
-# customized scripts for login
-if (-f "bin/mozilla/$form->{login}_$form->{script}") {
- eval { require "bin/mozilla/$form->{login}_$form->{script}"; };
- $form->error($@) if ($@);
-}
-
-if ($form->{action}) {
-
- # window title bar, user info
- $form->{titlebar} =
- "Lx-Office "
- . $locale->text('Version')
- . " $form->{version} - $myconfig{name} - $myconfig{dbname}";
-
- call_sub($locale->findsub($form->{action}));
-} else {
- $form->error($locale->text('action= not defined!'));
-}
-
-sub _show_error {
- my $template = shift;
- my $error_type = shift;
- my $locale = Locale->new($main::language, 'all');
- $form->{error} = $locale->text('The session is invalid or has expired.') if ($error_type eq 'session');
- $form->{error} = $locale->text('Incorrect password!.') if ($error_type eq 'password');
- $myconfig{countrycode} = $main::language;
- $form->{stylesheet} = 'css/lx-office-erp.css';
-
- $form->header();
- print $form->parse_html_template($template);
- exit;
-}
-
-# end
-
--- /dev/null
+admin.pl
\ No newline at end of file
use strict;
-our $cgi = new CGI('');
-our $form = new Form;
-our $locale = new Locale $main::language, "admin";
-our $auth = SL::Auth->new();
-
-if ($auth->session_tables_present()) {
- $auth->expire_sessions();
- $auth->restore_session();
- $auth->set_session_value('rpw', $form->{rpw});
-}
-
-# customization
-if (-f "bin/mozilla/custom_$form->{script}") {
- eval { require "bin/mozilla/custom_$form->{script}"; };
- $form->error($@) if ($@);
-}
+our $cgi;
+our $form;
+our $locale;
+our $auth;
-$form->{stylesheet} = "lx-office-erp.css";
-$form->{favicon} = "favicon.ico";
+sub run {
+ $::lxdebug->enter_sub;
+ my $session_result = shift;
-if ($form->{action}) {
- if ($auth->authenticate_root($form->{rpw}, 0) != $auth->OK()) {
- $form->{error_message} = $locale->text('Incorrect Password!');
- adminlogin();
- exit;
- }
+ $cgi = $::cgi;
+ $form = $::form;
+ $locale = $::locale;
+ $auth = $::auth;
- $auth->create_or_refresh_session() if ($auth->session_tables_present());
+ $::auth->set_session_value('rpw', $::form->{rpw}) if $session_result == SL::Auth->SESSION_OK;
- call_sub($locale->findsub($form->{action}));
-
-} elsif ($auth->authenticate_root($form->{rpw}, 0) == $auth->OK()) {
-
- $auth->create_or_refresh_session() if ($auth->session_tables_present());
+ $form->{stylesheet} = "lx-office-erp.css";
+ $form->{favicon} = "favicon.ico";
- login();
+ if ($form->{action}) {
+ if ($auth->authenticate_root($form->{rpw}, 0) != $auth->OK()) {
+ $form->{error_message} = $locale->text('Incorrect Password!');
+ adminlogin();
+ } else {
+ $auth->create_or_refresh_session() if ($auth->session_tables_present());
+ call_sub($locale->findsub($form->{action}));
+ }
+ } elsif ($auth->authenticate_root($form->{rpw}, 0) == $auth->OK()) {
-} else {
- # if there are no drivers bail out
- $form->error($locale->text('No Database Drivers available!'))
- unless (User->dbdrivers);
+ $auth->create_or_refresh_session() if ($auth->session_tables_present());
- adminlogin();
+ login();
+ } else {
+ # if there are no drivers bail out
+ $form->error($locale->text('No Database Drivers available!'))
+ unless (User->dbdrivers);
+ adminlogin();
+ }
+ $::lxdebug->leave_sub;
}
-1;
-
-# end
-
sub adminlogin {
my $form = $main::form;
my $locale = $main::locale;
#!/usr/bin/perl
#
-$| = 1;
+#$| = 1;
-use CGI::Carp qw(fatalsToBrowser);
+#use CGI::Carp qw(fatalsToBrowser);
use strict;
+sub run {
+ my $session_result = shift;
+
my $form = $main::form;
my $locale = $main::locale;
</html>
|;
+}
+
+1;
+
#
use strict;
-# This is required because the am.pl in the root directory
-# is not scanned by locales.pl:
-# $form->parse_html_template('login/password_error')
+our $cgi;
+our $form;
+our $locale;
+our $auth;
-our $form = new Form;
+sub run {
+ $::lxdebug->enter_sub;
+ my $session_result = shift;
-if (! -f 'config/authentication.pl') {
- show_error('login/authentication_pl_missing');
-}
-
-our $locale = new Locale $main::language, "login";
-
-our $auth = SL::Auth->new();
-if (!$auth->session_tables_present()) {
- show_error('login/auth_db_unreachable');
-}
-$auth->expire_sessions();
-my $session_result = $main::auth->restore_session();
-
-# customization
-if (-f "bin/mozilla/custom_$form->{script}") {
- eval { require "bin/mozilla/custom_$form->{script}"; };
- $form->error($@) if ($@);
-}
-
-# per login customization
-if (-f "bin/mozilla/$form->{login}_$form->{script}") {
- eval { require "bin/mozilla/$form->{login}_$form->{script}"; };
- $form->error($@) if ($@);
-}
-
-# window title bar, user info
-$form->{titlebar} = "Lx-Office " . $locale->text('Version') . " $form->{version}";
-
-if (SL::Auth::SESSION_EXPIRED == $session_result) {
- $form->{error_message} = $locale->text('The session is invalid or has expired.');
- login_screen();
- exit;
-}
-
-my $action = $form->{action};
+ $cgi = $::cgi;
+ $form = $::form;
+ $locale = $::locale;
+ $auth = $::auth;
-if (!$action && $auth->{SESSION}->{login}) {
- $action = 'login';
-}
-
-if ($action) {
- our %myconfig = $auth->read_user($form->{login}) if ($form->{login});
+ $form->{stylesheet} = "lx-office-erp.css";
+ $form->{favicon} = "favicon.ico";
- if (!$myconfig{login} || (SL::Auth::OK != $auth->authenticate($form->{login}, $form->{password}, 0))) {
- $form->{error_message} = $locale->text('Incorrect Password!');
+ if (SL::Auth::SESSION_EXPIRED == $session_result) {
+ $form->{error_message} = $locale->text('The session is invalid or has expired.');
login_screen();
exit;
}
+ my $action = $form->{action};
+ if (!$action && $auth->{SESSION}->{login}) {
+ $action = 'login';
+ }
+ if ($action) {
+ our %myconfig = $auth->read_user($form->{login}) if ($form->{login});
+
+ if (!$myconfig{login} || (SL::Auth::OK != $auth->authenticate($form->{login}, $form->{password}, 0))) {
+ $form->{error_message} = $locale->text('Incorrect Password!');
+ login_screen();
+ } else {
+ $auth->set_session_value('login', $form->{login}, 'password', $form->{password});
+ $auth->create_or_refresh_session();
+
+ $form->{titlebar} .= " - $myconfig{name} - $myconfig{dbname}";
+ call_sub($locale->findsub($action));
+ }
+ } else {
+ login_screen();
+ }
- $auth->set_session_value('login', $form->{login}, 'password', $form->{password});
- $auth->create_or_refresh_session();
-
- $form->{titlebar} .= " - $myconfig{name} - $myconfig{dbname}";
- call_sub($locale->findsub($action));
-
-} else {
- login_screen();
+ $::lxdebug->leave_sub;
}
-1;
-
sub login_screen {
$main::lxdebug->enter_sub();
my ($msg) = @_;
my $menu_script = $style_to_script_map{$user->{menustyle}} || '';
# made it this far, execute the menu
- $form->{callback} = build_std_url("script=menu${menu_script}.pl", 'action=display', "callback=" . $form->escape($form->{callback}));
+ # standard redirect does not seem to work for this invocation, (infinite loops?)
+ # do a manual invocation instead
+# $form->{callback} = build_std_url("script=menu${menu_script}.pl", 'action=display', "callback=" . $form->escape($form->{callback}));
$main::auth->set_cookie_environment_variable();
- $form->redirect();
+ $::form->{script} = "menu${menu_script}.pl";
+ $::form->{action} = 'display';
+ $::form->{callback} = $::form->escape($::form->{callback});
+
+ require "bin/mozilla/$::form->{script}";
+ display();
+
+# $form->redirect();
$main::lxdebug->leave_sub();
}
exit;
}
+1;
+
+__END__
use strict;
my $print_post;
-my %TMPL_VAR;
+our %TMPL_VAR;
1;
check_oe_access();
# Container for template variables. Unfortunately this has to be
- # visible in form_footer too, so my at package level and not here.
+ # visible in form_footer too, so package local level and not my here.
%TMPL_VAR = ();
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
#
# Beipiel:
# $LXDebug::global_level = LXDebug::TRACE | LXDebug::QUERY;
-$LXDebug::global_level = LXDebug::NONE;
+$LXDebug::global_level = LXDebug->NONE;
# Überwachung der Inhalte von $form aktiviert oder nicht? Wenn ja,
# dann können einzelne Variablen mit
+++ /dev/null
-#!/usr/bin/perl
-#
-
-use strict;
-
-BEGIN {
- 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.
-}
-
-use SL::LXDebug;
-our $lxdebug = LXDebug->new();
-
-use SL::Auth;
-use SL::Form;
-use SL::Locale;
-
-eval { require "config/lx-erp.conf"; };
-eval { require "config/lx-erp-local.conf"; } if (-f "config/lx-erp-local.conf");
-
-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();
-
-our %myconfig = $auth->read_user($form->{login});
-
-our $locale = new Locale "$myconfig{countrycode}", "kopf";
-
-delete $form->{password};
-
-eval { require "bin/mozilla/kopf.pl"; };
--- /dev/null
+admin.pl
\ No newline at end of file
'restore_dataset' => 'restore_dataset',
'restore_dataset_start' => 'restore_dataset_start',
'retrieve_partunits' => 'retrieve_partunits',
+ 'run' => 'run',
'sales_invoice' => 'sales_invoice',
'save' => 'save',
'save_group' => 'save_group',
+++ /dev/null
-#!/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 sets up the terminal and runs the scripts
-# in bin/$terminal directory
-# admin.pl is linked to this script
-#
-#######################################################################
-
-use strict;
-
-BEGIN {
- 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.
-}
-
-# setup defaults, DO NOT CHANGE
-$main::userspath = "users";
-$main::templates = "templates";
-$main::memberfile = "users/members";
-$main::sendmail = "| /usr/sbin/sendmail -t";
-########## end ###########################################
-
-$| = 1;
-
-use SL::LXDebug;
-$main::lxdebug = LXDebug->new();
-
-eval { require "config/lx-erp.conf"; };
-eval { require "config/lx-erp-local.conf"; } if -f "config/lx-erp-local.conf";
-
-if ($ENV{CONTENT_LENGTH}) {
- read(STDIN, $_, $ENV{CONTENT_LENGTH});
-}
-
-if ($ENV{QUERY_STRING}) {
- $_ = $ENV{QUERY_STRING};
-}
-
-if ($ARGV[0]) {
- $_ = $ARGV[0];
-}
-
-my %form = split /[&=]/;
-
-# fix for apache 2.0 bug
-map { $form{$_} =~ s/\\$// } keys %form;
-
-# name of this script
-$0 =~ tr/\\/\//;
-my $pos = rindex $0, '/';
-my $script = substr($0, $pos + 1);
-
-$form{login} =~ s|.*/||;
-
-if (-e "$main::userspath/nologin" && $script ne 'admin.pl') {
- print "content-type: text/plain
-
-Login disabled!\n";
-
- exit;
-}
-
-require "bin/mozilla/installationcheck.pl";
-verify_installation();
-
-$ARGV[0] = "$_&script=$script";
-require "bin/mozilla/$script";
-
-# end of main
-
--- /dev/null
+admin.pl
\ No newline at end of file