Rumah > pembangunan bahagian belakang > tutorial php > php通过判断来源主机头进行防盗链,php来源_PHP教程

php通过判断来源主机头进行防盗链,php来源_PHP教程

WBOY
Lepaskan: 2016-07-13 09:44:03
asal
883 orang telah melayarinya

php通过判断来源主机头进行防盗链,php来源

check.php

<span><</span><span>html</span><span>></span>
<span><</span><span>body</span><span>></span>
<span><</span><span>form </span><span>action</span><span>="test.php"</span><span> method</span><span>="post"</span><span>></span><span>
    message</span><span><</span><span>input </span><span>type</span><span>="text"</span><span> name</span><span>="name"</span><span> value</span><span>="123456"</span> <span>/></span>
    <span><</span><span>input </span><span>type</span><span>="submit"</span><span> value</span><span>="submit"</span> <span>/></span>
<span></</span><span>form</span><span>></span>
<span></</span><span>body</span><span>></span>
<span></</span><span>html</span><span>></span>
Salin selepas log masuk

test.php

<?<span>php
</span><span>header</span>("Content-type:text/html;charset='utf8'"<span>);
</span><span>error_reporting</span>(<span>E_ALL</span><span>);

</span><span>$url</span> = <span>parse_url</span>(<span>$_SERVER</span>['HTTP_REFERER'<span>]);
</span><span>//</span><span>print_r($url);</span>
<span>if</span>(<span>$url</span>['host'] != "localhost"<span>){
    </span><span>echo</span> "<script>alert('host error.');history.go(-1);</script>"<span>;
    </span><span>exit</span>(0<span>);
}</span><span>else</span><span>{
    </span><span>echo</span> "<script>alert('host right.');</script>"<span>;
    </span><span>echo</span> "<h1>Hello World!</h1>"<span>;
}</span>
Salin selepas log masuk

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1051325.htmlTechArticlephp通过判断来源主机头进行防盗链,php来源 check.php html body form action ="test.php" method ="post" message input type ="text" name ="name" value ="123456" / input...
Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan