sub GetFormVars { #- Var Declaration And Initialization my ($hr_self,$hr_module) = @_; # Retrieve the form variables $hr_module->{FORM} = $hr_module->{cgi}->Vars; # Retrieve the user's IP $hr_module->{FORM}{ip} = $ENV{REMOTE_ADDR}; # Iterate through the hash and transform the keys foreach my $key(keys %{$hr_module->{FORM}}) { my $new_key = $key; # Change spaces to underscores and remove any trailing or leading spaces $new_key =~ s/^\s+//; $new_key =~ s/\s+$//; $new_key =~ s/\s+/_/g; # If there has been a change... if ($new_key ne $key) { # Make all keys lower case $new_key = lc $new_key; # Create the new hash element $hr_module->{FORM}{$new_key} = $hr_module->{FORM}{$key}; # Remove the old key/value pair delete $hr_module->{FORM}{$key}; } # Reset the key value $key = $new_key; # Stop people from using subshells to execute commands. $hr_module->{FORM}{$key} =~ s/~!/ ~!/g; my $value = $hr_module->{FORM}{$key}; # Check for comments and stuff in the string if ($value =~ m/\<\!--\#(.*)\s+(.*)\s?=\s?(.*)--\>/ || $value =~ m/[;><\*`\|]/) { # Blank out the value undef ($hr_module->{FORM}{$key}); # Set an error message and return 0 return $hr_self->PrepareErrorMessage(10403, {'\$hr_self->{FORM}{ip}'=>$hr_module->{FORM}{ip}}); } # If this is a command, modify the value by changing spaces to # underscores and making it all lower case map {s/\s+/_/g;$hr_module->{FORM}{$key} = lc;} $hr_module->{FORM}{$key} if $key eq 'cmd'; } return 1; }