CGI script no funcionará.

  • ajdegans
  • Born
  • Born
  • No Avatar
  • Registrado: Sep 17, 2003
  • Mensajes: 4
  • Loc: netherlands
  • Status: Offline

Nota Septiembre 17th, 2003, 3:54 pm

Hola, soy bastante nuevo para secuencias de comandos CGI. Así que tomé algunas partes del código y formas hechas por correo electrónico.

Una de las obras!! Pero el segundo no funciona. del CGI es que por debajo de archivo en particular:

Código: [ Select ]
#!/usr/bin/perl
$sendmail_location = "/usr/sbin/sendmail";

read(STDIN, $formbuffer, $ENV{'CONTENT_LENGTH'});
@formpairs = split(/&/, $formbuffer);
foreach $formpair (@formpairs) {
    ($formname, $formvalue) = split(/=/, $formpair);
    $formvalue =~ tr/+/ /;
    $formvalue =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex())/eg;
  $formvalue =~ s/<([^>]|\n)*>//g;
    if ($FORM{$formname}) { $FORM{$formname} = $FORM{$formname}.",".$formvalue; }
    else { $FORM{$formname} = $formvalue; }
}


foreach $require (split(/\,/,$FORM{'require'})) {
if ($require eq "email" || $require eq "to") {
unless ($FORM{$require}=~ /\@/ && $FORM{$require}=~ /\./) {
$error .= "Error in $require.<BR>";
}
}
unless ($FORM{$require}) {
$error .= "Missing $require.<BR>";
}
}

unless ($FORM{'sendpage'}) {
$error .= "Missing confirmation page url<BR>";
}

if ($error) {
print "Content-type: text/html\n\n";
print qq(<CENTER><FONT COLOR="#000000"><B>Error</B><BR>-------------------------<BR>$error</FONT></CENTER>);
exit;
}

if ($FORM{'jounaam'}) {
$yeshow = qq(
Naam, $FORM{'jounaam'}
);
}

if ($FORM{'pakket'}) {
$yeshow = qq(
Pakket, $FORM{'pakket'}
);
}

if ($FORM{'email'}) {
$yeshow = qq(
E-mail, $FORM{'email'}
);
}

if ($FORM{'adres'}) {
$yeshow = qq(
Adres, $FORM{'adres'}
);
}

if ($FORM{'postcode'}) {
$yeshow = qq(
Postcode, $FORM{'postcode'}
);
}

if ($FORM{'plaats'}) {
$yeshow = qq(
Plaats, $FORM{'plaats'}
);
}

if ($FORM{'land'}) {
$yeshow = qq(
Land, $FORM{'land'}
);
}

if ($FORM{'telefoon'}) {
$yeshow = qq(
Telefoon, $FORM{'telefoon'}
);
}

if ($FORM{'gsm'}) {
$yeshow = qq(
gsm, $FORM{'gsm'}
);
}

if ($FORM{'message'}) {
$yeshow = qw(
From, $FORM{'message'}
);
}

if ($FORM{'hoekomjehier'}) {
$yeshow = qq(
Hoe kom je hier, $FORM{'hoekomjehier'}
);
}

open (MAIL, "|$sendmail_location -t") || die "Can't open $sendmail_location!\n";
print MAIL "From: $FORM{'jounaam'} <$FORM{'email'}>\n";
print MAIL "To: $FORM{'to'}\n";
print MAIL "Subject: $FORM{'subject'}\n\n";
print MAIL <<EOF;
$yeshow

$FORM{'message'}


EOF
close (MAIL);

