Ignore:
Timestamp:
07/27/10 13:15:56 (14 years ago)
Author:
Kris Deugau
Message:

/branches/htmlform

Switch all scripts to use CGI::Simple for HTML form data munging
instead of legacy CommonWeb.pm sub. Remove parse_post() sub from
CommonWeb.pm. See #15.

Location:
branches/htmlform/cgi-bin
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/htmlform/cgi-bin/CommonWeb.pm

    r415 r447  
    1616$VERSION     = 1.00;
    1717@ISA         = qw(Exporter);
    18 @EXPORT_OK      = qw(&parse_post &printFooter &printHeader &printError &printAndExit &desanitize &cleanInput &desanitize);
     18@EXPORT_OK      = qw(&printFooter &printHeader &printError &printAndExit &desanitize &cleanInput &desanitize);
    1919
    2020@EXPORT      = (); #export nothing by default
    21 %EXPORT_TAGS = ( ALL => [qw( &parse_post &printFooter &printHeader &printError
     21%EXPORT_TAGS = ( ALL => [qw( &printFooter &printHeader &printError
    2222                                &printAndExit &desanitize &cleanInput )],
    23                  lean    => [qw( &parse_post &printFooter &printHeader &printError
     23                 lean    => [qw( &printFooter &printHeader &printError
    2424                                &printAndExit &cleanInput )]
    2525                );
    26 
    27 sub parse_post {
    28   my $buffer;
    29   if ($ENV{'REQUEST_METHOD'} eq "GET") {
    30     $buffer=$ENV{'QUERY_STRING'}
    31   } elsif ($ENV{'REQUEST_METHOD'} eq 'POST' && $ENV{'CONTENT_TYPE'} eq "application/x-www-form-urlencoded") {
    32     read(STDIN, $buffer, $ENV{CONTENT_LENGTH});
    33   } else {
    34     $buffer = $ENV{'QUERY_STRING'};
    35     $buffer || read(STDIN, $buffer, $ENV{CONTENT_LENGTH});
    36   }
    37   my @pairs = split(/&/, $buffer);
    38   my %webvarLocal;
    39   foreach my $pair (@pairs) {
    40     my ($name, $value) = split(/=/, $pair);
    41     $name  =~ tr/+/ /;
    42     $name  =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    43     $value =~ tr/+/ /;
    44     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    45     $value =~ s/\'/\\\'/g;
    46     $webvarLocal{$name} = $value;
    47   }
    48   return %webvarLocal;
    49 }
    5026
    5127
  • branches/htmlform/cgi-bin/admin.cgi

    r438 r447  
    1515use warnings;
    1616use CGI::Carp qw(fatalsToBrowser);
     17use CGI::Simple;
    1718use DBI;
    1819use CommonWeb qw(:ALL);
     
    6263}
    6364
    64 my %webvar = parse_post();
    65 cleanInput(\%webvar);
     65# Set up the CGI object...
     66my $q = new CGI::Simple;
     67# ... and get query-string params as well as POST params if necessary
     68$q->parse_query_string;
     69
     70# Convenience;  saves changing all references to %webvar
     71##fixme:  tweak for handling <select multiple='y' size=3> (list with multiple selection)
     72my %webvar = $q->Vars;
    6673
    6774print "Content-type: text/html\n\n".
  • branches/htmlform/cgi-bin/main.cgi

    r442 r447  
    1212use warnings;   
    1313use CGI::Carp qw(fatalsToBrowser);
     14use CGI::Simple;
    1415use DBI;
    1516use CommonWeb qw(:ALL);
     
    5556
    5657
    57 # Global variables
    58 my %webvar = parse_post();
    59 cleanInput(\%webvar);
     58# Set up the CGI object...
     59my $q = new CGI::Simple;
     60# ... and get query-string params as well as POST params if necessary
     61$q->parse_query_string;
     62
     63# Convenience;  saves changing all references to %webvar
     64##fixme:  tweak for handling <select multiple='y' size=3> (list with multiple selection)
     65my %webvar = $q->Vars;
    6066
    6167
  • branches/htmlform/cgi-bin/newcity.cgi

    r431 r447  
    1313use warnings;
    1414#use CGI::Carp qw(fatalsToBrowser);
     15use CGI::Simple;
    1516use DBI;
    1617use CommonWeb qw(:ALL);
     
    3536}
    3637
    37 my %webvar = parse_post();
    38 cleanInput(\%webvar);
     38# Set up the CGI object...
     39my $q = new CGI::Simple;
     40# ... and get query-string params as well as POST params if necessary
     41$q->parse_query_string;
     42
     43# Convenience;  saves changing all references to %webvar
     44##fixme:  tweak for handling <select multiple='y' size=3> (list with multiple selection)
     45my %webvar = $q->Vars;
    3946
    4047my ($dbh,$errstr) = connectDB_My;
  • branches/htmlform/cgi-bin/newnode.cgi

    r417 r447  
    1313use warnings;
    1414#use CGI::Carp qw(fatalsToBrowser);
     15use CGI::Simple;
    1516use DBI;
    1617use CommonWeb qw(:ALL);
     
    3435}
    3536
    36 my %webvar = parse_post();
    37 cleanInput(\%webvar);
     37# Set up the CGI object...
     38my $q = new CGI::Simple;
     39# ... and get query-string params as well as POST params if necessary
     40$q->parse_query_string;
     41
     42# Convenience;  saves changing all references to %webvar
     43##fixme:  tweak for handling <select multiple='y' size=3> (list with multiple selection)
     44my %webvar = $q->Vars;
    3845
    3946my ($dbh,$errstr) = connectDB_My;
  • branches/htmlform/cgi-bin/search.cgi

    r439 r447  
    1414use warnings;   
    1515use CGI::Carp qw(fatalsToBrowser);
     16use CGI::Simple;
    1617use DBI;
    1718use CommonWeb qw(:ALL);
     
    5253# Global variables
    5354my $RESULTS_PER_PAGE = 25;
    54 my %webvar = parse_post();
    55 cleanInput(\%webvar);
     55
     56# Set up the CGI object...
     57my $q = new CGI::Simple;
     58# ... and get query-string params as well as POST params if necessary
     59$q->parse_query_string;
     60
     61# Convenience;  saves changing all references to %webvar
     62##fixme:  tweak for handling <select multiple='y' size=3> (list with multiple selection)
     63my %webvar = $q->Vars;
    5664
    5765if (defined($webvar{rpp})) {
  • branches/htmlform/cgi-bin/snCalc.cgi

    r371 r447  
    44use warnings;   
    55use CGI::Carp qw(fatalsToBrowser);
     6use CGI::Simple;
    67use NetAddr::IP;
    78use CommonWeb qw(:ALL);;
     
    910#file snCalc.cgi        little subnet calculator app
    1011
    11 my %webvar = parse_post();
     12# Set up the CGI object...
     13my $q = new CGI::Simple;
     14# ... and get query-string params as well as POST params if necessary
     15$q->parse_query_string;
     16
     17# Convenience;  saves changing all references to %webvar
     18##fixme:  tweak for handling <select multiple='y' size=3> (list with multiple selection)
     19my %webvar = $q->Vars;
     20
    1221my $input;
    1322
Note: See TracChangeset for help on using the changeset viewer.