This will pretty much require a database that you have said in a different post you do not have. If you tried to write this information to a flat file you are going to have problems.
__________________
+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++
-- (Terry Pratchett, Hogfather)
You need to get a database, most of the features that you want are going to be hard to code, and even harder to maintain data integrity. My suggestion for you is to get a database and then download an opensource CMS here is a bunch of them listed:
You may even get lucky and find a Gallery program that uses flat files.
Must read Review for Serious PHP Developers
NuSphere PhpED 5.5
: The Staff of php-editors.com recently spent a few days working with NuSphere
PhpED 5.5
(a popular PHP IDE) and
NuCoder 2.0
(a PHP Encoding Utility), read up on all the details.