vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.8 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=235)
-   -   Show Thread Enhancements - Title Tag Fetcher (Auto Replace URL with Titletag) (https://vborg.vbsupport.ru/showthread.php?t=189658)

mdawg 05-13-2017 01:48 AM

I have tried that yes - disabling AutoTagger but leaving this mod, which is the one I care about more, running, but still posts invisible and this PhP error:

With autotagger off, but external title fetcher ON (under php 7):

[12-May-2017 20:08:35 America/Los_Angeles] PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/*****/public_html/*****.com/forums/includes/functions_newpost.php(196) : eval()'d code on line 68

djbaxter 05-13-2017 02:14 AM

You could try editing the plugin from your AdminCP.

This seems to be what it doesn't like (at the very end of the plugin code - PLUGIN not PRODUCT):

Code:

        $messagetext = preg_replace(
                '#(^|\[/(' . $skiptaglist . ')\])(.*(\[(' . $skiptaglist . ')|$))#siUe',
                "convert_url_to_bbcode_callback_auto_title('\\3', '\\1')",
                $messagetext
        );

No idea if this will work or not but you could try replacing that line with

Code:

        $messagetext = preg_replace_callback(
                '#(^|\[/(' . $skiptaglist . ')\])(.*(\[(' . $skiptaglist . ')|$))#siUe',
                "convert_url_to_bbcode_callback_auto_title('\\3', '\\1')",
                $messagetext
        );

WARNING: If this breaks your forum and you can't get to your AdminCP, disable hooks so you can edit it back.

mdawg 05-13-2017 05:03 AM

Do appreciate the help! but it did not solve anything.

When I switched out that code and tested it with PhP 5.6 running, the mod stopped fetching external titles, and the regular URL posted with no conversion to title.

Same result with PhP 7 running, whether I had the other mod (auto tagger), on or off - posts were no longer invisible, but the regular URL posted with no conversion to title.

i.e. the replaced code did eliminate the weird, invisible post behavior, but it also stopped the external title fetcher from fetching external titles, whether in PhP 5.6 or 7.

Rhodium 05-14-2017 08:16 PM

Try that, works for me

replace
Code:

        $messagetext = preg_replace(
                '#(^|\[/(' . $skiptaglist . ')\])(.*(\[(' . $skiptaglist . ')|$))#siUe',
                "convert_url_to_bbcode_callback_auto_title('\\3', '\\1')",
                $messagetext
        );

to
Code:

        $messagetext = preg_replace_callback(
                '#(^|\[/(' . $skiptaglist . ')\])(.*(\[(' . $skiptaglist . ')|$))#siU',
                function($m) { return convert_url_to_bbcode_callback_auto_title($m[3], $m[1]); },               
                $messagetext
        );


mdawg 05-15-2017 08:19 PM

Very good! thank you. Now the Title Tag Fetcher (Auto Replace URL with Titletag) mod works at my forum running 4.2.5 with PhP 7 enabled, without making posts invisible.


I wonder if you could take a look at this:
https://vborg.vbsupport.ru/showthrea...07#post2586407
for the other mod, Automatic Tagger From Message Content and Title - the issue seems to be similar in that the threads/posts are happening, but error codes interrupt the process.

djbaxter 06-11-2017 09:02 AM

Quote:

Originally Posted by Rhodium (Post 2586513)
Try that, works for me

replace
Code:

        $messagetext = preg_replace(
                '#(^|\[/(' . $skiptaglist . ')\])(.*(\[(' . $skiptaglist . ')|$))#siUe',
                "convert_url_to_bbcode_callback_auto_title('\\3', '\\1')",
                $messagetext
        );

to
Code:

        $messagetext = preg_replace_callback(
                '#(^|\[/(' . $skiptaglist . ')\])(.*(\[(' . $skiptaglist . ')|$))#siU',
                function($m) { return convert_url_to_bbcode_callback_auto_title($m[3], $m[1]); },               
                $messagetext
        );


This solves the blank pages problem on vB 4.7.5 with PHP 7.1

However, on two SSL (https://) forums, it no longer fetches the page title, whether the URL being fetched is https:// or http://

This is the entire updated plugin:

PHP Code:

if (!function_exists(convert_url_to_bbcode_callback_auto_title)) {
function 
convert_url_to_bbcode_callback_auto_title($messagetext$prepend)
{
    
$messagetext str_replace('\"''"'$messagetext);
    
$prepend str_replace('\"''"'$prepend);

    static 
$urlSearchArray$urlReplaceArray$emailSearchArray$emailReplaceArray;
    if (empty(
$urlSearchArray))
    {
        
$taglist '\[b|\[i|\[u|\[left|\[center|\[right|\[indent|\[quote|\[highlight|\[\*' .
            
'|\[/b|\[/i|\[/u|\[/left|\[/center|\[/right|\[/indent|\[/quote|\[/highlight';
        
$urlSearchArray = array(
            
"#(^|(?<=[^_a-z0-9-=\]\"'/@]|(?<=" $taglist ")\]))((https?|ftp|gopher|news|telnet)://|www\.)((\[(?!/)|[^\s[^$`\"'|{}<>])+)(?!\[/url|\[/img)(?=[,.!)]*(\)\s|\)$|[\s[]|$))#siU"
        
);

        
$urlReplaceArray = array(
            
"[url]\\2\\4[/url]"
        
);

        
$emailSearchArray = array(
            
"/([ \n\r\t])([_a-z0-9-]+(\.[_a-z0-9-]+)*@[^\s]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))/si",
            
"/^([_a-z0-9-]+(\.[_a-z0-9-]+)*@[^\s]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))/si"
        
);

        
$emailReplaceArray = array(
            
"\\1[email]\\2[/email]",
            
"[email]\\0[/email]"
        
);
    }

    
$text preg_replace_callback($urlSearchArray"auto_title"$messagetext);

    if (
strpos($text"@"))
    {
        
$text preg_replace($emailSearchArray$emailReplaceArray$text);
    }

    return 
$prepend $text;
}

function 
auto_title ($text) {

$options = array( 'http' => array(
        
'user_agent'    => 'VBulletin Titletag Fetcher',
        
'max_redirects' => 10,
        
'timeout'       => 60,
    ) );
$context stream_context_create$options );

if (
$text[2] == 'www.' or $text[2] == 'Www.' or $text[2] == 'wWw.' or $text[2] == 'wwW.' or $text[2] == 'WwW.' or $text[2] == 'WWw.' or $text[2] == 'wWW.' or $text[2] == 'WWW.') { $text[4] = $text[2] . $text[4]; $text[2] = 'http://'; }

$paged    = @fopen$text[2] . $text[4], "r" ); #echo $page . "DONE"; 
if ($paged) {
    while (!
feof($paged) and ($x 1000)) { $page .= fread($paged8192); $x++; }
    
fclose($paged);
}

preg_match("/<title>[\n\r\s]*(.*)[\n\r\s]*<\/title>/"$page$title);

if (
$title[1] == '') { $title[1] = $text[2] . $text[4]; }
return 
"[url="" . $text[2] . $text[4] . ""]" preg_replace("/\&.+\;/"''$title[1]) . "[/url]";
}

}

    
$messagetext preg_replace_callback(
        
'#(^|\[/(' $skiptaglist ')\])(.*(\[(' $skiptaglist ')|$))#siU',
                function(
$m) { return convert_url_to_bbcode_callback_auto_title($m[3], $m[1]); },        
        
$messagetext
    
); 

RESOLVED:

See https://vborg.vbsupport.ru/showthread.php?t=323627

You need to have this setting enabled:

allow_url_fopen = On

djbaxter 06-11-2017 09:54 AM

1 Attachment(s)
To simplify updating for PHP 7.x, use attached product. The text files are for information only: Just delete the 1.5c version and import the new xml product (no files to upload).

Also posted at https://vborg.vbsupport.ru/showthread.php?t=325234

Please post there for support and I'll do what I can to help.

mdawg 06-13-2017 12:10 PM

Thanks djbaxter. So, I did what rhodium suggested in post #114 but what you updated and attached there is different?

djbaxter 06-13-2017 12:28 PM

Quote:

Originally Posted by mdawg (Post 2587490)
Thanks djbaxter. So, I did what rhodium suggested in post #114 but what you updated and attached there is different?

How is it different?

mdawg 06-13-2017 12:42 PM

I'm just asking if it is different. I simply did what Rhodium suggested it seems to work, but my forum is http not https.


All times are GMT. The time now is 11:05 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.01572 seconds
  • Memory Usage 1,785KB
  • 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
  • (6)bbcode_code_printable
  • (1)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete