\n"; } else { header("Content-type: $mime_type; charset=utf-8"); } ?> > CSCI 903 Assignment 3

CSCI 903 Assignment 3

Overview

This is a multipart assignment in which your course web site’s home index page is to provide a summary of projects done to date. Once this index page has been set up, the site is to adjust automatically to show new projects, when projects were last modified, and summary information about each project.

New Account For Course

With this project, we are also changing the “remote” server for your site from oak to babbage: I was unable to get the user-specific document root directories on oak to work as I had hoped I could. Your H: dive will continue to be available as your home directory when you access your lab account, and you should continue to use your lab account to write your code for the assignments. You can continue to work from off-campus using RDC, and in that way you can continue to use Dreamweaver in the lab. But, as explained in the TREE Lab Information page, and the pages linked from it, you are not required to use the TREE Lab if you have a different development environment you are already comfortable with.

But now you have another, separate, account with the same user name and password as your TREE Lab account. This one is on babbage.cs.qc.cuny.edu. The account is set up with a directory named htdocs in your home directory, just like (but separate from) the htdocs directory on your H: drive in the lab. The URL is the same as the one you used on oak: a tilde (~) followed by your account name.

To copy your files to your htdocs directory from another computer, using Dreamweaver’s sites feature, Aptana Studio, WinSCP, Fugu, or some other program, you need to know the pathname to your home directory. For Perfect Student with a student id of 99999999, it's:

/Volumes/Sensitive/Library/WebServer/Documents/babbage.cs.qc.cuny.edu/cs903/stpe9999/htdocs

Substitute your own account name for stpe9999.

Before you start work on this assignment, you need to make sure you can copy the code you develop in the lab or off campus to your babbage account, and to access it using a URL like http://babbage.cs.qc.cuny.edu/~stpe9999 .

Instructions

  1. For this step, you are to set up your htdocs directory so that there are three subdirectories, one for each of the first three assignments. Perfect Student used “Assignment_01,” “Assignment_02,” and “Assignment_03” for the three directory names, but you can use more descriptive names if you like. Just be sure there are no spaces in the directory names because they will be used in URLs, where spaces sometimes require extra effort to get them to work right.

    The only thing that goes in the Assignment 3 subdirectory (for now) is the stylesheet for assignment 3. The index page for this assignment is to be the index page for the htdocs directory. Create that index page using the PHP and <footer> element with validation links like the code in the previous assignments to start.

    Make the title and h1 elements of the index page tell what the web site is about. Perfect Student used the title, “Perfect Student’s Assignments for CSCI 903,” but you can make yours anything you like. If you use an apostrophe in your h1 element as Perfect Student did, it must be typographically correct (a right single “curly” quote(’), not a prime symbol (').

    Test your web site to make sure your new index page displays properly and that both validation links give no errors and no warnings except for the one about HTML5 from the XHTML validator.

    Now add a PHP block between the h1 and footer elements. This block is to display an h2 element for each file or directory in your htdocs directory, with the name of the file or directory as the contents of the heading.

    • Use the PHP opendir() function to get a PHP “resource” that represents the current directory. See the PHP Manual for more information on this function.
    • Use a while loop to get the names of the files and directories by calling readdir() repeatedly. Echo the names of the directories inside h2 elements; ignore the files. The first Example on the opendir() page of the PHP Manual shows how to do this, except you have to put the file or directory name inside an h2 element and you are not to display the file type. (It will always be “dir.” Lookup the is_dir() function in the PHP Manual if you are not sure what it does.

    Use a stylesheet to make your web page look “good.”

    Test your code! Try adding and removing subdirectories to your htdocs directory to make sure it displays them correctly. Be sure both validators continue to give your site a clean bill of health.

    Send me an email with “CSCI 903 Assignment 3A” as the subject, and be sure to include you account name in the message body. The assignment is due by midnight of the due date (March 5).

  2. Do not include this step in your web site until you have received your grade for the previous step of the project.

    There are some directories in your htdocs directory that have nothing to do with your assignments. If you use Dreamweaver, it will place a _notes there; if you use Git, it will place a .git directory there; all directories have two extra directory entries: ., which always represents the current directory, and .., which always represents the directory above the current directory. In Unix-based systems (Linux; Apple OS X), file and directory names that begin with a dot are hidden from normal directory listings, and you should eliminate them from your list of h2 elements. That is, you need to examine the first character of each directory name to see if it is a dot or an underscore (to handle Dreamweaver’s _notes directories).

    To do this filtering, you will have to start working with directory names using PHP’s string manipulation features. You will also need to learn how to manage the while loop so it skips the unwanted directories. Both of these topics will be covered in class.

    For this step you are also to turn your h2 text into clickable links to the appropriate assignment directories.

    Finally, look inside each directory to see if there is a file named README, README.md, or README.txt there. If so, pass the contents of the file to the Markdown() function and display the results in a div element right after the h2 element. If none of those files is there, display a paragrah saying there is no project description available. Do not put such a file in the directory for the first assignment, put one named README in the second assignment directory, and put one named README.md in the third assignment directory so you can test that this requirement works correctly. (What’s not being tested?)

    Test your code carefully, and send me email with CSCI 903 Assignment 3B as the subject, and your account name in the message body. The due date is midnight March 12.

  3. Do not include this step until you have received your grade for the previous step.

    For the last step in this project, you are to add the name and latest date at which any file in that directory or any of its subdirectories was modified. Also, add an empty index.php file to the directory for Assignment 3 so user will not be able to browse the directory from the web.

    Test the entire project carefully, and send me an email with CSCI 903 Assignment 3C as the subject and your account name in the message body. The due date is midnight March 19.