Re: Easier way to clean GET Variables ?

From: Date: Mon, 29 Aug 2005 17:45:54 +0000
Subject: Re: Easier way to clean GET Variables ?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-221524@lists.php.net to get a copy of this message
On Mon, 2005-08-29 at 11:07, Jay Paulson wrote: > > Can anybody point to a good resource of a collection of filtering for > > common inputs such as those listed by Chris above?... > > > > I've searched for that and generally found one of two things: > > > > 1. Nothing useful. > > 2. A system so baroque and complex and with so much other baggage, it > > would be impossible to integrate. See 1. > > > > I'm looking more for code snippets or specific Regex functions for > > each item, rather than a monolithic Borg-like "filtering package" and > > have never one I liked. > > > > That could be mostly my fault due to peculiar requirements, but there > > it is. > > I'd like to know this too. As well as the examples are in this thread > I don't think they handled multi dimensional arrays. It'd be nice if > they did. :) I've adapted my previous solution for multi-dimensional retrieval using unix directory style path lookup: function arrayGetValue( &$array, $path, $default=null ) { $subArray = &$array; $bits = explode( '/', $path ); foreach( $bits as $aBit ) { if( isset( $subArray[$aBit] ) ) { $subArray = &$subArray[$aBit]; } else { unset( $subArray ); $subArray = $default; break; } } return $subArray; } function arrayGetValueProcessed( &$array, $path, $process, $default=null ) { return $process( arrayGetValue( $array, $path, $default ) ); } function cleanser( $value ) { return mysql_real_escape_string( trim( $value ) ) ); } // // Example. // $title = arrayGetValueProcessed( $games, $userId.'/favourite/rpg' ) Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

« previous php.general (#221524) next »