Forums / General Questions / Host disabled stripslashes() What is a good way to replace/fix?

Host disabled stripslashes() What is a good way to replace/fix?

Views: 492

Results 1 to 4 of 4
3 Aug 2015, 4:28 AM
#1
deadeye avatar

deadeye

Zen Follower

Join Date:
Jul 2005
Posts:
109
Plugin Contributions:
0

Host disabled stripslashes() What is a good way to replace/fix?

str_replace()? preg_replace()?

Do I replace in each files with a new line of code or do I place an overriding version of the function (if possible) in some 'functions' php file?

Anyone with any suggestions?

3 Aug 2015, 4:52 AM
#2
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Host disabled stripslashes() What is a good way to replace/fix?

deadeye:

Anyone with any suggestions?

Change hosts.

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

3 Aug 2015, 4:08 PM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Host disabled stripslashes() What is a good way to replace/fix?

Seriously, a host who disables the stripslashes function doesn't know what they're doing. They probably think they're fixing a security problem, but in the end they're creating thousands. And that's probably why they're getting hacked.

Find a host who knows what they're doing.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

3 Aug 2015, 4:18 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Host disabled stripslashes() What is a good way to replace/fix?

Meanwhile, while you work on finding a new host, the following ideas may lead you to a temporary bandage.

These were found as user-contributed examples on php.net, and I have NOT tested them. Use at your own risk ...

Idea A: Use a preg_replace_array call:
To use, replace stripslashes($s) with the following. Be sure to alter the $s to match whatever variable was originally being sent to stripslashes.

preg_replace(array('/\x5C(?!\x5C)/u', '/\x5C\x5C/u'), array('','\\'), $s);

Idea B: Create stripslashes2() like this and simply search/replace all previous calls to stripslashes with stripslashes2

function stripslashes2($string) {
    $string = str_replace("\\\"", "\"", $string);
    $string = str_replace("\\'", "'", $string);
    $string = str_replace("\\\\", "\\", $string);
    return $string;
}

AGAIN: NEITHER OF THESE HAVE BEEN VETTED FOR SECURITY OR THOROUGHNESS. USE AT YOUR OWN RISK.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.