sub _store_value {
$main::lxdebug->enter_sub(2);
- my $self = shift;
+ my $curr = shift;
my $key = shift;
my $value = shift;
- my $curr = $self;
-
while ($key =~ /\[\+?\]\.|\./) {
substr($key, 0, $+[0]) = '';
sub _input_to_hash {
$main::lxdebug->enter_sub(2);
- my $self = shift;
- my $input = shift;
+ my $params = shift;
+ my $input = shift;
- my @pairs = split(/&/, $input);
+ my @pairs = split(/&/, $input);
foreach (@pairs) {
my ($key, $value) = split(/=/, $_, 2);
- $self->_store_value($self->unescape($key), $self->unescape($value));
+ _store_value($params, unescape(undef, $key), unescape(undef, $value));
}
$main::lxdebug->leave_sub(2);
sub _request_to_hash {
$main::lxdebug->enter_sub(2);
- my $self = shift;
- my $input = shift;
+ my $params = shift;
+ my $input = shift;
if (!$ENV{'CONTENT_TYPE'}
|| ($ENV{'CONTENT_TYPE'} !~ /multipart\/form-data\s*;\s*boundary\s*=\s*(.+)$/)) {
- $self->_input_to_hash($input);
+ _input_to_hash($params, $input);
$main::lxdebug->leave_sub(2);
return;
substr $line, $-[0], $+[0] - $-[0], "";
}
- $previous = $self->_store_value($name, '');
- $self->{FILENAME} = $filename if ($filename);
+ $previous = _store_value($params, $name, '');
+ $params->{FILENAME} = $filename if ($filename);
next;
}
$main::lxdebug->leave_sub(2);
}
+sub _recode_recursively {
+ my ($iconv, $param) = @_;
+
+ if (ref $param eq 'HASH') {
+ foreach my $key (keys %{ $param }) {
+ if (!ref $param->{$key}) {
+ $param->{$key} = $iconv->convert($param->{$key});
+ } else {
+ _recode_recursively($iconv, $param->{$key});
+ }
+ }
+
+ } elsif (ref $param eq 'ARRAY') {
+ foreach my $idx (0 .. scalar(@{ $param }) - 1) {
+ if (!ref $param->[$idx]) {
+ $param->[$idx] = $iconv->convert($param->[$idx]);
+ } else {
+ _recode_recursively($iconv, $param->[$idx]);
+ }
+ }
+ }
+}
+
sub new {
$main::lxdebug->enter_sub();
bless $self, $type;
- $self->_request_to_hash($_);
+ my $parameters = { };
+ _request_to_hash($parameters, $_);
+
+ my $db_charset = $main::dbcharset;
+ $db_charset ||= Common::DEFAULT_CHARSET;
+
+ if ($parameters->{INPUT_ENCODING} && (lc $parameters->{INPUT_ENCODING} ne $db_charset)) {
+ require Text::Iconv;
+ my $iconv = Text::Iconv->new($parameters->{INPUT_ENCODING}, $db_charset);
+
+ _recode_recursively($iconv, $parameters);
+
+ delete $parameters{INPUT_ENCODING};
+ }
+
+ map { $self->{$_} = $parameters->{$_}; } keys %{ $parameters };
$self->{action} = lc $self->{action};
$self->{action} =~ s/( |-|,|\#)/_/g;
var description = document.getElementsByName("description_" + row)[0].value;
} else var action = "calculate_qty";
url = "common.pl?" +
+ "INPUT_ENCODING=UTF-8&" +
"action=" + action + "&" +
"name=" + encodeURIComponent(name) + "&" +
"input_name=" + encodeURIComponent(input_name) + "&" +
var parm = centerParms(600,500) + ",width=600,height=500,status=yes,scrollbars=yes";
var name = document.getElementsByName(input_name)[0].value;
url = "common.pl?" +
+ "INPUT_ENCODING=UTF-8&" +
"action=set_longdescription&" +
"longdescription=" + encodeURIComponent(document.getElementsByName(input_name)[0].value) + "&" +
"input_name=" + encodeURIComponent(input_name) + "&"
var parm = centerParms(800,600) + ",width=800,height=600,status=yes,scrollbars=yes";
var name = document.getElementsByName(input_name)[0].value;
url = "common.pl?" +
+ "INPUT_ENCODING=UTF-8&" +
"action=cov_selection_internal&" +
"name=" + encodeURIComponent(name) + "&" +
"input_name=" + encodeURIComponent(input_name) + "&" +
var parm = centerParms(600,500) + ",width=600,height=500,status=yes,scrollbars=yes";
var name = document.getElementsByName(input_name)[0].value;
url = "common.pl?" +
+ "INPUT_ENCODING=UTF-8&" +
"action=delivery_customer_selection&" +
"name=" + encodeURIComponent(name) + "&" +
"input_name=" + encodeURIComponent(input_name) + "&" +
function set_email_window(input_subject, input_body, input_attachment) {
var parm = centerParms(800,600) + ",width=800,height=600,status=yes,scrollbars=yes";
var url = "dn.pl?" +
+ "INPUT_ENCODING=UTF-8&" +
"action=set_email&" +
"email_subject=" + encodeURIComponent(document.getElementsByName(input_subject)[0].value) + "&" +
"email_body=" + encodeURIComponent(document.getElementsByName(input_body)[0].value) + "&" +
var parm = centerParms(width, height) + ",width=" + width + ",height=" + height + ",status=yes,scrollbars=yes";
url = "fu.pl?" +
+ "INPUT_ENCODING=UTF-8&" +
"action=add" + "&" +
"POPUP_MODE=1";
options = "";
url = "common.pl?" +
+ "INPUT_ENCODING=UTF-8&" +
"action=part_selection_internal&" +
"partnumber=" + encodeURIComponent(partnumber) + "&" +
"description=" + encodeURIComponent(description) + "&" +
var parm = centerParms(600,500) + ",width=600,height=500,status=yes,scrollbars=yes";
var name = document.getElementsByName(input_name)[0].value;
url = "ic.pl?" +
+ "INPUT_ENCODING=UTF-8&" +
"action=parts_language_selection&" +
"id=" + encodeURIComponent(document.ic.id.value) + "&" +
"language_values=" + encodeURIComponent(document.ic.language_values.value) + "&" +
var parm = centerParms(800,500) + ",width=800,height=500,status=yes,scrollbars=yes";
var name = "History";
url = "common.pl?" +
+ "INPUT_ENCODING=UTF-8&" +
"action=show_history&" +
"longdescription=" + "&" +
"input_name=" + encodeURIComponent(id) + "&"
if (vc_id)
vc_id = vc_id[0].value;
url = "common.pl?" +
+ "INPUT_ENCODING=UTF-8&" +
"action=show_vc_details&" +
"vc=" + encodeURIComponent(vc) + "&" +
"vc_id=" + encodeURIComponent(vc_id)
var delivered = document.getElementsByName("delivered")[0].value;
url = "do.pl?" +
+ "INPUT_ENCODING=UTF-8&" +
"action=stock_in_out_form&" +
"in_out=" + encodeURIComponent(in_out) + "&" +
"row=" + encodeURIComponent(row) + "&" +
var parm = centerParms(600,500) + ",width=600,height=500,status=yes,scrollbars=yes";
var name = document.getElementsByName(input_name)[0].value;
url = "common.pl?" +
+ "INPUT_ENCODING=UTF-8&" +
"action=vendor_selection&" +
"name=" + encodeURIComponent(name) + "&" +
"input_name=" + encodeURIComponent(input_name) + "&" +
<!--
function open_connection_test_window() {
// host name port user passwd
- var url = "admin.pl?action=test_db_connection&" +
+ var url = "admin.pl?INPUT_ENCODING=UTF-8&action=test_db_connection&" +
"dbhost=" + encodeURIComponent(get_input_value("dbhost")) + "&" +
"dbport=" + encodeURIComponent(get_input_value("dbport")) + "&" +
"dbname=" + encodeURIComponent(get_input_value("dbname")) + "&" +
<!--
function open_connection_test_window() {
// host name port user passwd
- var url = "admin.pl?action=test_db_connection&" +
+ var url = "admin.pl?INPUT_ENCODING=UTF-8&action=test_db_connection&" +
"dbhost=" + encodeURIComponent(get_input_value("dbhost")) + "&" +
"dbport=" + encodeURIComponent(get_input_value("dbport")) + "&" +
"dbname=" + encodeURIComponent(get_input_value("dbname")) + "&" +