solusiromansa
10-29-2008, 02:55 PM
Hi there.. I'm having a difficulty with a script taken from here (http://bignosebird.com/carchive/survey.shtml).
My edited yet still troublesome online version here (http://solusiromansa.com/survey/survey.html).
I've done everything precisely according to the README; however I'm still stuck with 500 Internal Server Error. Could someone help a brother here, please???
mod_webhosting
10-29-2008, 03:11 PM
Your file permissions for that script might be wrong. Make sure the file and the folder in which the script is located are not writable by anyone but the owner.
If that doesn't help, look for the error log.
MichaelMcC
10-29-2008, 03:34 PM
Make sure all your permissions are correct.
Make sure your paths are correct.
Another thing people miss is the trailing simicolon.
$DATA_PATH="/home/httpd/cgi-bin/survey";
Some delete the trailing simicolon during edit.
Make sure it's still there after every line you edited.
Read the error log like mentioned above.
solusiromansa
10-30-2008, 12:03 AM
Akkai and MichaelMcC, THANK YOU GUYS... It's working fine right now, yay!
I'm going to write the fix walkthru here, just so that people who have the some trouble would know what to do.
1. Follow everything Akkai and Michael had said above.
2. Set the survey.cgi script to 755 (not 775 as mentioned in the README!)
3. set the survey.log and survey.srv to 666.
4. set the cgi-bin's SURVEY directory to 755 too.
5. if you don't know the $DATA_PATH (FULL system path to the cgi-bin directory), run this diagnose script (http://bignosebird.com/trouble.shtml) to get the address.
Recheck and recheck everything. Don't give up, cos this is the SIMPLEST script thing ever. Good luck.
Again, thanks Akkai and MichaelMcC.
I still have a little question here. The survey is wonderful already, yet the form can be submitted without having all the column filled, how can I prevent that? Is it fixable thru adding a very simple line? I don't know anything about programming, so a copy-paste thing would be awesome.
mod_webhosting
10-30-2008, 03:15 PM
I'm glad your original problem is solved.
Fixing your second problem is not hard but it is a bit harder than the one line solution you hoped for. If you'd want to have error message informing the user he has not entered all of the required fields and offering him a chance to fill out the questions he missed, you'd have to rewrite the code. Rewriting would consist of checking $fields array and outputting warnings if he missed any answer.
Is finding another script that would do what you want an option? If you're not experienced I'd suggest that course of action.
MichaelMcC
10-30-2008, 08:55 PM
I made a few changes to one of the aub routines in that script.
All you have to do is replace the existing subroutine with this one and it will require all fields filled in. You can take a look and see what was changed. I would also compare them to make sure the forum did not corrupt the code. Good luck..
sub decode_vars
{
$i=0;
if ( $ENV{'REQUEST_METHOD'} eq "GET")
{
$temp=$ENV{'QUERY_STRING'};
}
else
{
read(STDIN,$temp,$ENV{'CONTENT_LENGTH'});
}
@pairs=split(/&/,$temp);
foreach $item(@pairs)
{
($key,$content)=split(/=/,$item,2);
$content=~tr/+/ /;
$content=~s/%(..)/pack("c",hex($1))/ge;
$content=~s/\0//g;
$key=~s/\0//g;
$content=~s/\012//gs;
$content=~s/\015/ /gs;
$fields{$key}=$content;
#-----Added following line-----
if($content eq ""){$blank+=1;}
#------------------------------
}
#-----Added following lines-----
if($blank){
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>Survey</title>\n";
print "</head>\n";
print "<body>\n";
print "<script language=\"JavaScript\">\n";
print "{\n";
print "alert(\"$blank fields need to be completed.\");\n";
print "history.back(-1);\n";
print "}\n";
print "</script>\n";
print "</body></html>";
exit;
}
#------------------------------
if ($fields{'survey_name'}=~/^([-\@\w.]+)$/){
$SURVEY_NAME=$fields{'survey_name'};
}
else {exit;}
$fields{'comments'}=~s/\t/ /g;
$fields{'email'}=&valid_address($fields{'email'});
}
Tim Greer
10-31-2008, 03:19 AM
You should use warnings and strict in your code. Also, when filtering out characters in a field, it's always best to deny everything by default and then only allow the characters you want. Otherwise, if you are trying to prevent bad things, you will probably have the opposite result.
I'm curious about a few things, such as why are you capturing ^([-\@\w.]+)$ when you're not using it?
MichaelMcC
10-31-2008, 08:16 AM
You would have to ask the original author. It's linked in the 1st post.
Tim Greer
10-31-2008, 06:22 PM
The OP's last post said they replaced the original subroutine and posted the one they are now using, so this is why I asked them in the post here. I really have no desire or reason to contact the author of the script to satisfy my curiosity here in this thread about code posted in this thread.