<?php
/**
 * [UQcms System] Copyright uqcms.com
 * QQ: 2200631718
 * Author: gj.name
 * This is NOT a freeware
*/  function customError($errno, $errstr, $errfile, $errline){ echo "<b>Error number:</b> [$errno],error on line $errline in $errfile<br />"; die(); } set_error_handler("customError", E_ERROR); $getfilter="'|<[^>]*?>|^\\+\/v(8|9)|\\b(and|or)\\b.+?(>|<|=|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)"; $postfilter="^\\+\/v(8|9)|\\b(and|or)\\b.{1,6}?(=|>|<|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)"; $cookiefilter="\\b(and|or)\\b.{1,6}?(=|>|<|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)"; function StopAttack($StrFiltKey, $StrFiltValue, $ArrFiltReq){ if (preg_match("/".$ArrFiltReq."/is", $StrFiltKey) == 1){ safe_error_msg(); } $StrFiltValue = arr_foreach($StrFiltValue); if (preg_match("/".$ArrFiltReq."/is", $StrFiltValue) == 1){ safe_error_msg(); }else{ preg_match_all('/<\\s*img[^>]*>/Ui', $StrFiltValue, $match); if(!empty($match[0])){ foreach($match[0] as $v){ if((!strpos($v, 'onerror') == '') || (!strpos($v, 'javascript') == '')){ safe_error_msg(); } } } } } function safe_error_msg(){ if(empty($_POST['jq_time']) && empty($_GET['jq_time'])){ print "<div style=\"position:fixed;top:0px;width:100%;height:100%;background-color:white;color:green;font-weight:bold;border-bottom:5px solid #999;\"><br>您的提交带有不合法参数,谢谢合作!</div>"; exit(); }else{ exit(json_encode(array('error'=>'1', 'msg'=>'您的提交带有不合法参数,谢谢合作!'))); } } foreach($_GET as $key=>$value){ StopAttack($key, $value, $getfilter); } foreach($_POST as $key=>$value){ StopAttack($key, $value, $postfilter); } foreach($_COOKIE as $key=>$value){ StopAttack($key, $value, $cookiefilter); } $referer=empty($_SERVER['HTTP_REFERER']) ? array() : array($_SERVER['HTTP_REFERER']); foreach($referer as $key=>$value){ StopAttack($key, $value, $getfilter); } function arr_foreach($arr){ static $str; if (!is_array($arr)){ return $arr; } foreach ($arr as $key => $val){ if (is_array($val)){ arr_foreach($val); }else{ $str[] = $val; } } return implode($str); } ?>