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

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

程序员文章站 2024-01-19 11:06:46
...

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

check.php

html>
body>
form action="test.php" method="post">
    messageinput type="text" name="name" value="123456" />
    input type="submit" value="submit" />
form>
body>
html>

test.php

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

$url = parse_url($_SERVER['HTTP_REFERER']);
//print_r($url);
if($url['host'] != "localhost"){
    echo "";
    exit(0);
}else{
    echo "";
    echo "

Hello World!

"; }
相关标签: 防盗链