![]() |
Data Cleanse of $_REQUEST array
Hi - i'm pulling all input to drive my site from the php $_REQUEST variable and to protect my site from malicious input i want to find a neat way to loop through the $_REQUEST array and cleanse it probably by running a mysql function to remove injection code and also a php strip tags routine. How can i do this and repopulate each REQUEST parameter when i wont necessarily know what variables are set eg. sometimes it might be $_REQUEST['username'] sometimes other stuff but different depending on which command i am processing. Any ideas? Thanks.
|
Quote:
|
Alternatively you can make use of the excellent array_map function
Code:
$array = array_map('clean', $array); |
array_map is exactly what i'm looking for just looked it up. Thanks.
|
Can't get this to work. Here's my code all within a class:
Quote:
|
I always get a php error "The first argument $this->clean should be either NULL or a valid callback. Any thoughts? Got a feeling I'm doing sonthing stupid. Tried everything in the function field I.e. 'clean'.
|
The first argument, the callback, doesn't work that way.
For functions, we can provide a string argument For static methods we provide an array of the Class and the Static Method for methods within objects, we provide the object and the method name, so... array_map(array($obj, 'clean'), $arr); |
I get it now. For $obj i pointed the class to itself with $this and that has made it work. Thanks for your help. Cheers.
|
| All times are GMT. The time now is 12:25 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0