print "Location: $FORM{'sendpage'}\n\n";
exit;
  1. #!/usr/bin/perl
  2. $sendmail_location = "/usr/sbin/sendmail";
  3. read(STDIN, $formbuffer, $ENV{'CONTENT_LENGTH'});
  4. @formpairs = split(/&/, $formbuffer);
  5. foreach $formpair (@formpairs) {
  6.     ($formname, $formvalue) = split(/=/, $formpair);
  7.     $formvalue =~ tr/+/ /;
  8.     $formvalue =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex())/eg;
  9.   $formvalue =~ s/<([^>]|\n)*>//g;
  10.     if ($FORM{$formname}) { $FORM{$formname} = $FORM{$formname}.",".$formvalue; }
  11.     else { $FORM{$formname} = $formvalue; }
  12. }
  13. foreach $require (split(/\,/,$FORM{'require'})) {
  14. if ($require eq "email" || $require eq "to") {
  15. unless ($FORM{$require}=~ /\@/ && $FORM{$require}=~ /\./) {
  16. $error .= "Error in $require.<BR>";
  17. }
  18. }
  19. unless ($FORM{$require}) {
  20. $error .= "Missing $require.<BR>";
  21. }
  22. }
  23. unless ($FORM{'sendpage'}) {
  24. $error .= "Missing confirmation page url<BR>";
  25. }
  26. if ($error) {
  27. print "Content-type: text/html\n\n";
  28. print qq(<CENTER><FONT COLOR="#000000"><B>Error</B><BR>-------------------------<BR>$error</FONT></CENTER>);
  29. exit;
  30. }
  31. if ($FORM{'jounaam'}) {
  32. $yeshow = qq(
  33. Naam, $FORM{'jounaam'}
  34. );
  35. }
  36. if ($FORM{'pakket'}) {
  37. $yeshow = qq(
  38. Pakket, $FORM{'pakket'}
  39. );
  40. }
  41. if ($FORM{'email'}) {
  42. $yeshow = qq(
  43. E-mail, $FORM{'email'}
  44. );
  45. }
  46. if ($FORM{'adres'}) {
  47. $yeshow = qq(
  48. Adres, $FORM{'adres'}
  49. );
  50. }
  51. if ($FORM{'postcode'}) {
  52. $yeshow = qq(
  53. Postcode, $FORM{'postcode'}
  54. );
  55. }
  56. if ($FORM{'plaats'}) {
  57. $yeshow = qq(
  58. Plaats, $FORM{'plaats'}
  59. );
  60. }
  61. if ($FORM{'land'}) {
  62. $yeshow = qq(
  63. Land, $FORM{'land'}
  64. );
  65. }
  66. if ($FORM{'telefoon'}) {
  67. $yeshow = qq(
  68. Telefoon, $FORM{'telefoon'}
  69. );
  70. }
  71. if ($FORM{'gsm'}) {
  72. $yeshow = qq(
  73. gsm, $FORM{'gsm'}
  74. );
  75. }
  76. if ($FORM{'message'}) {
  77. $yeshow = qw(
  78. From, $FORM{'message'}
  79. );
  80. }
  81. if ($FORM{'hoekomjehier'}) {
  82. $yeshow = qq(
  83. Hoe kom je hier, $FORM{'hoekomjehier'}
  84. );
  85. }
  86. open (MAIL, "|$sendmail_location -t") || die "Can't open $sendmail_location!\n";
  87. print MAIL "From: $FORM{'jounaam'} <$FORM{'email'}>\n";
  88. print MAIL "To: $FORM{'to'}\n";
  89. print MAIL "Subject: $FORM{'subject'}\n\n";
  90. print MAIL <<EOF;
  91. $yeshow
  92. $FORM{'message'}
  93. EOF
  94. close (MAIL);
  95. print "Location: $FORM{'sendpage'}\n\n";
  96. exit;


Tal vez alguien puede encontrar el código equivocado. Me creo que la parte con:
Código: [ Select ]
if ($FORM{'jounaam'}) {
$yeshow = qq(
Naam, $FORM{'jounaam'}
);
}

if ($FORM{'pakket'}) {
$yeshow = qq(
Pakket, $FORM{'pakket'}
);
}

if ($FORM{'email'}) {
$yeshow = qq(
E-mail, $FORM{'email'}
);
}

if ($FORM{'adres'}) {
$yeshow = qq(
Adres, $FORM{'adres'}
);
}

if ($FORM{'postcode'}) {
$yeshow = qq(
Postcode, $FORM{'postcode'}
);
}

if ($FORM{'plaats'}) {
$yeshow = qq(
Plaats, $FORM{'plaats'}
);
}

if ($FORM{'land'}) {
$yeshow = qq(
Land, $FORM{'land'}
);
}

if ($FORM{'telefoon'}) {
$yeshow = qq(
Telefoon, $FORM{'telefoon'}
);
}

if ($FORM{'gsm'}) {
$yeshow = qq(
gsm, $FORM{'gsm'}
);
}

if ($FORM{'message'}) {
$yeshow = qw(
From, $FORM{'message'}
);
}

