Use get_magic_quotes_gpc();
function f_magic_quotes($text) { if ( !get_magic_quotes_gpc() ) { return addslashes($text); } else { return $text; } }
function f_clean_quotes($text) { if ( !get_magic_quotes_gpc() ) { return $text; } else { return stripslashes($text); } }
Source: ab-d