October 30, 2004

The plight of a Movable Type plugin

Nothing is ever as easy as you would hope it to be.

So i've been messing around with my comment spam stopping idea. When searching for sample code on the web, i kept coming across samples that use the MT::Plugin class which is new to MT 3.0+. I'm still running 2.661 after the problems i had last time i tried to update my blog. Now that i have a local installation on my Mac to play with, i thought i would take another shot at an upgrade. I downloaded the latest version, copied the new files to my local server, and tried to login. Unfortunately, i was welcomed by a the same "invalid login" error that i met the first time i tried this process.

I had to retrace my steps to see where i might have gone wrong. The upgrade version has a bunch of upgrade cgi scripts in it to change your existing data into the new format. Since i was running 2.6, i thought i should run the "upgrade26.cgi" file. I think this was my first mistake. It turns out i should have run the "30" and "31" versions. I wish they would have put a readme file in the download itself to explain this more carefully. Nevertheless, after running these, i still could not log in. My next step we to head back to the MT support forums to see if there were any more suggestions on what to do next. This time around i found a link to a helper cgi file called MT-Medic. It offers a way to reset your Moveable Type author account password, among other things. Thinking one of the upgrades may have rehashed my password, i figured it was worth a shot. That did the trick and i finally had the newest version of MT on my machine and i could get back to coding my plugin.

I thought i would use MTBlacklist as a good example of how to write a plug in so i tried installing it on my web server. As soon as i did entries poured into my error log telling me i was missing a required perl module, "Storable.pm." A google searched confirmed this to be a common problem. Prior version of MTBlacklist could use this module to store data or the could use an alternate module, YAML. The newest version does not have this flexibility. It looks like it actually effects any items that use the new MT::Plugin class because this module is referenced in the MT::PluginData class which i believe is used to persist plugin configuration data.

Apparently Storable.pm is not included in the standard installation of perl. I connected to cpan to download and install this module. However i kept getting errors that prevented the module from installing. It just would not work on my copy of OS 10.2.6 (yes, i know i should upgrade but its so close to Tiger so why not just wait it out). This meant i would be unable to use the MT::Plugin class which was why i had started this whole upgrade process in the beginning. Given this news, I decided there was no point to upgrade to 3.1 on my live site.

Back to square one, i started a new web search to find more samples. I stumbled across an enhancement that created image captchas in the MT comments form. This was closest to what i wanted and ultimately worked by hacking the standard Comments.pm file in the lib/MT/app/ folder. It's not every elegant but at least it seems to work.

Rather than using an image technique as most of these systems do, i went with simple math problem that the user must answer by choosing one of four potential responses. I figured it would be easier for legitimate posters to get past than retyping some silly distorted characters, and, at least for now, it's just as secure. I doubt anyone will spend the time coding a script to scrape and solve my math problems any time soon. Plus it's still accessible to all of my visually impaired comment posters (yes, all zero of them).

OK, i've ranted enough for now. If you run into any problems, drop me an e-mail: me {-at-} matthewflickinger {.dot.} com. Let's see if it works.

Posted by Matthew at October 30, 2004 10:45 PM
Comments

Matthew,
I finally realized something about your install of MT 3.xx. I'm pretty sure that it requires a dummy username/password (Melody/Nelson comes to mind)... wasn't sure if you had tried this yet, it's in the documentation...

Posted by: Shooter at October 31, 2004 10:24 PM