By Anonymous (not verified) on
[note: the 'magic_quotes_gpc = 0' requirement was removed in Drupal 4.4]
I'm trying out drupal on a managed host, which has magic_quotes_gpc = 1 globally. I've tried to set this variable locally with "ini_set( "magic_quotes_gpc", 0);" in common.inc, but drupal still complains at the top of every page.
And the .htaccess file does not seem to work. The web server never seems to reach the "" loop. If I just set "php_value magic_quotes_gpc 0" anywhere in .htaccess, I get server errors, which tells me that the file is being parsed, but overrides are not allowed.
Any pointers?
Thanks,
JM
Comments
anybody out there?
The site seems to be working fine, even though I disabled the check for magic_quotes_gpc. Should I be concerned?
Check the thread I had yester
Check the thread I had yesterday: http://drupal.org/node/view/3582
Any easier solution that worked for me was dropping a local php.ini in the drupal directory containing the variable overrides that were in the .htaccess file.
You'll have problems with posts with ' in them
The problem you'll have is that any posts with apostrophes will get escaped with backslashes in an ugly fashion. It really is about time we wrote some proper database/editing functions to get around the problem with register_globals and magic_quotes.
Same Issue
I completely agree. The amount of server config that Drupal requires is a bit much, considering most people who run sites use remote hosting plans that may be inflexible to this kind of thing.
It should be something that is handled within the code (as most CMS and blog systems manage to)
Yes, remove the php_value directive overrides in .htaccess
I completely agree as well. I tried to run drupal on a great free OS hosting service called polarhome.com and it may be impossible because of the php_value directive overrides in drupal's .htaccess. Some of these, I believe, can be overriden in the drupal code itself with ini_set (?), but not all of them.
Other CMS's don't have so many server overrides and I'm probably going to have to switch because this drupal 'feature.' e107 has none. I strongly encourage you to fix these server overrides soon.
thanks,
--
William
Is it the backslash problem?
if so I found a solution here:
http://www.drupal.org/node/view/2745
this solved my major problem with the software. I removed .htaccess entirely as it caused internal server errors but I believe by editing out the mod_rewrite and the override sections of code the rest of the functions will operate.
not ideal but it runs ok so far.
Howto request
Great to hear that you managed to sole this annoying backslash problem. I looked at the link you provide and saw the algorithms would you mind writing a sloppy HOWTO on how to use them in drupal.
My first question is which algorithm do you use?
My second question is where in mod_rewrite did you place this code?
Many thanks!! It will definitely be a great help to drupal users setting up drupal on stubborn sites.
--
William
How to Solve the Backslash Problem due to Magic Quotes on
KEYWORDS: Backslashes Magic Quotes On Server Configuration .htacess
THE CODE ( found on http://www.drupal.org/node/view/2745 and written by kloeschen - many thanks to him!!):
set_magic_quotes_runtime(0);
if (get_magic_quotes_gpc ()) {
array_stripslashes($_POST);
array_stripslashes($_GET);
array_stripslashes($_COOKIES);
}
function array_stripslashes(&$array)
{
if (is_array($array))
while (list($key) = each($array))
{
if (is_array($array[$key]))
{
array_stripslashes($array[$key]);
}
else
{
$array[$key] = stripslashes($array[$key]);
}
}
}
END OF THE CODE
WHAT TO DO WITH IT
Open "common.inc" contained in the folder "includes"
Copy the code above into the file directly below the commented line (the one begining with two slashes on the second line or so).
Save and FTP it up over the old common.inc on your server.
Remove your .htaccess file. It may only require removing the OVERRIDE code from it but since I do not have Mod_rewrite either I chose to remove the file entirely as the other options it sets are not required on my server.
Run it and test. I think this is exactly what I did. If you find any errors post them here and I'll try it out myself on my own server.
Hope this helps.
EDITED:
It strikes be I breezed through the .htaccess bit. If you have a problem with removing it entirely I'll post instructions to edit the offending code out of it so the rest is untouched...bit pressed for time tonight.
Perfect!
Thanks! I'll try it out tonight.
Sure hope the drupal developers realize how important this issue is. This thread has already had 278 views.
--
William
WOWOWOWO
WOWOWO
THX THX THX
this is exactly what i had searching for months.
Very big thx to all php developers !!!
visit me at www.infostand.net
MfG
DarkDexter
Thanks
Thank you for sharing your knowledge.
Thank You!
This piece of code stripped the escape characters nicely!
Awaiting 4.3, hopefully without the cumbersome .htacces file...
magic_quotes problem solved
Thanks a lot !!!!!!!
i was facing the problem for past two weeks. Atlast ur suggestion worked out.
Thanks again !!!!!!:-)