I run a small forum as a volunteer project using old forum software (FluxBB) which seems to not be supported any more. (Their website returns "server not found".)
My webhost asked me to upgrade my PHP to v8.0 and I did, but that broke the forum software. I don't know much PHP, but I was able to fix most of the problems, however I'm stuck on this one.
create_function has been removed from PHP and I don't know how to code around that, where the script is using it to convert BBcode to HTML, using an array of patterns and an array of replacements. It's not throwing any errors, but the loop runs only twice when it's supposed to run a bunch of times, and during those two times it doesn't perform the replacement. Here's the problem code:
Here's one such offending line:
$pattern_callback[] = '%\[url\]([^\[]*?)\[/url\]%';
$pattern_callback[] = '%\[url=([^\[]+?)\](.*?)\[/url\]%';
$pattern[] = '%\[email\]([^\[]*?)\[/email\]%';
$pattern[] = '%\[email=([^\[]+?)\](.*?)\[/email\]%';
/* And nine more array values defined here, as well as the replacements */
$count = count($pattern_callback);
for($i = 0 ; $i < $count ; $i++)
{
$text = preg_replace_callback($pattern_callback[$i], create_function('$matches', 'return '.$replace_callback[$i].';'), $text);
}
I tried replacing the "$text=..." line with this: $fixFunction =
function($matches) {
return $replace_callback[$i];
};
$text =
preg_replace_callback
(
$pattern_callback[$i],
$fixFunction,
$text
);
Can anyone help with this?