X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/4dbb09950c9f5596646537c12d991c99086fe7c1..0dfd8e90aa330f6b4b53f89f0eadf6f1e018a662:/SL/Form.pm
diff --git a/SL/Form.pm b/SL/Form.pm
index 5c2b57379..b6f62fb91 100644
--- a/SL/Form.pm
+++ b/SL/Form.pm
@@ -1,4 +1,4 @@
-#=====================================================================
+#====================================================================
# LX-Office ERP
# Copyright (C) 2004
# Based on SQL-Ledger Version 2.1.9
@@ -37,15 +37,17 @@
package Form;
+use HTML::Template;
+
sub _input_to_hash {
$main::lxdebug->enter_sub();
my $input = $_[0];
- my %in = ();
+ my %in = ();
my @pairs = split(/&/, $input);
foreach (@pairs) {
- my ($name, $value) = split(/=/,$_,2);
+ my ($name, $value) = split(/=/, $_, 2);
$in{$name} = unescape(undef, $value);
}
@@ -58,33 +60,38 @@ sub _request_to_hash {
$main::lxdebug->enter_sub();
my ($input) = @_;
- my ($i, $loc, $key, $val);
- my (%ATTACH, $f, $header, $header_body, $len, $buf);
- my ($boundary, @list, $size, $body, $x, $blah, $name);
+ my ($i, $loc, $key, $val);
+ my (%ATTACH, $f, $header, $header_body, $len, $buf);
+ my ($boundary, @list, $size, $body, $x, $blah, $name);
- if ($ENV{'CONTENT_TYPE'} &&
- ($ENV{'CONTENT_TYPE'} =~ /multipart\/form-data; boundary=(.+)$/)) {
+ if ($ENV{'CONTENT_TYPE'}
+ && ($ENV{'CONTENT_TYPE'} =~ /multipart\/form-data; boundary=(.+)$/)) {
$boundary = quotemeta('--' . $1);
- @list = split(/$boundary/, $input);
+ @list = split(/$boundary/, $input);
+
# For some reason there are always 2 extra, that are empty
- $size = @list -2 ;
+ $size = @list - 2;
for ($x = 1; $x <= $size; $x++) {
$header_body = $list[$x];
$header_body =~ /\r\n\r\n|\n\n/;
+
# Here we split the header and body
$header = $`;
- $body = $'; #'
+ $body = $'; #'
$body =~ s/\r\n$//;
+
# Now we try to get the file name
$name = $header;
$name =~ /name=\"(.+)\"/;
($name, $blah) = split(/\"/, $1);
+
# If the form name is not attach, then we need to parse this like
# regular form data
if ($name ne "attach") {
$body =~ s/%([0-9a-fA-Z]{2})/pack("c",hex($1))/eg;
$ATTACH{$name} = $body;
+
# Otherwise it is an attachment and we need to finish it up
} elsif ($name eq "attach") {
$header =~ /filename=\"(.+)\"/;
@@ -93,10 +100,10 @@ sub _request_to_hash {
$ATTACH{'FILE_NAME'} =~ s/\s//g;
$ATTACH{'FILE_CONTENT'} = $body;
- for($i = $x; $list[$i]; $i++) {
+ for ($i = $x; $list[$i]; $i++) {
$list[$i] =~ s/^.+name=$//;
$list[$i] =~ /\"(\w+)\"/;
- $ATTACH{$1} = $'; #'
+ $ATTACH{$1} = $'; #'
}
}
}
@@ -104,7 +111,7 @@ sub _request_to_hash {
$main::lxdebug->leave_sub();
return %ATTACH;
- } else {
+ } else {
$main::lxdebug->leave_sub();
return _input_to_hash($input);
}
@@ -135,15 +142,13 @@ sub new {
$self->{action} = lc $self->{action};
$self->{action} =~ s/( |-|,|#)/_/g;
- $self->{version} = "2.1.2";
- $self->{dbversion} = "2.1.2";
+ $self->{version} = "2.2.0";
$main::lxdebug->leave_sub();
bless $self, $type;
}
-
sub debug {
$main::lxdebug->enter_sub();
@@ -156,7 +161,6 @@ sub debug {
$main::lxdebug->leave_sub();
}
-
sub escape {
$main::lxdebug->enter_sub();
@@ -174,7 +178,6 @@ sub escape {
return $str;
}
-
sub unescape {
$main::lxdebug->enter_sub();
@@ -190,6 +193,47 @@ sub unescape {
return $str;
}
+sub quote {
+ my ($self, $str) = @_;
+
+ if ($str && !ref($str)) {
+ $str =~ s/"/"/g;
+ }
+
+ $str;
+
+}
+
+sub unquote {
+ my ($self, $str) = @_;
+
+ if ($str && !ref($str)) {
+ $str =~ s/"/"/g;
+ }
+
+ $str;
+
+}
+
+sub hide_form {
+ my $self = shift;
+
+ if (@_) {
+ for (@_) {
+ print qq|\n|;
+ }
+ } else {
+ delete $self->{header};
+ for (sort keys %$self) {
+ print qq|\n|;
+ }
+ }
+
+}
sub error {
$main::lxdebug->enter_sub();
@@ -200,17 +244,7 @@ sub error {
$msg =~ s/\n/
/g;
$self->header;
-
- print qq|
-
$msg - - -