if ($FORM{'hoekomjehier'}) {
$yeshow = qq(
Hoe kom je hier, $FORM{'hoekomjehier'}
);
}
  1. if ($FORM{'jounaam'}) {
  2. $yeshow = qq(
  3. Naam, $FORM{'jounaam'}
  4. );
  5. }
  6. if ($FORM{'pakket'}) {
  7. $yeshow = qq(
  8. Pakket, $FORM{'pakket'}
  9. );
  10. }
  11. if ($FORM{'email'}) {
  12. $yeshow = qq(
  13. E-mail, $FORM{'email'}
  14. );
  15. }
  16. if ($FORM{'adres'}) {
  17. $yeshow = qq(
  18. Adres, $FORM{'adres'}
  19. );
  20. }
  21. if ($FORM{'postcode'}) {
  22. $yeshow = qq(
  23. Postcode, $FORM{'postcode'}
  24. );
  25. }
  26. if ($FORM{'plaats'}) {
  27. $yeshow = qq(
  28. Plaats, $FORM{'plaats'}
  29. );
  30. }
  31. if ($FORM{'land'}) {
  32. $yeshow = qq(
  33. Land, $FORM{'land'}
  34. );
  35. }
  36. if ($FORM{'telefoon'}) {
  37. $yeshow = qq(
  38. Telefoon, $FORM{'telefoon'}
  39. );
  40. }
  41. if ($FORM{'gsm'}) {
  42. $yeshow = qq(
  43. gsm, $FORM{'gsm'}
  44. );
  45. }
  46. if ($FORM{'message'}) {
  47. $yeshow = qw(
  48. From, $FORM{'message'}
  49. );
  50. }
  51. if ($FORM{'hoekomjehier'}) {
  52. $yeshow = qq(
  53. Hoe kom je hier, $FORM{'hoekomjehier'}
  54. );
  55. }


init es lo badass pero no tengo ni idea de que para fijar gif "alt =":(" title =" triste "/>

Si alguien puede ayudar a :(

Gracias de antemano
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Septiembre 17th, 2003, 3:54 pm

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • Avatar de Usuario
  • Registrado: Dic 20, 2002
  • Mensajes: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Nota Septiembre 17th, 2003, 11:40 pm

Al ejecutar este script son conseguir que los errores? o qué es exactamente lo que no está funcionando?
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • ajdegans
  • Born
  • Born
  • No Avatar
  • Registrado: Sep 17, 2003
  • Mensajes: 4
  • Loc: netherlands
  • Status: Offline

Nota Septiembre 18th, 2003, 8:30 am

Me esta página de error

Código: [ Select ]
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, helpdesk@flexwebhosting.nl and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.



--------------------------------------------------------------------------------

Apache/1.3.27 Server at www.zerocom.nl Port 80
  1. Internal Server Error
  2. The server encountered an internal error or misconfiguration and was unable to complete your request.
  3. Please contact the server administrator, helpdesk@flexwebhosting.nl and inform them of the time the error occurred, and anything you might have done that may have caused the error.
  4. More information about this error may be available in the server error log.
  5. --------------------------------------------------------------------------------
  6. Apache/1.3.27 Server at www.zerocom.nl Port 80


Tuve que trabajar de alguna manera, pero entonces todos los campos del formulario se mantuvo Blanc. por lo que el formulario completo no era de uso...que no aparecen en el correo electrónico. Así que básicamente se funcioned pero sólo una parte...
  • bestempire
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Sep 18, 2003
  • Mensajes: 7
  • Status: Offline

Nota Septiembre 18th, 2003, 10:17 am

Compruebe si ha CHMODed correctamente el archivo y la ruta a Perl es derecho
  • ajdegans
  • Born
  • Born
  • No Avatar
  • Registrado: Sep 17, 2003
  • Mensajes: 4
  • Loc: netherlands
  • Status: Offline

Nota Septiembre 18th, 2003, 11:35 am

i comprobarse chmod

su:-rwxr-xr-x (755)

En el manual para otro mensaje de correo electrónico script funciona...

También la ruta a perl es correcta :)
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • Avatar de Usuario
  • Registrado: Dic 20, 2002
  • Mensajes: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Nota Septiembre 18th, 2003, 7:16 pm

¿Tiene acceso a su registro de errores del servidor? Más información debería estar allí que explicar exactamente por qué no funciona.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • ajdegans
  • Born
  • Born
  • No Avatar
  • Registrado: Sep 17, 2003
  • Mensajes: 4
  • Loc: netherlands
  • Status: Offline

Nota Septiembre 19th, 2003, 1:50 pm

Esto me lo dio el error_log

Código: [ Select ]
syntax error at bestelformulier.cgi line 97, near ")("
Execution of bestelformulier.cgi aborted due to compilation errors.

[Thu Sep 18 17:19:10 2003] [error] [client 62.131.20.6] Premature end of script headers: /home/virtual/site59/fst/var/www/cgi-bin/bestelformulier.cgi
  1. syntax error at bestelformulier.cgi line 97, near ")("
  2. Execution of bestelformulier.cgi aborted due to compilation errors.
  3. [Thu Sep 18 17:19:10 2003] [error] [client 62.131.20.6] Premature end of script headers: /home/virtual/site59/fst/var/www/cgi-bin/bestelformulier.cgi


Creo que la escribió. CGI mal, pero no tengo idea de cuál es incorrecto ya que no sé CGI...:)

Publicar Información

  • Total de mensajes en este tema: 7 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 114 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC