0

私は学校を通じて、自分のウェブサイトにコメント フォームを設置する任務を与えられました。難しいと思っていたことはすべてやり遂げましたが、今、大きな障害にぶつかっています。form-mail2 という perl スクリプトを渡されて、Web サーバーの cgi-bin に入れましたが、フォームで [送信] をクリックすると、次のようになりました。

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@randyloope.com 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.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

これはスクリプトに関連する必要があるため、ご連絡を差し上げたいと思います。スクリプト全体を受け取ったので、正しく構成されていないと思いますが、正しく構成する方法がわかりません。スクリプトは次のとおりです。

#!/usr/local/bin/perl

# ------------------------------------------------------------
# Form-mail.pl, by Reuven M. Lerner (reuven@the-tech.mit.edu).
#
# Last updated: March 14, 1994
#
# Form-mail provides a mechanism by which users of a World-
# Wide Web browser may submit comments to the webmasters
# (or anyone else) at a site.  It should be compatible with
# any CGI-compatible HTTP server.
# 
# Please read the README file that came with this distribution
# for further details.
# ------------------------------------------------------------

# ------------------------------------------------------------
# This package is Copyright 1994 by The Tech. 

# Form-mail is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version.

# Form-mail is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with Form-mail; see the file COPYING.  If not, write to the Free
# Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
# ------------------------------------------------------------

# Define fairly-constants

# This should match the mail program on your system.
$mailprog = '/usr/lib/sendmail';

# This should be set to the username or alias that runs your
# WWW server.

$recipient = 'salvador.voli@gmail.com' 


if ($recipient eq  "\@csprofessor.com") { 
    $recipient = $ENV{'SERVER_ADMIN'};
}

# Print out a content-type for HTTP/1.0 compatibility
print "Content-type: text/html\n\n";

# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Split the name-value pairs
@pairs = split(/&/, $buffer);

foreach $pair (@pairs)
{
    ($name, $value) = split(/=/, $pair);

    # Un-Webify plus signs and %-encoding
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

    # Stop people from using subshells to execute commands
    # Not a big deal when using sendmail, but very important
    # when using UCB mail (aka mailx).
    # $value =~ s/~!/ ~!/g; 

    # Uncomment for debugging purposes
    # print "Setting $name to $value<P>";

    $FORM{$name} = $value;
}

# If the comments are blank, then give a "blank form" response

unless ($FORM{'realname'}) { &blank_response("name");    }
unless ($FORM{'email'}   ) { &blank_response("email");   }   
unless ($FORM{'message'} ) { &blank_response("message"); }
unless ($FORM{'rating'}  ) { &blank_response("rating");  }

# Print a title and initial heading
print "<html>\n";
print "<Head><Title>Thank you</Title></Head>";
print "<Body><H1>Thank you</H1>";
print "<p>Thank you for sending your comments!<br>";
print "</body></html>";

# Now send mail to $recipient

open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";
print MAIL "To: sgifford\@csprofessor.com\n";
#print MAIL "To: $recipient\n";
print MAIL "From: $FORM{'email'} ($FORM{'realname'})\n";
print MAIL "Reply-to: $FORM{'email'} ($FORM{'realname'})\n";
print MAIL "Subject: Web Site Comments\n\n";
print MAIL "------------------------------------------------------------\n";
print MAIL "$FORM{'email'} ($FORM{'realname'}) Stopped by\n";
print MAIL "Phone: $FORM{'phone'}\n";
print MAIL "Birthday: $FORM{'bday'}\n";
print MAIL "------------------------------------------------------------\n";
print MAIL "And this is what $FORM{'realname'} had to say:\n\n";
print MAIL "$FORM{'message'}";
print MAIL "\n------------------------------------------------------------\n";
print MAIL "Web Site Rating: $FORM{'rating'}";
print MAIL "\n------------------------------------------------------------\n";
print MAIL "Server protocol: $ENV{'SERVER_PROTOCOL'}\n";
print MAIL "Remote host: $ENV{'REMOTE_HOST'}\n";
print MAIL "Remote IP address: $ENV{'REMOTE_ADDR'}\n";
print MAIL  "------------------------------------------------------------\n";
close (MAIL);

# Make the person feel good for writing to us

# ------------------------------------------------------------
# subroutine blank_response
sub blank_response
{

    print "<html>\n";
    print "<Head><Title>Incomplete Comment Form</Title></Head>";
    print "<Body><H1>Incomplete Comment Form</H1>";
    print "<p>";
    print "The $_[0] field appears to be blank! ";
    print "Please finish filling out the form and re-submit your comments. ";
    print "</body></html>";
    exit;
}

そして、ここに私のコードのフォーム部分があります:

<form name="usercomments" action="/cgi-bin/form-mail2.pl" method="post" onsubmit="return finalCheck()">


Name: <input type="text" name="realname" onchange= "nameCheck()" value="" /><br />

email: <input type="text" name="email" onchange = "emailCheck()" value="" /><br />

phone: <input type="text" name="phone" onchange = "phoneCheck()" value="" /><br />

birthday: <input type="text" name="bday" onchange = "birthdayCheck()" value="" /><br />


How would you describe your experience today? <br/ >

  <input type="radio" name="rating" value="Awesome" checked="checked" /> Awesome<br />
  <input type="radio" name="rating" value="Mediocre"  /> Mediocre<br />
  <input type="radio" name="rating" value="Terrible"  /> Terrible<br />

Comments: <br />
<textarea name="message"  rows="5" cols = "100" > 
</textarea><br />

<input type="submit" value="Submit" />
</form>

あなたが与えることができるどんな提案も大歓迎です。

4

3 に答える 3

4

おそらく、「最後に更新された1994」は、ちょっとした危険信号だったはずですか?

Perlでフォームメールを実行する場合は、NMS FormMailスクリプトから始める必要があります。このスクリプトは、適切に記述され、コメントが付けられており、お持ちのスクリプトよりもはるかに安全です。

しかし、はい、サーバーのエラーログを見てください。

于 2011-09-26T01:03:08.590 に答える
3

私はそのform-mailプログラムを 1993 年に書きました。

最新の Web サーバーでは使用しないでください。Web がまだ黎明期だった時代には十分すぎて、セキュリティについて (あまり) 心配する必要はありませんでした。そしてCGIモジュールが書かれる前。などなど。

もう誰もそれを使うべきではありません。Web サーバーから電子メールを送信する方法は数十、おそらく数百ありますが、セキュリティ上の懸念はform-mailありません。

于 2016-04-20T19:11:51.940 に答える
2

メッセージのこの部分を見たので:

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

ここで、「サーバー エラー ログの内容を確認するにはどうすればよいですか?」と尋ねる必要があります。:-)

短い答えは、「特定の Web サーバーの構成方法によって異なります」です。

すなわち。ウェブマスター/ISP にその質問をする必要があります。

詳細については、雑誌の記事があります (コードと同じ作者によって書かれています):

Learning to use the httpd error log to debug CGI programs
http://www.linuxjournal.com/article/2055

よくある質問への回答で説明されているように、これらのメッセージをブラウザーにも表示するように簡単に調整できます。

http://perldoc.perl.org/perlfaq9.html#My-CGI-script-runs-from-the-command-line-but-not-the-browser.-%28500-Server-Error%29
于 2011-09-25T13:21:10.907 に答える