function init_variable() { $return = array(); foreach(array($_GET,$_POST) AS $type) { if( is_array($type) ) { foreach ( $type AS $k => $v) { if ( is_array($type[$k]) ) { foreach ( $type[$k] AS $k1 => $v1) { $return[ $this->clean_key($k) ][ $this->clean_key($k1) ] = $this->clean_value($v1); } } else { $return[ $this->clean_key($k) ] = $this->clean_value($v); } } } } return $return; } function clean_key($key) { if ($key == "") return ""; return preg_replace( array("/\.\./", "/\_\_(.+?)\_\_/", "/^([\w\.\-\_]+)$/"), array("", "", "$1"), $key ); }
function clean_value($val) { if ($val == "") return ""; $pregfind = array ( " ", "&", "<!--", "-->" ); $pregreplace = array ( " ", "&", "<!--", "-->" ); $val = str_replace($pregfind, $pregreplace, $val); $val = preg_replace( "/<script/i", "<script", $val ); $pregfind = array ( ">", "<", "\"", "!", "'" ); $pregreplace = array ( ">", "<", """, "!", "'" ); $val = str_replace($pregfind, $pregreplace, $val); $pregfind = array ( "/\n/", "/\\\$/", "/\r/" ); $pregreplace = array ( "<br />", "$", "" ); $val = preg_replace($pregfind, $pregreplace, $val);
if ( $this->allow_unicode ) { $val = preg_replace("/&#([0-9]+);/s", "&#\\1;", $val ); } if ( get_magic_quotes_gpc() ) { $val = stripslashes($val); } return preg_replace( "/\\\(&#|\?#)/", "\", $val ); } |