#!/usr/bin/perl #========================================================================= # CSEE Course Database Processor # # File: courses.cgi # Author(s): Hank Burton (WHB), Literati Information Technology # # This script reads the CSEE courses database file created by the # DB_Manager application and processes the database for either the # syllabus or current course WWW page. If a WWW page is found for # the course, that site is displayed. Otherwise, the user is # informed that no page exists. # # Paramters: # course : CSEE course number (CS156, EE151, CPE112) # want : requested itemf or course -- 'syllabus' or 'current' # # 05-06-98 (WHB) : created #========================================================================= $|=1; require("../cgi-bin/cgi-lib.pl") || die "require cgi-lib.pl died"; require("../cgi-bin/csee-lib.pl") || die "require csee-lib.pl died"; require("../cgi-bin/ls-lib.pl") || die "require ls-lib.pl died"; &CheckCGIExecute; &ReadParse(*in); # # Process CGI Parameters ------------------------------------------------- # $course = $in{'course'}; $course_want = $in{'want'}; # # verify CGI paramters # # * 'course' & 'course_want' are required # * 'course_want' must have the value 'syllabus' or 'current' # if ( "$course" eq "" or "$course_want" eq "" ) { &litBeginHTMLOutput; print ""; &DisplayFile("../common/header.html"); print <ERROR!

Parameters course and want are both required!

EOT &DisplayFile("../common/footer.html"); exit 1; } elsif ( "$course_want" ne "syllabus" and "$course_want" ne "current" ) { &litBeginHTMLOutput; &DisplayFile("../common/header.html"); print <ERROR!

Parameter want has an invalid value! It must be either syllabus or current

EOT &DisplayFile("../common/footer.html"); exit 1; } # # Read and Search the Courses Database ----------------------------------- # open COURSES, "../DB_Manager/Data_files/courses.data"; $isMatch = 0; COURSES: while ( ) { ($xCourse, $xSyllabus, $xCurrent) = split /\|/, $_; $xCourse = lc $xCourse; if ( "$xCourse" eq "$course" ) { if ( "$course_want" eq "syllabus" and "$xSyllabus" ne "" ) { $link = $xSyllabus; $isMatch = 1; } elsif ( "$course_want" eq "current" and "$xCurrent" ne "" ) { $link = $xCurrent; $isMatch = 1; } } last COURSES if $isMatch; } close COURSES; # # Display Results of Search ---------------------------------------------- # if ( $isMatch ) { # # display resulting page # $_ = $link; if ( /http:/i == 0 ) { $link = $WWWSite . "courses/syllabus/" . $link; } #&litBeginHTMLOutput; #print "$link"; &NewWWWPage("$link"); } else { # # 'no document' message if requested course document is not available # $course = uc $course; $course_want = "current course information" if "$course_want" eq "current"; &litBeginHTMLOutput; print ""; &DisplayFile("../common/header.html"); print <

The class you selected, $course, does not have a WWW area available for the $course_want. We apologize for the inconvenience.


EOT &DisplayFile("../common/footer.html"); } 1; # exit program