开发者

another stripslashes problem

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);
}

C开发者_开发问答ould somebody have an idea? thx


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