PDA

View Full Version : IMG to URL convert


Bulent Tekcan
02-11-2020, 10:53 AM
Hello,


I'm using this code in class_bbcode.php line 1866



// Start IMG to URL BBCode Converter
if ($this->contains_bbcode_img_tags($message))
{
$message = preg_replace('#\[img\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/img\]#iUe', "\$this->handle_bbcode_url(str_replace('\\\"', '\"', '\\1'), '')", $message);
}
// End IMG to URL BBCode Converter


I think something is old in this code,because this is generate error.log like that


PHP Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /includes/class_bbcode.php on line 1866



But this code is working without any problem. Only generate this error.log


My php version is 5.6.x and vB 4.2.x


Regards

iA1
02-11-2020, 11:49 AM
It is php error. Just remove e from preg_replace.

Updated code will be like this:

// Start IMG to URL BBCode Converter
if ($this->contains_bbcode_img_tags($message))
{
$message = preg_replace('#\[img\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/img\]#iU', "\$this->handle_bbcode_url(str_replace('\\\"', '\"', '\\1'), '')", $message);
}
// End IMG to URL BBCode Converter

Bulent Tekcan
02-11-2020, 12:41 PM
It is not OK :( This error occured in qoute and not work


$this->handle_bbcode_url(str_replace('\"', '"', 'https://images2.imgbox.com/5f/28/NEN92qNM_o.png'), '')
It is php error. Just remove e from preg_replace.

Updated code will be like this:

// Start IMG to URL BBCode Converter
if ($this->contains_bbcode_img_tags($message))
{
$message = preg_replace('#\[img\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/img\]#iU', "\$this->handle_bbcode_url(str_replace('\\\"', '\"', '\\1'), '')", $message);
}
// End IMG to URL BBCode Converter

shka
02-11-2020, 01:45 PM
I think

// Start IMG to URL BBCode Converter
if ($this->contains_bbcode_img_tags($message)) {
$message = preg_replace_callback(
'#\[img\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/img\]#iU',
function ($matches) {
return $this->handle_bbcode_url(str_replace('\"', '"', $matches[1]), '');
},
$message
);
}
// End IMG to URL BBCode Converter

Bulent Tekcan
02-11-2020, 06:16 PM
Thanks so much :up: This code is perfectly working and didn't create any error.log


Many thanks again






I think

// Start IMG to URL BBCode Converterif ($this->contains_bbcode_img_tags($message)) { $message = preg_replace_callback( '#\[img\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/img\]#iU', function ($matches) { return $this->handle_bbcode_url(str_replace('"', '"', $matches[1]), ''); }, $message );}// End IMG to URL BBCode Converter