當前位置:首頁 » 編程語言 » phpget過濾

phpget過濾

發布時間: 2022-06-26 23:17:06

A. php if ($_GET['key'] 過濾

如果是特殊的需要key匹配的特點去寫正則匹配.例如

$w='kjhgerz123z1iuhiugerhhg';
$s='kjhgerz2z1iuhiugerhhg';
$m='/z[0-9]{2,}/';
if(preg_match($m,$w)){
echo"出現關鍵字";
}else{
echo"關鍵字未出現過";
}
if(preg_match($m,$s)){
echo"出現關鍵字";
}else{
echo"關鍵字未出現過";
}

B. php中post get不能自動過濾,求解

我暈,兄弟你怎麼又問了一次,你如果輸入問號,你在列印的時候直接print( get_str($name) )估計就是你想要的結果了

C. PHP 如果不對 POST 或者 GET 請求做過濾處理就會被注入嗎

是的,如果不做過濾肯定很容易就被注入的

D. PHP如何過濾POST、GET、COOKIE

首先命葯明白POST,GRT,COOKIE,其實它是一個數組。
你可以print_r($_POST)就明白了
所以你一可以寫一個方法,
public function a ($_POST){
foreach($_POST as $val) {
/將所有的值過濾掉後賦予一個新的數組

}
return $arr;

}

E. PHP怎麼過濾GET或者POST的參數怎麼樣才能保證代碼不被注入

if (!get_magic_quotes_gpc())//如不美觀沒有開啟的話{ /****需要對這幾個數組,遍歷,注重數組多維的情形,addslashes($str)就可以 $_GET $_POST $_COOKIE $_REQUEST ****/}

F. php中過濾post get session cookie

在配置文件的入口加入默認處理函數,對post、get等進行集中處理,然後按照自己的規則重新定義這些數據。

G. PHP $_GET方法傳過來參數過濾問題求高手指導一二!!

php有個防止sql注入的函數addslashes(),這樣就會把你搜索框里傳過來的單引號雙引號轉義掉,還有要防止跨站腳本攻擊xxs,用函數htmlspecialchars (),詳細可看php手冊

H. 如何在PHP中成功的過濾危險HTML的代碼

//php批量過濾post,get敏感數據
if(get_magic_quotes_gpc()){
$_GET=stripslashes_array($_GET);
$_POST=stripslashes_array($_POST);
}

functionstripslashes_array(&$array){
while(list($key,$var)=each($array)){
if($key!='argc'&&$key!='argv'&&(strtoupper($key)!=$key||''.intval($key)=="$key")){
if(is_string($var)){
$array[$key]=stripslashes($var);
}
if(is_array($var)){
$array[$key]=stripslashes_array($var);
}
}
}
return$array;
}
//--------------------------

//替換HTML尾標簽,為過濾服務
//--------------------------
functionlib_replace_end_tag($str)
{
if(empty($str))returnfalse;
$str=htmlspecialchars($str);
$str=str_replace('/',"",$str);
$str=str_replace("\","",$str);
$str=str_replace("&gt","",$str);
$str=str_replace("&lt","",$str);
$str=str_replace("<SCRIPT>","",$str);
$str=str_replace("</SCRIPT>","",$str);
$str=str_replace("<script>","",$str);
$str=str_replace("</script>","",$str);
$str=str_replace("select","select",$str);
$str=str_replace("join","join",$str);
$str=str_replace("union","union",$str);
$str=str_replace("where","where",$str);
$str=str_replace("insert","insert",$str);
$str=str_replace("delete","delete",$str);
$str=str_replace("update","update",$str);
$str=str_replace("like","like",$str);
$str=str_replace("drop","drop",$str);
$str=str_replace("create","create",$str);
$str=str_replace("modify","modify",$str);
$str=str_replace("rename","rename",$str);
$str=str_replace("alter","alter",$str);
$str=str_replace("cas","cast",$str);
$str=str_replace("&","&",$str);
$str=str_replace(">",">",$str);
$str=str_replace("<","<",$str);
$str=str_replace("",chr(32),$str);
$str=str_replace("",chr(9),$str);
$str=str_replace("",chr(9),$str);
$str=str_replace("&",chr(34),$str);
$str=str_replace("'",chr(39),$str);
$str=str_replace("<br/>",chr(13),$str);
$str=str_replace("''","'",$str);
$str=str_replace("css","'",$str);
$str=str_replace("CSS","'",$str);

return$str;

}

熱點內容
火車軟卧無線密碼是多少 發布:2024-04-19 07:38:59 瀏覽:422
vb系統文件夾 發布:2024-04-19 07:29:58 瀏覽:739
qt怎麼添加文件夾 發布:2024-04-19 07:22:53 瀏覽:255
sql查詢表是否存在 發布:2024-04-19 06:11:48 瀏覽:622
T178Tccftp 發布:2024-04-19 06:11:35 瀏覽:185
電腦遠程訪問自己的伺服器 發布:2024-04-19 00:08:03 瀏覽:96
噸包演算法 發布:2024-04-19 00:02:13 瀏覽:328
win8解壓縮軟體官方下載 發布:2024-04-18 23:52:27 瀏覽:727
手機軟體在哪個文件夾 發布:2024-04-18 23:51:26 瀏覽:373
未加密魔獸地圖 發布:2024-04-18 23:39:13 瀏覽:947