FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Failed @getimagesize() print to error_log?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Failed @getimagesize() print to error_log? [message #173067 is a reply to message #173066] Sun, 20 March 2011 02:44 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 3/19/2011 9:58 PM, jwcarlton wrote:
> I have the following in a script:
>
> if (($image)&& (@getimagesize("/home/myaccount/www/thumbs/$image")))
> $height = "75";
>
> else {
> $image = "noimage.gif";
> $height = "75";
> }
>
>
> And I have a gazillion of these in my error log:
>
> File does not exist: /home/myaccount/public_html/thumbs/
> some_image_name.jpg
>
>
> This is the only script that refers to the "thumbs" directory (as far
> as I know), so I'm pretty sure that this is the culprit.
> Unfortunately, the error_log isn't giving a referer, so I'm not 100%
> sure that the references aren't coming from something like Google
> Images.
>
> Would a failed @getimagesize() write to the error_log? If so, would it
> be better to use is_readable()?
>
> if (($image)&& (is_readable("/home/myaccount/www/thumbs/$image")))

First of all, why are you using '@' to potentially hide errors? You
should not be using this; you need error messages displayed on your
development system. Rather, disable the displaying of error messages in
the php.ini of your production system.

And yes, a failed getimagesize() obviously writes to the error log. And
you won't get a referrer; getimagesize() is completely independent of
any web server.

is_readable() will help you determine if it's a file and is readable,
but it won't tell you whether it is a valid image file or not. But if
the only files in this directory are image files, you should be ok.

So the question is - does the file exist? Is it an image file? You can
check to see if the file exists with file_exists(), but you can't easily
tell if it is an image file or not.

If you really need to find out who the referrer is (does it make a
difference?), check the time of the error message and see what's
happening at that time in your web server access log. It should tell
you more about the request.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: PDO MySQL
Next Topic: Very strange behaviour of imageftbbox()?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 01:56:55 GMT 2024

Total time taken to generate the page: 0.04834 seconds