爱程序网

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

来源: 阅读:

check.php

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

test.php

<?phpheader("Content-type:text/html;charset='utf8'");error_reporting(E_ALL);$url = parse_url($_SERVER['HTTP_REFERER']);//print_r($url);if($url['host'] != "localhost"){    echo "<script>alert('host error.');history.go(-1);</script>";    exit(0);}else{    echo "<script>alert('host right.');</script>";    echo "<h1>Hello World!</h1>";}

 

相关文章列表:
关于爱程序网 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助