si , se que es perl pero no sabia donde ponerlo, y si es q no me cabia el codigo completo , podria ponerlo en varias veces si ves que es mejor y asi quedaria completo, vuelvo a ponerlo completo a ver q tal
1º PARTE DEL CODIGO
Código perl:
Ver original#!/usr/bin/perl
$header = "header.html";
$footer = "footer.html";
$mailprogram = "smtp.gmail.com";
$returnpage = "/";
$csvfilename = "orders.csv";
$csvquote = "\"\"";
$mode = "FILE";
#These are required fields. I recommend enforcing these by javascript,
#but let's just make sure here as well.
@required = (
'b_first',
'b_last',
'b_addr',
'b_city',
'b_state',
'b_zip',
'b_phone',
'b_email'
);
FUNCTION: urlDecode
RETURNS: The decoded string.
PARAMETERS: An encoded string.
PURPOSE: Decodes a URL encoded string.
sub urlDecode {
my ($string) = @_;
$string =~ tr/+/ /;
$string =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex($1))/eg;
$string =~ s/['"]/\'/g;
}
#FUNCTION: processCGI
sub processCGI {
local ($cgiData, $key, $value, $pair, @pairs);
if ($ENV{'REQUEST_METHOD'} eq 'GET') { $cgiData = $ENV{'QUERY_STRING'}; }
else { $cgiData = <STDIN>; }
@pairs = split (/&/, $cgiData); foreach $pair (@pairs) {
($key, $value) = split (/\=/, $pair); $key = &urlDecode($key);
$value = &urlDecode($value);
${$key} .= ", ".$value;
}else{
${$key} = $value;
}
}
}
FUNCTION: doFormError
sub doFormError {
my ($errString) = @_;
@LINES = <HEAD>;
print "Content-type: text/html\n\n";
print "<FONT SIZE=+2>The form you submitted was not complete.<BR><BR></FONT>"; print "$errString<BR><BR>\n"; print "<INPUT TYPE=BUTTON ONCLICK='history.back()' VALUE=' Return to the checkout page '><HR>";
@LINES = <FOOT>;
}
#FUNCTION: doError
ub doError {
my ($errString) = @_;
print "Content-type: text/html\n\n";
@LINES = <HEAD>;
print "$errString<BR><BR>\n";
@LINES = <FOOT>;
}
FUNCTION: invalidE
sub invalidE {
my ($szEmail) = @_;
my ($user, $host);
$szEmail =~ tr/A-Z/a-z/;
if ($szEmail =~ /\s/) { return 1; } ($user, $host) = split (/\@/, $szEmail); if ($host =~ /compuserve/i) { ; }
else {
if (! $user =~ /\D/) { return 1; } if (! $host =~ /\D/) { return 1; } }
if ($szEmail =~ /\w+\@[\w|\.]/) { return 0; } }
sub populateDateVar {
@months = ();
push(@months,"February"); push(@months,"September"); push(@months,"November"); push(@months,"December"); @days = ();
($sec,$min,$hour,$day,$month,$year,$day2) =
if ($sec < 10) { $sec = "0$sec"; }
if ($min < 10) { $min = "0$min"; }
if ($hour < 10) { $hour = "0$hour"; }
if ($day < 10) { $day = "0$day"; }
$year += "1900";
#$todaysdate = "$months[$month] $day, $year $hour:$min:$sec";
}
MAIN
# process the form input.
&processCGI;
&populateDateVar;
foreach $check(@required) {
unless ($check) {
doFormError("It appears that you forgot to fill in the <strong>$check</strong> field.");
}
}
# checks for valid email address
if( &invalidE($b_email) ){
doFormError('You submitted an invalid email address.');
}