#!/usr/bin/perl ############################################## ############################################## # SCRIPT NAME: Page_Comments.cgi # FUNCTION: A simple bulletin board for # everyone working with the database ############################################## # MINE: Molecular INformation Explorer # Copyright 2000 Dawn Field. All rights reserved. # The CGI-PERL scripts belonging to MINE # may be used and modified freely, but I do # request that this copyright notice remain attached # to this file/source code. If you make modifications # please do not distribute unless # you fully document the modifications. use CGI; require "CGI-MINE.pl"; ################# # START EACH MINE CGI SCRIPT ################# # this redirects the error messages to the user's screen # and is useful for debugging CGI scripts! open (STDERR, ">&STDOUT"); # print errors to screen $| = 1; # flush the print buffer continuously # make a new query object using CGI.pm module $query = new CGI; # print the required header and start the web page print $query->header; print $query->start_html('MINE'); # Each time a script is invoked for the first time (or $action undef), # log the visit in the custom MINE server log (see CGI-MINE.pl) # (put this after the header incase an error message is printed) # check value of $action $action = $query->param('action'); if ($action eq undef) {&log();} $debug = ""; # "1" to print, "0" to hide print statements # this script makes a very simple form for keeping comments on a project # Here's where we take action on the previous request if ($query->param('action') eq 'Submit!') { print "Your comment has been successfully submitted.
"; # print end of table &table_bottom(); } # end if action = submit on last click ####### # START THE WEBPAGE ####### # print the MINE menu &menu; # start the basic gray table used for formatting MINE pages &table_top(); # put the main title of your page here print "Comments on the $database_name
"; # end table &table_bottom(); # unless the user hit the submit button, print the form if ($query->param('action') ne 'Submit!') { ############ # START FORM ############ &table_top(); print $query->startform(); # print some buttons # textfield for name print "NAME " ; print $query->textfield(-name=>name, -size=>50, -maxlength=>80); # text box for the comments print "
COMMENTS "; print $query->textarea(-name=>'comment', -rows=>10, -columns=>60); print "
";
# print a 'submit' button at end of form: script self-calls
print $query->submit('action','Check Entry Before Submitting');
# print a 'clear' button at end of form: script self-calls
print $query->defaults('Clear');
# print a 'GO!' button at end of form: script self-calls
print $query->submit('action','Submit!');
print $query->endform();
&table_bottom();
#################
# END FORM
#################
} # end if ($query->param('action') eq 'Submit!') {
#################
# PROCESS FORM
################
# get the values
$action = $query->param('action');
# get the variables to keep in the archive
$name = $query ->param(name) || undef;
$comment = $query ->param(comment) || undef;
# add some color to the text in the variable $name!
$name = "$name";
# get the date (may be different on different unix systems)
$date = `/usr/bin/date`;
# make the new comment entry
$new_entry = "Date Submitted: $date
Submitted by: $name
Comment: $comment
This is what your comment will look like. If happy press Submit!, otherwise Fix it!
"; # $new_entry contains the newly formatted comment print $new_entry; &table_bottom(); } # end if ($action eq "Check Entry Before Submitting") { ######## # IF BUTTON CLICKED is not 'SUBMIT' ######## # unless the user hit the submit button, print the past comments if ($query->param('action') ne 'Submit!') { if (-e "archive_file") { &table_top(); print "
Past Comments
";
# collect up the past entries from the archive file
open (IN, "archive_file") || die "can't open the archive file";
while ($line =
";
print "$all_entries";
&table_bottom();
} # end if (-e "archive_file")
} # end if ($action eq "Check Entry Before Submitting")
########
# IF BUTTON CLICKED is SUBMIT
########
# if the user selects submit, process the comment into the archive
if ($query->param('action') eq 'Submit!' && (length $name >=2) && (length $comment >=2)) {
&table_top();
# the first time the script is used, the archive file must be given the line to make it html
if (! -e "archive_file") {
open (IN, ">archive_file") || die "can't open the archive file";
open (GET, "archive_file");
chmod 0666, "archive_file";
}
if (-e "archive_file") {
# collect up the past entries from the archive file
open (IN, "archive_file") || die "can't open the archive file";
while ($line =
";
print "$new_entry$all_entries";
&table_bottom();
} # end if archive_file
# clear the query object after a submission
$query ->delete_all;
} # end if ($action eq "submit")
# PRINT BOTTOM OF EACH WEB PAGE
# if $show_source is set to 1 show a link
# at the bottom of each script to the source
# code - pass the name of this script to the
# function in CGI-MINE.pl
if ($show_source) {
$script_name = $query->script_name();
&source ($script_name);
} # ATTACH the MINE copywrite
&mine_cp;
print $query->end_html;
#################
# END WEBPAGE
#################