Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X

Removing Backslashes from MODx on a Shared Host without touching php.ini file

It's being a while I have posted on this blog. It wasn't as if I have stop development but I got some contract and got so much jobs that I couldn't afford to write. Anyway, I am back.

I ran into a challenge I resolved some years back but I've forgotten how I resolved it. I am blogging now to document the solution so I can have a refrence point next time I am faced with such again. The issue is after installing modx for a client, blackslashes are added everytime he tries updating the content.

The solution that is prevalent on the internet is editing the php.ini file but I don't have access to the php.ini file because the client is using a shared host. I finally resolved this issue by adding this code snippet to the index.php file in the document root and also the index.php file in the manager folder. It resolves the problem.

if (get_magic_quotes_gpc()) {
function stripslashes_gpc(&$value){ $value = stripslashes($value); }
array_walk_recursive($_GET, 'stripslashes_gpc');
array_walk_recursive($_POST, 'stripslashes_gpc');
array_walk_recursive($_COOKIE, 'stripslashes_gpc');
array_walk_recursive($_REQUEST, 'stripslashes_gpc');
}

 

 Best Luck!

 


comments powered by Disqus