PHP Uploader for SmugMug

EDIT (9/28/2009): I pulled the sourcecode out of the post as it was far too long. I have also updated the download package with a couple of important fixes.

I just recently started playing with SmugMug and am really liking it so far. One of my complaints so far is the upload process. Let me be clear here…they have many upload options and odds are good that those options work for the majority of people. But I’m not one of them. Basically I want to be able to keep my online galleries in sync with the photos on my computer and I didn’t see an easy way to do this with the available options. Fortunately, SmugMug provides a solid API and many people have written tools that make use of it. I looked through what people have already written and unsurprisingly didn’t find one that did exactly what I wanted. I did find phpSmug which is a PHP class that makes using the api extremely simple.

Over the course of two days, I have written 2 separate (but related) uploaders that handle the things I need them to. Both require an API key and a valid SmugMug account. These aren’t necessarily the prettiest code I have ever written, but I think they work pretty well.

Download full (UPDATED) package

upload.php

This one is a fairly simple uploader. You give it the name of an album and a list of pictures to upload and it will upload any files that don’t already exist, replace files that do exist and update the metadata for those files.

multi-album-upload.php

This is the one that will keep a filesystem in sync with SmugMug. Point it at a folder and it will create categories, albums and handle the uploading (in the same way as upload.php).

cat-delete.php

This is a quick way to delete categories. Mostly I made it for while I was testing, but as there doesn’t seem to be a way to delete categories through the SmugMug UI this may be useful to someone.

Standard disclaimers apply to all of this. If it somehow causes the world to end or any other undesired effect, I take no responsibility. That said, it works pretty well for me. If you find any problems, let me know and I will update what I have posted.

Download full package

Slicehost

I have finally upgraded to my own VPS. Dreamhost was a great host, but I prefer being able to setup and break everything all by myself. Also, having dedicated resources makes things like photo galleries work much better. As such, 3dgo.net and all of its related sites are now running on a 256 slice from Slicehost. I’m running Ubuntu Hardy with Lighttpd as the web server.

When I was setting up the server I initially used Apache as it is what I am most familiar with and it is pretty easy to get up and running. But when I was trying to use my site, I realized that Apache is far too heavy with its memory usage. Even caching various things there was still not enough memory available for any kind of load. I had used Lighttpd once at work for a Rails app and had heard that it was significantly lighter than Apache. As such, I decided to try getting it up and working. That was easier said than done…

Problem: PHP wouldn’t work
Solution: Install php5-cgi and then activate the fcgi module (not the other way around)

Problem: Multiple virtual hosts by hostname?
Solution: http://www.debianhelp.co.uk/virtualhostslighttpd.htm

Problem: No .htaccess support (for mod_rewrite, mod_deflate)
Solution: No ideal solution for this one really, but you can setup mod_rewrite/mod_deflate rules in the config for each vhost. I prefer the .htaccess method, but this works for now. For most popular apps you should be able to find lighttpd rules to replace the .htaccess rewrite rules.

On the off-chance, you want to signup for Slicehost and wouldn’t mind using me as a referral, here is my affiliate link: https://manage.slicehost.com/customers/new?referrer=de41b271f1865e85d87b32e6996d4ee9