hi i want to check if a image is hotlinked protected or not. i searched several sites and found the http header as best solution for checking this but when i implemented i found that it is giving wrong result.
for example http header response is coming
Array ( [0] => HTTP/1.1 200 OK [1]
but when i link in iframe or directly in php its throwing error.access denied the image is hotlinked protected. i was trying for this image link
<?php
$url = 'http://s.wallpaperhere.com/thumbnails/preview/20130702/51d3b5478d616.jpg';
print_r(get_headers($url));
print_r(get_headers($url, 1));
?>
is there any best way to cheek this and store the correct image in database which is not protected
"hotlink" detection is normally performed on the referrer header. Your example won't send a referrer so the remote side is assuming it's a direct request.
You can add a referrer header to the get_headers() call using stream_context_set_default(). Example below. There's not really even a need to change the header value I've provided... I'd think it can be anything.
I've tested this with your example URL and it works as expected. Output below: