Home >Backend Development >PHP Tutorial >Say goodbye to hotlinks..._PHP Tutorial
Randomly generate a number (0-15) on the first page - "dechex() and save it in the session
Then use this tag to perform calculations on the URL. You can do the calculation as you wish, but it must be reversed. ~
The second page detects whether there is this mark, if so, performs the inverse operation, and then takes out the variable
Advantages: (Must visit the site URL to be valid~)
Disadvantages: (All links saved to local pages are invalid, hotlinks are invalid)
------------------------------ ------------------
ob_start();
session_start();
if(isset($_SESSION [key])){ //Have a key
$key=$_SESSION[key]; //Get the key
$str=$_SERVER[QUERY_STRING]; //Get the encrypted data
$decryptstr=decrypt($str,$key); //Use the key to unlock the data (note, this is your inverse algorithm)
............. ............//(Decompose data into variables)
}else{ ; /Generate key
//If your page is already the last page and hotlinking is not allowed
//echo "Your link does not come from this site! Please visit the site and then visit this page.. .";
//exit();
}
?>
HTML content............(This contains many links... )
$htmlcontent=ob_get_contents(); //Get all HTML content
........................ ........... // Replace all connection parameters href=url?Replaced data (a set of regular)
ob_end_flush(); )
?>