I need to allow site users to supply remote "hotlinked" images.
I realize this is a little dangerous, so here's the procedure currently:
1) parse the path provided using PHP pathinfo and break the path into parts (host, filename, extension) that are then properly escaped.
2) execute a curl request for the image headers as described here: How can one check to see if a remote file exists using PHP? and verify that it's got a valid png or jpg mime type and an HTTP 200 return code.
3) verify that the filename and extension (from the pathinfo above) is a valid png or jpg file (I'm not accepting gifs etc.)
4) finally, store the image path data in multiple columns in the DB (escaping the data)
Am I missing anything? Is there any danger still lurking? I was thinking perhaps I should re-do the curl function on the display end too, to make sure the image is still there and that it's still an image.
Thanks for any advice.