show external link names MOD...

User avatar
spaceace
Site Owner
Posts: 947
Joined: Wed Dec 16, 2009 8:30 pm
Location: Ontario, Canada
Flag: Canada

show external link names MOD...

Post by spaceace » Mon Jan 02, 2017 8:05 pm

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);
Last edited by spaceace on Mon Jan 02, 2017 8:17 pm, edited 1 time in total.

if you like my work and would like to contribute to my development of styles, please donate by using the donate button in the header.

Image

Image