当前位置:首页 > PHP教程 > PHP高级教程

如何在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>


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!