欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

如何在PHP程序中防止盗链

程序员文章站 2023-01-24 20:26:56
example:     页面: dl.php      -------...
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>