sandorah
03-10-2003, 12:00 AM
Hi all...
I'm getting a particular error that I can't seem to resolve no matter WHAT I change in my script.
I'm using a FormMail script from http://www.scriptarchive.com/formmail.html (recommended by my hosting comp) and I've followed through setting up the .pl file but keep getting an internal server error. I've even looked at the configuration of a working .pl on the same server. Same file... same settings
I looked at the error logs and this is what I'm getting.....
Premature end of script headers:
Does anyone have a clue as to what this could be???
Thanks!
San
stylempire
03-10-2003, 04:57 PM
Have you set permissions to all pl/cgi files to 755?
and does the form point to the exact location of the formmail.pl/.cgi script?
sandorah
03-11-2003, 12:44 PM
Hi.. thanks for the reply. Yes, I do the cgi-bin permissions set up and set 755. And I believe I have the path correct as well....
The site I'm working on is a sub domain, could it be that the my @referers are set up incorrectly?? The only mention of sub domain in the README/'How-to-configure-this-thing' file is under reciepients.......
Just thought of something I could try..... :)
sandorah
03-11-2003, 12:51 PM
Diddn't work :( *sighs*
Any other suggestions??
This is the www.scriptarchive.com script I'm using below.... (I've taken out the copyright information due to character constraints on this board)
#!/usr/bin/perl
$mailprog = '/usr/sbin/sendmail';
@referers = ('builderbuyers.com','63.126.124.21');
@recipients = ('^webmaster\@builderbuyers\.com');
# ACCESS CONTROL FIX: Peter D. Thompson Yezek #
# @valid_ENV allows the sysadmin to define what environment variables can #
# be reported via the env_report directive. This was implemented to fix #
# the problem reported at http://www.securityfocus.com/bid/1187 #
@valid_ENV = ('REMOTE_HOST','REMOTE_ADDR','REMOTE_USER','HTTP_USER_AGENT');
# Check Referring URL
&check_url;
# Retrieve Date
&get_date;
# Parse Form Contents
&parse_form;
# Check Required Fields
&check_required;
# Send E-Mail
&send_mail;
# Return HTML Page or Redirect User
&return_html;
# NOTE rev1.91: This function is no longer intended to stop abuse, that #
# functionality is now embedded in the checks made on @recipients and the #
# recipient form field. #
sub check_url {
# Localize the check_referer flag which determines if user is valid. #
local($check_referer) = 0;
# If a referring URL was specified, for each valid referer, make sure #
# that a valid referring URL was passed to FormMail. #
if ($ENV{'HTTP_REFERER'}) {
foreach $referer (@referers) {
if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {
$check_referer = 1;
last;
}
}
}
else {
$check_referer = 1;
}
# If the HTTP_REFERER was invalid, send back an error. #
if ($check_referer != 1) { &error('bad_referer') }
}
sub get_date {
# Define arrays for the day of the week and month of the year. #
@days = ('Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday');
@months = ('January','February','March','April','May','June','July',
'August','September','October','November','December');
# Get the current time and format the hour, minutes and seconds. Add #
# 1900 to the year to get the full 4 digit year. #
($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;
# Format the date. #
$date = "$days[$wday], $months[$mon] $mday, $year at $time";
}
sub parse_form {
# Define the configuration associative array. #
%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','');
# Determine the form's REQUEST_METHOD (GET or POST) and split the form #
# fields up into their name-value pairs. If the REQUEST_METHOD was #
# not GET or POST, send an error. #
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
# Split the name-value pairs
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
}
else {
&error('request_method');
}
# For each name-value pair: #
foreach $pair (@pairs) {
# Split the pair up into individual variables. #
local($name, $value) = split(/=/, $pair);
Philip M
03-11-2003, 06:45 PM
If that is all there is a great deal missing! Perhaps that is the "premature end" referred to.
Matt's FormMail ought to work without problems, and the instructions for configuration are very clear.
ian17
03-12-2003, 07:45 AM
"Premature end of script headers" is a common message and it means that the script was able to be run, but it aborted with an error. I get it a lot.
First thing you need to do is add the -w switch in the first line of your script. Then details of the error will appear in the error log (unless your ISP has them suppressed).
Next, try running your script from the command line, invoked by you instead of invoked by the web browser. Chances are that perl will tell you everything that you need to know. If the script works OK from the command line, your console screen will fill with raw html, at least you'll know it's running right.
Best of luck with it.
sandorah
03-12-2003, 04:43 PM
Thanks for responding, Ian, I'll try that... it's another direction for me to try :thumbsup:
Philip... I had to remove part of the script due to character constraints on the message board.. so, there's alot more to the script but I have yet to change any of it yet (i.e. the response html etc.) I was just trying to get the thing working and thought if I posted the values I had changed, that someone might be able to see if I had my syntax wrong or something..... but thanks for taking a look at it... greatly appreciate it. :)
Philip M
03-12-2003, 07:23 PM
Another vital thing -
make sure that
#!/usr/bin/perl
is the very, very first line, with no spaces or anything
before it.
I don't see anything wrong but Perl can be very picky about
unwanted/extra spaces.
Likewise, make sure that the final } is the very, very last character, again with no spaces or newlines after it.
If it still does not work, I can only suggest that you start again.
Change only one line (from the original) at a time, and test before continuing. You can comment out (say) referers to start with - get the recipients bit right so you can receive the form. It is possible that you have inadvertently altered something in the script which now throws an error - it is easily done, as I know.
Any @ signs in email addresses must be escaped thus: \@
Comment out lines (or sub-routines) by starting them with a #,
then test just the pared down script, and reintroduce the commented out lines or subroutines one at a time.
See also the helpful advice given by Steven Coutts in another thread "Hanging Perl Scripts".
sandorah
03-15-2003, 03:26 PM
Thanks Philip for taking the time to reply...
I've tried a couple of the things you suggested (no unwanted spaces), and I'm at the point of starting again and methodically stepping through the process....
I thought to take out the 'text' box to see if that helps since I've looked through the script and do not see the definition for grabbing that information in the text box except '&body_attributes;'.
My thought was that if I didn't properly support (in the page) snagging that text, then it would fail.... hmmm...
It may be a silly question, but where in the script does it grab the text from the text box to post in the email...????
And I will also check out that other thread posted you mentioned... thanks for the 'heads-up'... :thumbsup:
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.