Script imposible
Soy un novato en esto, y tengo que incluuir un pequeño carro de la compra en mi página web. Lo he hecho con un programa gratuito que se llama cibertienda. Lo malo es que al subir el archivo en perl a mi servidor (sync) no me funciona. Le he dado los privilegios 755, le he dado la ruta correcta de perl (/usr/bin/perl) y del sendmail (/usr/sbin/sendmail) estos dos datos facilitados por mi servidor. Ni con esas me funciona. Me da el siguiente error: Premature end of script headers. Te envio el script completo (se llama enviar. Pl) por si es algun error de programacion. Muchas gracias
#!/usr/bin/perl
##############################################################################
# FormMail Version 1.9 #
# Copyright 1995-2001 Matt Wright [email protected] #
# Created 06/09/95 Last Modified 08/03/01 #
# Matt's Script Archive, Inc.: http://www.worldwidemart.com/scripts/ #
##############################################################################
rint "Content-type: text/html\n\n";
$mailprog = '/usr/sbin/sendmail';
@referers = ('todobaile.net');
@recipients = ('[email protected]');
@valid_ENV = ('REMOTE_HOST','REMOTE_ADDR','REMOTE_USER','HTTP_USER_AGENT');
&check_url;
&get_date;
&parse_form;
&check_required;
&send_mail;
&return_html;
sub check_url {
local($check_referer) = 0;
if ($ENV{'HTTP_REFERER'}) {
foreach $referer (@referers) {
if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {
$check_referer = 1;
last;
}
}
}
else {
$check_referer = 1;
}
if ($check_referer != 1) { &error('bad_referer') }
}
sub get_date {
@days = ('Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday');
@months = ('January','February','March','April','May','June','July',
'August','September','October','November','December');
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
$time = sprintf("%02d:%02d:%02d",$hour,$min,$sec);
$year += 1900;
$date = "$days[$wday], $months[$mon] $mday, $year at $time";
}
sub parse_form {
%Config = ('recipient','', 'subject','',
'email','', 'realname','',
'redirect','', 'bgcolor','',
'background','', 'link_color','',
'vlink_color','', 'text_color','',
'alink_color','', 'title','',
'sort','', 'print_config','',
'required','', 'env_report','',
'return_link_title','', 'return_link_url','',
'print_blank_fields','', 'missing_fields_redirect','');
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
}
else {
&error('request_method');
}
foreach $pair (@pairs) {
local($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
if (defined($Config{$name})) {
$Config{$name} = $value;
}
else {
if ($Form{$name} && $value) {
$Form{$name} = "$Form{$name}, $value";
}
elsif ($value) {
push(@Field_Order,$name);
$Form{$name} = $value;
}
}
}
$Config{'required'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$Config{'required'} =~ s/(\s+)?\n+(\s+)?//g;
$Config{'env_report'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$Config{'env_report'} =~ s/(\s+)?\n+(\s+)?//g;
$Config{'print_config'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$Config{'print_config'} =~ s/(\s+)?\n+(\s+)?//g;
@Required = split(/,/,$Config{'required'});
@Env_Report = split(/,/,$Config{'env_report'});
@Print_Config = split(/,/,$Config{'print_config'});
foreach $env_item (@Env_Report) {
foreach $valid_item (@valid_ENV) {
if ( $env_item eq $valid_item ) { push(@temp_array, $env_item) }
}
}
@Env_Report = @temp_array;
}
sub check_required {
local($require, @error);
if ($Config{'subject'} =~ /(\n|\r)/m ||
$Config{'recipient'} =~ /(\n|\r)/m) {
&error('no_recipient');
}
if (!$Config{'recipient'}) {
if (!defined(%Form)) { &error('bad_referer') }
else { &error('no_recipient') }
}
else {
$valid_recipient = 0;
foreach $send_to (split(/,/,$Config{'recipient'})) {
foreach $recipient (@recipients) {
if ($send_to =~ /$recipient$/i) {
push(@send_to,$send_to); last;
}
}
}
if ($#send_to < 0) { &error('no_recipient') }
$Config{'recipient'} = join(',',@send_to);
}
foreach $require (@Required) {
if ($require eq 'email' && !&check_email($Config{$require})) {
push(@error,$require);
}
elsif (defined($Config{$require})) {
if (!$Config{$require}) {
push(@error,$require);
}
}
elsif (!$Form{$require}) {
push(@error,$require);
}
}
if (@error) { &error('missing_fields', @error) }
}
sub return_html {
local($key,$sort_order,$sorted_field);
if ($Config{'redirect'}) {
print "Location: $Config{'redirect'}\n\n";
}
else {
print "Content-type: text/html\n\n";
print "<html>\n <head>\n";
if ($Config{'title'}) { print " <title>$Config{'title'}</title>\n" }
else { print " <title>Thank You</title>\n" }
print " </head>\n <body";
&body_attributes;
print ">\n <center>\n";
if ($Config{'title'}) { print " <h1>$Config{'title'}</h1>\n" }
else { print " <h1>Thank You For Filling Out This Form</h1>\n" }
print "</center>\n";
print "Below is what you submitted to $Config{'recipient'} on ";
print "$date<p><hr size=1 width=75\%><p>\n";
if ($Config{'sort'} eq 'alphabetic') {
foreach $field (sort keys %Form) {
if...
#!/usr/bin/perl
##############################################################################
# FormMail Version 1.9 #
# Copyright 1995-2001 Matt Wright [email protected] #
# Created 06/09/95 Last Modified 08/03/01 #
# Matt's Script Archive, Inc.: http://www.worldwidemart.com/scripts/ #
##############################################################################
rint "Content-type: text/html\n\n";
$mailprog = '/usr/sbin/sendmail';
@referers = ('todobaile.net');
@recipients = ('[email protected]');
@valid_ENV = ('REMOTE_HOST','REMOTE_ADDR','REMOTE_USER','HTTP_USER_AGENT');
&check_url;
&get_date;
&parse_form;
&check_required;
&send_mail;
&return_html;
sub check_url {
local($check_referer) = 0;
if ($ENV{'HTTP_REFERER'}) {
foreach $referer (@referers) {
if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {
$check_referer = 1;
last;
}
}
}
else {
$check_referer = 1;
}
if ($check_referer != 1) { &error('bad_referer') }
}
sub get_date {
@days = ('Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday');
@months = ('January','February','March','April','May','June','July',
'August','September','October','November','December');
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
$time = sprintf("%02d:%02d:%02d",$hour,$min,$sec);
$year += 1900;
$date = "$days[$wday], $months[$mon] $mday, $year at $time";
}
sub parse_form {
%Config = ('recipient','', 'subject','',
'email','', 'realname','',
'redirect','', 'bgcolor','',
'background','', 'link_color','',
'vlink_color','', 'text_color','',
'alink_color','', 'title','',
'sort','', 'print_config','',
'required','', 'env_report','',
'return_link_title','', 'return_link_url','',
'print_blank_fields','', 'missing_fields_redirect','');
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
}
else {
&error('request_method');
}
foreach $pair (@pairs) {
local($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
if (defined($Config{$name})) {
$Config{$name} = $value;
}
else {
if ($Form{$name} && $value) {
$Form{$name} = "$Form{$name}, $value";
}
elsif ($value) {
push(@Field_Order,$name);
$Form{$name} = $value;
}
}
}
$Config{'required'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$Config{'required'} =~ s/(\s+)?\n+(\s+)?//g;
$Config{'env_report'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$Config{'env_report'} =~ s/(\s+)?\n+(\s+)?//g;
$Config{'print_config'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$Config{'print_config'} =~ s/(\s+)?\n+(\s+)?//g;
@Required = split(/,/,$Config{'required'});
@Env_Report = split(/,/,$Config{'env_report'});
@Print_Config = split(/,/,$Config{'print_config'});
foreach $env_item (@Env_Report) {
foreach $valid_item (@valid_ENV) {
if ( $env_item eq $valid_item ) { push(@temp_array, $env_item) }
}
}
@Env_Report = @temp_array;
}
sub check_required {
local($require, @error);
if ($Config{'subject'} =~ /(\n|\r)/m ||
$Config{'recipient'} =~ /(\n|\r)/m) {
&error('no_recipient');
}
if (!$Config{'recipient'}) {
if (!defined(%Form)) { &error('bad_referer') }
else { &error('no_recipient') }
}
else {
$valid_recipient = 0;
foreach $send_to (split(/,/,$Config{'recipient'})) {
foreach $recipient (@recipients) {
if ($send_to =~ /$recipient$/i) {
push(@send_to,$send_to); last;
}
}
}
if ($#send_to < 0) { &error('no_recipient') }
$Config{'recipient'} = join(',',@send_to);
}
foreach $require (@Required) {
if ($require eq 'email' && !&check_email($Config{$require})) {
push(@error,$require);
}
elsif (defined($Config{$require})) {
if (!$Config{$require}) {
push(@error,$require);
}
}
elsif (!$Form{$require}) {
push(@error,$require);
}
}
if (@error) { &error('missing_fields', @error) }
}
sub return_html {
local($key,$sort_order,$sorted_field);
if ($Config{'redirect'}) {
print "Location: $Config{'redirect'}\n\n";
}
else {
print "Content-type: text/html\n\n";
print "<html>\n <head>\n";
if ($Config{'title'}) { print " <title>$Config{'title'}</title>\n" }
else { print " <title>Thank You</title>\n" }
print " </head>\n <body";
&body_attributes;
print ">\n <center>\n";
if ($Config{'title'}) { print " <h1>$Config{'title'}</h1>\n" }
else { print " <h1>Thank You For Filling Out This Form</h1>\n" }
print "</center>\n";
print "Below is what you submitted to $Config{'recipient'} on ";
print "$date<p><hr size=1 width=75\%><p>\n";
if ($Config{'sort'} eq 'alphabetic') {
foreach $field (sort keys %Form) {
if...
1 respuesta
Respuesta de hmk_usuario
1