Welcome Guest, Not a member yet? Register   Sign In
Safely parsing complex permutations of $_POST data
#2

[eluser]Tominator[/eluser]
Hello,
you can make function like this:

Code:
function MakeMeSave(&$input) {
   if(is_array($input)) {
      array_walk_recursive($input,"SaveValue");
   } else {
      safetyValue($input);
   }
}
function SaveValue(&$value) {
    
   if (get_magic_quotes_gpc()) {
      $value = stripslashes($value);
   }
  
   $value = htmlspecialchars($value);
   $value = str_replace("'", "'", $value);
   $value = str_replace("\\", "\\\\", $value);
   $value = str_replace("%", "%", $value);
   $value = trim($value);
}

And then in your code you can call just:
Code:
MakeMeSave($POST);

It will work correctly in PHP5. If would you like to make max-lenght limit, you can just add line.


Messages In This Thread
Safely parsing complex permutations of $_POST data - by El Forum - 03-27-2010, 09:48 AM
Safely parsing complex permutations of $_POST data - by El Forum - 03-27-2010, 01:41 PM



Theme © iAndrew 2016 - Forum software by © MyBB