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.

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:

    $yoursite = ""; //Your site url without http://
    $yoursite2 = ""; //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
        exit(); //Stop running the script



This article offers an alternative method making use of PHP sessions.

2019-05-17 10:35:26