diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-03-16 06:00:09 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-03-16 06:00:09 +0000 |
commit | ade367296c479b593370a659c6c75c24c8c73526 (patch) | |
tree | d7647ad208e53f5fe97a9eab840a226df5d80ae0 | |
parent | 547e6b5f1273da8fa7ad04883cd44e061c8bd975 (diff) |
Moved LedgerSMB::new to use CGI.pm for parameter parsing.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@916 4979c152-3d1c-0410-bac9-87ea11338e46
-rwxr-xr-x | LedgerSMB.pm | 68 |
1 files changed, 20 insertions, 48 deletions
diff --git a/LedgerSMB.pm b/LedgerSMB.pm index 2b02c052..3a06bacf 100755 --- a/LedgerSMB.pm +++ b/LedgerSMB.pm @@ -72,7 +72,8 @@ $msg. =item redo_rows (fields => \@list, count => $integer, [index => $string); This function is undergoing serious redesign at the moment. If index is defined, that field is used for ordering the rows. If not, runningnumber is -used. +used. Behavior is not defined when index points to a field containing +non-numbers. =head1 Copyright (C) 2006, The LedgerSMB core team. @@ -98,6 +99,7 @@ used. #====================================================================== =cut +use CGI; use Math::BigFloat lib=>'GMP'; use LedgerSMB::Sysconfig; use Data::Dumper; @@ -107,43 +109,29 @@ package LedgerSMB; sub new { - # This will probably be the last to be revised. - # Based on SQL-Ledger's Form::new + my $type = shift @_; + my $argstr = shift @_; - my $type = shift; - - my $argstr = shift; - - read(STDIN, $_, $ENV{CONTENT_LENGTH}); - - if ($argstr){ - $_ = $argstr; - } - elsif ($ENV{QUERY_STRING}) { - $_ = $ENV{QUERY_STRING}; - } - - elsif ($ARGV[0]) { - $_ = $ARGV[0]; - } - my $self = {}; - %$self = split /[&=]/; - for (keys %$self) { $self->{$_} = unescape("", $self->{$_}) } + $self->{version} = "1.3.0 Alpha 0 Pre"; + $self->{dbversion} = "1.2.0"; + bless $self, $type; + + my $query = ($argstr) ? new CGI($argstr) : new CGI; + my $params = $query->Vars; - if (substr($self->{action}, 0, 1) !~ /( |\.)/) { - $self->{action} = lc $self->{action}; - $self->{action} =~ s/( |-|,|\#|\/|\.$)/_/g; - } + $self->merge($params); - $self->{menubar} = 1 if $self->{path} =~ /lynx/i; - #menubar will be deprecated, replaced with below - $self->{lynx} = 1 if $self->{path} =~ /lynx/i; + $self->{action} =~ s/\W/_/g; + $self->{action} = lc $self->{action}; - $self->{version} = "1.3.0 Alpha 0 Pre"; - $self->{dbversion} = "1.2.0"; + if ($self->{path} =~ /lynx/i){ + $self->{menubar} = 1; + #menubar will be deprecated, replaced with below + $self->{lynx} = 1; + } - bless $self, $type; + $self; } @@ -178,22 +166,6 @@ sub escape { } -sub unescape { - # Based on SQL-Ledger's Form::unescape - my ($self) = @_; - my %args = @_; - my $str = $args{string}; - - $str =~ tr/+/ /; - $str =~ s/\\$//; - - $str =~ s/%([0-9a-fA-Z]{2})/pack("c",hex($1))/eg; - $str =~ s/\r?\n/\n/g; - - $str; - -} - sub is_blank { my $self = shift @_; my %args = @_; |