Page 1 of 1

show external link names MOD...

Posted: Mon Jan 02, 2017 8:05 pm
by spaceace
this is a MOD to show external link names that is used here. i got the code from RMcGirr83's site when it was still around ;)

the finds are adjusted to work with phpBB 3.1.10 as it is exactly what is used here
Open includes/functions_content.php
Find
Tip: This may be a partial find and not the whole line.
Code: Select all
/**
* A subroutine of make_clickable used with preg_replace
Add before
Tip: Add the following line(s) on a new blank line before the preceding line(s) of find.
Code: Select all
/**
* A subroutine of make_clickable to retrieve
* titles of links posted
*
*/
function make_title_link($url, $text)
{
	$handle = @file_get_contents($url);
	if(!empty($handle))
	{
		preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s+charset=([^\s"]+))?@i', $handle, $matches );
		if(isset($matches[3]))
		{
			$handle = $handle;
		}
		else
		{
			$handle = mb_convert_encoding($handle, 'HTML-ENTITIES', "UTF-8");
		}

		$dom = new DOMDocument();
		if (@$dom->loadHTML($handle))
		{
			$xpath = new DOMXPath($dom);
			if (!empty($xpath->query('//title')->item(0)->nodeValue))
			{
				$title = $xpath->query('//title')->item(0)->nodeValue;
				$text = str_replace("\n", " ",$title);
				return $text;
			}
		}
	}
	return $text;
}
Find
Tip: This may be a partial find and not the whole line.
Code: Select all
			$tag	= 'm';
			$text	= $short_url;
Add after
Tip: Add the following line(s) on a new blank line after the preceding line(s) of find.
Code: Select all
$text	= make_title_link($url, $text);
Find
Tip: This may be a partial find and not the whole line.
Code: Select all
			$url	= 'http://' . $url;
			$text	= $short_url;
Add after
Tip: Add the following line(s) on a new blank line after the preceding line(s) of find.
Code: Select all
$text	= make_title_link($url, $text);