风一样的回忆

新浪微薄腾讯微薄

最新碎语:从未遇见一位没亏过钱的富人,却遇见许多从未亏掉一毛钱的穷人

您的位置:风一样的回忆 >php> php批量转义函数

php批量转义函数

/* SQL语句过滤 */
function dowith_sql($str)
	{
		$str = str_replace("and","",$str);
		$str = str_replace("execute","",$str);
		$str = str_replace("update","",$str);
		$str = str_replace("count","",$str);
		$str = str_replace("chr","",$str);
		$str = str_replace("mid","",$str);
		$str = str_replace("truncate","",$str);
		$str = str_replace("char","",$str);
		$str = str_replace("select","",$str);
		$str = str_replace("delete","",$str);
		$str = str_replace("insert","",$str);
		$str = str_replace("create","",$str);
		$str = str_replace("or","",$str);
		$str = str_replace("=","",$str);
		$str = str_replace("declare","",$str);
		$str = str_replace("'","",$str);
		$str = str_replace("''","",$str);
		$str = str_replace(" ","",$str);
		$str = str_replace("%20","",$str);
		return $str;	
	}
 
        /*  预定地点添加反斜杠 */
	function daddslashes($string, $force = 1){
		if(is_array($string)){
			$keys = array_keys($string);
			foreach ($keys as $key){
				$val = $string[$key];
				unset($string[$key]);
				$string[addslashes($key)] = daddslashes($val,$force);
			}	
		}else {
			$string = addslashes($string);
		}
		return $string;
	}

---

转载请注明本文标题和链接:《php批量转义函数

分享到:

发表评论

路人甲 表情
看不清楚?点图切换 Ctrl+Enter快速提交