#!/usr/bin/perl -Tw #warnings and taint mode now enabled use CGI; use strict; $CGI::POST_MAX=1024 * 500; # max 500k post $CGI::DISABLE_UPLOADS = 1; # No uploads print "Content-type:text/html\n\n"; my $temp; $temp = "$ENV{'QUERY_STRING'}"; $temp =~ tr/\/A-Za-z0-9_.-//dc; $temp =~ s/\.+\///g; if( $temp =~ m#(^.+\.{1}?\w+)# ) { $temp= "../www$1"; } else { dienice "Invalid template file name..."; } #you may now use the CGI methods. my ($query) = new CGI; my (@values, $key, $i, @fary); foreach $key ($query->param) { $i = $query->param($key); if ($key =~ /required/i) {if ( ($i eq "") && ($i == "") ) {failure();}} } open(INF, "< $temp") or dienice("Cant open $temp"); seek(INF,0,0); @fary = ; close (INF); foreach $key ($query->param) { @values = $query->param($key); foreach $i (@fary) {$i =~ s/\[$key\]/@values/g;} } my $mailprog = '/usr/lib/sendmail'; open (MAIL, "|$mailprog -t") or dienice("Can't access $mailprog!\n"); foreach $i (@fary) { print MAIL "$i"; } close (MAIL); my $url = $query->param('success'); print "\n\n"; print "If you are not forwarded in 5 seconds, please click here.<\/a>"; exit; sub failure { my $url = $query->param('failure'); print "\n\n"; print "If you are not forwarded in 5 seconds, please click here.<\/a>"; exit; } sub dienice { my($errmsg) = @_; my($webmaster) = 'webmaster@mydomain.com'; print <Error!!The error was $errmsg Eof exit; }