朱纯树博客
VPS测评推荐网站
cloudacead cloudacead

PHP 过滤 post,get传入内容,防止字符串注入

介绍

可以简单拦截POST,GET传入的危险字符,有效防止字符串注入

拦截页面也是仿的宝塔的,截图演示:

PHP 过滤 post,get传入内容,防止字符串注入插图

代码

<?php
function safe_html(){
	echo <<<HTML

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>网站防火墙</title>
<style>
*{margin:0;padding:0;color:#444}
body{font-size:14px;font-family:"宋体"}
.main{width:600px;margin:10% auto;}
.title{background: #20a53a;color: #fff;font-size: 16px;height: 40px;line-height: 40px;padding-left: 20px;}
.content{background-color:#f3f7f9; height:280px;border:1px dashed #c6d9b6;padding:20px}
.t1{border-bottom: 1px dashed #c6d9b6;color: #ff4000;font-weight: bold; margin: 0 0 20px; padding-bottom: 18px;}
.t2{margin-bottom:8px; font-weight:bold}
ol{margin:0 0 20px 22px;padding:0;}
ol li{line-height:30px}
</style>
</head>

<body>
	<div class="main">
		<div class="title">网站防火墙</div>
		<div class="content">
			<p class="t1">您的请求带有不合法参数,已被网站管理员设置拦截!</p>
			<p class="t2">可能原因:</p>
			<ol>
				<li>您提交的内容包含危险的攻击请求</li>
			</ol>
			<p class="t2">如何解决:</p>
			<ol>
				<li>检查提交内容;</li>
				<li>如网站托管,请联系空间提供商;</li>
				<li>普通网站访客,请联系网站管理员;</li>
				<li>这是误报,请提交工单 <a href="https://www.zhuchunshu.com/requests" target="_brank">https://www.zhuchunshu.com/requests</a></li>
			</ol>
		</div>
	</div>
</body>
</html>


HTML;
}
function safes()
	{
	    foreach($_REQUEST as $sql_str){
		    $check= preg_match('/and|or|where|limit|group by|select|insert|eval|system|exec|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile/i',$sql_str);
		    if ($check) {
		    	safe_html();
		        die;
		    }
		}
	}
safes();
?>

使用方法

新建一个PHP文件,把上面的代码贴进去并保存,然后引入这个文件即可

赞(0) 打赏
未经允许不得转载:VPS测评推荐网站 - 朱纯树博客 » PHP 过滤 post,get传入内容,防止字符串注入

评论 40

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #45

    sildenafil daily sildenafil gel caps

    Stephengrimi2天前回复
  2. #44

    https://prednisonepills.site/# prednisone 5mg daily

    Jamesjoing3天前回复
  3. #43

    https://prednisonepills.site/# prednisone cream

    Carlossoami4天前回复
  4. #42

    do my essay cheap
    help me with my essay
    live essay help

  5. #41

    help me essay
    quality custom essay
    the best essay writers

  6. #40

    https://naijamoviez.com/# best canadian pharmacies online

    JosephOrarM1周前 (11-27)回复
  7. #39

    non prescription on line pharmacies naijamoviez.com
    mexican mail order pharmacy top erectile dysfunction pills

    DennisCip1周前 (11-27)回复
  8. #38

    write my essay website
    online essay help
    help writing a compare and contrast essay

    NaniceonEt1周前 (11-26)回复
  9. #37

    higher english essay help
    help writing a college essay
    write my essay today

    AshlenonEt2周前 (11-23)回复