Quote:
Originally Posted by Rhodium
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($paged, 8192); $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