Welcome to maniacmartin, the personal site of Martin Smith.
I'm listening to P.O.D. – Preach

18 October 2007

Fixing File Uploads after upgrading to PHP5

Filed under: Computer — martin @ 1:21 pm

As some of you may know, I upgraded from PHP4 to PHP5 recently. And it went smoothly - or so I thought. Now, it seems I overlooked the fact that the reference $HTTP_POST_FILES has been phased out. This has been replaced with $_FILES. This is great, since Zen Cart, custom scripts, old phpBB installations and other old php scripts where users can upload a fail now fail spectacularly as they access an empty array.

First I wanted to write a perl script which I fed a list of files, but with 10GB of websites, this would take ages (and given a list , the number of arguments exceeded perls limit). So instead I ran this command from /var/www/vhosts
find . -name '*.php' -exec perl -p -i -e 's/\$HTTP_POST_FILES/\$_FILES/g' {} \;
find . -name '*.inc' -exec perl -p -i -e 's/\$HTTP_POST_FILES/\$_FILES/g' {} \;

to spawn a new perl instance per file, without checking jpegs and stuff.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment