COP3832, Assignment 3
Due 3/4 at the start of class
-
Create a web directory on mongoose. The name for the directory is
public_html. Give it the correct permissions.
-
Create an index.html page that will have a link to
COP3832/run-hw3.cgi. Give it the correct permissions.
-
Create a subdirectory of public_html named COP3832. Use uppercase
letters. Give it execute permissions.
-
Recreate the .htaccess file in COP3832. It should have the same contents
as before. Give it the correct permissions.
-
Create a script in COP3832 named hw3.cgi. You should be the only user
that has access to this file. Be sure that it can be executed.
-
Copy the script run-hw3.cgi into the COP3832 directory from my
directory
cp /home/scsfac/downeyt/public/bin/run-hw3.cgi
~/public_html/COP3832
-
Your script will generate a dynamic HTML page as follows:
-
Depending on the current time, your page will look different. If the number
of seconds is even than your page will look one way, if the number
of seconds is odd, the page will look another way. To isolate the
number of seconds in the time, use this Perl code
($seconds) = localtime =~ /:(\d{1,2})\s/;
-
Use CSS to control the look of the page. You must change at least these
three styles:
-
Text color for the page
-
Background color for the page. Be sure that the text is easily readable with
this background color.
-
Font for the page (be sure to specify a default if your font is not available).
Be sure that the fonts look different.
-
If there is extra path information in the URL, then use it as the title of
the page, and put it into a level one heading. If there is not any extra
path info, then display a default title and heading.
-
Remember that the path info could contain special characters, so you will
need to decode it. To include the url_decode function that I covered
in class, add the following to your Perl script:
use lib "/home/scsfac/downeyt/scripts";
use CGILib;
-
The extra path info may have a leading / in it. The following Perl code will
remove it from a string if it is there. If it is not there, then the string
will be unchanged.
($string) = $string =~ /^\/?(.*)$/;
-
Display an image, based on the browser that is being used to view the page.
-
If the browser is Internet Explorer, then display the following
-
This page is best viewed with Netscape Navigator
-
Display this image
/~downeyt/images/nnc_lockup.gif
-
Set the width and height of the image to 123 by 25.
-
If the browser is not Internet Explorer, then display the following
-
This page is best viewed with Internet Explorer
-
Display this image
/~downeyt/images/bnrIE.gif
-
Set the width and height of the image to 250 by 60.
-
Internet Explorer browsers have MSIE contained in the string that
is sent to the server that identifies the browser. To test if a string contains
MSIE, use the following Perl syntax
if ($string =~ /MSIE/) {...
-
Include some text in the page so that I can view the effect of the CSS.
-
If you should get a 500 Internal Server Error, you can issue the following
command from the command line to view the most recent errors in the servers
error log. If you need to see more lines from the file, change -20 to any
number that you like.
tail -20 /home/mongoose2/aul-user-web/logs/error_log
The most common error will be "Premature end of script headers". To fix this,
make sure that the first text that is sent to the browser
is
Content-type: text/html
and that it is followed by a blank line.