PHP anti theft chain code example
- 2021-07-16 02:05:04
- OfStack
Anti-theft chain is a very common web programming skill at present. This paper shows the implementation method of PHP anti-theft chain with an example. Share it with you for your reference. The specific methods are as follows:
The main function codes are as follows:
<?php
/*
Usage : Save the above code as dao4.php,
For example, for testing validatecode.rar At the site http://www.XXXX.com Inside ,
The download connection is represented by the following code .
Filename ?site=1&file= Documents
For example, the following URL :
http://www.XXXX.cn/dao4.php?site=1&file=validatecode.rar
*/
$ADMIN[defaulturl] = "http://www.XXXX.com/404.htm"; // The address returned by the stolen chain
$okaysites = array(
"http://www.XXXX.com/",
"http://XXXX.com"
); // White list
$ADMIN[url_1] = "http://www.XXXX.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]");
}
?>
I hope this article is helpful for everyone to learn PHP programming.