Forum Moderators: coopster

Message Too Old, No Replies

php getimagesize function and limiting ip's in htaccess

         

rfontaine

7:43 pm on Dec 5, 2005 (gmt 0)

10+ Year Member



This is interesting: if I use .htaccess RewriteEngine to allow only our ip to view the website, I get this error whenever I attempt to use the GETIMAGESIZE function in a PHP script yet everything else seems to work.

Warning: getimagesize(http://www.example.net/myimages/47.jpg): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /home/example/public_html/admin/news/edit-images.php on line 121

The same thing happens if I password protect the directory.

What's up with that? Any ideas?

rfontaine

8:21 pm on Dec 5, 2005 (gmt 0)

10+ Year Member



Interesting, in case someone else runs into this - when the site is password protected, the getimagesize() function has to refer to the image as:

/home/example/public_html/images/image43.jpg

rather than as

http://www.example.com/images/image43.jpg

I am sure there is a reason, but for the application I am working on it does not really matter.

py9jmas

8:32 pm on Dec 5, 2005 (gmt 0)

10+ Year Member



http://www.example.com/images/image43.jpg

Like this the PHP code requests the graphic over HTTP just like a browser. The server processes it exactly as it would a request from a browser, and the request has to pass through all the access controls.
/home/example/public_html/images/image43.jpg

Like this, the PHP code opens the graphic as a local file, completely independantly to the web server and the server's access contorls, it only has to get through the OS's file access controls.