0

I have in shared server magic_quotes_gpc is on. I have tried adding the following code to my .htaccess file.

php_flag magic_quotes_gpc Off

When I use the above line in .htaccess, it throws 500 internal server error.

Even I've tried using ini_set too.

The problem is with CKEEditor. It addslashes the double quotes. And the editor is not woeking properly. I have gone through several answers also but not getting the answer properly.

Please guide me.

PHP Version: 5.3.24

Dushyant Joshi
  • 3,672
  • 3
  • 28
  • 52

2 Answers2

2

If you can't disable magic quotes by any means, use the example code from the PHP manual as a workaround to strip the extra slashes: http://php.net/manual/en/security.magicquotes.disabling.php:

if (get_magic_quotes_gpc()) {
    $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
    while (list($key, $val) = each($process)) {
        foreach ($val as $k => $v) {
            unset($process[$key][$k]);
            if (is_array($v)) {
                $process[$key][stripslashes($k)] = $v;
                $process[] = &$process[$key][stripslashes($k)];
            } else {
                $process[$key][stripslashes($k)] = stripslashes($v);
            }
        }
    }
    unset($process);
}
Mate Solymosi
  • 5,699
  • 23
  • 30
  • That snippet (and this question all together) has already been [copied/pasted into enough answers](https://www.google.com/#q=site%3Astackoverflow.com+%22%24process+%3D+array(%26%24_GET%2C+%26%24_POST%2C+%26%24_COOKIE%2C+%26%24_REQUEST)%3B%22).. we don't need to continue duplicating it. – Mike B Nov 04 '13 at 13:14
1

According to the docs, the magic_quotes_gpc directive is PHP_INI_PERDIR so you should be able to change it.

Whenever you see a "500 Internal Server Error" status code in your live server you should head to the log files and find out the exact reason (rather than guessing). Whatever, I suspect that Apache is complaining that the php_flag directive is unknown. If that's the case, your PHP interpreter is not running as Apache module, thus you cannot use Apache files to change it.

Since your hosting account seems to be pretty old, you'll probably have a custom php.ini file somewhere in your FTP account.

Álvaro González
  • 142,137
  • 41
  • 261
  • 360