#!/usr/bin/perl # Notebook.cgi # Accesses and Creates databases # Methods of Calling # 1: QUERY_STRING # 2: CONTENT_LENGTH # 3: Interapplication Communication # Outline: # Figure out what method of calling and parse into an array # Check for certain methods of calling to determine action # Respond to the call by displaying HTML or a file with # text strings # Initalize modules print "Content-type: text/html\n\n"; use Getopt::Long; # Routines to handle interapplication input use DB_File; # load database module #print "Notebook.cgi In \n"; # initalize variables $script = 'notebook.cgi'; $url = 'http://destiny.mbhs.edu/ncsa/riverweb/notebook/notebook1/'; $path = '/var/apache/htdocs/ncsa/riverweb/notebook/notebook1/'; $dbmlocation = '/var/apache/htdocs/ncsa/riverweb/notebook/notebook1/database/'; $datadir = '/var/apache/htdocs/ncsa/riverweb/notebook/notebook1/'; $tmpdir = '/tmp/'; # require notebook files require 'parseform.pl'; require 'search.pl'; require 'add.pl'; require 'editregistration.pl'; require 'dbaccess.pl'; require 'htmlroutines.pl'; require 'paresdata.pl'; # begin program # Detect method and parse data # all routines must return data set in $call{'DATA'} format if ($ENV{'QUERY_STRING'}){ ParseQuery(); $method = 'QUERY_STRING'; } elsif($ENV{'CONTENT_LENGTH'}){ ParseForm(); $method = 'CONTENT_LENGTH'; } #elsif($ARGV){ called from interapplication #} else { &printHtmlHeader; print "

"; print "Incorrect Calling Method. Please see documentation for information\n"; print "about the methods of making calls to this program\n"; print "

"; &printHtmlFooter; exit; } # call{'database'} is how we define which database to be used # therefore it must be present at all calls to riverweb # This element should be checked in the beginning of the # script. The routine should return a error page if the # database does not exist or if it is unaccessable. &checkDatabase; # All calls to the script must have $call{'database'} need error syntax $dbmfile = ($dbmlocation . $call{'database'}); # check for certain methods and determine action if ($call{'add'}){ # Add # Add is responsible for adding a question to the database. # First it must check the form input, second, see if there # are any other database questions for that location, when # there are other questions it must ask the user to set the # order of the questions for the location. Finally, Add must # edit the database two ways: a count must be incremented # and the entry must be assembeled and then added to the # database Add(); } elsif ($call{'edit'}){ Edit(); } elsif ($call{'editregistration'}){ EditRegistration(); } elsif ($call{'newdatabase'}){ New(); } elsif ($call{'keywords'}){ # Search # This subroutine is responsible for searching through the # database for relevant keywords, and to fill an array with # the relevant database entries, In the order they are to be # displayed &Search; } else { &printHtmlHeader; print "

"; print "Improper request method you may have to add some more\n"; print "input variables. ie: For forms, add a hidden input that \n says what you want to do. See the documentation about request methods\n"; print "

"; &printHtmlFooter; exit; }