Categories
PHP programming security

PHP: Anti-spam CAPTCHA using photos

I’m just finishing up a quick PHP project at the moment, which allows anyone to register an account – so as the final step before launching it, I needed to add some form of CAPTCHA system. I tried a couple of 3rd party ones and source code ones and none quite worked for me. This post gives full source for a simple user-friendly photo-based CAPTCHA in PHP. Use at your own risk – but it’s short and easy to integrate.

NB: this was more a quick-and-dirty practice exercise than a serious attempt at a CAPTCHA. I don’t believe in CAPTCHAs, generally – but if you ARE going to use them, it’s best to have a lot of them in the wild, so it’s harder for crackers to do “crack once, spam everywhere”. See the section at the bottom for links to suggestions for other people’s CAPTCHAs that I reckon would be better for production use if you can get them to work :).

Categories
bitching dev-process fixing your desktop iphone programming

Unity: First impressions

I had to do some iPhone prototyping recently, and we had a trial copy of Unity to hand. I thought this was a great excuse to try using it. First impressions of the editor/IDE/environment – at least on OS X – are not good.

NB: In general, in terms of what can be done with it etc, I’m a fan of Unity. But I’ve never developed with it directly myself, and I’m now finding it surprisingly painful / steep learning curve.

Need to know basis

None of the built-in tutorials work, flat out, because the startup code has apparently changed substantially since they were written. The tutorials keep talking about things like “create a new project; by default it will X and Y and Z” but Unity no longer does any of those by default. Sadly, the tutorials don’t tell you how to get any of those manually – because, you know, they’re done for you by default, why would you ever need to know how to do them by hand?

File Association Theft

I was also *extremely* unhappy to discover a short while later that Unity has stolen the file association for PHP files. Under OS X (thanks, Apple) managing file associations is a surprisingly irritating business, as bad as with Microsoft Windows (Apple deems users too stupid to be allowed to simply edit associations – but applications are allowed to overwrite each other with absolute trust from Apple, and no user intervention allowed), so this is a pain to fix. In particular, I have an entire *suite* of applications and IDE’s for doing web editing, including a specialized high quality PHP IDE. Not any more; Unity has clobbered that with a crappy text editor that does nothing more than basic syntax hilighting. This is pretty offensive: firstly, don’t steal my files without asking, and secondly – give me back my IDE!

NB: I have no idea how it has done this, but Unity appears to have overridden OS X’s systems for file association management – following the standard procedure (e.g. here) has no effect, and Unity keeps stealing control of the files immediately that you confirm you want to give the assocation to some other app.

At this rate, if I can’t find out what it’s done to my OS and undo it, I’ll be uninstalling and deleting Unity with extreme prejudice in the very near future. Sure, this is partly Apple’s fault for assuming all apps are perfect and all users are not, but at a simpler level I just cannot afford to have a non-functioning development computer just because of one badly behaved application.