Change magic_quotes_gpc & register_globals PHP

Change magic_quotes_gpc & register_globals PHP

Posted by: nocloo
Posted on: 2006-05-04 11:20:00

Hi,

I'm having some issues with changing the PHP magic_quotes_gpc & register_globals config.
I'm trying to use PHP5 and create 2 files in the subdir of my software:

.htaccess
php_value register_globals 0
php_flag register_globals off
php_value magic_quotes_gpc 1
php_flag magic_quotes_gpc on

and create a php.ini :

register_globals off
magic_quotes_gpc on

None of the option works either w/ Web security enabled or disabled in my domain config. How do I change that ?

Thanks,
-M

Re: Change magic_quotes_gpc & register_globals PHP

Posted by: scjessey
Posted on: 2006-05-04 11:31:00

register_globals is already off with PHP 5. You should be able activate magic quotes in your .htaccess file with:

php_flag magic_quotes_gpc on

Which is what you thought. A much better solution is to handle the quotes manually, with addslashes() and stripslashes(). If you are going to be wacking something into MySQL, you will get better results with mysql_real_escape_string() instead.

Re: Change magic_quotes_gpc & register_globals PHP

Posted by: kchrist
Posted on: 2006-05-04 12:05:00

You should be able activate magic quotes in your .htaccess file

Only if he's using mod_php, which isn't an option with PHP 5.

I agree with your recommendation against using magic_quotes, but if he must have it enabled, he'll have to set it via ini_set().

Re: Change magic_quotes_gpc & register_globals PHP

Posted by: scjessey
Posted on: 2006-05-04 14:46:00

In reply to:

Only if he's using mod_php, which isn't an option with PHP 5.


Does the AddHandler application/x-httpd-php .php trick not work with PHP5 then?

Re: Change magic_quotes_gpc & register_globals PHP

Posted by: kchrist
Posted on: 2006-05-04 15:58:00

That maps the given file extention to a single Apache module, and we already know it uses mod_php4.

If I were to guess at how to make this work with PHP 5, I might try using application/x-httpd-php5, but given DH's preference for PHP-CGI, it's unlikely to work. I doubt mod_php5 is even installed.


Re: Change magic_quotes_gpc & register_globals PHP

Posted by: nocloo
Posted on: 2006-05-06 10:21:00

Thanks for the answers ... But I still cannot setup magic quotes on. I'm now on apache 2, php5. Is there anyway I can copy php.ini and tell php to use my local php.ini config so it'll work out alright ?

Thanks
==

Tags: gpcmagicquotes