Archive for the 'php' Category

animated GIFs in PHP

Sunday, December 4th, 2005

i've started to look at imagemagick and the magickwand API for PHP. the docs are a little bit opaque, IMHO, but i did find the sample/demo PHP file, which is supposed to be included with the magickwand PHP distribution, but isn't.

in any case, the demo file helps a lot.

i'm surprised i don't see more animated-GIF generators online (maybe i'm just not looking hard enough?). i may start generating animated GIFs instead of SWF files for things that don't require interaction… for example, the non-interactive versions of the pets, for sites that don't allow you to embed flash.

[UPDATED: 2006-05-09: the link to the sample code is gone now. grr! and the README file in the magickwand for PHP archive refers to sample directories that don't exist. anyway, i have found another location of the sample code. i think i should make a local copy available here for future reference, in case that disappears too…]

flash, forms and character encoding

Thursday, June 9th, 2005

good to remember: when flash submits a form via LoadVars.send(), it sends text encoded as UTF-8. my current PHP scripts expect ISO-8859-1 (ISO-Latin1), so in my PHP scripts, i have to utf8_decode() the values.

this is all part of a process of making the pets less english-centric. right now they only allow the letters a-z in adopter and pet names. supporting all the alphabetical characters in ISO-8859-1 is just the first step, i hope.

i haven't delved into unicode and multibyte string support in PHP4, but i hear it's not so good :-\ it's supposed to be better in PHP5. i may upgrade if that's the case…

things like this make me miss java :) i also may start looking into other server-side scripting languages with better unicode support.

eAccelerator, and more on lighttpd

Wednesday, June 1st, 2005

i just installed eAccelerator, a PHP accelerator. it took a while to install it properly on this freeBSD box…

my first install attempt resulted in apache dying with 'Undefined symbol "php_session_register_module"'. it turns out eaccelerator needs to be loaded after the php session module is loaded. the annoying thing is that the instructions given to you by the port is what causes this error. it tells you to add "extension=eaccelerator.so" to your php.ini file… which causes it to load before any of the extensions specified in the php/extensions.ini file. the solution is to put the "extension=eaccelerator.so" line at the bottom of extensions.ini, where all the other extension loading is. sheesh.

i also found this post on the freeBSD ports mailing list. without the supplied patch, eaccelerator causes apache to segfault after every request, on freeBSD 4.x. it doesn't kill apache (just the child processes i guess), but the last thing i need is more process thrashing.

anyway… now that it's installed, it seems to be working fine. i'll be keeping a close eye on server load and any anomalies.

as for lighttpd, it seems to be working great. at the moment, all it's serving are the swf files for the embedded pets (and doing so with a very small memory footprint), but apache seems to be seizing up a lot less (before, apache was going down or slowing to a crawl for hours at a time, every couple of days).