How to make PHPBB3 codded link clickable

Status
Not open for further replies.
9 comments
I'm pretty sure he means he wants to have the links clickable server-side, not client-side like GreaseMonkey script functions.

You can check the includes\bbcode.php file, look for
PHP:
function bbcode_second_pass_code($type, $code)
Add the following line after the three lines starting with $code:

PHP:
$code = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $code);
note: I just looked around and did this quick and dirty, if there is another better way to do it - please post :D

EDIT: Fixed the RegEx that it also catches a dash (-) :)
 
I'm pretty sure he means he wants to have the links clickable server-side, not client-side like GreaseMonkey script functions.

You can check the includes\bbcode.php file, look for
PHP:
function bbcode_second_pass_code($type, $code)
Add the following line after the three lines starting with $code:

PHP:
$code = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $code);
note: I just looked around and did this quick and dirty, if there is another better way to do it - please post :D

EDIT: Fixed the RegEx that it also catches a dash (-) :)

GREAT!
I do it
It's so cool ,so simple
It's OK
Thanks:D
 
I'm pretty sure he means he wants to have the links clickable server-side, not client-side like GreaseMonkey script functions.

You can check the includes\bbcode.php file, look for
PHP:
function bbcode_second_pass_code($type, $code)
Add the following line after the three lines starting with $code:

PHP:
$code = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $code);
note: I just looked around and did this quick and dirty, if there is another better way to do it - please post :D

EDIT: Fixed the RegEx that it also catches a dash (-) :)

It cannot fully parse some links. Example:

http://extabit.com/file/2ducb95j3wszx/Compliance.(2012).LiMiTED.1080p.BluRay.x264.SPARKS.part1.rar

Only the blue portion is parsed.
 
you can use this;

open includes/bbcode.php;
Find this
Code:
$code = $this->bbcode_tpl('code_open') . $code . $this->bbcode_tpl('code_close');

Replace
Code:
// make links clickable in [ code ] tags / 4seven / 2010
              preg_match_all("#(((file|gopher|news|nntp|telnet|http|ftp|https|ftps|sftp)://)|(www\.))+(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9\&amp;%_\#\./-~-]*)?#is",  $code, $find_urls2);
        
            $find_urls2[0] = preg_replace('#http:\/\/#is', '', $find_urls2[0]);
            $code = str_replace('http://', '', $code);

            foreach ($find_urls2[0] as $urls1)
            {
            $code = str_replace($urls1, "<a href='http://$urls1'>$urls1</a>", $code);        
            }  
            $code = $this->bbcode_tpl('code_open') . $code . $this->bbcode_tpl('code_close'); 
            // make links clickable in [ code ] tags / 4seven / 2010
 
Status
Not open for further replies.
Back
Top