summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xLedgerSMB.pm18
-rw-r--r--bin/login.pl2
-rwxr-xr-xlogin.pl90
-rw-r--r--lsmb-request.pl8
-rw-r--r--t/11-ledgersmb.t4
5 files changed, 18 insertions, 104 deletions
diff --git a/LedgerSMB.pm b/LedgerSMB.pm
index a8ccb2d4..ac5c8e29 100755
--- a/LedgerSMB.pm
+++ b/LedgerSMB.pm
@@ -164,10 +164,13 @@ sub new {
#this is an ugly hack we need to rethink.
return $self;
}
-
- $self->{_user} = LedgerSMB::User->fetch_config($self->{login});
my $locale = LedgerSMB::Locale->get_handle($self->{_user}->{countrycode})
or $self->error(__FILE__.':'.__LINE__.": Locale not loaded: $!\n");
+ if ( !${LedgerSMB::Sysconfig::GLOBALDBH} ) {
+ $locale->text("No GlobalDBH Configured or Could not Connect");
+ }
+
+ $self->{_user} = LedgerSMB::User->fetch_config($self->{login});
$self->{_locale} = $locale;
$self->{stylesheet} = $self->{_user}->{stylesheet};
if ( $self->{password} ) {
@@ -242,9 +245,12 @@ sub _get_password {
sub debug {
my $self = shift @_;
- my %args = @_;
- my $file = $args{file};
- my $d = Data::Dumper->new( [@_] );
+ my $args = shift @_;
+ my $file;
+ if (scalar keys %$args){
+ my $file = $args->{'file'};
+ }
+ my $d = Data::Dumper->new( [$self] );
$d->Sortkeys(1);
if ($file) {
@@ -650,7 +656,7 @@ sub _db_init {
if ( $myconfig->{dboptions} ) {
$dbh->do( $myconfig->{dboptions} );
}
-
+ $self->{dbh} = $dbh;
my $query = "SELECT t.extends,
coalesce (t.table_name, 'custom_' || extends)
|| ':' || f.field_name as field_def
diff --git a/bin/login.pl b/bin/login.pl
index 3d0e99b7..b015dbf7 100644
--- a/bin/login.pl
+++ b/bin/login.pl
@@ -255,7 +255,7 @@ sub login {
# upgrade dataset and log in again
if ( !$LedgerSMB::Sysconfig::db_autoupdate ) {
- $form->error( $locale->text("Dabase Version too Old") );
+ $form->error( $locale->text("Database Version too Old") );
}
for (qw(dbname dbhost dbport dbdriver dbuser dbpasswd)) {
diff --git a/login.pl b/login.pl
index c7c3b8e2..5a396335 100755
--- a/login.pl
+++ b/login.pl
@@ -1,91 +1,3 @@
#!/usr/bin/perl
-#
-######################################################################
-# LedgerSMB Accounting and ERP
-
-# http://www.ledgersmb.org/
-#
-# Copyright (C) 2006
-# This work contains copyrighted information from a number of sources all used
-# with permission.
-#
-# This file contains source code included with or based on SQL-Ledger which
-# is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
-# under the GNU General Public License version 2 or, at your option, any later
-# version. For a full list including contact information of contributors,
-# maintainers, and copyright holders, see the CONTRIBUTORS file.
-#
-# Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
-# Copyright (C) 2001
-#
-# Author: Dieter Simader
-# Email: dsimader@sql-ledger.org
-# Web: http://www.sql-ledger.org
-#
-# Contributors:
-#
-#
-# Web: http://www.ledgersmb.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 LedgerSMB::Sysconfig;
-require "common.pl";
-
-$| = 1;
-
-if ( $ENV{CONTENT_LENGTH} ) {
- read( STDIN, $_, $ENV{CONTENT_LENGTH} );
-}
-
-if ( $ENV{QUERY_STRING} ) {
- $_ = $ENV{QUERY_STRING};
-}
-
-if ( $ARGV[0] ) {
- $_ = $ARGV[0];
-}
-
-%form = split /[&=]/;
-
-# fix for apache 2.0 bug
-map { $form{$_} =~ s/\\$// } keys %form;
-
-# name of this script
-$0 =~ tr/\\/\//;
-$pos = rindex $0, '/';
-$script = substr( $0, $pos + 1 );
-
-#This needs to be a db query
-#if (-e "${LedgerSMB::Sysconfig::userspath}/nologin" && $script ne 'admin.pl') {
-# print "Content-Type: text/html\n\n<html><body><strong>";
-# print "\nLogin disabled!\n";
-# print "\n</strong></body></html>";
-# exit;
-#}
-
-$ARGV[0] = $_;
-require "bin/$script";
-
-# end of main
+require 'lsmb-request.pl';
diff --git a/lsmb-request.pl b/lsmb-request.pl
index afc3f2a8..47eec723 100644
--- a/lsmb-request.pl
+++ b/lsmb-request.pl
@@ -36,14 +36,10 @@ use Data::Dumper;
eval { require "custom.pl"; };
$request = new LedgerSMB;
+$request->{action} = '__default' if (!$request->{action});
-$0 =~ m/([^\/\\]*.pl)$/;
-if (!$1){
- $0 =~ m/([^\/\\]*.pl)[? ]/;
-}
-
+$0 =~ m/([^\/\\]*.pl)\?*.*$/;
$script = $1;
-
$locale = LedgerSMB::Locale->get_handle( ${LedgerSMB::Sysconfig::language} )
or $request->error( __FILE__ . ':' . __LINE__ . ": Locale not loaded: $!\n" );
diff --git a/t/11-ledgersmb.t b/t/11-ledgersmb.t
index cdb42507..90dd782f 100644
--- a/t/11-ledgersmb.t
+++ b/t/11-ledgersmb.t
@@ -127,11 +127,11 @@ is($lsmb->num_text_rows('string' => "012345 67890123456789", 'cols' => 10),
my $lsmb = LedgerSMB->new();
@r = trap{$lsmb->debug()};
like($trap->stdout, qr|\n\$VAR1 = bless\( {[\n\s]+'action' => '',[\n\s]+'dbversion' => '\d+\.\d+\.\d+',[\n\s]+'path' => 'bin/mozilla',[\n\s]+'version' => '$lsmb->{version}'[\n\s]+}, 'LedgerSMB' \);|,
- 'debug: $lsmb, no file');
+ 'debug: $lsmb->debug');
SKIP: {
skip 'Environment for file test not clean' if -f "t/var/lsmb-11.$$";
$lsmb->{file} = "t/var/lsmb-11.$$";
- $lsmb->debug('file' => $lsmb->{file}, $lsmb);
+ $lsmb->debug({'file' => $lsmb->{file}});
ok(-f "t/var/lsmb-11.$$", "debug: output file t/var/lsmb-11.$$ created");
open(my $FH, '<', "t/var/lsmb-11.$$");
my @str = <$FH>;