Project 5. Description.

Main assignment

In this project you need to complete the Picture Album site you have been working on during the semester. This project includes several parts.

Part 1: Working with the file storing info about the pictures.

In homework assignment you developed a script that appends info about a new picture into the text file that contains info about all uploaded pictures and the script that displays the contents of the file as a table. Now you need to be able to remove a picture from the "database". In order to do that, you need to replace the first character in the line that contains this picture info with the character X. Thus, you need to read the file line by line searching for the picture name to remove until you find the string that has the data you need, then using fseek() function move the file cursor back to the beginning of the line, and write a character X. Of course, you need to open the file for both reading and writing, but make sure you don't loose the contents of the file. You script should print a message confirming the deletion or an error message if you were not able to locate the picture or some other error occurred. You also need to get back to the script that displays your "database" as a table and make sure that the last column with the delete images now work referring to the new script you just developed.

In this part you also need to modify the table thsi script produces in such a way that each column header become a link to the same page (but with different parameter) and once you click on this link you should be given the same table sorted by the specified column. Please note that I don't want you to sort just one column and leave the others untouched. I want you to sort one column and reorder the others appropriately. See examples on the PHP example page and especially this short one.

Part 2: Making the slide show dynamic

In the second part you need to rewrite your slide show script as a PHP file versus static HTML page you had before. The only difference would be that now the JavaScript array

var img_info = var Array (
                                  { fname: "first.jpg", title:"My first picture", date:"Oct 12, 2004",
                                    time:"12:30pm", camera:"Sony", descr:"Log text goes here" },
                                  { fname: "second.jpg", title:"My second picture", date:"Oct 15, 2004",
                                    time:"13:30pm", camera:"Sony", descr:"Another long-long text goes here"},
                                  { fname: "third.jpg", title:"My last picture", date:"Dec 31, 2004",
                                    time:"12:00am", camera:"Canon", descr:""}
                                );
has to be dynamically generated by the PHP code using the data from the picture info file. That is, your PHP script should read the file, and for each line that has V character as the first symbol you need to add another element of the JavaScript array. This is the only change you need to make for your old HTML slide show.

Part 3: PHP regular expressions

You need to get back to your PHP script that uploads the picture and insert code that checks the script arguments (date, time, title, type of the file, etc) for appropriate format. You need to apply PHP regular expressions to test the values of the arguments your script received. The script should generate an error message if the date or time is in a wrong format, the title is empty, or the uploaded file is not an image file.

Additional credits

For additional credits you can demonstrate that you know how to hide PHP error/warning messages and display your own error messages instead.

Do not forget to place all your files into your directory on the CIT-PROJECTS server and insert the link to the last project into your index.html page. Failing to insert a link on your front page may result in lower grade for the project.