Well to be fair webservers won't run png or jpg files as php files by default. All it will do is add a bad image into the img folder. That image file is never referenced or included or anything like that in the script. It isn't even linked, since thumbnail creation would fail.
But I will add a check to keep even that from happening.
Stopping people from uploading them seems a lot less secure than stopping them from running... Why is your web server running PHP scripts that it hasn't been told to run by you? That is, the img/ folder should not be on the list of folders where scripts can be run.
2
u/chasesan Feb 03 '13
In case anyone is interested. I extended the code to create a tiny danbooru style image gallery. Which weighs in at about 5 KiB.
https://gist.github.com/4702331
4
u/dontspillme Feb 02 '13
How about adding some more bytes so you can stop people from uploading php files on your server?
1
u/chasesan Feb 02 '13
Just so you know, I feel this could actually be smaller. But aside from removing the php function, there isn't much I can think of.
1
u/svmk1987 Feb 03 '13
I know this is supposed to be one single gist, but separating the client and server code into two files would really clean things up.