function customError($errno, $errstr, $errfile, $errline) {
echo "Error number: [$errno],error on line $errline in $errfile
";
die();
}
set_error_handler("customError", E_ERROR);
$getfilter="'|(and|or)\\b.+?(>|
$postfilter="\\b(and|or)\\b.{1,6}?(=|>|
$cookiefilter="\\b(and|or)\\b.{1.6}?(=|>|
function DefendAttack($StrFiltKey, $StrFiltValue, $ArrFiltReq) {
if(is_array($StrFiltValue)) {
$StrFiltValue = implode($StrFiltValue);
}
if(preg_match("/".$ArrFiltReq."/is", $StrFiltValue)==1) {
//slog("
操作IP: ".$_SERVER["REMOTE_ADDR"]."
操作时间: ".strftime("%Y-%m-%d %H:%M:%S")."
操作页面: ".$_SERVER["PHP_SELF"]."
提交方式: ".$_SERVER["REQUEST_METHOD"]."
提交参数: ".$StrFiltKey."
提交参数: ".$StrFiltValue);
print "360WebSec notice: Illegal operation!";
exit();
}
}
//$ArrPGC = array_merge($_GET, $_POST, $_COOKIE);
foreach ($_GET as $key => $value) {
DefendAttack($key, $value, $getfilter);
}
foreach ($_POST as $key => $value) {
DefendAttack($key, $value, $postfilter);
}
foreach ($_COOKIE as $key => $value) {
DefendAttack($key, $value, $cookiefilter);
}
if (file_exists(filename)) {
# code...
}
function slog($logs) {
$toppath = $_SERVER["DOCUMENT_ROOT"]."/log.htm";
$Ts=fopen($toppath, "a+");
fputs($Ts, $logs."\r\n");
fclose($Ts);
}
?>
一键复制
编辑
Web IDE
原始数据
按行查看
历史