I'll try to keep this simple. As of the time of this writing, PSU implemented a (relatively) new PHP server available to student/clubs/faculty/etc. However, the PHP server is running in safe_mode and it also disallows all exec() calls. As such, not much pre-existing code works on it. I tried to get about nine (9) different 'gallery' types of programs to work, but all failed. Some were almost functional, and others failed miserably.

This gallery is a rip of the "gallery" program, found on SourceForge.net. It's an awesome program, but requires safe_mode to be disabled and exec() to be enabled in PHP. I didn't want to recode the entire beast and all its features. As it stands now, I wrote an indexing system to auto-index directories and files (index.shtml and cgi-bin/directory.tcl). Then there is the 'gallery' engine; I kept all the JavaScript code (because it rocks) and linked it to a Tcl engine to feed it all the images (gallery.shtml and cgi-bin/gallery.tcl). I also added in a browsing option, (browse.shtml and cgi-bin/browse.tcl) which is accessed via the main directory listing. As of this writing, I do not support "galleries" awesome features of: comments (does anyone in WSF really want/need this??), large file links, large file mode, and the ever-so-useful remote-uploading. Also, with my implementation this is *no* database. All data is pulled dynamically directly from the directories/files. Yes, if this were a very high-traffic site that would really be horrible... but that's not the case.

The purpose of this document isn't so much to help users, but to help whomever ends up maintaining this gallery database at a later time.

I find that the easiest method is to use ImageMagick to rotate and resize the images, and organize them into directories on my own computer. Then upload the photos into the data/ directory of the gallery. All files/directories are auto-indexed, so there's not much to do, as long as PSU continues to allow Tcl code to be run as an SSI CGI.

I'll assume you have ImageMagick already installed. You can find it on SourceForge.net; search for it; goto their homepage; download a binary compilation for Windows or whatever OS you're using. ImageMagick will let you resize an entire directory of images at once. At a DOS prompt in XP, I used the command:

FOR /F "delims=" %i IN ('dir /B *.jpg') DO convert -resize 400x300 "%i" "small_%i"

Be sure to keep a backup of the original images on CD, etc. The reason the original images are not included in this gallery script is because of the limiting 50MB quota imposed by PSU on each club's web space.

Limitations: The main index page has a known problem... due to my lazy coding. Only the first "root" image directories are given special treatment when calculating image totals. They show the number of photos in their own directory and all subdirectories. All other subdirectories only show the file total in themselves, not include any files in their own subdirectories. Tough. Directory names may not include "[" or "]", to prevent someone from attempting to run arbitrary code in Tcl.

Pluses: As written, this script should support spaces in both directory and file names. Yay. I initially wanted to use the unix/linux 'find' command to index directories, but it looks like the PSU webserver might be disallowing access to that. As such, all code is written entirely in Tcl8.2. (Yeah, I asked for an upgrade; it hasn't happened yet.) The point... this beast should run on pretty much *any* server. (with Tcl and Apache... who knows maybe even IIS)

This project took about 9 hours of development and testing. Wee! I hope it's appreciated/enjoyed. I certainly wasn't planning on spending that much time on it.

Note (9/28/04): I changed the program so it does not auto-index itself. This keeps it from running an index every time the main page is called, saving time and CPU. When new files are added, a WSF webadmin must login to the shell and run the program "re-index-files". It will create a new index.html file. Another side benefit of this change is that the index.html now can be called from the regular clubs.psu.edu server, rather than test.scripts.psu.edu. Yay!

--
Aaron Stephens
9/2004
AStephens at psu.edu
NASAdude at bigfoot.com (etc, etc, etc)