Home > Backend Development > PHP Tutorial > 对盗链说再见..._PHP

对盗链说再见..._PHP

WBOY
Release: 2016-06-01 12:32:25
Original
859 people have browsed it

第一页内随机的产生一个数(0-15)-》dechex()保存在session内



然后将URL使用此标记进行运算,随便你运算了,不过要能逆过来才行~



第二页则检测是否有此标记,有则进行逆运算,然后将变量取出



优点:(必须访问站点URL才有效~)



缺点:(保存到本地的页面链接全部失效,盗链失效)



---------------------------------------------




ob_start();

session_start();

if(isset($_SESSION[key]))else{                    //无钥匙

    $key=dechex(rand(0,15));    //产生钥匙

    //如果您本页已经是最后一页,而不允许盗链的链接的话

    //echo "您的链接并非来自本站!请访问站点后访问此页...";

    //exit();

}

?>

HTML内容..............(这里包含很多链接的...)




$htmlcontent=ob_get_contents();        //获取所有HTML内容

...............................        //替换所有连接参数href=url?被替换的数据(一组正则)

ob_end_flush();                //输出HTML内容(href=已经加密后的数据)

?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template