|
1樓 220.221.122.*
2010-12-11 14:16
看來php獲取ajaxcode編碼的參數,用的函數太多了,太混亂了。乾脆這樣:
//ajax獲得參數簡寫函數 function reajax($name,$code=2,$type=false){ //$code:0=不編碼,1=htmlspecialchars,2=mysql_real_escape_string //$type:false=post,true=get if ($type){ $b=$_GET[$name]; }else{ $b=$_POST[$name]; //默認 } $b=trim(read_utf8_uns($b)); switch ($code){ case 1: $b=htmlspecialchars($b); break; case 2: $b=mysql_real_escape_string($b); //默認 break; } return $b; }
|
|
2樓 220.221.122.*
2010-12-11 14:17
mysql_real_escape_string(trim(read_utf8_uns($_POST['b'])))
就可以簡寫為reajax('b');
|
|
3樓 220.221.122.*
2010-12-11 14:18
還差個unajaxcode……
|
|
4樓 220.221.122.*
2010-12-11 14:19
//ajax獲得參數簡寫函數 function reajax($name,$code=2,$type=false,$nounajaxcode){ //$code:0=不編碼,1=htmlspecialchars,2=mysql_real_escape_string //$type:false=post,true=get //$nounajaxcode:是否不還原ajaxcode編碼 if ($type){ $b=$_GET[$name]; }else{ $b=$_POST[$name]; //默認 } $b=trim(read_utf8_uns($b)); if (!$nounajaxcode) $b=unajaxcode($b); switch ($code){ case 1: $b=htmlspecialchars($b); break; case 2: $b=mysql_real_escape_string($b); //默認 break; } return $b; }
|
|
5樓 220.221.122.*
2010-12-11 14:22
//ajax獲得參數簡寫函數 function reajax($name='i',$code=2,$type=false,$nounajaxcode){ //$code:0=不編碼,1=htmlspecialchars,2=mysql_real_escape_string //$type:false=post,true=get //$nounajaxcode:是否不還原ajaxcode編碼 if ($type){ $b=$_GET[$name]; }else{ $b=$_POST[$name]; //默認 } $b=trim(read_utf8_uns($b)); if (!$nounajaxcode) $b=unajaxcode($b); switch ($code){ case 1: $b=htmlspecialchars($b); break; case 2: $b=mysql_real_escape_string($b); //默認 break; } return $b; }
現在這三個參數都是可選的。
reajax()≌mysql_real_escape_string(unajaxcode(trim(read_utf8_uns($_POST['i']))))
|