-1

I am installing phpfox script, after installation it is showing the following error,

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead - include/library/phpfox/setting/setting.class.php (321)

I have just got to the code and i am unable to change the syntax to preg_replace_callback

so i am writing the code below, kindly convert it for me thanks. 1

$aRow['value_actual'] = preg_replace("/s:(.*):\"(.*?)\";/ise", "'s:'.strlen('$2').':\"$2\";'", $aRow['value_actual']);

2

preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING']

3

preg_replace("/(.*?)\.(.*?)$/i", ".$2", $_SERVER['HTTP_HOST']

kindly convert 4th one as well.

4

preg_replace("/s:(.*):\"(.*?)\";/ise", "'s:'.strlen('$2').':\"$2\";'", (isset($aRow['user_group_id2']) && isset($aRow[$aRow['user_group_id']])) ? $aRow[$aRow['user_group_id']] : $aRow['value_actual']);
Zain Azeem
  • 19
  • 1
  • 6
  • What did you try and what happened with your attempt? – chris85 Sep 04 '17 at 21:29
  • actually i installed phpfox script on my server, it was installed perfectly but when i get to the homepage it shows following error preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead - include/library/phpfox/setting/setting.class.php (321) – Zain Azeem Sep 04 '17 at 21:30
  • you may have a look by visiting this link : www.uksocialfanz.com – Zain Azeem Sep 04 '17 at 21:31
  • So you need to use `preg_replace_callback`. Maybe contact the developers, or install a newer version. – chris85 Sep 04 '17 at 21:31

1 Answers1

0

2 and 3 don't have the e modifier. Nothing to do. For 1 use:

$aRow['value_actual'] = preg_replace_callback(
'/s:(.*):\"(.*?)\";/is',
function ($m) { return "s:".strlen($m[2]).':"'.$m[2].'";';},
$aRow['value_actual']);

If you want an explanation for any of them, please update your question. If you don't that's fine, too.

4

 preg_replace("/s:(.*):\"(.*?)\";/ise", "'s:'.strlen('$2').':\"$2\";'", 
 (isset($aRow['user_group_id2']) && isset($aRow[$aRow['user_group_id']])) ? 
 $aRow[$aRow['user_group_id']] : $aRow['value_actual']);

becomes:

 preg_replace("/s:(.*):\"(.*?)\";/is", 
 function ($m) { return "s:".strlen($m[2]).':"'.$m[2].'";';}, 
 (isset($aRow['user_group_id2']) && isset($aRow[$aRow['user_group_id']])) ? 
 $aRow[$aRow['user_group_id']] : $aRow['value_actual']);
jh1711
  • 2,288
  • 1
  • 12
  • 20
  • I have done this but now it showing one more same kind of error, this time of different page. so if you can convert this one as well, that would be great. . preg_replace("/s:(.*):\"(.*?)\";/ise", "'s:'.strlen('$2').':\"$2\";'", (isset($aRow['user_group_id2']) && isset($aRow[$aRow['user_group_id']])) ? $aRow[$aRow['user_group_id']] : $aRow['value_actual']);preg_replace("/s:(.*):\"(.*?)\";/ise", "'s:'.strlen('$2').':\"$2\";'", (isset($aRow['user_group_id2']) && isset($aRow[$aRow['user_group_id']])) ? $aRow[$aRow['user_group_id']] : $aRow['value_actual']); – Zain Azeem Sep 04 '17 at 21:42
  • Those are almost literally the same expression. But ok. If you edit your question with points 4,5,6..., I'll update my answer. Longer code in comments is very hard to read. – jh1711 Sep 04 '17 at 21:47
  • I have edited the question, you may convert it now for me, thanks in advance. – Zain Azeem Sep 04 '17 at 21:52
  • done. Please note: The expressions phpfox uses are not optimal for the task I think they do. I translated them to the callback notation, but I don't endorse them. – jh1711 Sep 04 '17 at 22:00