php简单防盗链验证实现方法

作者:shichen2014 时间:2023-09-12 04:55:15 

这里分析了php的简单防盗链实现方法。分享飞大家供大家参考。具体如下:

index.php页面如下:


<html>
<head>
<meta http-equiv="Content-Language" content="en" />
<meta name="GENERATOR" content="PHPEclipse 1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>防盗链</title>
</head>
<body>
<form action="check.php" method="post">
提交信息:<input type="text" name="name" value=""/>
<input type="submit" name="submit" value="提交"/>
</form>
</body>
</html>

check.php页面如下:


$urlar=parse_url($_SERVER['HTTP_REFERER']);
print("<pre>");
print_r($urlar);
print_r($_SERVER['HTTP_REFERER']);
if($urlar['host']!="localhost"){//此处可替换成当前使用的域名
echo "验证错误!";
echo "<script>alert('连接失败');location.href='index.php';</script>";
exit;
}
print("</pre>");

 希望本文所述对大家php程序设计有所帮助。

标签:php,防盗链,验证
0
投稿

猜你喜欢

  • python实现时间o(1)的最小栈的实例代码

    2021-08-01 15:24:42
  • 利用Python批量压缩png方法实例(支持过滤个别文件与文件夹)

    2021-07-16 11:37:24
  • javascript window.opener的用法分析

    2024-05-05 09:22:49
  • mysql #1062 –Duplicate entry '1' for key 'PRIMARY'

    2024-01-18 22:15:16
  • 彻底理解Python list切片原理

    2023-10-19 03:34:43
  • Python整数对象实现原理详解

    2022-10-09 13:53:03
  • 如何解决国外空间显示乱码问题

    2007-11-18 14:28:00
  • 在Pandas中导入CSV数据时去除默认索引的方法汇总

    2023-03-16 02:35:53
  • Python使用defaultdict读取文件各列的方法

    2021-08-05 00:34:24
  • Go语言开发保证并发安全实例详解

    2024-02-21 10:19:48
  • 关于mysql delete的问题小结

    2024-01-17 09:28:39
  • CSS3变换入门

    2010-01-30 13:29:00
  • Python上传package到Pypi(代码简单)

    2022-04-21 17:09:33
  • python list格式数据excel导出方法

    2023-09-19 14:21:01
  • Vue过滤器的用法和自定义过滤器使用

    2024-05-09 10:41:20
  • Javascript 注册事件浅析

    2024-04-28 10:20:22
  • golang实现的文件上传下载小工具

    2023-06-28 05:34:34
  • python 字符串的驻留机制及优缺点

    2022-11-16 10:07:37
  • jQuery实现弹出带遮罩层的居中浮动窗口效果

    2024-04-19 10:17:20
  • python Tkinter是什么

    2022-07-26 08:31:51
  • asp之家 网络编程 m.aspxhome.com