[all versions] minor enhancement for url_image_size in Subs.php

Started by Christian Land, April 27, 2004, 06:02:30 AM

Previous topic - Next topic

Christian Land

Nothing special, just replace

// See if it returned a 404/403 or something.
if ($test != '4')
return @getimagesize($url);


with

// See if it returned an HTTP Status beginning with 4 or 5 (=error)
if (($test != '4') && ($test != '5'))
return @getimagesize($url);


... i don't know how PHP handles the 3** http-status-codes, but it could probably be a good idea to check for them, too ...

[Unknown]

How many times is the status code going to be 50x?

-[Unknown]

Oldiesmann

There are really only 3 status codes you need to check for:
403 - Permission Denied
404 - File Not Found
500 - Internal Server Error

I can't really think of why you would get anything else while looking for an image unless there was a problem with the server the image was stored on...
Michael Eshom
Christian Metal Fans

[Unknown]

I can't even think of why you would get a 500 :P.  Those error codes are mainly used for overloaded servers and bad scripts...

-[Unknown]

Christian Land

::) It doesn't matter if the 50* errors are happening often. It simply makes sense to handle errors that can be handled.

[Unknown]

Well, I did change it, but still it's not a big deal is what I'm saying.  I actually just used < 4.

And, I don't believe PHP handles redirects, but if it does... great.

-[Unknown]


[Unknown]

Well, I used:

if ($test < 4)

Which means, basically, if it wasn't an error proceed with the getimagesize'ing.

-[Unknown]

Peter Duggan

Ah well, I realised as soon as I'd posted that I'd probably just mixed it up myself, but thought I'd leave the question up out of curiosity! ;)

David

500 seems reasonable to check for, not sure about other 5xx errors though.
This space for rent.

[Unknown]

4xx and 5xx are reserved for error codes anyway.  IIS abuses some of the 5xx range for ASP error codes.

-[Unknown]

Oldiesmann

The only other 5xx error I've seen is a "503 Service Temporarily Unavailable" error that was caused by a heavily overloaded server...
Michael Eshom
Christian Metal Fans

Advertisement: