
Man, this was hard and this is an ugly presentation of the assignment but hopefullly I'll have a chance to go back and spruce up the style a bit.
Code Files
here
Implementation:
I used the $_SERVER php variable in the login.php and upload.php pages. I use it to test if a visitor to the page is already in the page and has clicked the submit button or if he/she is just coming to the page from somewhere else.
Example from login.php
if ($_SERVER["REQUEST_METHOD"] == "POST")This code tests to see if the REQUEST_METHOD equals POST, i.e., was the submit button clicked on this page. If yes, the code inside the "if" block is executed which processes the login logic. If no, we know the user is just arriving to the page via normal methods, e.g., redirected to this page, and we show the XHTML and the login logic is not executed (until submit button clicked).
I used the php function shell_exec() to execute the bash commands "tail -6 | tac > images_reversed.txt". These commands lists the last 6 lines of the image.txt file and then reversed the order of the lines and redirected the output to a new file "images_reversed.txt"