欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php簡單防盜鏈驗證實現(xiàn)方法 原創(chuàng)

原創(chuàng)  更新時間:2016年07月09日 23:28:35   原創(chuàng) 投稿:shichen2014  
這篇文章主要介紹了php簡單防盜鏈驗證實現(xiàn)方法,通過$_SERVER['HTTP_REFERER']獲取來路頁面URL再進(jìn)行判斷進(jìn)而實現(xiàn)對非本地URL的攔截功能,需要的朋友可以參考下

這里分析了php的簡單防盜鏈實現(xiàn)方法。分享飛大家供大家參考。具體如下:

index.php頁面如下:

<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頁面如下:

$urlar=parse_url($_SERVER['HTTP_REFERER']);
 print("<pre>");
 print_r($urlar);
 print_r($_SERVER['HTTP_REFERER']);
 if($urlar['host']!="localhost"){//此處可替換成當(dāng)前使用的域名
 echo "驗證錯誤!";
 echo "<script>alert('連接失敗');location.href='index.php';</script>";
 exit;
 }
 print("</pre>");

 希望本文所述對大家php程序設(shè)計有所幫助。

相關(guān)文章

最新評論