Skip to content

Commit

Permalink
fix for php < 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
conejoninja committed Oct 17, 2015
1 parent c7848d4 commit 0093be4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion oc-includes/osclass/helpers/hErrors.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,21 @@ function getErrorParam($param, $htmlencode = false, $quotes_encode = true)
}

if(get_magic_quotes_gpc()) {
$value = strip_slashes_extended($value);
$value = strip_slashes_extended_e($value);
}

return ($value);
}
function strip_slashes_extended_e($array) {
if(is_array($array)) {
foreach($array as $k => &$v) {
$v = strip_slashes_extended_e($v);
}
} else {
$array = stripslashes($array);
}
return $array;
}
function osc_get_absolute_url() {
$protocol = (getErrorParam('HTTPS') == 'on' || getErrorParam('HTTPS') == 1 || getErrorParam('HTTP_X_FORWARDED_PROTO')=='https')? 'https' : 'http';
return $protocol . '://' . getErrorParam('HTTP_HOST') . preg_replace('/((oc-admin)|(oc-includes)|(oc-content)|([a-z]+\.php)|(\?.*)).*/i', '', getErrorParam('REQUEST_URI', false, false));
Expand Down

6 comments on commit 0093be4

@dev-101
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Conejo,

I think it would be better to move strip_slashes_extended_e() inside [corrected] utils.php below existing strip_slashes_extended() ?

@dev-101
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I do not see any difference between already existing function ?

@conejoninja
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is the same as strip_slahes_extended and it's only there to avoid loading more files (as the error could happen when there's no lib loaded yet). We'll be dropping 5.4 support in next version, since it's officially unsupported.

strip_slashes_extended_e will only be called if you use an unsupported PHP version 5.3 ("dead" on August 2014) or older AND you have to set the magic quotes to ON (by default they are enabled). After 5.4 (5.4 included), get_magic_quotes_gpc will return false as it was removed and the function will not be needed.

@dev-101
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for the explanation, I suspected it wasn't without a reason :)

@conejoninja
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If was a quick and dirty fix, we will stop supporting 5.4 and previous version in future releases (not sure how will do that yet)

@dev-101
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know... you announced this @ forums few weeks ago, not sure if it will be "welcomed" by some users on older PHP versions.

Some users had issues when switching to 5.5 probably due very old plugins:

http://forums.osclass.org/plugins-20/finally-social-media-auto-poster-plugin-for-osclass-is-ready-30840/msg131067/#msg131067

But there shouldn't be any major issues past 5.5 now.

Please sign in to comment.