介绍
可以简单拦截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文件,把上面的代码贴进去并保存,然后引入这个文件即可
Hurda bakır alan istanbul hurdacı firması olarak her türlü madeni değerinde alıyoruz hurdacı istanbul hurdaci https://www.hurdacisitesi.com.tr
İstanbul hurdacı firması olarak tüm hurdalarınızı adresinizden alıyoruz.