How to restrict access to a PHP file?

后端 未结 7 1304
故里飘歌
故里飘歌 2021-01-06 20:47

I\'d like to restrict access to a PHP file on my server. This PHP file takes data from an HTTP GET request and appends it to a file. Simple. But I don\'t want this PHP fi

7条回答
  •  再見小時候
    2021-01-06 21:19

    Define a salt in both your app and php file, then hash that salt combined with the current time. That's unlikely to ever get spoofed.

    $hash = sha1(time() . 'bladieblasalt');
    
    if($_GET['hash'] == sha1(time() . 'samehash'))
    {
        echo 'valid';
    }
    

提交回复
热议问题