- Timestamp:
- 07/27/10 13:15:56 (14 years ago)
- Location:
- branches/htmlform/cgi-bin
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/htmlform/cgi-bin/CommonWeb.pm
r415 r447 16 16 $VERSION = 1.00; 17 17 @ISA = qw(Exporter); 18 @EXPORT_OK = qw(&p arse_post &printFooter &printHeader &printError &printAndExit &desanitize &cleanInput &desanitize);18 @EXPORT_OK = qw(&printFooter &printHeader &printError &printAndExit &desanitize &cleanInput &desanitize); 19 19 20 20 @EXPORT = (); #export nothing by default 21 %EXPORT_TAGS = ( ALL => [qw( &p arse_post &printFooter &printHeader &printError21 %EXPORT_TAGS = ( ALL => [qw( &printFooter &printHeader &printError 22 22 &printAndExit &desanitize &cleanInput )], 23 lean => [qw( &p arse_post &printFooter &printHeader &printError23 lean => [qw( &printFooter &printHeader &printError 24 24 &printAndExit &cleanInput )] 25 25 ); 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 }50 26 51 27 -
branches/htmlform/cgi-bin/admin.cgi
r438 r447 15 15 use warnings; 16 16 use CGI::Carp qw(fatalsToBrowser); 17 use CGI::Simple; 17 18 use DBI; 18 19 use CommonWeb qw(:ALL); … … 62 63 } 63 64 64 my %webvar = parse_post(); 65 cleanInput(\%webvar); 65 # Set up the CGI object... 66 my $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) 72 my %webvar = $q->Vars; 66 73 67 74 print "Content-type: text/html\n\n". -
branches/htmlform/cgi-bin/main.cgi
r442 r447 12 12 use warnings; 13 13 use CGI::Carp qw(fatalsToBrowser); 14 use CGI::Simple; 14 15 use DBI; 15 16 use CommonWeb qw(:ALL); … … 55 56 56 57 57 # Global variables 58 my %webvar = parse_post(); 59 cleanInput(\%webvar); 58 # Set up the CGI object... 59 my $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) 65 my %webvar = $q->Vars; 60 66 61 67 -
branches/htmlform/cgi-bin/newcity.cgi
r431 r447 13 13 use warnings; 14 14 #use CGI::Carp qw(fatalsToBrowser); 15 use CGI::Simple; 15 16 use DBI; 16 17 use CommonWeb qw(:ALL); … … 35 36 } 36 37 37 my %webvar = parse_post(); 38 cleanInput(\%webvar); 38 # Set up the CGI object... 39 my $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) 45 my %webvar = $q->Vars; 39 46 40 47 my ($dbh,$errstr) = connectDB_My; -
branches/htmlform/cgi-bin/newnode.cgi
r417 r447 13 13 use warnings; 14 14 #use CGI::Carp qw(fatalsToBrowser); 15 use CGI::Simple; 15 16 use DBI; 16 17 use CommonWeb qw(:ALL); … … 34 35 } 35 36 36 my %webvar = parse_post(); 37 cleanInput(\%webvar); 37 # Set up the CGI object... 38 my $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) 44 my %webvar = $q->Vars; 38 45 39 46 my ($dbh,$errstr) = connectDB_My; -
branches/htmlform/cgi-bin/search.cgi
r439 r447 14 14 use warnings; 15 15 use CGI::Carp qw(fatalsToBrowser); 16 use CGI::Simple; 16 17 use DBI; 17 18 use CommonWeb qw(:ALL); … … 52 53 # Global variables 53 54 my $RESULTS_PER_PAGE = 25; 54 my %webvar = parse_post(); 55 cleanInput(\%webvar); 55 56 # Set up the CGI object... 57 my $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) 63 my %webvar = $q->Vars; 56 64 57 65 if (defined($webvar{rpp})) { -
branches/htmlform/cgi-bin/snCalc.cgi
r371 r447 4 4 use warnings; 5 5 use CGI::Carp qw(fatalsToBrowser); 6 use CGI::Simple; 6 7 use NetAddr::IP; 7 8 use CommonWeb qw(:ALL);; … … 9 10 #file snCalc.cgi little subnet calculator app 10 11 11 my %webvar = parse_post(); 12 # Set up the CGI object... 13 my $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) 19 my %webvar = $q->Vars; 20 12 21 my $input; 13 22
Note:
See TracChangeset
for help on using the changeset viewer.