Taipo, on 23 May 2011 - 11:31 PM, said:
/**
* Clean up GET request vars
* as well as multidimensional arrays
*/
function scrubster( $nodes ) {
if ( is_array( $nodes ) ) {
foreach( $nodes as $key=>$value ) {
if ( is_array( $value ) ) {
scrubster( $value );
} else {
$nodes = getCleaner( $nodes, TRUE );
$nodes = preg_replace("/[^\w\s?,€=@%:{}\/_.-]/i", "", urldecode( $nodes ) );
$nodes = getCleaner( $nodes, FALSE );
}
}
} else {
$nodes = getCleaner( $nodes, TRUE );
$nodes = preg_replace("/[^\w\s?,€=@%:{}\/_.-]/i", "", urldecode( $nodes ) );
$nodes = getCleaner( $nodes, FALSE );
}
return $nodes;
}
/**
* Called above, this will clean up
* values but not interfere with umlauts
*/
function getCleaner($string, $conv=1) {
$x = md5( $_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"] .
$_SERVER["HTTP_HOST"] . $_SERVER["DOCUMENT_ROOT"] . $_SERVER["SERVER_SOFTWARE"] . $_SERVER["PATH"] );
$tolist = explode(",", "ä,ö,ü,Ä,Ö,Ü,€,ß,ä,ö,ü,Ä,Ö,Ü,€,&szlig");
$fromlist = explode(",", "ae,oe,ue,Ae,Oe,Ue,euro,szlig,ae,oe,ue,Ae,Oe,Ue,euro,szlig");
$finlist = explode(",", "ä,ö,ü,Ä,Ö,Ü,€,ß,ä,ö,ü,Ä,Ö,Ü,€,ß");
for($wr=0;$wr<=count($tolist);$wr++) {
if ( $conv > 0 ) {
$string = str_replace($tolist[$wr], $x.$fromlist[$wr], $string);
} else {
$string = str_replace($x.$fromlist[$wr], $finlist[$wr], $string);
}
}
return $string;
}








