如何在PHP程序中防止盗链
(编辑:jimmy 日期: 2024/11/17 浏览:3 次 )
example:
页面: dl.php
--------------------------------------------------------------------------------------
复制代码 代码如下:
<?php
$id = $_GET['id'];
$act = $_GET['act'];
switch($act) {
default :
case "display" : displayHTML(); break;
case "down" : down(); break;
}
function displayHTML($id) {
setcookie("visited", "true");
// print your HTML.
}
function down($id) {
if(! isset($_COOKIE['visited']) ) print "你盗联?";
$sql = "select path from TABLE where id=". $id;
//..............................
}
?>
<a href="dl.php?id=1&act=down">Download Now...</a>
页面: dl.php
--------------------------------------------------------------------------------------
复制代码 代码如下:
<?php
$id = $_GET['id'];
$act = $_GET['act'];
switch($act) {
default :
case "display" : displayHTML(); break;
case "down" : down(); break;
}
function displayHTML($id) {
setcookie("visited", "true");
// print your HTML.
}
function down($id) {
if(! isset($_COOKIE['visited']) ) print "你盗联?";
$sql = "select path from TABLE where id=". $id;
//..............................
}
?>
<a href="dl.php?id=1&act=down">Download Now...</a>
下一篇:php的access操作类