Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/06/2003, 19:07
Avatar de lantrax
lantrax
 
Fecha de Ingreso: abril-2003
Ubicación: Spain is different
Mensajes: 310
Antigüedad: 21 años, 10 meses
Puntos: 0
Necesito un poco de ayuda

Hola.

Necesito un poco (bastante) ayuda.
Tengo q poner un cgi para mandar info a traves de un formulario normalito en un servidor en el cual no saben ni ellos ( o no lo quieren decir) si es unix o windows. Vamos q lo unico q se es q tiene soporte para cgi y punto. La empresa en cuestion a la q estoy renovando la web se niega a cambiar de host, así q como el cliente siempre tiene razón, tengo q encontrar otra solución.
Básicamente: se q un cgi no funciona igual en plataforma windows q en unix. Hay alguna forma de saber q plataforma es la del host en cuention???
Una vez sabido, en que carpeta debo instalar el cgi?? en /cgi-bin/ del directorio raiz del espacio web q tiene esta empresa contratado???

Por cierto pongo aquí el codigo cgi q he voy a poner por si a alguien le puede servir, en principio es gratuito, más q nada por si hubiera que hacer modificacion segun plataforma.

Código:
#!/usr/bin/perl
##############################################################################
# Cliff's Form Mailer Version 1.0                                            # 
# Copyright 1998 Shaven Ferret Productions                                   #
# Created 6/4/98                                                             #
# Available at http://www.shavenferret.com/scripts                           #
##############################################################################
# COPYRIGHT NOTICE                                                           #
# Copyright 1998 Shaven Ferret Productions All Rights Reserved.              #
#                                                                            #
# This script can be used\modified free of charge as long as you don't       #
# change this header thing, or the part that gives me credit for writing     #
# script in the e-mail.  If you really need to remove this part, go to       #
# http://www.shavenferret.com/scripts/register.shtml .  By using this script #
# you agree to indemnifyme from any liability that might arise from its use. #
# In simple English, if this script somehow makes your computer run amuck    #
# and kill the pope, it's not my fault.                                      #
#                                                                            #
# Redistributing\selling the code for this program without prior written     #
# consent is expressly forbidden.                                            #
##############################################################################

# Enter the location of sendmail.  
$mailprogram = "/usr/lib/sendmail -t";

# Enter the fields that are required.  They should each be in quotes and
# separated by a comma.  If no fields are required, change the next line
# to @required = ();
@required = ('email','subject');

# Enter your e-mail address.  Be sure to put a \ in front of the @.
# ([email protected] becomes user\@domain.com)
$youremail = "yourname\@yourdomain.com";

##############################################################################
# Congratulations!  You've finished defining the variables.  If you want to, #
# you can continue screwing with the script, but it isn't necessary.         #
##############################################################################

# Put the posted data into variables

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
        ($name, $value) = split(/=/, $pair);
        $value =~ tr/+/ /;
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
        $FORM{$name} = $value;
}

# Check for all required fields

foreach $check(@required) {
        unless ($FORM{$check}) {
                print "Content-type: text/html\n\n";
                print "<html><head><title>Missing Information</title></head>\n";
                print "<body><h1>Missing Information</h1><br>\n";
                print "I'm sorry, but it would appear that you've forgotten to\n";
                print "fill out the $check field.  Please click\n";
                print "back and try again.\n";
                print "</body></html>\n";
                exit;
        }
}

# Check the senders email

if ($FORM{'email'}) {
        unless ($FORM{'email'} =~ /\w+@\w+.\w+/) {
                print "Content-type: text/html\n\n";
                print "<html><head><title>Bad E-mail</title></head>\n";
                print "<body><h1>Bad E-mail</h1><br>The e-mail address that you've\n";
                print "entered, $FORM{'email'}, is invalid.  Please click back and\n";
                print "try again.\n";
                exit;
        }
}

open (MAIL,"|$mailprogram");
print MAIL "To: $youremail\n";
print MAIL "From: $FORM{'email'}\n";
print MAIL "Subject: $FORM{'subject'}\n";
print MAIL "Hello.  The following information has been submitted:\n\n";
foreach $pair (@pairs) {
        ($name, $value) = split(/=/, $pair);
        $value =~ tr/+/ /;
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
        unless ($name eq "response" || $name eq "email" || $name eq "subject") { 
                print MAIL "$name: $value\n";
        }
}
close MAIL;

if ($FORM{'response'} && $FORM{'email'}) {
        open (RESPONSE, $FORM{'response'});
        @response = <RESPONSE>;
        close(RESPONSE);
        open (MAIL,"|$mailprogram");
        print MAIL "To: $FORM{'email'}\n";
        print MAIL "From: $youremail\n";
        print MAIL "Subject: $FORM{'subject'} -- Autoresponse\n";
        foreach $line (@response) {
                print MAIL "$line";
        }
        print MAIL "The person you are communicating with is using Cliff's\n";
        print MAIL "Form Mailer Script.  If you would like to add this script\n";
        print MAIL "to your web site, you can find it and many more perl scripts at\n";
        print MAIL "http://www.shavenferret.com/scripts\n";
        close MAIL;
}

print "Content-type: text/html\n\n";
print "<html><head><title>Thank you!</title></head>\n";
print "<body><h1>Thank you!</h1><br>Thanks for your input! \n";
if ($FORM{'response'} && $FORM{'email'}) {
        print "You should receive an autoresponse shortly.<p>\n";
}
print "Please click back.\n";
Gracias y...A ver si hay suerte

Salu2

Lantrax