How to stop accessibility of a PHP documents from various other websites
I read someplace concerning warm connecting of images. Protecting against photo warm connecting aids to stop transmission capacity burglary from your website. Would certainly it benefit a PHP documents?
In my instance, I am making use of a PHP documents to create thumbnails from a photo. I do not desire others to refer this PHP documents from their website.
0
Amit Kumar Gupta 2019-05-13 02:11:41
Source
Share
Answers: 1
One programmatic means is to examine the referrer to see to it the demand originated from your website:
<?php
$yoursite = "yoursite.com"; //Your site url without http://
$yoursite2 = "www.yoursite.com"; //Type your domain with www. this time
$referer = $_SERVER['HTTP_REFERER'];
//Check if browser sends referrer url or not
if ($referer == "") { //If not, set referrer as your domain
$domain = $yoursite;
} else {
$domain = parse_url($referer); //If yes, parse referrer
}
if($domain['host'] == $yoursite || $domain['host'] == $yoursite2) {
//Run your image generation code
} else {
//The referrer is not your site, we redirect to your home page
header("Location: http://yoursite.com");
exit(); //Stop running the script
}
?>
Edit
This article offers an alternative method making use of PHP sessions.
0
BenV 2019-05-17 10:35:26
Source
Share
Related questions