View Single Post
Old 09-08-2009, 09:15 AM  
GrouchyAdmin
Now choke yourself!
 
GrouchyAdmin's Avatar
 
Industry Role:
Join Date: Apr 2006
Posts: 12,085
This is incredibly basic shit. The following is a top-down-no-classes-used example, using cURL, as suggested above. Note the lack of RETURNTRANSFER as we're only checking the status code.

Code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.site.com/blah/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch,CURLOPT_VERBOSE, FALSE);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$pageData=curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

switch ($statusCode) {
  case 404:
    filemissing()...
    break;
  case 401:
    authreq();
    break;
  default:
   whatev();
}
Quote:
Originally Posted by nation-x View Post
if the file is an image every time... you can use getimagesize >> http://us2.php.net/getimagesize
Do not use getimagesize() as a boolean for validation - that is VERY unsafe.
__________________

Last edited by GrouchyAdmin; 09-08-2009 at 09:18 AM.. Reason: getinagesize() is bad for all living things
GrouchyAdmin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote