vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   IMG to URL convert (https://vborg.vbsupport.ru/showthread.php?t=327820)

Bulent Tekcan 02-11-2020 10:53 AM

IMG to URL convert
 
Hello,


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



Code:

// 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:
Code:

// 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


Code:

$this->handle_bbcode_url(str_replace('\"', '"', 'https://images2.imgbox.com/5f/28/NEN92qNM_o.png'), '')
Quote:

Originally Posted by iA1 (Post 2602010)
It is php error. Just remove e from preg_replace.

Updated code will be like this:
Code:

// 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

PHP Code:

// 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






Quote:

Originally Posted by shka (Post 2602014)
I think

PHP Code:

// 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 




All times are GMT. The time now is 04:07 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01083 seconds
  • Memory Usage 1,731KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete