unkwntech Posted July 21, 2008 Share Posted July 21, 2008 We used to pull this little trick with MySpace, we would insert an 'image' that was hosted on our servers ex: http://domain.tld/image.jpg however image.jpg would actually be a directory with a index.php that would print the users IP, user-agent and what not. I would like to prevent this on my own projects so I'm wondering if there is an easy way to check if an external image is an image, without having to store it locally. Edit: To clarify I don't want to check if the file is there but I want to check that the file is not a dir. Link to comment https://forums.phpfreaks.com/topic/115753-checking-if-an-image-is-an-image/ Share on other sites More sharing options...
cooldude832 Posted July 21, 2008 Share Posted July 21, 2008 Its difficult because the GD library in php can still produce an IMAGE but still process data based on the request (such as get the IP of the remote) address Look at the thread below this about images I posted an is_img function that is fairly good. http://www.phpfreaks.com/forums/index.php/topic,207782.0.html Link to comment https://forums.phpfreaks.com/topic/115753-checking-if-an-image-is-an-image/#findComment-595085 Share on other sites More sharing options...
unkwntech Posted July 21, 2008 Author Share Posted July 21, 2008 Yah, I was hoping to be able to detect if it was a script or a folder. Anyone know if there is anything like is_dir() that would work on a remote directory? Link to comment https://forums.phpfreaks.com/topic/115753-checking-if-an-image-is-an-image/#findComment-595089 Share on other sites More sharing options...
trq Posted July 21, 2008 Share Posted July 21, 2008 We used to pull this little trick with MySpace, we would insert an 'image' that was hosted on our servers ex: http://domain.tld/image.jpg however image.jpg would actually be a directory with a index.php that would print the users IP, user-agent and what not. I think you'll find your directory was actually a php script (index.php) so your not looking to detect if the image is a directory but a php file producing an image. Unfortunately, there is no difference in the end. As long as the php file sends the correct headers, it is an image, just as browsers think php pages are html. Link to comment https://forums.phpfreaks.com/topic/115753-checking-if-an-image-is-an-image/#findComment-595100 Share on other sites More sharing options...
cooldude832 Posted July 21, 2008 Share Posted July 21, 2008 thorpe was it you t hat wrote that is_img function I'm smearing on almost every board? or was it Baaran Link to comment https://forums.phpfreaks.com/topic/115753-checking-if-an-image-is-an-image/#findComment-595101 Share on other sites More sharing options...
trq Posted July 21, 2008 Share Posted July 21, 2008 What is_img function? Its easy enough to find out if something is an image by using getimagesize which will return false if the file provided isn't an image. However, as I said in my last post, as long as the php script in question sends the appropriate headers it is an image. Link to comment https://forums.phpfreaks.com/topic/115753-checking-if-an-image-is-an-image/#findComment-595109 Share on other sites More sharing options...
unkwntech Posted July 21, 2008 Author Share Posted July 21, 2008 Allright well thanks anyways guys.... Link to comment https://forums.phpfreaks.com/topic/115753-checking-if-an-image-is-an-image/#findComment-595113 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.