0

I didnt find a real solution for this. As many others now I use a jquery wysiwyg editor and save the output in mysql. The problem occurs when I load back into editor and save it again. The backslash and the " marks increasing every time when I press submit. Off course before write to DB I do a mysql_real_escape_string().

I use the strpslashes recursively but it doesnt work.

function decodeEscapedString($value) {
  if (get_magic_quotes_gpc()) {

     $value = is_array($value) ?
       array_map(array('self', 'decodeEscapedString'), $value) :
       stripslashes($value);

     return $value;

  } else
     return stripslashes($value);
}

Could somebody have an idea? thx

Explosion Pills
  • 188,624
  • 52
  • 326
  • 405
szatti1489
  • 352
  • 2
  • 5
  • 16

1 Answers1

0

I'd say you have a slight logic error as well as a possible reference error where you have 'self' in the array_map().

Assuming this is a class method, try something like this

public function filter($value)
{
    return get_magic_quotes_gpc() ? $this->clean($value) : $value;
}

protected function clean($value)
{
    return is_array($value) ? array_map(array($this, 'clean'), $value) : stripslashes($value);
}

You then just call the filter() method, eg

$value = $obj->filter($_POST['something']);

Adapted from http://blog.philipbrown.id.au/2008/10/zend-framework-forms-and-magic_quotes_gpc/

Phil
  • 157,677
  • 23
  • 242
  • 245