The due date is 11:30 a.m. on Friday, March 12.
1. A better counter.
(a) Implement the lock and unlock subroutines described in Handout S.
Put them in the cgi_helper
file. Remember to keep 1;
as the
last thing in that file.
(b) Rename your home page index.shtml
.
(c) Write an improved counter program that locks out multiple users, as described in Handout S. This time have the output be simply the content-type line, a blank line, and the count, rather than a full virtual page.
(d) In your home page, add a line such as ``There have been ...visitors to this page.'' But where I just wrote ``...'', put in a server-side exec to get the count. Remember that in testing you will need to use the ``reload'' button in your browser to get the current count.
Submit your counter file but not your home page (which can be viewed directly).
2. Images.
Images are easy to include on a web page. If you have a file
my_image.gif
just put the tag
<IMG SRC="my_image.gif">
or better,
<IMG SRC="my_image.gif" ALT="my favorite image">
where
the ALT
part is text to be displayed if the user has browser
images turned off.
Put one or more images on your home page using the IMG
tag and
the ALT
attribute. (Some members of the class have done so already;
they don't need to do anything new.)
Netscape will also handle .jpeg
images.
The problem with images is that many of them are copyrighted, so they
can't just be taken off the web and put on the UCLA site. It is
not even permitted to link them directly by giving their URL's in the
SRC
attribute.! For free clip art, see links on the PIC 40
home page. If a few people would like photographs scanned, I
can do that.
3. Cascading style sheets.
This topic will be discussed in lecture. Add some style sheet information to your home page, affecting various elements in a reasonable way. Try to make use of various kinds of style items from lectures, a forthcoming handout, and section. If necessary, add more text to your home page so you have enough material to which to attach styles.
Again, you do not need to use submit
for this problem. Although
you are not responsible for material beyond lectures, handouts,
and discussion section, some good references can be found under
``links'' on the PIC 40 home page.
4. A password check.
Write an HTML page and CGI script to ask for and check a user id and password. However, this is to be only a sample script that checks for just one user:
The user id larissas
with password hiho23#
should be
accepted. All other user id's and passwords should be rejected.
If the password is accepted, a virtual page saying ``Welcome'' should be
displayed; if it is rejected, the a virtual copy of the original
page should be displayed but this time with the notation
``Invalid information; please re-enter.''
To make this more realistic, make up a password file that contains just (i) the correct user id and (ii) the encrypted password. For salt, use your own user id. (Only the first two letters matter.)
To make up this password file, you will need to write a small script to do the encryption once. This script need not be handed in. In a real password procedure there might be another introductory page and CGI script for new users to request a password.
Your CGI script should check the password file for the correct user and encrypted password. The user and password (encrypted or not) should not be mentioned in your CGI script.
Lock the file while it is being read. (Normally a file that is read-only doesn't have to be locked, but we are imagining that this file could in theory be added to.)
Your HTML form should use the POST
method to avoid showing the
password in the URL.
Submit your HTML page, your CGI script, and the password file.