Page 1 of 1

[Snippet] Link as Website Title (en) (update)

PostPosted: Sun 8. Nov 2009, 18:08
by 4seven
Website Title as Link

With this Snippet u can post a link, that automatically shows the link-title of the website as link-description.

Example:

This Link..
Code: Select all
[url_title]http://sekuro.se.funpic.de/phpbb3/posting.php?mode=post&f=20[/url_title]

produces..
BBCodeBox3 • Post a new topic

Screen: http://4seven.bplaced.net/pix/url_title_1.png

Requirement: allow_url_fopen must be activated



Instruction:

1. Make a BBCode

BBCode usage
Code: Select all
[url_title]{URL}[/url_title]


HTML replacement
Code: Select all
{URL}


2. Open

viewtopic.php

Find

Code: Select all
// Output the posts
$first_unread = $post_unread = false;
for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
{


Before Add

Code: Select all
// Link as Website Title / 4seven / 2009
function getTitleTag($uwebsite) {   
   $uhtml = implode("", file(html_entity_decode($uwebsite)));
   if (preg_match("/<title>(.*)<\/title>/isU", $uhtml, $utitle)){
   $utitletag = trim($utitle[1]);
   return '<a href="' . $uwebsite . '">' . $utitletag . '</a>';}}
// Link as Website Title / 4seven / 2009


Find

Code: Select all
$message = censor_text($row['post_text']);


After Add UPDATE

Code: Select all
// Link as Website Title / 4seven / 2009
if((preg_match("#\[url_title:#", $message)) && preg_match("#\[\/url_title:#", $message)){
$message = preg_replace("/\[url_title(.*?)\](.*?)\[\/url_title(.*?)\]/eU", 'getTitleTag("\\2")', $message);}
// Link as Website Title / 4seven / 2009


3. Clear all Caches

Re: [Snippet] Link as Website Title (en) (update)

PostPosted: Wed 24. Feb 2010, 04:38
by 4seven
UPDATE is red colored