You are here: Re: [PHP] Easier way to clean GET Variables ? « PHP « IT news, forums, messages
Re: [PHP] Easier way to clean GET Variables ?

Posted by Robert Cummings on 08/29/05 20:45

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. |
`------------------------------------------------------------'

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация