Chris Pollett >
Old Classes >
PIC40

   ( Print View )

Lecture Notes-PDF

Spring '01 Ad: Enrollment info

Course Info: Homework Assignments:
Practice Exams:
PIC:
                           












HW#4 --- last modified January 16 2019 00:35:22..

Solution set.

Due date: noon Feb. 23
=========

Files to be submitted:  p40hw4file1.html --main search page
======================  p40hw4file2.cgi --adds page and prints if
                                          succeeded on main page
                        p40hw4file3.cgi --prints out the results of a
                                          search query.
                        p40hw4file4.php --add a new site form

                        These files should be both put in your
                        \SUBMIT directory under DOS and also
                        in a hw4 subdirectory of your public_html
                        directory. Make sure to chmod 755 things.
                        Note: both .cgi files need to print out that
                        the content type is text/html for anything to
                        appear.

HW4 Purpose: To build a user maintained toy search engine for the web.
============ To learn about server-side-include directives, form
             processing, perl directory and more file commands.

Specification:
==============
For this homework you can use the library subparseform.lib
which you can find off this page.

The two HTML files you write should both use server side includes to print out
the last time they were modified. p40hw4file1.html should have
in its head the title Toy Search Engine. In the body it should first exec
the file p40hw4file2.cgi. This file then checks to see if form data variable
submit2 exists. If not, it
checks if there exists a directory named searchdb in the current
directory. If this directory does not exist it creates it. We
will describe what p40hw4file2.cgi does if something is posted in a moment.
The file p40hw4file1.php then has in a centered h1 heading at its
top Toy Search Engine. Beneath this it says: "Search database for a
single keyword:". Next to this it has a textfield named searchfield 15
characters wide which accepts up to 80 characters of input. Next to the
textfield it has a submit button named submit1.
After this p40hw4file1.php exec's the cgi
script p40hw4file3.cgi. This script checks if the form data variable
searchfield exists and if so detrmines its value. If it does not exist it
does nothing. Otherwise, it  then looks in the searchdb directory
for a dbm hash with this name. If such a hash does not exist,
it prints "Sorry, no matches." If the dbm hash exists it  prints out
all the URL keys (also make these link to the appropriate places) followed
by their description values.
The last thing the file p40hw4file1.html has in it is a link to
the file p40hw4file4.php called "Add a page to database."
The file p40hw4file4.php has title: "Toy Search Engine -- add a page"
and also has this at the start of its body in a centered h1 heading.
In then says, "Enter a list of space separated keywords:" followed
by a textfield of width 40 characters of maxlength 120 characters
named keywords. It then says "Enter a URL:" which is followed by a
textfield of the same dimensions as keywords. This textfield is named
url. It then says: "Enter a description:" which is followed by
a 40 column by 10 row textarea named description. Beneath this text
area are two buttons: a submit and reset button. The name of the submit button
is submit2. This form also uses the GET method and its action is the page
p40hw4file1.html. You can assume that this form is always filled out with at
least one keyword and a valid url and description (you don't need to error
check). When this form is submitted, in p40hw4file1.php the file
p40hw4file2.cgi will be exec'd and see that there is a form variable submit2.
For each keyword in keywords it then opens a dbm hash in
searchdb and adds a row which has a key which is the url submitted
and a value which is the description submitted. After doing all this
it then prints out "URL added to appropriate DBMs". (Thus, this will appear
when you look at p40hw4file1.html in this instance.)


Point Breakdown for HW4
=======================
Comments...............................1pt
The two HTML files use an SSI to
   print out the last time they were
   modified............................1pt
p40hw4file1.html looks as described....1pt
p40hw4file1.html has exec SSI
 directives as described above.........1pt
p40hw4file4.php looks as described....1pt
p40hw4file2.cgi checks if directory
searchdb exists and if not creates
in case no data posted.................1pt
p40hw4file2.cgi if data is posted
adds URL's and description
to appropriate DBMs....................1pt
p40hw4file3.cgi lists out URL
and description associated with a
 keyword as described above............1pt

Total..................................8pts