PHP with MySQL Beoyond the Basics
Photo Gallery Project
The photo gallery project utilizes many of the concepts previously covered.
Exericse
- Photo Gallery: Public Access | Photo Gallery: Administrative Access
- The Photo Gallery project is a simple application. The administrator has the ability to upload, and delete images, delete comments, and view a log of actions that have been taken on the site. This section is password protected. The public section allows users to view images and leave comments.
Username: User
Password: Pass - Actually, for some reason, my ability to enable a user to log in and out stopped working halfway through the project (I've no idea why), so the application has been modified so as not to require the login.
List of Changes to Photo Gallery Project
General Changes
- Strived to keep all HTML valid.
- Altered unnessary HTML tables to a more valid structure.
- Updated the look-and-feel.
- Added breadcrumbs for easier navigation.
- Added preview of images to admin homepage.
- Drastically updated the look of the user-submitted comment area.
- Made page redirect to bottom of comments upon submission of new comment.
- Updated the admin comment area to handle both comments related to an images and all comments.
- Added "current page" display to pagination.
- Added "disabled" links to previous/next buttons.
Coding Changes
- Used camel case instead of underscores on all custom variables and methods, excluding globals and variables which mirror table columns.
- Made a "TABLE_PREFIX" constant, as I couldn't make a unique database.
- Reduced code redundancy where applicable.
- Added "fetchAssoc" method to the database class.
- Addded "$_SESSION['username']" to the session class.
- Simplified $_GET strings, such as $_GET['clear'] == true to jsut be $_GET['clear']
- Made "sizeAsText" method hading GB as well as B, KB, and MB.
- Added a dynamic photograph display option: less than 10 photos, single column display; more than 10 photos, two column display
- Abstracted pagination logic to Pagination class.
- Added code which allows for pagination to work on pages with an id in the URL.
- Made a Logger class to handle log files
- The class handles both text and databse logs, either of which can be changed at will or set when the class is instantiated.
- The class ocntains functions for displaying logs in either a table or in paragraph form.
- Archives are never delted: Database logs have an "active" state, which is set to non-active; text logs are moved to an archive folder and the the date and time appended to the file name.