這里分析了php的簡(jiǎn)單防盜鏈實(shí)現(xiàn)方法。分享飛大家供大家參考。具體如下:
index.php頁(yè)面如下:
<html>
<head>
<meta http-equiv="Content-Language" content="en" />
<meta name="GENERATOR" content="PHPEclipse 1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>防盜鏈</title>
</head>
<body>
<form action="check.php" method="post">
提交信息:<input type="text" name="name" value=""/>
<input type="submit" name="submit" value="提交"/>
</form>
</body>
</html>
check.php頁(yè)面如下:
$urlar=parse_url($_SERVER['HTTP_REFERER']);
print("<pre>");
print_r($urlar);
print_r($_SERVER['HTTP_REFERER']);
if($urlar['host']!="localhost"){//此處可替換成當(dāng)前使用的域名
echo "驗(yàn)證錯(cuò)誤!";
echo "<script>alert('連接失敗');location.href='index.php';</script>";
exit;
}
print("</pre>");
希望本文所述對(duì)大家php程序設(shè)計(jì)有所幫助。