Hi all
I'm writing a code to search image on google and parse the urls to a flash aplication. More and more I don't get the image but a picture that tells me not to hotlink. I want to detect this so I can look for another image. I've written a funtion that checks the heather so filter bad urls but it don't detect hotlink prevention. I don't want to load the image end check it size, it will slow down my code to much.
Anyone an idear?
my funtion:
function goodUrl($urlString)
{
if (strpos($urlString,'http://')===0)
{
$pf = curl_init($urlString);
curl_setopt($pf, CURLOPT_HEADER,True);
curl_setopt($pf, CURLOPT_FOLLOWLOCATION,False);
curl_setopt($pf, CURLOPT_RETURNTRANSFER,True);
curl_setopt($pf, CURLOPT_NOBODY, True);
curl_setopt($pf, CURLOPT_TIMEOUT,30);
$ret = curl_exec($pf);
$heathers = curl_getinfo($pf);
if ((empty($ret)) || ($heathers["http_code"] <> 200) || // bad connection
(strpos($heathers["content_type"],"image/") === false)) // not an image
{
curl_close($pf); // close cURL handler
return False;
}
else
{
curl_close($pf); // close cURL handler
return True;
}
}
else
{
return False;
}
}