Here is a sample code that I got in order to fix the deprecated preg_replace () function and / e modifier. Maybe someone will come in handy.
$text = preg_replace_callback(
'#\[url\]([\r\n]*)(http://|ftp://|https://|ftps://)([^\s\'\"]*?)([\r\n]*)\[/url\]#si',
function ($m) use($pathto) {
$link = $m[2].$m[3];
return "<a href='$pathto"
.base64_encode($link)
."' rel='nofollow' target='_blank' title='$link'>"
.trimlink($link, 20)
.(strlen($link)>30?substr($link, strlen($link)-10, strlen($link)):'')
.'</a>';
},
$text
);
And here is the old code, for comparison.
$text = preg_replace('#\[url\]([\r\n]*)(http://|ftp://|https://|ftps://)([^\s\'\"]*?)([\r\n]*)\[/url\]#sie', "'<a href=\'".$pathto."'.base64_encode('\\2\\3').'\' rel=\'nofollow\' target=\'_blank\' title=\'\\2\\3\'>'.trimlink('\\2\\3', 20).(strlen('\\2\\3')>30?substr('\\2\\3', strlen('\\2\\3')-10, strlen('\\2\\3')):'').'</a>'", $text);
There are two more lines of code that are becoming outdated, and I don't know how to fix them.
$guest_msg = '[ link is hidden ] ( <a href=\''.BASEDIR.'register.php\'><u>registration</u></a> | <a href=\''.BASEDIR.'login.php\'><u>input</u></a> )';
$pathto = ($friendlyurl?BASEDIR.$friendlypath.'?':INCLUDES.'bbcodes/url_bbcode_include.php?');
I have a warning like this:
Quote
Warning: Use of undefined constant INCLUDES - assumed 'INCLUDES' (this will throw an Error in a future version of PHP)
If I understand correctly, I need to put quotation marks, but it doesn’t work out for me to do it correctly. Can you help?