A piece of PHP code for anti-theft connection_PHP tutorial

WBOY
Release: 2016-07-21 15:59:31
Original
936 people have browsed it

$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]");
}

?>


Usage: Save the above code as dao4.php,
For example, the test validatecode.rar is on the site http:// In 163.com/download,
uses the following code to represent the download link.

File name?site=1&file=file

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317312.htmlTechArticle$ADMIN[defaulturl]=http://www.163.com/404.htm;//hotlink Returned address $okaysites=array("http://www.163.com/","http://163.com");//Whitelist $ADMIN[url_1]=http://www.163. com/download/…
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!