Home > Article > Backend Development > PHP code A piece of anti-theft PHP code
$ADMIN[defaulturl] = http://www.163.com/404.htm; //The address returned by the hotlink
$okaysites = array("http://www.163.com/","http:/ /163.com"); //Whitelist
$ADMIN[url_1] = http://www.163.com/download/; //Download location 1
$ADMIN[url_2] = "";//Download location 2. And so on
$reffer = $HTTP_REFERER;
if($reffer) {
$yes = 0;
while(list($domain, $subarray) = each($okaysites)) {
if (ereg($ subarray,"$reffer")) {
$yes = 1;
}
}
$theu = "url"."_"."$site";
if ($ADMIN[$theu] AND $yes == 1) {
header("Location: $ADMIN[$theu]/$file");
} else {
header("Location: $ADMIN[defaulturl]");
}
} else {
header("Location : $ADMIN[defaulturl]");
}
?> Then use the following code to represent the download link.
File name?site=1&file=file
The above introduces the PHP code. A piece of anti-theft PHP code, including the content of PHP code. I hope it will be helpful to friends who are interested in PHP tutorials.